diff --git a/README.md b/README.md index de48b3c..5812cd0 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,9 @@ libraries marked with it are published, in the superproject's `main`. | organization | [agent-skills](organization/openspec/changes/archive/2026-10-13-agent-skills) | organization: agent skills in .agents/skills, in the proposals and the superproject | organization | implemented | 0.1.0 | 2026-10-13 | [code](https://github.com/webcpporg/webcpp/tree/5a441c1e90c5b242cf55c351edf6c79c37ef1f8d) | | organization | [coding-guidelines](organization/openspec/changes/archive/2026-10-28-coding-guidelines) | organization: CODING-GUIDELINES.md, the single source of the rules and the design decisions | organization | implemented | 0.1.0 | 2026-10-26 | [code](https://github.com/webcpporg/webcpp/tree/a4c770e07becaa32b840554512b37d96b4440d18) | | organization | [contributor-identity](organization/openspec/changes/archive/2026-10-13-contributor-identity) | organization: every contributor commits under their own git identity | organization | implemented | 0.1.0 | 2026-10-13 | [code](https://github.com/webcpporg/webcpp/tree/9a268b7efa8a9b7eab8810bc024486288c689fab) | -| asio | [genesis](libraries/asio/openspec/changes/genesis) | asio: Boost.Asio natively, the browser's event loop on Emscripten | wrapper | implementing | | 2026-10-11 | | -| beast | [genesis](libraries/beast/openspec/changes/genesis) | beast: Boost.Beast natively, the browser's WebSocket and fetch on Emscripten | wrapper | draft | | | | +| asio | [genesis](libraries/asio/openspec/changes/genesis) | asio: Boost.Asio across native, browsers and WASI | wrapper | implementing | | 2026-10-11 | [code](https://github.com/webcpporg/asio) | +| beast | [genesis](libraries/beast/openspec/changes/genesis) | beast: existing Boost.Beast applications on WASIp2, WASIp3 and Emscripten | wrapper | implementing | | 2026-11-06 | [code](https://github.com/webcpporg/beast) | +| cobalt | [genesis](libraries/cobalt/openspec/changes/genesis) | cobalt: existing Boost.Cobalt applications on native, browsers and WASIp2/P3 | wrapper | implementing | | 2026-11-06 | [code](https://github.com/webcpporg/cobalt) | | config | [genesis](libraries/config/openspec/changes/archive/2026-10-09-genesis) | config: webcpp's configuration, the target, exceptions and version every library includes first | own | implemented | 0.1.0 | 2026-10-09 | [code](https://github.com/webcpporg/config/tree/2fad162) | | crypto | [genesis](libraries/crypto/openspec/changes/genesis) | crypto: authenticated encryption, randomness and secp256k1 over C backends | wrapper | accepted | | 2026-10-11 | | | document | [genesis](libraries/document/openspec/changes/archive/2026-10-12-genesis) | document: a JSON document for C++20 that behaves as JavaScript does, in one relocatable image | own | implemented | 0.1.0 | 2026-10-12 | [code](https://github.com/webcpporg/document/tree/ac29296) | diff --git a/libraries/asio/openspec/changes/genesis/.openspec.yaml b/libraries/asio/openspec/changes/genesis/.openspec.yaml index d02f2fb..a1df0ef 100644 --- a/libraries/asio/openspec/changes/genesis/.openspec.yaml +++ b/libraries/asio/openspec/changes/genesis/.openspec.yaml @@ -2,10 +2,10 @@ schema: spec-driven created: 2026-10-10 webcpp: library: asio - title: "asio: Boost.Asio natively, the browser's event loop on Emscripten" + title: "asio: Boost.Asio across native, browsers and WASI" kind: wrapper port_of: null status: implementing release: null - implementation: null + implementation: https://github.com/webcpporg/asio decided: 2026-10-11 diff --git a/libraries/asio/openspec/changes/genesis/design.md b/libraries/asio/openspec/changes/genesis/design.md index 81f40e8..e8cd4b3 100644 --- a/libraries/asio/openspec/changes/genesis/design.md +++ b/libraries/asio/openspec/changes/genesis/design.md @@ -14,7 +14,7 @@ Constraints every decision below works within, from the superproject's rulebook - header-only C++20, namespace `webcpp::asio`, headers under ``, internals in `detail`, macros `WEBCPP_ASIO_*`, include guards `WEBCPP_ASIO_
_HPP`, the b2 target `/webcpp/asio//asio`, the error category `webcpp.asio`; -- the library is built for native and Emscripten and has no WASI target; every test runs on each +- the library is built for native, Emscripten and WASIp2/P3; every test runs on each target its Jamfile names, with exceptions on and off, in both suspension variants; - errors as values (`boost::system::error_code`); an API that throws sits behind `WEBCPP_ASIO_NO_EXCEPTIONS` and raises through `boost::throw_exception`; @@ -45,27 +45,36 @@ Constraints every decision below works within, from the superproject's rulebook **Non-Goals:** -- A WASI backend (`wasi:io/poll`, p3's async): a later increment with its own specification. +- WASIp2 multi-thread execution without an SDK/runtime profile; portable WASI host APIs remain separate. - WebSocket and HTTP clients (webcpp::beast), WebRTC (webcpp::webrtc), relay transports and the b2 feature that enables one, trystero's migration, and offering the additions upstream to Boost.Asio. - Polling the page from C++, running the run family from a JavaScript event, or blocking the page's thread without suspending. -- A thread pool: the page has no threads (`BOOST_ASIO_DISABLE_THREADS`). +- Implicit workers in a single-thread browser build. Explicit pthread builds retain their separate environment and affinity requirements. ## Decisions -### D1. A class derived from Boost's io_context, and every other name Boost's +### D1. Actual native Boost types and explicit Wasm source distribution -`webcpp::asio::io_context` derives from `boost::asio::io_context` on both targets, shares its -executor type and converts to `boost::asio::io_context&`; the timers are aliases of Boost's; a -program keeps naming `post`, `co_spawn`, `use_awaitable` and `bind_executor` from Boost. +The owner-approved 2026-11-06 migration supersedes the former derived native +context and include-overlay approach. Native equivalents are aliases of actual +Boost types. Wasm uses versioned implementation files under explicit WebCPP paths, +with one backend across Asio, Cobalt and Beast. Browser turn options are target +extensions, not extra native constructors. Applications migrate includes/namespaces +and use the selected backend's executors, traits and completion tokens consistently. -- **Why:** a program sets its options the same way everywhere, and code written against either - interoperates; Cobalt and Beast are templates over Boost's executor. -- **Alternatives:** a fork of Asio's scheduler (a maintenance burden and incompatible with - every library on Asio); a free function that runs a Boost context (nowhere to keep the - options). +`sources.json` identifies compiled support units and feeds the B2 source list. +Direct compiler and CMake consumers use an extracted archive with explicit SDK and +provider inputs, without Git, B2, patch programs or undeclared checkout paths. +Maintainer generators retain upstream hashes/licenses; consumers never execute them. +Known native Boost defects remain documented under the native identity contract. +Cobalt owns its core, runner and corrected SSL wrapper, including the separately +approved native SSL identity exception. Old Asio Cobalt names only forward. + +The earlier decisions below record browser algorithm and integration history; +references to Boost's internals mean the selected Wasm backend, not permission to +restore native derived types, consumer overlays or Cobalt ownership inside Asio. ### D2. The run family is a composition of Boost's calls @@ -79,18 +88,16 @@ in the reactor's `select`). Natively they are Boost's own through `using` declar - **Consequence:** code that calls `run` through a `boost::asio::io_context&` gets Boost's run without the limit (documented); Cobalt's `co_main` gets the limit by D11. -### D3. The yield is a MessageChannel macrotask, the limit 1000 +### D3. A MessageChannel macrotask and a configurable default of 100 -The yield is an `EM_ASYNC_JS` import whose promise a `MessageChannel` message resolves. The -default `max_handlers_per_turn` is 1000 (measured: the `setTimeout(0)` ran at iteration 1,000 -under JSPI and 999 under Asyncify); 0 is taken as 1; a program changes it at construction or -later. A deadline is checked before each handler, so a passed deadline runs nothing and a -self-posting handler cannot outrun `run_for`. +The yield is an `EM_ASYNC_JS` import whose promise a `MessageChannel` message resolves. +The original default was 1000. After the 2026-10-15 yield-cost and responsiveness measurements, +the owner selected 100. `WEBCPP_ASIO_MAX_HANDLERS_PER_TURN` in config sets the compile-time +default; an application may define it before inclusion and override it per context. Zero +normalizes to one. A deadline is checked before each handler. No setting preempts a handler. -- **Why:** a macrotask lets the browser render, run timers and deliver events; `MessageChannel` - exists in node and in every browser. The default is to be measured again in the browser lane - against a frame's budget (the plan's stop rule: a 95th percentile above 8 ms stops the work - for the owner's decision). +The guide retains the benchmark methodology and observed costs. These observations justify +an adjustable compromise, not a portable time bound or an assurance of a fixed frame rate. ### D4. JSPI and Asyncify are build variants, a composite propagated feature @@ -222,18 +229,39 @@ fails the same way, so only webcpp::beast's browser streams accept it and Beast' code runs unchanged. A resolver that failed like the sockets was rejected: every Beast client would change a line. -### D15. TLS names natively, a record on Emscripten, OpenSSL named by the program +### D15. Explicit source-built TLS on native and WASI + +`` is Boost's SSL interface on native and WASIp2/P3. The program explicitly +selects `/webcpp/asio//openssl` or `//tls`, backed by `/webcpp/third_party//openssl` and a +matching generated header/archive pair. The latter includes verified, replaceable embedded +CA data. Emscripten retains the browser TLS settings adapter and refuses guest OpenSSL. +Cobalt's optional `//cobalt_ssl` uses the same provider and checked SSL state/cancellation fixes. + +This supersedes the original departure 4 (system shared OpenSSL). The source build and CA +package were approved in October and integrated locally on 2026-11-02; the owner ratified +reconciliation of this proposal with that implementation on 2026-11-03. OpenSSL's process-global +memory hooks are not an Asio per-operation allocator; the guide states that allocation boundary. + +### D16. WASIp3 sockets, with explicit profile limitations + +The original accepted browser scope excluded WASI because unmodified Boost 1.92 did not build +there. The owner approved the WASIp3 port on 2026-10-15, subsequently approved source-built TLS, +and approved applying these changes to this proposal on 2026-11-03. A checked private Boost +overlay now supplies timers, TCP/UDP and Cobalt integration on WASIp3. Native and browser +semantics remain distinct from host-controlled WASI network permissions. -`` (not in the convenience header) is Boost's `ssl` natively, which needs -OpenSSL 3, and on Emscripten a record of the program's TLS settings that only webcpp::beast's -browser streams read. A program names `/webcpp/asio//openssl` for its native builds alone, by a -condition in its project; naming it for WebAssembly stops the compile with an instruction -(the owner rejected ignoring it there), and a machine that lacks OpenSSL stops the build. +WASIp3 single-thread builds support exceptions on/off. Cooperative threads require the SDK's +matching experimental sysroot; SDK 34 lacks its C++ exception runtime, so that profile refuses +exceptions on. The later owner-approved P2 extension below adds a single-thread reactor. Beast socket profiles follow +Asio's targets; Beast's portable messages, host HTTP and supplied streams do not require this +reactor and may support WASIp2 independently. -### D16. No WASI target +### D17. Coexistence with Trystero -Boost.Asio 1.92 does not compile for wasm32-wasip2 or wasm32-wasip3 with wasi-sdk 34. A library -on webcpp::asio declares native and Emscripten at most. +The owner clarified on 2026-11-03 that Asio and Beast are intended foundations for Trystero's +later migration. Combining the libraries MUST NOT be prohibited as a workaround for OpenSSL +provenance. A combined native program must use one OpenSSL provider, including libdatachannel's +transitive dependency. Migrating Trystero's application APIs remains a separate workstream. ## Risks / Trade-offs @@ -251,23 +279,56 @@ on webcpp::asio declares native and Emscripten at most. ## Migration Plan -Nothing depends on asio yet. The library is developed in a superproject worktree at -`libs/asio`; once it is complete (task 23) the owner creates `webcpporg/asio` (gate G1), adds the -submodule (G2) and approves the pushes (G3). trystero's migration onto asio, webcpp::beast and -webcpp::webrtc are separate proposals. +The repository `webcpporg/asio` exists and the superproject integrated its submodule in +`2ba5116` on 2026-11-02. Tasks 22/23 now close the reconciled rulebook, complete-branch review +and both CI gates. `reference/STATUS.md` records exact tested commits and remaining work. +Beast already uses Asio; Trystero's migration onto Asio and Beast follows this foundation. ## Open Questions -- The default `max_handlers_per_turn` of 1000 is to be measured in headless Chrome (task 13); - the stop rule hands any value above an 8 ms 95th percentile to the owner. - The b2 feature that enables a relay transport for a whole program (D13) is designed with the first relay library. - `asyncify-stack-size` should be measured again when b2's release link passes the optimization level, and again when the Cobalt tests join the lane (task 16 step 5). - The CI's levels (nightly, release) do not exist, so the Asyncify lanes run on every push (departure 1) until they do. -- `/webcpp/asio//openssl` links the system's shared OpenSSL until webcpp::crypto builds - `/third_party//openssl` (departure 4). -- Native suites without exceptions run only on Emscripten for now (departure 5). -- The re-review of task 9's fix round was stopped by the owner's request to review every task one - by one (2026-10-11); it is open. +- The final review must cover the complete Asio branch and root integration, not only the + earlier task 9, tasks 17-21 or WASIp3/TLS review subsets. + +### WASIp2 scope amendment approved on 2026-11-03 + +After the earlier P2 exclusion, Rodrigo explicitly approved both an Asio P2 +pollable-based core and the four Beast supplied-stream WebSocket combinations. +This supersedes the no-P2-reactor restriction. Retain the Boost scheduler and +libc select/poll translation for timers, TCP and UDP. Forward asynchronous DNS +uses native address-stream pollables, with deferred initiation, cancellation and +associated executor/allocator semantics. The generic pollable descriptor bridge +is isolated and pinned to SDK 34.0's private libc ABI. P2 single-thread execution +supports both exception modes; the follow-up below adds verified guest TLS and +Cobalt. Multi-thread execution remains unavailable with the pinned SDK. Host HTTP and supplied streams remain separate +capabilities. This amendment does not declare every Beast P2 socket application +validated or restore the removed proposal tasks without their own evidence. + + +### Capability completion approved on 2026-11-03 + +The owner approved completing WebCPP-owned gaps and leaving SDK/host limits +explicitly documented and guarded. P2 receives the shared source-built OpenSSL, +CA and Cobalt/SSL targets in both exception modes. WASI UDP gains connected gather +send and scatter receive without weakening datagram boundaries. P3 asynchronous +forward DNS uses native subtasks/waitables in both thread profiles, with a checked +private libc descriptor bridge, deferred initiation and cancellation. + +Explicit Emscripten pthread builds retain the selected JSPI/Asyncify mechanism. +Contexts run only on their creation thread; cross-thread posting and an explicit +main-runtime executor provide handoff without sharing JavaScript values across +threads. The main-thread poll adapter preserves ordinary application main/DOM +behavior rather than implicitly proxying main to a worker. Page isolation and +engine support remain external requirements. + +`config.hpp` owns derived 0/1 capabilities. Optional provider selection is +separate, and explicit application requirements reject compiler-visible unsupported +combinations. Target-specific headers explain missing facilities. Runtime grants, +peer identities and host-blocking imports cannot be diagnosed by preprocessing. +No SDK upgrade, upstream Cobalt issue 287 repair or new Beast application-corpus +claim is implied by this amendment. Fresh publication gates remain necessary. diff --git a/libraries/asio/openspec/changes/genesis/proposal.md b/libraries/asio/openspec/changes/genesis/proposal.md index c90629e..481d977 100644 --- a/libraries/asio/openspec/changes/genesis/proposal.md +++ b/libraries/asio/openspec/changes/genesis/proposal.md @@ -18,12 +18,16 @@ own asynchronous model (promises, events) should reach C++ as ordinary Asio oper ## What Changes - **New library `webcpp::asio`**, a wrapper (webcpp's interface over Boost.Asio, not a port): - header-only C++20 over Boost.Asio on two targets, native and Emscripten. - Natively every name is Boost's. On Emscripten it is Boost's own `io_context` suspended into - the browser's event loop. There is no WASI target (Boost.Asio 1.92 does not compile for - wasm32-wasip2 or wasm32-wasip3 with wasi-sdk 34). -- `webcpp::asio::io_context`, derived from `boost::asio::io_context` on both targets, with - `io_context_options{max_handlers_per_turn}` (1000 by default), a reactor made at construction + C++20 over Boost.Asio on native, Emscripten, WASIp2 and WASIp3. Native names retain Boost's + behavior. Emscripten suspends Boost's own `io_context` into the browser event loop. + A checked Boost overlay provides timers and TCP/UDP on WASIp2 and WASIp3. + WASIp2 adds pollable-driven forward async DNS and supplied CLI streams, with a + pinned private wasi-libc descriptor bridge. It is single-threaded and supports + the shared source-built OpenSSL, embedded/replacement CAs and Cobalt/SSL with + exceptions on or off. WASIp3 also supports these facilities and its validated + cooperative thread profile. Unsupported combinations are refused by name. +- `webcpp::asio::io_context`, derived from `boost::asio::io_context` across targets, with + `io_context_options{max_handlers_per_turn}` (100 by default, configurable in config.hpp or by compiler define), a reactor made at construction and a run family composed of `poll_one` and `run_one` that yields to the browser through a `MessageChannel` macrotask after every turn on Emscripten; timers are aliases of Boost's. - The bridge, `webcpp::asio::browser::bridge`, a service of the io_context through which browser @@ -38,7 +42,8 @@ own asynchronous model (promises, events) should reach C++ as ordinary Asio oper - Superproject changes the library needs: the propagated composite feature `webcpp-suspend`, a test support that fails a test whose `main` did not finish (`webcpp::test::exit_status`), `webcpp.variants`, `webcpp.size-table`, and `/webcpp//boost_cobalt`. -- No breaking change: nothing depends on asio yet. +- Beast builds on this foundation; the owner intends a later Trystero migration to Asio + and Beast. Combining the libraries remains supported through one OpenSSL provider. ## Capabilities @@ -48,7 +53,7 @@ own asynchronous model (promises, events) should reach C++ as ordinary Asio oper suspended into the page's event loop, with its io_context, run family, turn limit, bridge, detection, suspension variants, Asyncify stack, loader, Cobalt `run_main`, promises and events as operations, transport point, resolver, `ssl` names, allocation and exception - guarantees, tests, examples and documentation. + guarantees, WASI timers/networking and supplied streams, tests, examples and documentation. ### Modified Capabilities @@ -56,22 +61,22 @@ None. ## Impact -- **Kind:** a wrapper (`"port-of": null`): webcpp's interface over Boost.Asio, repository - `webcpporg/asio` (not created; the owner creates it, gate G1), checked out as the submodule - `libs/asio`, BSL-1.0, "Copyright (c) 2026 WebCpp.org". -- **Implementation:** a local repository, unpublished, 13 commits on `main` of 2026-10-11 (tip - `7cfd449`), all as `R`, covering tasks 1 and 4 to 9 of the plan; the superproject's tasks 2 and - 3 are 10 commits on a superproject branch, also local. `reference/source/` is the library's - tree at the tip; `reference/STATUS.md` says how the two local copies differ and how to resume. - Tasks 10 to 23 are not started. -- **Dependencies:** Boost 1.92 headers (Asio, and for the tests Beast's `test::stream`; - Cobalt's sources are compiled by the superproject, task 15; Core's `lightweight_test`; - Unordered's `unordered_flat_map` for the bridge), Emscripten 6.0.11 with embind, node 26.7.0 for - the tests, chrome-headless-shell for the browser lane, OpenSSL 3 natively and only for - ``. webcpp::xactor is a user of the library, not a dependency. No new - third-party code. -- **Status:** `implementing`; not in a release; the owner accepted the specification on - 2026-10-11 and approved the plan's five departures the same day. -- **Other proposals:** webcpp::beast (WebSocket and HTTP, over the bridge, the transport point - and the `ssl` record), webcpp::webrtc (over the bridge) and trystero's migration onto asio - (its event-side polling removed) depend on this one; none exists as a proposal yet. +- **Kind:** a wrapper (`"port-of": null`), repository `webcpporg/asio`, checked out as + the superproject submodule `libs/asio`, under BSL-1.0. +- **Implementation:** tasks 1-21, the later WASIp3/TLS increments and the approved + single-thread WASIp2 core/supplied-stream increment are implemented locally. + The approved capability extension adds P2 TLS/Cobalt, native asynchronous P3 DNS, + complete WASI UDP sequences, browser pthread handoff and compile-time guards. + The repository was created on 2026-11-03 UTC and the owner-authorized superproject + integration is commit `2ba5116`. Tasks 22/23 close the documentation, conformance, + complete-branch review and final CI gates. `reference/STATUS.md` distinguishes tested + commits from work in progress and identifies the exact reference source snapshot. +- **Dependencies:** Boost 1.92, WebCPP config, Emscripten 6.0.11, the pinned Node/browser + test tools, WASI SDK 34 and Wasmtime 50.0.1. Guest TLS explicitly selects source-built + OpenSSL 3.5.9 and optionally the verified embedded Mozilla CA snapshot. xactor is a + user of Asio, not a dependency of it. +- **Status:** `implementing`, for 0.1.0 in preparation. The owner accepted the original + specification and five departures on 2026-10-11, approved subsequent WASIp3/TLS work, + and ratified the reconciled scope on 2026-11-03. No release has been published. +- **Other proposals:** Beast has its own proposal and uses the browser and socket + facilities. WebRTC and Trystero's application migration remain separate workstreams. diff --git a/libraries/asio/openspec/changes/genesis/reference/STATUS.md b/libraries/asio/openspec/changes/genesis/reference/STATUS.md index 01ca44d..33f553c 100644 --- a/libraries/asio/openspec/changes/genesis/reference/STATUS.md +++ b/libraries/asio/openspec/changes/genesis/reference/STATUS.md @@ -1,5 +1,1290 @@ # webcpp::asio: where the implementation stands, and how to resume +## Coordinated publication in progress, 2026-11-07 + +The owner authorized publication and remote CI for the reviewed migration. +The immutable library candidates are Asio `e7cf267b4ab43437a09ce68f40a3994ca63b9054`, +Cobalt `36b9f2475aab1171e0898ab87d5b9630a8e04d71`, and Beast +`6c53f854070a4eebd844f21c29692e938181f8f6`. Superproject commit +`c411965` records those three revisions and the new public Cobalt submodule. +All three candidate branches are published. No main integration is claimed. + +CI environment preparation is running at +https://github.com/webcpporg/webcpp/actions/runs/42370588658 . The complete +combined CI and library CI remain pending. The preceding local validation +records remain evidence for their stated scope, not remote-CI certification. +No release or proposal archival is part of this publication step. The release +packaging check still rejects the prepared 0.1.0 freeze together with these +libraries' Unreleased entries; reconcile that state in the release procedure. + +## Current local migration, 2026-11-07 + +The owner-approved 2026-11-06 distribution contract is now implemented locally in +the coordinated Asio/Cobalt/Beast candidate. Native equivalents are actual Boost +types; Wasm selects explicitly shipped sources, without consumer patches or Boost +include overlays. Cobalt's corrected native SSL wrapper is the approved exception. +Direct compiler/CMake consumers passed from an extracted source archive, including +custom executor/PMR settings, multiple translation units and optional TLS. + +This candidate remains uncommitted. The starting revisions are superproject +`d3a67959cbe52e6d972ef575be8870cc79da1312`, Asio +`db4f7fc6afc516fdef057614cc971cdc39484099`, Beast +`31af69150d61776e7699cb89125f79d103e11ac8`, and local Cobalt +`58701c7dd22777c84c17ac9bbeea6d517c0c7f38`. These hashes identify bases, not the +edited tree. Dated evidence includes source snapshots and artifact hashes. +Historical remote CI below does not certify this local candidate. No new remote +CI, push, merge, repository publication or release is claimed. + +Nine maintained guide programs cover 180 cells: 92 passing expected-output +comparisons across 17 feasible profiles, 61 not applicable and 27 SDK blocked. +This is not the full Boost.Asio original example corpus. Node example execution +and actual Chrome scheduling/worker execution remain distinct evidence. +The fresh yield suite contains 442 cases, 970,139,132 operations and 9,429,856 +clock pairs. Median per-run direct mean gaps are 4.103 us (JSPI) and 4.763 us +(Asyncify); default turn size remains 100. This is not a loaded-page frame bound. +See `libs/asio/doc/example-matrix.adoc`, `doc/yield-current.adoc` and +`bench/yield/results/2026-11-07/` in the implementation tree. + +Documentation and proposal records have been reconciled with the shipped-source +contract. All three strict MrDocs/AsciiDoc builds passed again. A fresh independent +whole-candidate review, followed by focused reviews of every correction, has no +open findings. Local closure items 4 and 5 are complete: the lint covered 831 +translation units and 1,528 compilation commands. The complete run found two +final style issues; both were corrected and their exact checks passed again. +Its original exit status and diagnostics are retained, alongside the successful +follow-ups, in `closure-lint-reconciled.json`. All other lint rules and the tooling +regression suites passed. SDK 34 P2 pthread/P3 cooperative EH limits, versioned P3 +LTO diagnostics, Boost.Context restrictions and native Boost +defects remain explicit, not passing support cells. The local execution ledger is +`.superpowers/sdd/2026-11-06-portable-network-libraries/progress.md` in the +superproject. New implementation boxes remain unchecked until coordinated commits; +publication/CI is a separate step. No proposal is archived or marked implemented. + +## Historical records + +The following snapshots and task states describe their dates, not the migration above. + + +## Current committed snapshot + +- Asio: `db4f7fc6afc516fdef057614cc971cdc39484099`. +- Integrated superproject: `80a48ff989bfa301917936af5945de0149bffa08`, with Asio + `4199a45f0625ecb5a9319a5b9eb28dbd1e0a48a9`. +- Documentation follow-up candidate: superproject + `d994334102d138e2847b7e8463fb1c06a859bd42`, with the current Asio snapshot. +- `reference/source/`: 208 tracked files, exported from the Asio commit above. +- Scope: native/browser functionality, explicit browser pthread execution and + main-thread handoff, WASIp2/P3 networking/TLS/Cobalt, complete connected UDP + sequences, native P3 async DNS and central compile-time capability diagnostics. + P2 multiple threads and P3 cooperative exceptions remain SDK restrictions. +- Publication gates: the documentation follow-up, individual library integration + and main CI/site publication remain pending. The implementation candidate passed + complete remote CI and was integrated; the records below identify both commits. + +## Current CI follow-up, 2026-11-04 + +The corrected implementation candidate `44a2ee0` passed +[CI 41803777144](https://github.com/webcpporg/webcpp/actions/runs/41803777144): +all tests and examples built in 78 lanes, all eight tool-test and lint shards, +documentation and site checks passed. [Root PR 7](https://github.com/webcpporg/webcpp/pull/7) +merged it as `80a48ff` on 2026-11-04. Its tree is identical to the tested tree. +The new [main CI 41814889451](https://github.com/webcpporg/webcpp/actions/runs/41814889451) +is responsible for the main record and site publication. + +A real-browser review of that CI's site artifact confirmed that the Asio and Beast +pages render and Asio's capabilities link navigates to its table. It found stale P2 omissions in +Asio target summaries. Asio `db4f7fc` corrects four guide fragments and two API +comments, including the existing generated P2 test count. No executable code +changed. A focused independent review and a fresh `b2 -a libs/asio/doc` passed, +including MrDocs, source and rendered-page checks; the clean root release check +also passed. [Asio CI 41817278691](https://github.com/webcpporg/asio/actions/runs/41817278691) +tests this new candidate with the integrated parent main. The earlier manual +Asio run `41815054019` is superseded by this candidate. + +Parent run [41793433211](https://github.com/webcpporg/webcpp/actions/runs/41793433211) +finished with failures. It found a stale OpenSSL header-stage test assertion, missing generated +libdatachannel headers during lint and two Beast server readiness failures caused by +cold runtime compilation. All identified groups now have focused passing checks and independent review, +including the Windows driver quoting and portable Trystero allocation witness. +The corrected parent is clean and passes the prepared release check and Pyright +on all 136 repository Python files. +Individual library integration, the documentation follow-up checks and main site +publication remain gates. GitHub reported an active incident affecting Git operations, +pull requests and Actions during this follow-up; incomplete runs are not failures +or passing evidence. No release tag or completed archive is claimed. + +## Publication verification, 2026-11-03 + +The owner authorized push and integration after green CI. Source branches are now +published. Root run 41675267321 stopped during checkout because a Trystero gitlink +had not yet been pushed; the missing Trystero and WASI commits are now published. +Asio run 41675251165 uses the old superproject main and fails to find the new P2 +build project. Its checks must be rerun after the tested parent machinery is integrated. + +The full documentation build passed locally and in root CI at `3b2bf44`. +Final local lint passed all 803 translation units and every text/type/style rule. +Its compilation database contains 1,451 commands. Program-specific OpenSSL header +preparation now uses a dedicated B2 target; clean, repeated and stale/missing-header +regressions pass without compiling or executing consumers. The own-lane release +default, relocated build tree and both exception modes are covered. + +Root CI 41680879413 was canceled after the incremental preparation defect was +found locally. Its report also identified four Chrome startup timeouts, despite +the browser-workers job itself returning success. The launcher now bounds startup +at 30 seconds, bounds each discovery request, stops on process errors and reports +the last discovery stage. A real Chrome delayed by 11 seconds fails the old limit +and passes the new one. Pinned Linux Chrome 155 passed 18 worker/move fixtures, +loader/idle/render with both exception profiles, and the startup regressions. +The public B2 startup target passed both exception profiles. The cause of Chrome's +historical startup delay remains unknown; D-Bus/fontconfig warnings also occur +in successful runs and are not diagnosed as the cause. + +Independent reviews accepted both fixes. Root CI run 41686583077 tests the +published superproject `d7a6614` with Asio `059f64c`; it does not test the newer +local candidate above. Remote green results and main integration remain gates; +no formal approval or merge is claimed yet. + +That run identified two stale build fixtures: the Windows allocator overlay +fixture omitted Config, and the Cobalt SSL guard fixture still rejected P2. +Both are corrected in the local candidate. Their exact cases and neighboring +checks passed, with scoped type checking and independent review. + +The Windows MSVC 14.3 XML also exposed a failed oversized UDP assertion despite +the job reporting success. Native Boost.Asio forwarded IOCP's system error 1784 +instead of `message_size` for the asynchronous send. The test now accepts only +that exact additional error under IOCP; synchronous and WASI expectations remain +strict. Zero bytes, deferred single completion and no received datagram remain +required. Fresh native/P2/P3 tests passed with and without exceptions, scoped +lint passed, and independent review accepted the change. No Windows runtime was +available locally; the updated Windows test still requires remote confirmation. + +The partial report from this run passed all tests and examples in 25 other lanes, +including GCC 15 and Apple Clang. This partial result is not a complete CI verdict. + +## Driven-test and lint follow-up, 2026-11-03 + +The candidate above is committed locally and not yet pushed. The same remote run +also exposed the IOCP assertion in MSVC 14.5, POSIX-only signal imports in the +Windows TLS runner, and empty WASIp3 TLS executables. The shared driven-test +runner now uses Windows Job Objects, preserves 32-bit exit codes and checks +nested-job cleanup while the surrounding job remains alive. Ten local driver +cases and twelve server cases pass; the two Windows-only cases require the next +remote Windows run. Both Windows compiler jobs now run those actual regressions. + +The B2 generator now retains an existing executable when its producer also returns +symbols or component metadata. The old generator reproduced the WASIp3 +`undefined_weak:main` trap in a real consumer; the correction passes with both +exception modes. All seventeen WASIp3 TLS integration fixtures passed a fresh +build under Wasmtime 50.0.1, and their XML report passed. MSVC graph regressions +also prove that each actual fixture is linked and that single-threaded OpenSSL +uses the static CRT, rather than silently selecting the multi-threaded profile. +Independent review accepted these corrections. + +Actual remote XML reports confirm sixty-seven other lanes passing. These are +partial results from the older candidate, not the final CI gate. Four lint shards +hit the sixty-minute limit; cold profiling found that header preparation also +built OpenSSL archives and ran optional upstream tests. A separate generated-header +action is being validated locally. Full consumers must retain their archive builds +and upstream tests, and no final lint or CI result is claimed for that change yet. + +## Final report follow-up, 2026-11-04 + +Root run 41686583077 finished with a failing consolidated report, two tools +failures and five lint timeouts. Every lane artifact was inspected. The local +candidate includes the earlier Windows/WASI corrections and two further fixes: + +- OpenSSL header generation has its own B2 action. Cold native header preparation + took 30 seconds; the former action spent 610 seconds building libraries and + running tests before failing a sandboxed bind. The corrected full cold database + preparation completed in 642 seconds. The old and new collectors produce + exactly the same 1,449 commands on the same snapshot, including their order. + Native upstream tests passed 347 files and 4,009 tests in each thread profile, + and verified the hashes of the archives consumed by the application. Fresh P2 + and P3 entropy/TLS consumers passed their XML reports after the provider change. +- The global P2 test launcher imposed a focused 60-second limit on large finite + document workloads. Five remote failures were runtime interrupts; four were + reproduced locally. P2 now follows P3's configurable finite 600-second default. + The five unchanged document programs passed fresh builds and their XML report. + Twelve launcher regressions passed, including real runtime completion and + interruption of an infinite loop on both targets. + +The native Trystero follow-up now passes all 29 interoperability scenarios. +A controlled real browser/native reproduction demonstrated frames arriving +before a receiver was installed; bounded allocator-aware retention repairs +that handoff. This does not prove the precise ordering in the historical CI +failure. The correction and its timer/lifetime regressions passed independent +review and are published as Trystero `9b7879515461dcfdc3f32f287db822b977654b84`. + +The last full local lint found three Trystero test-fixture style defects and +an obsolete Beast host-TLS helper. Focused checks pass for all four fixes; +Pyright passed over all 135 repository Python sources. The actual Beast TLS +lanes passed 28 driver executions and 88 cases across P2/P3 and EH on/off. +Full local documentation and the 21-page, 11-library site passed, as did the +prepared 0.1.0 release check. The candidate above and all dependency commits +are published. Its new complete remote lint/CI and main integration remain +gates; no release tag or green final remote verdict is claimed. + +## Capability completion, 2026-11-03 + +The owner requested completing WebCPP-owned gaps while documenting SDK/environment +restrictions and diagnosing unsupported compile-visible combinations. The committed +candidate above implements those extensions. Its exact 208-file reference export +was verified against every Git blob and executable mode. The original completion +checkpoint preceded publication; the current publication state is recorded above. +The final whole-candidate review and its scoped +fix re-review are complete; every finding is addressed with no new breakage. + +Final local Release runs passed 105 native, 66 P2, 117 P3 and 233 Emscripten B2 test +targets with exceptions on/off, plus the applicable example output comparisons. +The Emscripten count covers Node JSPI/Asyncify execution; real browser validation +is recorded separately. Initial broad WASI builds omitted the runtime launcher; +those runtime failures are not evidence. Corrected commands executed the freshly +built artifacts through the pinned Wasmtime launcher and passed. + +Separate P2 TLS/Cobalt checks passed both exception profiles, including real TLS +trust/identity, embedded/replacement CAs, transfer, handshake and shutdown errors +and cancellation. Native/P3 TLS controls passed. The registered P2 TLS own lane +passed all 16 driver runs. Host entropy failure is fail-closed; distinct generated +keys test wiring and do not measure entropy strength. + +P3 async forward DNS uses the native async host import with a checked libc +descriptor bridge, without a worker or polling interval. Tests cover deferred +start, unrelated timer progress, pending cancellation, allocation and two-runner +cooperative lifetime. Connected UDP gathers/scatters the complete sequence while +preserving one-datagram semantics, truncation and cancellation. + +Real Chrome passed explicit pthread JSPI/Asyncify profiles with exceptions on/off, +including main-thread handoff, worker affinity, reentrant context destruction and +allocation cleanup. The raw Asyncify pthread-return probe remains a documented SDK +counterexample, not a passing test. The default browser profile remains single +threaded and the per-turn handler budget remains 100. + +At the earlier local completion checkpoint, focused clang-tidy, owned +Python/text/format checks, overlay/source-build tests, MrDocs and rendered guide +checks passed. That checkpoint did not claim full repository lint; the publication +verification above records its later successful complete run. +Complete lint database generation passed with 1,451 commands and materialized +headers; it is not a full tidy run. The local release check also passed. +Visual screenshot review remains unverified after blank local screenshots and a +browser file-URL refusal. Runtime network grants, page isolation, host-blocking +imports and trust/hostname errors cannot be inferred from target macros. + +Task-specific reviews approved the changes after public regressions fixed transient +UDP send retries, canonical empty-result cleanup, cooperative DNS cancellation +lifetime and browser reentrant destruction/throwing moves. The root verification +record names exact commands and chronology limits. The historical entries below +describe earlier candidates and do not override this current scope. + +The final review also corrected recurring test planning: both worker lanes now +provision Chrome, worker requests cover JSPI/Asyncify and both EH modes, the +throwing-move fixture covers only EH-on in both variants, and P2 TLS requests both +EH modes. All 41 matrix-tool tests passed. Local B2 XML verified 34 actual driver +configurations. The guide's P2 command now names the explicit TLS lane, and stale +DNS/profile-count statements are corrected. These are local planning and graph +checks, not a remote CI run. The scoped re-review accepted the complete fix wave. + +## WASIp2 follow-up verified and committed, 2026-11-03 + +The final documentation-only root commit is `15e2f44d2bdff0602b8e761a5a9c89b98c3a5d97`; implementation +remains root `e80ffab`, Asio `dad1aef` and Beast `ab95e84`. A later fresh Emscripten +Release regression passed 271 B2 test targets, covering the default suites and +Asio Asyncify/Cobalt lanes with EH on/off. This is Node-based execution, not a +fresh complete browser run. Full lint compilation-database preparation passed +with 1,419 commands, including P2 aggregate EH twins. The focused clang-tidy scope +remains the 20 configurations below; database generation is not a full tidy run. + +The owner approved both the Asio pollable core and supplied-stream WebSocket work. +The local implementation commits are Asio `dad1aef`, Beast `ab95e84` and superproject +`e80ffab`. Each library's `reference/source/` is exported from its exact committed +tree, with every Git blob and executable mode verified. These new commits have not +been pushed or tested by remote CI. The older green root run does not validate them. + +Fresh Release builds passed 138 native, 131 WASIp3 and 68 WASIp2 B2 test targets, +including compile/header and runtime targets, with exceptions on/off. The selected +scope covers the default suites and supplied-stream lanes; it is not a new complete +all-platform CI run. Focused clang-tidy passed 20 translation-unit configurations. +Formatting, text rules, Pyright, Asio/Beast MrDocs and rendered-guide checks passed. +Build tests verify the public P2 target, explicit multi-thread/Cobalt/TLS rejection, +pinned SDK/private-ABI refusal and unchanged P3 profile selection. Root +`b2 check-release` passed after the implementation commits. + +One independent review found two defects, each reproduced before its correction: +guard-only idle trapped on an empty poll list, and a valid 64-bit host write permit +could narrow to zero on wasm32. Idle now waits on a clock pollable; the permit is +clamped before narrowing. Added consumers cover readiness at registration and +pending-write cancellation. A controlled ABI fixture supplies the large/zero +permit; it does not claim every host's stdout import is nonblocking or preemptible. + +P2 core supports timers, TCP/UDP, forward asynchronous DNS and the supplied CLI +stream in a single thread. DNS preserves deferred initiation and handler +associations. P2 guest TLS, Cobalt and multiple threads remain explicitly rejected. +Both supplied WebSocket roles pass with EH on/off. Their actual exchanges cover +upgrade, text/binary frames, fragmentation, ping/pong, close, truncated input, +consumer pause/resume and pending-read cancellation. The application matrix records +571 passed, 216 blocked and 432 platform-unavailable cells. P2 raw-socket Beast +application integration remains blocked despite the now-working Asio core. + +## Joint Asio and Beast closure, 2026-11-03 + +The owner approved applying the remaining Asio tasks 22/23 to the current Beast closure. +The owner also clarified that Asio and Beast are foundations for Trystero's later migration; +a temporary prohibition on combining them was proposed in an external audit but was not +approved or implemented. Dependency provenance is being corrected instead. + +Repository `webcpporg/asio` exists (created 2026-11-03 UTC), and superproject commit `2ba5116` +records its owner-authorized submodule integration. G1 and G2 are complete. The five original +departures were approved on 2026-10-11 as already recorded in `reference/plan.md`; task 23.4 +records that existing decision. G3 still requires final successful library and root CI. + +The pre-closure published candidate is root `55a72c0`, Asio `9ed4ba8`, Beast `c173858`. +Root CI run `41597577370` verifies that baseline; its results must not be presented as proof +for subsequent local changes. The library's own CI had no runs at the start of this audit. +The closure review covers Asio changes and superproject integration beyond +previous task-specific reviews; its fixes are in the subsequent local candidate. No final merge, archived implementation claim or release is +recorded by this progress entry. + +The proposal now includes WASIp3 timers, TCP/UDP, source-built TLS, cooperative-profile +limitations, the selected default of 100 and the Diataxis page order. This reconciles the +original accepted scope with the later approvals; the original dated implementation entries +below remain historical records. `reference/source` now records the exact committed +library tree identified at the top of this file. + +## Tasks 17 through 21 and default 100, 2026-10-15 + +The library is at `f5fd7a8` on `work/task14-guide` in +`asio-task9-review/libs/asio` in the local organization checkout. The superproject +is at `063343d` on `work/asio-task9-review`. `source/` is exported from the +committed library tree; patch 0016 records the superproject change. No CI, +push, merge or publication ran. Tasks 22 and 23 remain pending. + +| Work | Commit | Result | +| --- | --- | --- | +| Configurable default 100 | `24c1e2c` | Compiler and per-context overrides remain supported | +| 17: promises | `7aea14a` | Resolution, rejection, cancellation, Cobalt, shutdown and allocator tests | +| 18: event waits | `68213bb` | One-shot events, cancellation, listener removal and deferred type ownership | +| 19: sockets and transport point | `9b37306` | Native aliases, browser unsupported results and custom transport forwarding | +| 20: resolver | `557d452` | Retained names, service parsing, posted results and deferred input ownership | +| 21: TLS settings and explicit OpenSSL | `d438a61` | Native linking, browser settings, PMR storage and actionable refusal tests | + +Validation completed locally with Apple Clang, Boost 1.92, Emscripten 6.0.11, +Node 26 and HeadlessChrome 153.0.8010.12. Native and WebAssembly suites were +rebuilt from scratch, including JSPI and Asyncify with exceptions on/off, +Cobalt, examples and native/browser TLS. The final native build updated 199 +targets and the WebAssembly build 778; these are build-target counts, not +assertion counts. Full lint, MrDocs/AsciiDoc generation and rendered checks +passed. The local matrix tool's unit suite passed; no CI job was dispatched. + +The Chrome lane passed loader, idle and responsiveness checks. With the new +default 100, JSPI observed 60 animation callbacks in one second and processed 1,550,817 +handlers, turn p95 0.100 ms and maximum 0.600 ms; Asyncify observed 61 callbacks +and processed 606,601 handlers, p95 0.300 ms and maximum 2.100 ms. Each unbounded +control observed zero animation callbacks. Both idle cases observed one +setTimeout(300000) and no polling over three seconds. These are local +observations of trivial handlers, not scheduling guarantees. + +TLS host recording used exactly one allocation from the supplied resource, +with zero counted global new/C/aligned allocations in all four WebAssembly +configurations. The independently owning verification request is constructed +before that measurement and moved into the context. Explicit missing OpenSSL +and an invalid root stopped with guidance; the optional native suite without +OpenSSL reported omission and passed. The checkout-local OpenSSL link was +restored. C and C++ negative tests confirmed the actual WebAssembly refusal, +not an unrelated missing-header failure. + +One independent final review found four important issues. Commit `f5fd7a8` +fixes all four with permanent regressions observed failing before the fixes: +promise/event operations retain their handler's associated executor work; +moved-from default transports remain usable; socket close forwards to the +custom transport's close hook; and the native umbrella header exposes all +three socket templates. Success, cancellation, shutdown, move construction +and assignment are exercised. The full suites, followed by focused tests after +style-only test changes, passed. Final lint and rendered documentation are clean. +Custom transports must supply close() to cancel pending work and release resources, +and preserve a usable executor in a moved-from source. + +One minor documentation finding remains: the TLS example is compiled and run +but lacks page variants and a row in the page size table. Carry this into task +22's documentation work; no binary-size claim is made for that example here. + +The next implementation task is 22 (rulebook, +index and full page), followed by 23 (broader release checks and gates). The +owner's no-CI instruction still applies to those later gates. + + +## Yield benchmark charts and complete tables, 2026-10-15 + +Library commit `3b5d1f5` adds four scientific figures in PNG and SVG, a +four-page PDF and a flattened table of all 102 configurations from 442 runs. +The reproducible plotting script reads the committed summary; no measurements +were rerun or changed. The guide includes all four figures inline. Full local +lint, documentation generation and rendered checks passed. CSV values match +the source summary; inline SVG identifiers are unique. The original raw-data +archive and its checksum remain unchanged. No CI, push or merge ran. The +default remains 1000 and task 17 remains pending. source/ matches library HEAD. + +## Default turn-limit rationale documented, 2026-10-15 + +Library commit `0aed494` explains that 1000 was the initial design policy, +then retained after task 13's workload-specific turn-duration check. The later +Release benchmark measures yield cost independently; it does not derive an +optimal default. The guide now links this provenance, the historical 8 ms p95 +screening criterion and an illustrative application cost model. Assumed callback +costs and overhead targets are explicitly not the historical selection rule. +Documentation generation and rendered checks passed. Only documentation changed; +no benchmark observations, scheduling behavior or defaults changed. The raw-data +archive remains the original measurement snapshot. No CI, push or merge ran. +Task 17 remains pending, and source/ matches the committed library. + +## Yield latency benchmark after task 16, 2026-10-15 + +Library commits `543e764` and `793c4c2` add a manual benchmark and its report; +`source/` matches library HEAD `793c4c2`. The superproject stays `8829e99`. +The default remains 1000; task 17 has not started. No CI, push or merge ran. + +The real production yield was measured locally in Release with compile/link +-O3, under JSPI and Asyncify, exceptions on/off, on Apple M5 Max and +HeadlessChrome 153.0.8010.12. All 442 fresh-page cases completed and validated: +970,139,132 operations and 9,429,856 timing pairs, including limits 1, 10, 100, +1000, 5000 and 10000. Seven primary repetitions gave median per-run direct +means of 4.062 us for JSPI and 4.7365 us for Asyncify; a matching JavaScript +control gave 3.9255 us. The observed isolated clock step was 5 us, ordinary +page step 100 us. C++ and JS monotonic reads share the same underlying clock. + +The report distinguishes direct round trips, callback-boundary gaps, +instrumented phase means and confounded whole-program control differences. +A deliberate 2 ms message-handler delay validated the phase attribution. +No outliers were removed: chain maxima were 5.01 ms and 39.72 ms. These data +support amortization for trivial handlers, not a claim that 1000 is optimal. +Observer overhead, clock quantization, warmup and baseline limitations are +explicit. Independent review found no remaining blocker. Five analyzer tests, +full local lint, documentation generation and rendered checks passed. + +Reproduction code is in `bench/yield/`, the guide report in +`doc/yield-cost.adoc`, and per-run CSV, summary and build hashes in +`bench/yield/results/2026-10-15/`. Raw timestamp arrays and logs are preserved +locally at `asio-task9-review/.local/yield-benchmark-2026-10-15.tar.gz`, +SHA-256 `2fbe2f23e6df9155ebc397da12bd12e94946a6bbbc4417f624fdc841a3baa341`. + +## Configurable default turn limit after task 16, 2026-10-15 + +Library commit `3817dc9` adds the owner-requested compiler configuration; +`source/` matches it. The superproject remains `8829e99`. Task 17 has not +started. No CI, push or merge ran. + +`WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN` is declared and documented in +config.hpp, defaulting to 1000. It initializes io_context_options; explicit +context options and the setter keep precedence. Zero is normalized to one, +negative build defaults are rejected, and native scheduling stays unchanged. +Apply the same definition to every relevant translation unit and rebuild all +of them, including Cobalt's separately compiled runner. The documented b2 +command passes the definition globally and uses a separate build directory. +Do not configure an existing runner archive by defining the macro only in an +application source file, or mix differently configured objects. + +Validation first reproduced the ignored value 100 in both context constructors +and Cobalt's real JSPI run. The corrected implementation passed the custom +and zero-default cases, the negative compile-fail case, the full native and +WebAssembly suites, documentation/rendered checks and full lint. Cobalt's +5,000-post regression passed with limit 100 under JSPI and Asyncify, with +exceptions on and off. Compiler command logs confirm the define reaches all +four separately compiled runner variants. An independent review found a test +expectation that incorrectly required a full 10,000-handler lot from only +5,000 samples; it failed with 5000 versus 10000, then passed after bounding +the expected observation by the sample size. No review finding remains. + +The MrDocs reference and guide include the macro and rebuilding requirements. +The guide now describes browser work as an opportunity, not a guarantee that +a particular timer or frame happens before resumption. Existing turn-duration +measurements are not measurements of the isolated yield overhead. No new +latency benchmark or claim of an optimal default is introduced here. + + +## Task 16 completed: Cobalt co_main with bounded turns, 2026-10-15 + +Library commit `c74f511` completes task 16 on the existing `work/task14-guide` +branch in the isolated checkout. `source/` matches that committed library. +The superproject remains `8829e99`; no new superproject patch is needed. +Tasks 0-16 are complete. Task 17 is next and has not started; tasks 17-23 remain. +No CI, push or merge ran, and the primary checkout was not changed. + +`/webcpp/asio//cobalt` links Boost's sources and webcpp's replacement +`main_promise::run_main` and `final_suspend`. The application keeps its ordinary +co_main. Its executor uses the bounded webcpp context, with the existing +1,000-handler default on Emscripten and native Boost behavior. Context and signal +objects are destroyed before Asyncify's explicit exit preserves co_return. +The adapter preserves the original Boost author's copyright notice. + +Validation: native Clang, JSPI and Asyncify passed with exceptions on and off. +The 5,000-post test checks bounded turns and both Cobalt and Asio timers. The +external drivers verify exact statuses 7 and 0, output, absence of signals and +restricted stderr; raw run-fail is not the sole exit-status oracle. Negative +scratch controls reproduced the lost status without std::exit and the unbounded +turn with Boost's original context; restored code passed. The ordinary library +suites and existing real-browser lane passed. The new example also passed in +HeadlessChrome 153.0.8010.12 under both variants and both exception modes at -O2. +This session did not execute the CI-pinned browser version. + +Six Cobalt suspension-stack configurations passed: debug, default-link release +and release linked with -O3, with exceptions on/off. The deepest observed Cobalt +path was 1,088 bytes. The existing 8,192-byte allocation remains unchanged. The +probe forces actual blocking polls by posting cancellation from a JavaScript +macrotask. The run-family probe remains covered through the shared observer. + +All 24 Release page modules completed once with the expected output. The six +profiles are -O2, -O3, -Os, -Oz, -O3 -flto and -Oz -flto, crossed with exception +mode and suspension variant. Compile/link flags and LTO bitcode were checked. +The full Wasm/JavaScript size matrix is in doc/cobalt.adoc, and the generated +release size table includes the fourth example. The documentation build and +rendered-content checks passed. The final full lint passed. There are no new +public headers requiring additional MrDocs declarations. + +Independent read-only review found one important attribution omission, fixed +and checked against Boost's original main.cpp. No functional defect or deferred +minor was reported for this task. The final verification command passed after +commit; its log remains under the library's .superpowers/sdd/plan/task-16-tests.log. + +### Task 16 decisions and their limits + +- Use yield_counter for the handler bound and observe page_timeout separately. + Host timers do not run at a fixed callback index. If the witness proves + insufficient, strengthen it without imposing a false timing guarantee. +- Test both exception modes with result adapters and retain issue 287's warning. + This does not repair pending-task moves or prove universal no-exception safety; + applications that use the affected upstream operation can still abort. +- Require exact status 7 and 0 with external drivers in their own local lanes. + A trap or unfinished main must not satisfy a run-fail test. The driver accepts + only Emscripten's exact debug runtime-retained notice in addition to empty stderr. +- Preserve EXIT_RUNTIME=0 instead of forcing shutdown. External runtime callbacks + may remain active after std::exit; full runtime teardown is not promised. +- Suppress only Clang's coroutine-missing-unhandled-exception diagnostic for + explicitly exception-free Cobalt consumers. Boost omits that promise member. + This one diagnostic is unavailable for other coroutines in those translation + units until upstream provides a compatible declaration; other warnings remain. +- Preserve upstream executor/resource and signal lifetimes. Review found no new + regression; existing upstream limitations remain outside this adapter's scope. +- Keep task 14 timings scoped to its three original examples. Cobalt's separate + size matrix is not a timing benchmark; repeated isolated timing runs would + be required for such claims. Profiles other than -O2 were checked under Node, + not individually in Chrome. +- Keep task 17 and later pending and preserve the local branch/checkout. The + next task's promise integration is not supplied by this completion. + +To resume, use library `c74f511` with superproject `8829e99`, read task 17 and +these decisions, and implement browser promises as operations. Preserve the +owner's no-CI instruction and exception policy unless explicitly changed. + + +## Task 15 completed: compiled Cobalt source target, 2026-10-14 + +Superproject commit `8829e99` completes task 15 on the isolated +`work/asio-task9-review` branch. Patch 0015 records that commit, preserving the +previous patches. The library remains `ee64779`; `source/` is unchanged. +Tasks 0-15 are complete. Task 16 is next and has not started; tasks 16-23 remain. +No CI, push or merge ran, and the primary checkout was not changed. + +`/webcpp//boost_cobalt` builds 24 of Boost 1.92's 26 sources, excluding +`src/main.cpp` and `src/io/ssl.cpp`. Its implementation defines +`BOOST_COBALT_SOURCE=1` and `BOOST_COBALT_IO_SOURCE=1`. Consumers receive +`BOOST_COBALT_NO_LIB=1`; Emscripten sources and consumers receive +`BOOST_ASIO_DISABLE_THREADS`, with native thread support unchanged. +Ordinary `main` consumers work. The replacement `co_main` runner belongs to +task 16 and is not supplied by this archive. + +The consumer's exception setting is preserved. With exceptions disabled, b2 +prints a non-fatal configuration warning linking +https://github.com/boostorg/cobalt/issues/287 and recommending exceptions. +This warning is not a compiler diagnostic, does not become fatal under +warnings-as-errors, and does not detect moves or establish runtime safety. +It is cached per base configuration within a b2 invocation. No warning is +printed for an exceptions-enabled configuration or an unrelated target. + +Validation: all 20 compiled-Boost-library cases, 11 Jamroot cases and 45 local +installer cases passed. The source-composition test first failed on the missing +I/O source macro and deliberately invalid main.cpp, then passed after the fix. +The real Cobalt consumer compiles, links and executes on native Clang, JSPI and +Asyncify with exceptions off and on. Each configuration rebuilds exactly 24 +sources and verifies macro and exception propagation. It exercises eager +promises, a completed result, Cobalt's I/O timer and timer cancellation handled +as a value. Missing or mismatched sources and nested installer preservation +also pass. Pyright reports zero errors and warnings; licence, line length, +blank lines, Jam comments, shell syntax and git whitespace checks pass. +These are local tests, not a CI run or a full browser/API validation. + +### Decisions against the older plan + +- Keep the existing shared BOOST_SOURCE discovery, version check and installer, + rather than add a second Cobalt source tree. The existing installer already + preserves nested Cobalt sources. If a separate layout becomes necessary, + source discovery must be adapted without changing the public target. +- Keep compiled-library regressions in boost_libraries_test.py, their current + home; also run the plan's Jamroot and installer suites. Moving their location + later does not change the covered behavior. +- Replace three archive-only builds with six real archive-and-consumer builds; + they additionally execute the result. Direct archive builds can be repeated + if a target-only distinction is discovered. +- Exclude main.cpp as required, deferring its replacement to task 16. Until + then co_main consumers must supply run_main separately. +- Preserve the owner-approved non-fatal warning instead of forbidding builds + without exceptions. The known upstream runtime risk remains unresolved. + +Independent read-only review found no Critical or Important issue. One minor +wording correction is deferred: AGENTS.md says distinct configuration, whereas +the warning cache uses distinct base configurations and ignores free flags. +The reviewer deliberately left co_main to task 16 and did not claim real-browser +or exhaustive I/O coverage. Broader guarantees need their own tests. The +reviewer did not rerun the suites; execution evidence comes from the executor. +The final verification log is retained in the isolated worktree at +`.superpowers/sdd/plan/task-15-tests.log`. + +To resume, keep the existing isolated checkout at `8829e99` and library at +`ee64779`, read task 16 in plan.md and the rulings above, and implement the +replacement main_promise::run_main with webcpp::asio's turn limit. Do not restore +the old blanket exception restriction or silently enable exceptions. + + +## Cobalt exception-policy correction before task 15, 2026-10-14 + +The owner explicitly requested removing the blanket rejection of Cobalt builds +with exception-handling=off. Superproject commit `d507a93` removes that conditional +from tools/boost/Jamfile, corrects AGENTS.md, and adds a real compiled-library +regression to tools/test/boost_libraries_test.py. It preserves the consumer's +exception setting; it does not force exceptions on. Patch 0014 records this +commit without changing any earlier patch. The library remains `ee64779`. + +The old command `/webcpp//boost_cobalt exception-handling=off` was reproduced +failing before compilation. The final regression consumer was also rejected by +the old rule in a separate scratch checkout. With the correction, eager promises, +as_result on a completed promise, and timer cancellation through as_tuple compile, +link and execute on native Clang, JSPI and Asyncify, with exceptions both off and +on. All six archives are built from Boost's sources; the test checks that +-fno-exceptions reaches the library and consumer only when off. The Emscripten +requests explicitly provide BOOST_ASIO_DISABLE_THREADS; automatic configuration +and the remaining task 15 integration are still pending. + +Validation: the full 17-case boost_libraries_test.py suite passed, including the +six Cobalt configurations and existing URL, Charconv and Locale cases. Pyright +reported zero errors and warnings. Licence, Python line length and blank-line, +Jam comment and git whitespace checks passed. Independent static review found no +blocking issue; its stale native-only comment finding was corrected. +No CI, push or merge ran. The primary checkout remains unchanged. + +### Upstream limitations found during validation + +Removing the configuration refusal does not establish universal Cobalt support +without exceptions. A first consumer using a pending task with as_result and +spawn compiled and linked but aborted under native libc++ with +`make_exception_ptr was called in -fno-exceptions mode`. Boost 1.92's +`task_receiver` move constructor calls moved_from_exception(), which constructs +an exception_ptr. The reproduction is retained locally as +`.local/cobalt-moved-task-noexceptions.cpp`. The build comments and AGENTS.md +record this limitation. No Boost sources were patched or exception settings +silently enabled. + +A further exploratory probe retaining a lazy task in place and awaiting it via +as_result did not complete; the eager-promise regression does not claim to cover +that path. Investigate lazy-task adapters and movement before claiming full +no-exceptions support in the Cobalt integration. The remaining task 15 and task 16 +work has not been marked complete. + +## Task 14 follow-up: exception support, sizes and timings, 2026-10-14 + +The owner requested comparisons with exceptions on and off, including both +build duration and runtime. The isolated library is `ee64779` on +`work/task14-guide`; `source/` matches all 72 tracked files. Only README.md, +doc/building.adoc and doc/testing.adoc changed. The superproject remains +771a247. No CI, push, merge or task 15 work ran. + +Measured all six profiles (-O2, -O3, -Os, -Oz, -O3 -flto, -Oz -flto), both +suspension variants, both exception settings and all three page examples: +72 modules. Each configuration had one cache-preparation build and three +measured builds in fresh directories, with -a -j4 and compile/link flags +checked. All four builds produced identical file sizes. The build median +covers the complete six-module batch, including manifests and size tables. +No measured build generated an Emscripten system library. + +| Profile | Build median, exceptions on | Build median, exceptions off | +| --- | ---: | ---: | +| -O2 | 3.33 s | 3.16 s | +| -O3 | 4.08 s | 3.61 s | +| -Os | 3.93 s | 3.58 s | +| -Oz | 3.94 s | 3.51 s | +| -O3 -flto | 4.72 s | 4.17 s | +| -Oz -flto | 4.46 s | 4.01 s | + +Runtime: one discarded round followed by eleven measured rounds in fresh +Node processes, alternating order. All 864 runs matched expected output, +reported exactly one successful completion and produced no stderr. Module +initialization starts after JavaScript import and Wasm file reading; +execution starts at onRuntimeInitialized and ends at webcppTestFinished(0), +before local-object cleanup. Asyncify factory resolution alone is not used +as completion. Timings include timer waits and scheduling, are not CPU-only +or warmed-JIT measurements, and do not measure throw/catch latency. + +Environment: Emscripten 6.0.11, Boost 1.92, C++20, Node 26.7.0, macOS 27 +arm64, Apple M5 Max, 128 GiB RAM, Asyncify suspension stack 8192 bytes. +With exceptions on, JSPI uses Wasm exceptions and Asyncify JavaScript-based +exceptions. With exceptions off, all objects use -fno-exceptions. + +-Oz -flto produced the smallest Wasm and combined payload in every +example/variant/exception setting. Disabling exceptions reduced Wasm and +total payload throughout. JSPI -O2 JavaScript alone grew by 38 bytes; +other JavaScript files shrank. Full size, build-time and runtime tables, +including variability, are in source/doc/testing.adoc. + +Validation: 72 artifact sizes and hashes, 792 measured samples and their +statistics, 48 build logs, and all 78 measurement rows in source and rendered +HTML checked. MrDocs, Asciidoctor, source/rendered checks and shell syntax +passed. An independent read-only review approved the measurement method, +final tables and conclusions with no blocking findings. No full library +suite or real-browser matrix was rerun for this documentation follow-up. + +Evidence in the isolated superproject: .local/measure-asio-exceptions.py, +.local/asio-runtime-measure.mjs, +.local/task14-exceptions-20261014-142622/results.json and its 48 build logs, +bin/task14-eh-20261014-142622-* and bin/task14-exceptions-doc. +The primary checkout remains unchanged. Task 15 has not started. + +## Task 14 follow-up: six release profiles, 2026-10-14 + +The owner authorized compiling all six proposed profiles before moving to the +next task. The isolated library is `a4ecb6b` on `work/task14-guide`; `source/` +matches all 72 tracked files. No production code or build rules changed in this +follow-up. No CI, push, merge or task 15 work ran. + +Built all three examples in JSPI and Asyncify for -O2, -O3, -Os, -Oz, +-O3 -flto and -Oz -flto: 36 page modules. Each profile used a fresh isolated +build directory, release/NDEBUG, and the same flags at compile and link. +Every effective optimization flag was checked in the verbose build log, and +LTO object files were verified to contain LLVM bitcode. Every exact page +module ran under Node 26.7.0 and matched its expected output, without stderr. +Emscripten 6.0.11, Boost 1.92, C++20, macOS arm64; exception settings and +Asyncify's 8192-byte suspension stack were unchanged across profiles. + +The guide now contains three matrices with Wasm and JavaScript bytes separately, +plus commands that reproduce all profiles. All 72 recorded sizes were checked +against the files and the rendered documentation. MrDocs, Asciidoctor and +source/rendered checks passed. No full library suite or real-browser run was +performed per profile; the matrix establishes the examples' behavior under Node. + +| Flags | Example | JSPI Wasm | Asyncify Wasm | JSPI JS | Asyncify JS | +| --- | --- | ---: | ---: | ---: | ---: | +| -O2 | asio_quick_start | 81,162 | 157,410 | 79,404 | 90,706 | +| -O2 | asio_timers | 82,969 | 162,160 | 79,394 | 90,696 | +| -O2 | asio_turn_limit | 78,205 | 149,904 | 79,402 | 90,704 | +| -O3 | asio_quick_start | 80,979 | 153,459 | 78,899 | 89,248 | +| -O3 | asio_timers | 82,724 | 157,831 | 78,889 | 89,238 | +| -O3 | asio_turn_limit | 78,085 | 146,529 | 78,897 | 89,246 | +| -Os | asio_quick_start | 74,490 | 147,893 | 78,899 | 88,867 | +| -Os | asio_timers | 74,987 | 150,501 | 78,889 | 88,857 | +| -Os | asio_turn_limit | 71,052 | 139,673 | 78,897 | 88,661 | +| -Oz | asio_quick_start | 70,771 | 148,813 | 78,328 | 88,296 | +| -Oz | asio_timers | 72,022 | 153,293 | 78,318 | 88,286 | +| -Oz | asio_turn_limit | 67,838 | 141,185 | 78,326 | 88,090 | +| -O3 -flto | asio_quick_start | 86,096 | 143,667 | 79,747 | 89,240 | +| -O3 -flto | asio_timers | 87,840 | 148,668 | 79,737 | 89,496 | +| -O3 -flto | asio_turn_limit | 83,189 | 136,877 | 79,745 | 89,238 | +| -Oz -flto | asio_quick_start | 65,712 | 127,067 | 79,176 | 88,871 | +| -Oz -flto | asio_timers | 67,968 | 132,768 | 79,166 | 89,386 | +| -Oz -flto | asio_turn_limit | 62,824 | 120,140 | 79,174 | 89,104 | + +-Oz -flto produced the smallest Wasm and combined two-file payload in every +example/variant. -Os beat -Oz for Asyncify Wasm without LTO; -O3 -flto increased +JSPI Wasm size. These are size measurements, not performance benchmarks. + +Evidence in the isolated superproject: `.local/task14-release-matrix.json`, +`.local/measure-asio-release-matrix.py`, `.local/task14-matrix-*.log`, +`bin/task14-matrix-{o2,o3,os,oz,o3-lto,oz-lto}` and `bin/task14-matrix-doc`. +The earlier release correction below remains the source of the full suite, +lint and browser results. The primary checkout remains unchanged. +Task 15 has not started. + +## Task 14 follow-up: optimized release sizes, 2026-10-14 + +The owner requested release-only binary-size documentation. The isolated library +is now `c87731f` on `work/task14-guide`; `source/` matches its 72 tracked files. +The superproject remains `771a247`. No CI, push, merge or task 15 work ran. + +### Release build and measurements + +Both compilation and link use `-O3`, with `variant=release` and `NDEBUG`. +The explicit link flag is necessary with the current b2 Emscripten toolset. +Emscripten 6.0.11, Boost 1.92, C++20, macOS arm64; exceptions enabled for both +variants, Asyncify stack 8192, no LTO or compression requested. These are complete +page modules without the Node harness, excluding JavaScript glue and runtime memory. + +| program | jspi bytes | asyncify bytes | asyncify / jspi | +| --- | ---: | ---: | ---: | +| page-asio_quick_start | 80,979 | 153,459 | 1.90 | +| page-asio_timers | 82,724 | 157,831 | 1.91 | +| page-asio_turn_limit | 78,085 | 146,529 | 1.88 | + +Reproduce from the superproject root: + +```sh +b2 -a toolset=emscripten variant=release linkflags=-O3 libs/asio/example//asyncify +``` + +The measured artifacts and generated table are in +`bin/task14-release-sizes-final/` in the isolated checkout. All six exact page +modules were also loaded under Node 26.7.0 and matched their expected output. +The guide and README require release for binary-size publication; the former +unqualified three-times Asyncify estimate now points to the measured table. + +### Defects found by release validation + +- Optimized JSPI with WebAssembly exceptions failed to link the native dependencies + of JavaScript's stackSave/stackRestore. Emscripten reads EM_JS_DEPS after native + linking. Asio's target now explicitly exports emscripten_stack_get_current and + _emscripten_stack_restore. The optimized bridge regression failed before this + correction and passes afterward, alongside a no-exceptions control. +- Native optimized allocation instrumentation failed 11 checks because compiler + allocation builtins elided or reordered calls relative to measurement flags. + Only the native allocation tests use -fno-builtin on Clang/GCC. A permanent + allocation_native_release target covers this configuration. Application builds + and size measurements keep their normal optimizations. + +### Validation + +Fresh builds passed 16 native release test markers, 76 WebAssembly test markers, +three examples natively and under each optimized WebAssembly variant, and all four +browser drivers in optimized release. HeadlessChrome 153.0.8010.12 passed loader, +idle and rendering checks for both variants. The native allocation controls retain +correct attribution and still detect an unbound handler's C allocation. + +MrDocs, Asciidoctor and source/rendered documentation checks passed. Full lint was +clean with 97 compilation commands and 33 translation units. Read-only review found +no Critical or Important issues; its README placement finding was fixed. A scoped +review of the later native instrumentation correction found no issues. + +Build directories are `bin/task14-release-native-final`, +`bin/task14-release-fix-suite`, `bin/task14-release-browser`, +`bin/task14-release-asyncify-examples`, and `bin/task14-release-doc-complete`. +The primary checkout remains unchanged. Task 15 has not started. + +## Task 14 completed locally, 2026-10-14 + +This update supersedes the task statuses below. Tasks 15 to 23 remain unstarted. +The owner authorized task 14 and requested Diataxis writing while retaining the +superproject's AsciiDoc and MrDocs documentation pipeline. No CI, push or merge ran. +The primary superproject remains `eba8545`, with its Asio library at `a179adc`. +Tasks 12 to 14 remain in the isolated checkout. + +The isolated superproject branch `work/asio-task9-review` is `771a247`; the library +branch `work/task14-guide` is `f6ce577`, based on task 13's `3d22924`. +`source/` matches all 72 tracked library files byte for byte. The new `0013` patch +records the build correction; historical patches `0001` to `0012` are unchanged. + +### Guide, examples and contracts + +- Added a guided first-program tutorial, task-focused timer and turn-limit sections, + application-testing instructions and navigation by learning, doing, understanding + and reference needs. The existing single-page layout, AsciiDoc, generated MrDocs + reference and stable section titles remain in use. +- Added three compiled examples with exact `.expected` files. The quick start arms + its 50 ms timer inside the posted handler. The timers example shares one clock + origin for 60/20/40 ms deadlines and demonstrates cancellation after restarting + the drained context. Their output order does not rely on setup speed. +- Added nine numbered guarantees, moving existing anchors into one chapter and + preserving their identifiers. The text qualifies polling-turn bounds, timed-call + scheduling, supported callers, assertion behaviour and allocator exclusions. + Corrected the run-family test's reference to its general semantics section. +- README code and output are checked copies of the compiled quick start. Every + shown guide listing includes its real source or expected output. +- The examples use the existing completion helper when main finishes after suspension. + Page variants receive its header directory without the Node test harness. + +### Reproduced defects and review + +The actual WebAssembly example runner selected `browser-src.o` as expected output, +while the size-table action attempted to parse it as JSON. Inherited library source +usage appended that object to each make action's sources. Two scratch integration +regressions reproduced those failures before the fix. The actions now select the +expected file and JSON manifests by suffix, preserving their build dependencies. +The example regression also proves that deliberately wrong output still fails. + +Independent read-only review found two Important issues: executable-only tutorial +targets did not run their programs, and suspended Asyncify examples did not report +completion to the test harness. Both were reproduced and fixed. The five individual +guide commands now name `.output` targets, actually run and capture the documented +text. The tutorial explains that output is captured, not automatically printed. +There were no Critical or Minor findings. The later tool fix was validated by the +parent with regression and integration tests; it was not independently re-reviewed. + +### Validation + +After commit, fresh builds passed 15 native and 78 WebAssembly test markers, plus +all three examples natively, under JSPI and under Asyncify. The real browser lane +passed too. Every example output matched its fixture. Each missing fixture had +first been observed failing on native and Emscripten builds. + +All 25 Emscripten tool integration cases, the example-runner tests and five variant +tests passed. Full lint was clean: 91 compilation commands, 33 translation units, +Pyright and the remaining text and boundary checks. MrDocs, Asciidoctor, source and +rendered documentation checks passed. Navigation and all nine guarantee anchors +occur exactly once in the generated HTML. + +The integrated browser rejected a direct local-file URL, so visual inspection was +not completed and no workaround was attempted. Automated rendered-HTML checks passed. +The OpenSpec CLI is unavailable; strict CLI validation remains unperformed. + +### Measured page-module sizes + +The optimized release measurements in the follow-up above supersede the +initial debug measurements. Published binary-size documentation uses release only. + +The complete post-commit log is `libs/asio/.superpowers/sdd/plan/task-14-tests.log` +in the isolated checkout. Other task 14 logs and the verification script are beside +it. The script builds native tests/examples, WebAssembly tests and the browser lane, +JSPI examples and the size table, Asyncify examples, and the documentation in fresh +`bin/task14-committed-*` directories, using `.local/review-b2 -a -j4 --verbose-test`. +Proposal validation passed: 22 proposals with zero problems and all 17 checker tests. +Keep the isolated checkout. The next task is 15 and has not started. + +## Task 13 completed locally, 2026-10-14 + +This update supersedes the task statuses below. Tasks 14 to 23 remain unstarted. +The owner authorized task 13 without CI. No CI, push or integration of tasks 12 and 13 ran. +The primary superproject remains `eba8545`, with its local Asio library at `a179adc`. + +The isolated superproject branch `work/asio-task9-review` is `3d069a1`; its library +branch `work/task13-browser` is `3d22924`, based on task 12's `da3c790`. +`source/` matches all 64 tracked library files byte for byte. The new `0012` patch +records the superproject change; patches `0001` to `0011` remain unchanged. + +### Changes and decisions + +- Added real headless Chrome idle, render and loader drivers alongside the existing + Node loader driver, covering both JSPI and Asyncify. +- Idle observation lasts three seconds: exactly one `setTimeout(300000)`, with no + other recorded timer or message polling. A work guard keeps the context pending. +- Self-posting handlers run for one second. With the default 1,000-handler turn limit, + animation callbacks occur; both unbounded Boost controls produce zero callbacks. + Callback entry uses `performance.now()`, avoiding stale animation-frame timestamps. + This observes animation opportunities, not proof of specific pixels being painted. +- Full turns end at the yield message post and start at message delivery. The final + partial turn is excluded; p95 uses the nearest-rank statistic. The driver rejects + p95 above 8 ms and missing animation callbacks. The default remains unchanged. +- Loader checks execute three handlers in each actually imported variant, including + Asyncify selected after removing `WebAssembly.Suspending` before page execution. + The fixture identifies the imported artifact before awaiting its factory: the JSPI + factory awaits `main`, and the idle program intentionally never returns. +- The driver rejects console errors, uncaught exceptions and reported loader errors. + Bounded waits, signal handling and cleanup remove its Chrome process and profile. +- Added Asio to `CHROME_LANES`, preserving existing document and Trystero entries. + The matrix change was tested before implementation; no CI workflow was executed. +- Used the existing bound-function-pointer handler pattern to satisfy static analysis + without suppressing its recursion diagnostic. No production Asio or loader code changed. + +### Validation + +On macOS arm64, local Playwright HeadlessChrome 153.0.8010.12, Emscripten 6.0.11, +Boost 1.92 and Node 26.7.0, three fresh serial browser builds passed all four drivers. +The final six measurements are recorded in `source/AGENTS.md`: + +- JSPI: p95 0.700 ms in every run; maximum up to 1.900 ms; 60 animation callbacks. +- Asyncify: p95 1.600 ms in every run; maximum up to 9.200 ms; 61 animation callbacks. +- Both unbounded controls: zero callbacks in all runs. Both idle and loader variants passed. + +A fourth fresh browser build passed after commit and recorded task completion. +Fresh full suites passed 15 native and 78 WebAssembly markers before the final C++ +style corrections; all changed browser programs were then rebuilt and retested in +all four final browser runs. Full lint after those corrections passed with 85 compilation +commands and 30 translation units. Documentation generation and rendered checks, +35 matrix tests, JavaScript syntax and diff checks passed. + +Scratch negative controls proved detection of console errors, uncaught exceptions, +import failures, wrong variants and polling. A SIGTERM check returned 143 and left +no owned Chrome process or profile. Independent read-only review found no Critical, +Important or Minor issues. + +Commands from the isolated superproject: + +```sh +.local/review-b2 -a -j1 --verbose-test --build-dir=bin/task13-final-measure-1 toolset=emscripten libs/asio/test/browser//browser +.local/review-b2 -a -j1 --verbose-test --build-dir=bin/task13-final-measure-2 toolset=emscripten libs/asio/test/browser//browser +.local/review-b2 -a -j1 --verbose-test --build-dir=bin/task13-final-measure-3 toolset=emscripten libs/asio/test/browser//browser +.local/review-b2 -a -j1 --verbose-test --build-dir=bin/task13-committed toolset=emscripten libs/asio/test/browser//browser +``` + +Logs are under `.local/task13-validation/`; committed verification output is at +`libs/asio/.superpowers/sdd/plan/task-13-tests.log`. The local Chrome version differs +from the CI pin; the pinned browser and other platforms were not executed here. +The OpenSpec CLI is unavailable, so strict CLI validation remains unperformed. +Proposal validation passed: 22 proposals with zero problems and all 17 checker tests. +Keep the isolated checkout. The next task is 14 and has not started. + +## Tasks 9 to 11 integrated locally; task 12 completed, 2026-10-14 + +This update supersedes the earlier task statuses below. Tasks 13 to 23 remain unstarted. +The owner authorized local integration of tasks 9, 10 and 11 and implementation of task 12. +No CI workflow, push, remote repository or registered submodule was created. + +### Local integration + +- `webcpp/main` fast-forwarded from `9a268b7` to `eba8545`, carrying the ten prerequisite + superproject commits already validated in the isolated checkout. +- `webcpp/libs/asio` was absent, so a local clone brought in the library's complete history. + Its `main` is `a179adc`, including tasks 9, 10 and 11. It has no remote and remains ignored + by the superproject until registration is authorized. +- Fresh post-integration Asio suites passed: 15 native and 74 WebAssembly markers. + Local tool checks also passed: variants (5 cases), lint tests (57), build declarations (35), + matrix planning (34) and Emscripten integration (22). These are local test scripts, not CI. + Logs are in the primary checkout's `.local/asio-merge-validation/`. + +### Task 12 + +The isolated checkout remains `asio-task9-review`. Its superproject branch +`work/asio-task9-review` is now `35c8aa7`; its library branch `work/task12-loader` is `da3c790`. +These task 12 commits are not integrated into the primary checkout. +`source/` matches all 59 tracked files at library commit `da3c790` byte for byte. +The new `0011` superproject patch records the build correction; patches `0001` to `0010` +remain unchanged historical records. + +- Added the loader's `supportsJspi`, `pick` and `load` functions, using artifact names from + the generated manifest, explicit variant overrides and replaceable fetch/import functions. +- Added the browser lane's Node driver and a real page program that posts three handlers, + runs its context and prints its completion. Both generated JSPI and Asyncify artifacts load. +- The driver waits for observed output within its 60-second bound. It replaces the plan's + fixed 200 ms sleep, avoiding an assumption about machine speed. +- Fixed `webcpp.variants` exporting consumed library source dependencies through its finished + executables. This caused duplicate symbols when the manifest and driver consumed both + variants. A real linked fixture failed before the fix and passed afterward; each executable + still consumes its dependencies for its own compilation and link. +- Applied library requirements only to the page program. The driver uses `.//page_program` + and removes the inherited library requirement, avoiding another unintended link. +- Independent read-only review identified one important issue: HTTP redirects changed the + manifest's directory, but the loader used the original URL. A real loopback HTTP 302 + reproduced the wrong artifact path. The fix uses `response.url`, falling back to the + requested URL for custom fetch implementations. The regression and both real variants pass. +- Documented the manifest, loader options, errors, redirects and the distinction between + factory readiness and completion of a suspended main. README reflects the Node lane. + +### Task 12 validation + +With Boost 1.92, Emscripten 6.0.11, Node 26.7.0 and native Clang 21: + +- Fresh full suites: 15 native and 75 WebAssembly passing markers. Following the review fix, + the affected browser lane was rebuilt from scratch and passed, including once after commit. +- Full local lint: `lint: clean`, including 76 compilation commands for 27 C++ translation + units, Pyright, formatting, library boundaries and all text rules. +- All 23 Emscripten tool integration cases passed with the new variant dependency regression. +- Full documentation generation and rendered checks passed; the page lists 78 distinct tests, + 15 native and 75 Emscripten, with overlap between targets. JavaScript syntax and diff checks + passed. The runtime browser test is Node-only here; Chrome measurements belong to task 13. + +Commands from the isolated superproject, using `.local/review-b2`: + +```sh +.local/review-b2 -a -j4 -d+2 --verbose-test --build-dir=bin/task12-final-native libs/asio/test +.local/review-b2 -a -j4 -d+2 --verbose-test --build-dir=bin/task12-final-wasm toolset=emscripten libs/asio/test libs/asio/test//asyncify libs/asio/test/browser//browser +.local/review-b2 -a -j4 --verbose-test --build-dir=bin/task12-committed toolset=emscripten libs/asio/test/browser//browser +.local/review-b2 -a -j4 --verbose-test --build-dir=bin/task12-final-doc libs/asio/doc +``` + +Suite logs and lint output are under `.local/task12-validation/`; the committed browser +lane's complete output is `libs/asio/.superpowers/sdd/plan/task-12-tests.log`. +The next task is 13. Preserve the isolated checkout and use its two task 12 commits as the +base when authorized to continue. No task 13 code or CI configuration was added. +Proposal validation passed: 22 proposals with zero problems and all 17 checker tests. +The OpenSpec CLI is unavailable, so strict CLI validation remains unperformed. + +## Task 11 completed, 2026-10-14 + +This update supersedes task 11's status in the historical sections below. Tasks 12 to 23 +remain unstarted. `source/` matches local library commit `a179adc` on top of `ded30cb`. +The isolated superproject worktree remains at `eba8545`, with no production changes here. + +### Changes + +- Added `test/allocation_test.cpp`, registered natively and in all four WebAssembly + configurations: JSPI and Asyncify, each with and without exceptions. +- Counted all eight global `operator new` forms and the platform's C and aligned allocation + entry points. The supplied allocator obtains its storage through the uncounted backend, + avoiding double counting. Direct controls exercise the intercepted allocation functions. +- Measured context construction and destruction, a 5 ms timer, ten bound posts and, on + Emscripten, two bridge deliveries that post bound handlers. All operations must finish; + the supplied allocator must be used, with zero unexpected allocations. +- Kept the named runtime allocations separate: a stack-backed test replacement for + Emscripten's `select` poll array, and a flag around Asyncify's unwind-data allocation. + A separate explicit suspension proves that the latter counter works, independently of + whether the timer is already ready when `run` begins. +- Added the unbound-handler control: default handler storage is visible through the C or + aligned counters even though it does not call global `operator new`. +- Added `doc/allocation.adoc`, including the compiled scenario, platform limitations and + the distinction between context and handler allocators. No production implementation + change was necessary. Independent read-only review found no Critical or Important issues; + its minor documentation correction about MSVC counting all threads was applied. + +### Local validation + +With Boost 1.92, Emscripten 6.0.11, Node 26.7.0 and the configured native Clang 21 toolset: + +- Fresh native suite: 15 passing markers. The scenario reported `given=18 new=0 c=0 + aligned=0 runtime=0`; the unbound handler reported `c=1`. +- Fresh WebAssembly suite, including Asyncify: 74 passing markers. The allocation scenario + passed in all four configurations with `given=22 new=0 c=0 aligned=0`; runtime allocations + depend on suspension. The explicit suspension reported runtime 1 on Asyncify and 0 on + JSPI. Each unbound handler reported `aligned=1`. +- Removing only the context allocator in a scratch copy failed on native and all four + WebAssembly configurations, with `operator_new_calls > 0` and exit status 1. The native + count was 7. The temporary Jamfile declarations were restored. The correct source then + passed the fresh full suites after the instrumentation cleanup. +- clang-tidy passed in six configurations: native with and without exceptions and all four + WebAssembly configurations. Dependency diagnostics use the existing suppression policy; + no project findings remain. clang-format, changed-file text rules and diff checks passed. +- Full local documentation passed: MrDocs, source checks, Asciidoctor conversion and rendered + HTML checks. It lists 77 distinct tests, 15 native and 74 Emscripten, with overlap between + targets. The allocation section and compiled listing are present. + +Commands from `asio-task9-review`, through its existing toolchain wrapper: + +```sh +.local/review-b2 -a -j4 -d+2 --verbose-test --build-dir=bin/task11-suite-native libs/asio/test +.local/review-b2 -a -j4 -d+2 --verbose-test --build-dir=bin/task11-suite-wasm toolset=emscripten libs/asio/test libs/asio/test//asyncify +.local/review-b2 -a -j2 -d+2 --build-dir=bin/task11-doc libs/asio/doc +``` + +Full logs are `.local/task11-validation/native.log`, `wasm.log` and `doc.log`. Six compile +command databases and analysis logs are under `.local/task11-validation/lint/`. Scratch +negative-control logs are `.local/task11-negative/native.log` and `wasm.log`. + +### Measurement decisions and limits + +LLDB traced an initial native `calloc` to dyld instantiating Asio's thread-call-stack TLS. +The test initializes that thread runtime by querying `running_in_this_thread` on a temporary +context before measurement. The measured context and all operations are still fresh. The +assertion therefore covers routing after thread runtime initialization, not cold-start +memory usage. This scope is explicitly documented. A thread-local bookkeeping flag was +also replaced with main-thread-only access after LLDB reproduced recursion through the +macOS allocation logger while dyld initialized the flag itself. + +An assertion that the timer must suspend was removed after it failed when the timer was +already ready. Its replacement deliberately suspends in a separate control; no elapsed-time +tolerance or allowance for unexpected allocations was introduced. + +JavaScript heap allocations, leak detection and later resolver/socket/coroutine scenarios +are outside this task. Linux/glibc, MSVC and AddressSanitizer hooks were not executed on this +Mac. No CI, push, merge, real-browser execution or whole-organization lint was run. The +OpenSpec CLI remains unavailable, so strict OpenSpec CLI validation was not performed. +Proposal validation also passed: 22 proposals with zero problems and all 17 checker tests. +The reference snapshot matches all 53 tracked library files byte for byte. +The next implementation task is task 12; it has not been started. + +## Task 10 completed, 2026-10-14 + +This update supersedes the task 10 status in the historical sections below. Tasks 11 to 23 +remain unstarted. `source/` now matches local library commit `ded30cb` on top of `ad6367b`. +The isolated superproject worktree and its tip remain as described in the task 9 update. + +### Changes + +- Added `test/timers_test.cpp` with five cases: steady timers registered at 60, 20 and 40 ms + complete in deadline order; a 30 ms system timer; cancellation of a timer; cancellation of + one wait through its slot, signalled by a 10 ms timer; and Beast's 100 ms WebSocket handshake + timeout over its in-memory test stream. +- Ordered steady deadlines share a clock origin. Completion counts and error values are + asserted. The cancellation-slot case keeps a second wait on the same timer and verifies + that explicit cleanup still cancels one operation, proving isolation of the signalled wait. +- Registered `timers_native` and the four WebAssembly configurations: JSPI and Asyncify, each + with and without exceptions. Every test reports its cases and ends through `exit_status`. +- Added `doc/timers.adoc`, included by the page, with compiled test listings and guarantee 8. + An independent read-only review found no blocking issue. Its numbering observation was + corrected with `[start=8]`, and the generated HTML was checked for that numbering. +- No production implementation change was needed. + +### Local validation + +With Boost 1.92, Emscripten 6.0.11, Node 26.7.0 and Apple Clang 21: + +- Fresh native suite: 14 passing markers. +- Fresh WebAssembly suite, including the Asyncify lane: 70 passing markers. Expected failures + are counted only through their corresponding negative-test declarations. +- All five new cases passed natively and in each of the four WebAssembly configurations. +- A scratch copy expected the deliberately wrong order 60, 20, 40. JSPI and Asyncify both + reported the three order mismatches and exited 1. The temporary Jamfile declarations were + restored, and the final correct suite then passed from scratch. +- clang-tidy passed on the new test in six configurations: native with and without exceptions, + plus the four WebAssembly configurations, using the actual build options. Dependency + diagnostics were suppressed according to the existing lint configuration; no project + findings remained. clang-format, changed-file text rules and diff checks passed. +- The full local library documentation build passed, including MrDocs, source checks, + Asciidoctor conversion and rendered HTML checks. Its counts are 72 distinct tests, 14 native + and 70 Emscripten; these overlap because some tests run on both targets. + +Commands from `asio-task9-review`, using its existing `.local/review-b2` toolchain wrapper: + +```sh +.local/review-b2 -a -j4 -d+2 --verbose-test --build-dir=bin/task10-suite-native libs/asio/test libs/asio/example +.local/review-b2 -a -j4 -d+2 --verbose-test --build-dir=bin/task10-suite-wasm toolset=emscripten libs/asio/test libs/asio/example libs/asio/test//asyncify +.local/review-b2 -a -j2 -d+2 --build-dir=bin/task10-doc libs/asio/doc +``` + +Full suite logs are in `.local/task10-validation/native.log` and `wasm.log`; the six analysis +commands and their logs are under `.local/task10-validation/lint/`. Negative-control output is +in `.local/task10-negative/build.log`. The local HTML is `libs/asio/doc/html/index.html`. + +These are local task checks, not a release or merge gate: no CI, push, merge, real-browser test +or whole-organization lint was run. The OpenSpec CLI is not installed in this environment. +The next authorized implementation task would be task 11; it has not been started. + +## Task 9 re-review completed, 2026-10-14 + +This update supersedes the open task 9 review recorded below. Tasks 10 to 23 remain unstarted. +The historical sections below describe the imported 2026-10-13 baseline; `source/` now includes +this review's corrections, matching local library commit `ad6367b` on top of import `a9a48f0`. + +The active superproject worktree is `asio-task9-review`, beside `webcpp` and `proposals` in the +organization directory, on branch `work/asio-task9-review`, tip `eba8545`. It starts at +`9a268b7` and carries the ten recorded superproject patches. Integration preserves both the +current Boost.Cobalt support and the node test support. `libs/asio` is its own local repository, +without a remote or a registered submodule. The historical patch files are unchanged. + +### Findings and corrections + +- An expired 1 ms timer still suspends in Emscripten's initial nonblocking poll, so the suspected + missing-suspension failure was not reproduced. The real gap was a shorter measurement path: + delaying entry by 25 ms changed `run_for` from 1104 to 1060 bytes and `run_until` from 1092 to + 1048, while the old test passed. +- The test now observes nonzero-timeout calls to `doPollAsync` and requires one for every + reactor-wait case. With the old timer and the 25 ms delay, all eight wait assertions failed. +- Reactor cases now keep outstanding work until a JavaScript macrotask posts the completing + handler. They retain the 25 ms entry delay as a regression case. Pending callbacks are + cancelled at destruction, and the fixture cannot move or copy. +- The yield of `run_until` is measured separately. The bridge comments now state the actual + guarantee, no entry after Emscripten sets `ABORT`, without claiming every raw Wasm trap sets it. +- An independent review checked the corrected instrumentation, callback lifetime and test + evidence, and found no remaining blocking issue in this scoped task 9 review. + +### Validation performed locally + +With Emscripten 6.0.11, Node 26.7.0 and Boost 1.92: + +- Native Asio suite: 13 passing test markers, built from scratch with Apple Clang 21. +- Asio JSPI and Asyncify suites: 66 passing test markers, built from scratch; expected compile + and runtime failures were accepted only by their corresponding negative tests. +- After the final measurement correction, all six changed Asyncify stack builds were rebuilt + from scratch and passed: debug, release and release linked with `-O3`, each with and without + exceptions. There are eleven measured paths with exceptions and nine without. +- Their maxima (exceptions on/off) were 1164/844 bytes in debug, 2896/1940 in release and 384/288 + with the optimized link, below half of the configured 8192 bytes in every case. +- The five variants-tool cases and three selected superproject integration cases passed: + suspension variants, node test support linkage and the variants manifest. +- clang-tidy passed all four compile configurations of the changed test; clang-format, + changed-file text rules, source documentation checks and `git diff --check` passed. + +This was a scoped local review, not the release gate: CI, a full organization lint, rendered +HTML generation, GCC and Chrome were not run. No remote repository, push, merge or CI run was +created. The user's instruction is to stop here before task 10. + +### Resume task 10 + +Use the existing worktree and `libs/asio` repository. `.local/review-b2` supplies its isolated +Emscripten cache, Python 3.14 and `.local/user-config.jam`; it accepts ordinary b2 arguments. +Read the original plan's task 10 before starting. The toolchains are reused from the older +local superproject, and the build outputs remain isolated in this worktree's `bin/`. + +## Historical handoff, 2026-10-13 + Written 2026-10-13, when this proposal took the library in as a partly implemented genesis. `spec.md` (approved by the owner on 2026-10-11, marked active) and `plan.md` (24 tasks, 0 to 23, every task with its code) are the specification and the plan; `../tasks.md` is the checklist; diff --git a/libraries/asio/openspec/changes/genesis/reference/plan.md b/libraries/asio/openspec/changes/genesis/reference/plan.md index b390b82..63df31f 100644 --- a/libraries/asio/openspec/changes/genesis/reference/plan.md +++ b/libraries/asio/openspec/changes/genesis/reference/plan.md @@ -9,6 +9,12 @@ created: 2026-10-11 > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. +**Execution update, 2026-10-15:** The owner selected 100 as the configurable +default turn limit. Tasks 17 through 21 are implemented and committed locally; +tasks 22 and 23 remain pending. No CI, push or merge was run for this work. +See STATUS.md for the current commits and validation record. Historical plan +examples and measurements retain the values they originally specified. + **Goal:** a new library, webcpp::asio, at `libs/asio`: Boost.Asio itself natively, and on emscripten Boost.Asio's own `io_context` suspended into the browser's event loop, with what Boost lacks there (the threads configuration, a reactor made at construction, a run family @@ -3846,7 +3852,7 @@ lib boost_cobalt - Produces: `int boost::cobalt::detail::main_promise::run_main(::boost::cobalt::main mn)`, defined by webcpp; `/webcpp/asio//cobalt`. -- [ ] **Step 1: Write the page's section** `doc/cobalt.adoc` (`[#asio-cobalt]`): spec +- [x] **Step 1: Write the page's section** `doc/cobalt.adoc` (`[#asio-cobalt]`): spec section 5.2 whole: a Cobalt program changes nothing and links `/webcpp/asio//cobalt`; why not a `co_main` of webcpp's own; the members it reads and the probe; the fallback; and that under Asyncify webcpp's `run_main` ends the program with `std::exit` so its @@ -3854,7 +3860,7 @@ lib boost_cobalt `io/ssl.cpp`, which needs OpenSSL, so a program that uses `boost::cobalt::io::ssl_stream` does not link with it (a difference from spec section 5.2's "every source but `main.cpp`", under "Departures from the spec"). -- [ ] **Step 2: Write the failing tests.** `test/cobalt_test.cpp`: an unchanged `co_main` of +- [x] **Step 2: Write the failing tests.** `test/cobalt_test.cpp`: an unchanged `co_main` of 5,000 `co_await boost::asio::post(exec, cobalt::use_op)`, a 50 ms `boost::cobalt::io::steady_timer` wait and a 20 ms `boost::asio::steady_timer` wait with `cobalt::use_op`, a `webcpp::test::page_timeout` (`"page_timeout.hpp"`, Task 6) armed first @@ -3883,7 +3889,7 @@ for local test in cobalt cobalt_status ``` Run the emscripten lane. Expected: FAIL, `/webcpp/asio//cobalt` not found. -- [ ] **Step 3: Implement** `src/cobalt_main.cpp`: +- [x] **Step 3: Implement** `src/cobalt_main.cpp`: ```cpp // Copyright (c) 2026 WebCpp.org @@ -3979,22 +3985,22 @@ alias cobalt : : : : asio cobalt-main /webcpp//boost_ # end::cobalt[] ``` -- [ ] **Step 4: Run** every lane. Expected: PASS: `cobalt` natively and on both variants; +- [x] **Step 4: Run** every lane. Expected: PASS: `cobalt` natively and on both variants; `cobalt_status` fails as a `run-fail` on all three, and its `.output` says `EXIT STATUS: 7` on each, the asyncify one included. Then run `cobalt_status_asyncify` with the `std::exit` removed from a scratch copy. Expected: `EXIT STATUS: 1` and the test support's line `webcpp: main did not finish`: the 7 was lost, and only the explicit exit keeps it. Restore. -- [ ] **Step 5: Measure Asyncify's stack again** with the Cobalt tests in the lane, as Task +- [x] **Step 5: Measure Asyncify's stack again** with the Cobalt tests in the lane, as Task 9's Step 3 does; raise the value if S grew, and record it. -- [ ] **Step 6: Write the twin example** `asio_cobalt.cpp` (a `co_main` that sleeps 50 ms on +- [x] **Step 6: Write the twin example** `asio_cobalt.cpp` (a `co_main` that sleeps 50 ms on a `steady_timer` with `cobalt::use_op`, prints `cobalt slept` and `co_return 0;`) with its `.expected`, in `example/Jamfile` as `webcpp.example asio_cobalt.cpp : /webcpp/asio//cobalt ;`, a `webcpp.variants page-asio_cobalt : asio_cobalt.cpp : /webcpp/asio//cobalt ;` and its name in the size table. Include it in `cobalt.adoc`. Run both lanes and the doc build. Expected: PASS, the same output natively and in the browser. -- [ ] **Step 7: Commit** (library): `"asio: Boost.Cobalt's co_main, unchanged, with the turn +- [x] **Step 7: Commit** (library): `"asio: Boost.Cobalt's co_main, unchanged, with the turn limit"`. ## Task 17: Promises as operations @@ -4027,14 +4033,14 @@ auto async_await(const boost::asio::any_io_executor& executor, emscripten::val p } ``` -- [ ] **Step 1: Write the page's section** `doc/promises.adoc` (`[#asio-promises]`): spec +- [x] **Step 1: Write the page's section** `doc/promises.adoc` (`[#asio-promises]`): spec section 4.7 for promises: every token works; the error; cancellation; lifetime; allocation; embind. Guarantees: `[[asio-invariant-10]]` "A promise completes its operation through the bridge with its value, or with `promise_rejected` and its reason; a cancellation completes it at once with `operation_aborted`, and a later settlement finds nothing."; `[[asio-invariant-11]]` "A pending operation is outstanding work; destroying the io_context destroys its handler without calling it." -- [ ] **Step 2: Write the failing test** `test/promise_test.cpp` (cases, each a function; +- [x] **Step 2: Write the failing test** `test/promise_test.cpp` (cases, each a function; `browser_values.hpp` gives the promises): - `a_resolved_promise_completes_with_its_value`: `test_promise_after(20, 42, false)`, a callback; `ec` is success, the value 42; @@ -4071,8 +4077,8 @@ auto async_await(const boost::asio::any_io_executor& executor, emscripten::val p `promise` joins `browser-tests`; `allocation_test.cpp` gains, on emscripten, a resolved and a rejected promise awaited with handlers bound to `counted`, still with no `operator new`. -- [ ] **Step 3: Run** the emscripten lane. Expected: FAIL, `async_await.hpp` not found. -- [ ] **Step 4: Implement** `browser/error.hpp` (a category whose `name()` is `"webcpp.asio"` +- [x] **Step 3: Run** the emscripten lane. Expected: FAIL, `async_await.hpp` not found. +- [x] **Step 4: Implement** `browser/error.hpp` (a category whose `name()` is `"webcpp.asio"` and whose `message(1)` is `"the promise was rejected"`, any other value `"unknown webcpp.asio error"`; `make_error_code`; `is_error_code_enum`), and `browser/async_await.hpp`: @@ -4172,8 +4178,8 @@ auto async_await(const boost::asio::any_io_executor& executor, emscripten::val p (The allocator is taken from the handler before the handler moves and the operation ends; the completion's own allocation, the post, is the handler's.) Each member gets its Doc Comment; every `boost/asio/` include says why after `lint-world:`. -- [ ] **Step 5: Run** every lane, then the lint. Expected: PASS, `lint: clean`. -- [ ] **Step 6: Write the example** `asio_promise.cpp` (emscripten only: +- [x] **Step 5: Run** every lane, then the lint. Expected: PASS, `lint: clean`. +- [x] **Step 6: Write the example** `asio_promise.cpp` (emscripten only: `webcpp.example asio_promise.cpp : : emscripten ;`): awaits a resolved and a rejected promise with callbacks, prints `resolved: 42` and `rejected: promise_rejected 9`; its `.expected`; include it in `promises.adoc`. @@ -4181,7 +4187,7 @@ auto async_await(const boost::asio::any_io_executor& executor, emscripten::val p name `page-asio_promise` in `webcpp.size-table asio` (spec sections 4.4 and 9: every example, both variants); the asyncify lane then prints one more row. Run the emscripten lane, the asyncify lane and the doc build. Expected: PASS. -- [ ] **Step 7: Commit** (library): `"asio: a JavaScript promise as an Asio operation"`. +- [x] **Step 7: Commit** (library): `"asio: a JavaScript promise as an Asio operation"`. ## Task 18: Events as operations @@ -4204,7 +4210,7 @@ auto async_wait_event(const boost::asio::any_io_executor& executor, emscripten:: } ``` -- [ ] **Step 1: Write the failing test** `test/event_test.cpp`: +- [x] **Step 1: Write the failing test** `test/event_test.cpp`: - `an_event_completes_with_itself`: `test_event_target()`, `test_dispatch_after(target, 20, 5)`, awaited for `"message"`; success, and `event["detail"].as() == 5`; - `only_the_next_event`: two dispatches 20 ms apart, one wait; the second event is not @@ -4222,8 +4228,8 @@ auto async_wait_event(const boost::asio::any_io_executor& executor, emscripten:: target's own `addEventListener` and `removeEventListener` that keep a count, and returns it.) `event` joins `browser-tests`; `allocation_test.cpp` gains an event awaited with a handler bound to `counted`, still with no `operator new`. -- [ ] **Step 2: Run.** Expected: FAIL, `async_wait_event.hpp` not found. -- [ ] **Step 3: Implement** `async_wait_event.hpp` in the shape of `async_await.hpp`: its +- [x] **Step 2: Run.** Expected: FAIL, `async_wait_event.hpp` not found. +- [x] **Step 3: Implement** `async_wait_event.hpp` in the shape of `async_await.hpp`: its operation keeps `target`, the type as a JavaScript string made by `webcpp_asio_string(type.data(), type.size())` (no `std::string`: the view needs no null and nothing is allocated), and the bridge's function; `start` calls @@ -4232,15 +4238,15 @@ auto async_wait_event(const boost::asio::any_io_executor& executor, emscripten:: `cancel` calls `removeEventListener(type, function)`, removes the id and completes with `operation_aborted`; `shutdown` (the io_context's destruction) clears the slot, calls `removeEventListener(type, function)` too, and destroys the handler without calling it. -- [ ] **Step 4: Run** every lane and the lint. Expected: PASS. -- [ ] **Step 5: Write the example** `asio_event.cpp` (emscripten): waits for a `message` on an +- [x] **Step 4: Run** every lane and the lint. Expected: PASS. +- [x] **Step 5: Write the example** `asio_event.cpp` (emscripten): waits for a `message` on an `EventTarget` that a `setTimeout` dispatches, prints `event: message 5`; its `.expected`; in the page. `example/Jamfile` also gains `webcpp.variants page-asio_event : asio_event.cpp ;` and the name `page-asio_event` in `webcpp.size-table asio` (spec sections 4.4 and 9: every example, both variants); the asyncify lane then prints one more row. Run the emscripten lane, the asyncify lane and the doc build. Expected: PASS. -- [ ] **Step 6: Commit** (library): `"asio: a browser event as an Asio operation"`. +- [x] **Step 6: Commit** (library): `"asio: a browser event as an Asio operation"`. ## Task 19: Sockets and the transport point @@ -4300,7 +4306,7 @@ class transport; // primary: every operation fails with operation_not_supported Each asynchronous one goes through `boost::asio::async_initiate` and completes through a post. -- [ ] **Step 1: Write the page's section** `doc/sockets.adoc` (`[#asio-sockets]`): spec +- [x] **Step 1: Write the page's section** `doc/sockets.adoc` (`[#asio-sockets]`): spec section 7: why webcpp's own templates on emscripten (SOCKFS opens a WebSocket, getaddrinfo invents 172.29.x.x addresses), the subset, the failures as values, the transport point and its one-definition rule, and that Beast's `tcp_stream` wraps Boost's socket, so a relay @@ -4308,7 +4314,7 @@ class transport; // primary: every operation fails with operation_not_supported each socket and acceptor operation but `open` and `close` fails with `operation_not_supported` unless a transport provides it; a synchronous one never blocks, an asynchronous one completes through a post." -- [ ] **Step 2: Write the failing tests.** `test/sockets_test.cpp` (emscripten): for +- [x] **Step 2: Write the failing tests.** `test/sockets_test.cpp` (emscripten): for `ip::tcp::socket`, `ip::udp::socket` and `ip::tcp::acceptor`, every operation of the list above in its `error_code&` form gives `operation_not_supported` and returns at once; every asynchronous one completes with it through a post (a flag set after the call returns is seen @@ -4324,8 +4330,8 @@ class transport; // primary: every operation fails with operation_not_supported `boost::asio::ip::tcp` and `webcpp::asio::ip::tcp::socket` is Boost's socket. `sockets` and `transport` join `browser-tests`; `allocation_test.cpp` gains an `async_connect` bound to `counted`, with no `operator new`. -- [ ] **Step 3: Run.** Expected: FAIL, `ip/tcp.hpp` not found. -- [ ] **Step 4: Implement** the headers. The transport's primary: +- [x] **Step 3: Run.** Expected: FAIL, `ip/tcp.hpp` not found. +- [x] **Step 4: Implement** the headers. The transport's primary: ```cpp namespace webcpp::asio::browser { @@ -4531,8 +4537,8 @@ private: kin from `` (each `lint-world:`). `headers-alone`'s first call takes `asio/ip/*.hpp` with the rest; the emscripten-only `browser/transport.hpp` is in the second call's glob. -- [ ] **Step 5: Run** every lane and the lint. Expected: PASS. -- [ ] **Step 6: Write the example** `asio_sockets.cpp` (emscripten): a `tcp::socket` opened +- [x] **Step 5: Run** every lane and the lint. Expected: PASS. +- [x] **Step 6: Write the example** `asio_sockets.cpp` (emscripten): a `tcp::socket` opened and connected to `127.0.0.1:80`; prints `open: true`, `connect: operation_not_supported` (comparing the code, never its message), `close: ok`; its `.expected`; in `sockets.adoc`. @@ -4540,7 +4546,7 @@ private: name `page-asio_sockets` in `webcpp.size-table asio` (spec sections 4.4 and 9: every example, both variants); the asyncify lane then prints one more row. Run the emscripten lane, the asyncify lane and the doc build. Expected: PASS. -- [ ] **Step 7: Commit** (library): `"asio: sockets that fail as values, behind the transport +- [x] **Step 7: Commit** (library): `"asio: sockets that fail as values, behind the transport point"`. ## Task 20: The resolver (option A) @@ -4593,13 +4599,13 @@ public: `operation_not_supported`. `cancel` does nothing: every resolution has completed when it starts (as an operation Boost had completed). -- [ ] **Step 1: Write the page's part** in `doc/sockets.adoc`: spec section 7, "The resolver" +- [x] **Step 1: Write the page's part** in `doc/sockets.adoc`: spec section 7, "The resolver" (decision 5): the entry, the port of each service, why not a failing resolver (every Beast client would change a line), reverse resolution. Guarantee `[[asio-invariant-13]]`: "On emscripten, `resolve(host, service)` completes with one entry whose `host_name()` and `service_name()` are the arguments and whose endpoint is the unspecified address and the service's port; a plain socket's `connect` on it fails with `operation_not_supported`." -- [ ] **Step 2: Write the failing test** `test/resolver_test.cpp` (emscripten): +- [x] **Step 2: Write the failing test** `test/resolver_test.cpp` (emscripten): - `resolve_makes_one_entry`: `tcp::resolver r(io); r.resolve("example.com", "https", ec)`: no error, one entry, `host_name() == "example.com"`, `service_name() == "https"`, `endpoint().address().is_unspecified()`, port 443; @@ -4631,22 +4637,22 @@ constexpr std::array services{{ `names_test.cpp` gains, natively, `static_assert` that `webcpp::asio::ip::tcp::resolver` is `boost::asio::ip::tcp::resolver`. `resolver` joins `browser-tests`. -- [ ] **Step 3: Run.** Expected: FAIL, `ip/basic_resolver.hpp` not found. -- [ ] **Step 4: Implement** the header; `tcp::resolver` and `udp::resolver` become +- [x] **Step 3: Run.** Expected: FAIL, `ip/basic_resolver.hpp` not found. +- [x] **Step 4: Implement** the header; `tcp::resolver` and `udp::resolver` become `basic_resolver` and `basic_resolver`. The port is parsed with `std::from_chars` into a `std::uint32_t` after the all-digits check, a guard at the top of a function of its own, `std::optional port_of(std::string_view service, flags f) noexcept`. -- [ ] **Step 5: Run** every lane and the lint. Expected: PASS. `allocation.adoc` names the +- [x] **Step 5: Run** every lane and the lint. Expected: PASS. `allocation.adoc` names the resolver's results as the third of the runtime's allocations (`new`, in Boost's `basic_resolver_results::create`). -- [ ] **Step 6: Write the example** `asio_resolver.cpp` (emscripten): resolves +- [x] **Step 6: Write the example** `asio_resolver.cpp` (emscripten): resolves `("example.com", "wss")` asynchronously and prints `example.com wss 443 unspecified: true`; its `.expected`; in `sockets.adoc`. `example/Jamfile` also gains `webcpp.variants page-asio_resolver : asio_resolver.cpp ;` and the name `page-asio_resolver` in `webcpp.size-table asio` (spec sections 4.4 and 9: every example, both variants); the asyncify lane then prints one more row. Run the emscripten lane, the asyncify lane and the doc build. Expected: PASS. -- [ ] **Step 7: Commit** (library): `"asio: the resolver of option A, whose entry the +- [x] **Step 7: Commit** (library): `"asio: the resolver of option A, whose entry the browser's streams accept"`. ## Task 21: The `ssl` names, and OpenSSL named by the program @@ -4768,7 +4774,7 @@ public: Each setting is recorded and succeeds; whether the browser honours it is webcpp::beast's judgement. The verification host is held in a `std::pmr::string` of the given resource. -- [ ] **Step 1: Write the failing tests.** `test/ssl_test.cpp`: natively, `static_assert`s +- [x] **Step 1: Write the failing tests.** `test/ssl_test.cpp`: natively, `static_assert`s that `webcpp::asio::ssl::context` is `boost::asio::ssl::context` and `webcpp::asio::ssl::stream_base` Boost's, and a `context(tlsv12_client)` made; on emscripten: a context of `tlsv12_client` records its method; `set_verify_mode(verify_peer)`, @@ -4815,7 +4821,7 @@ webcpp.compile-fail openssl_named_on_emscripten : openssl_named_test.cpp FAIL: `ssl.hpp` and `src/openssl_on_webassembly.hpp` do not exist, `openssl_named_on_emscripten` compiles (nothing refuses it yet, so the compile-fail test fails), and `needs_external('asio')` is false. -- [ ] **Step 2: Implement.** `build.jam` (with `import webcpp ;` at its top): +- [x] **Step 2: Implement.** `build.jam` (with `import webcpp ;` at its top): ```jam # OpenSSL 3, natively, for , found by webcpp.external @@ -4894,7 +4900,7 @@ explicit openssl-tests ; unless `WEBCPP_ASIO_HAS_OPENSSL`, then `#include // lint-world: TLS over Asio's sockets` and the namespace alias; on emscripten the record. `tools/ci/matrix.py`'s `EXTERNAL_DEPENDENCIES` gains `'asio': ('openssl',)`, with its comment naming asio's `ssl`. -- [ ] **Step 3: Run** every lane, `python3 tools/ci/matrix_test.py` and the lint. Expected: +- [x] **Step 3: Run** every lane, `python3 tools/ci/matrix_test.py` and the lint. Expected: PASS, `ssl_without_openssl` among them. Then the two ways OpenSSL can be missing: - `$B2 -sOPENSSL_ROOT=/nonexistent libs/asio/test//ssl`. Expected: the build stops, naming `/nonexistent` (webcpp.external's refusal of a wrong `-s`). @@ -4911,7 +4917,7 @@ explicit openssl-tests ; a "file not found" (broken quoting, a wrong `WEBCPP_ASIO_ROOT`) is a failure of this step (re-review 2, R2-2). The refusal is a ``, so a C source of the program is refused as a C++ one is (R2-1). -- [ ] **Step 4: The form a program built for both targets writes, built by an example in +- [x] **Step 4: The form a program built for both targets writes, built by an example in the CI.** `example/tls/Jamfile`, a project of its own whose requirements are the user's lines, verbatim: @@ -4960,7 +4966,7 @@ webcpp.lane tls : asio_tls asio_tls.output : native emscripten ; neither (`-d+2`). Then `$B2 -d0 declared-lanes`: lines `asio tls libs/asio/example/tls native programs` and `... emscripten programs`; and `python3 tools/ci/matrix.py own-lanes --library asio` gives the native entry `external` true, so the CI's job installs OpenSSL. -- [ ] **Step 5: Write the page's parts**, for a reader who may be an AI agent writing a +- [x] **Step 5: Write the page's parts**, for a reader who may be an AI agent writing a Jamfile at once: - in `building.adoc`, a section `[#asio-tls]` "TLS: name OpenSSL for native builds alone": a program that includes `` and is built only natively writes @@ -4974,7 +4980,7 @@ webcpp.lane tls : asio_tls asio_tls.output : native emscripten ; WebAssembly), and the region `openssl` of `{library-root}/build.jam`; - in `sockets.adoc`, "TLS settings": natively Boost's `ssl`; in the browser a record that webcpp::beast's streams judge; and the example's listing and output. -- [ ] **Step 6: Commit** (library): `"asio: the ssl names, Boost's natively with OpenSSL named +- [x] **Step 6: Commit** (library): `"asio: the ssl names, Boost's natively with OpenSSL named by the program and refused on WebAssembly, and a record of the settings in the browser"`; (superproject): `"tools/ci: asio's ssl needs OpenSSL natively"` with `tools/ci/matrix.py tools/ci/matrix_test.py`. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/AGENTS.md b/libraries/asio/openspec/changes/genesis/reference/source/AGENTS.md index a33cd3d..55cb3e8 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/AGENTS.md +++ b/libraries/asio/openspec/changes/genesis/reference/source/AGENTS.md @@ -3,7 +3,9 @@ webcpp's rules apply here: read the superproject's [AGENTS.md](../../AGENTS.md) () first. This file -holds only what is specific to asio. +holds only what is specific to asio. Also read the superproject's +[CODING-GUIDELINES.md](../../CODING-GUIDELINES.md), which holds the shared +code and design rules. ## What asio is @@ -38,6 +40,15 @@ reach the `io_context`. and a test that overflows traps with `RuntimeError: unreachable`, every time. When b2's release link gets its `-O`, measure again: the deepest build becomes debug's. +- **The stack test must reach the intended wait.** Its reactor cases hold + work until a JavaScript macrotask posts the completing handler, delay entry + by 25 ms and require a nonzero-timeout poll. An already-expired C++ timer + can suspend in the initial poll without reaching the deeper wait. The + test reads `doPollAsync` as well as Asyncify's private runtime; a runtime + change that removes either observation must fail rather than skip it. + The 2026-10-14 re-review measured maxima of 1164/844 bytes in debug, + 2896/1940 in release and 384/288 in release linked with `-O3`, with/without + exceptions respectively. `run_until` has its own yield measurement too. - **The run family is called on `main`'s stack alone**, or on the stack of another export the program lists for suspension. Anywhere else its first suspension fails: under JSPI it throws a `SuspendError`, and under @@ -68,3 +79,230 @@ reach the `io_context`. `run_main`, which gives `co_main` the turn limit and which `/webcpp/asio//cobalt` links. A program never compiles either itself: the targets link each once, and a second definition fails at link. + +## The turn limit, measured in Chrome + +On 2026-10-14, macOS arm64, HeadlessChrome 153.0.8010.12 from the local +Playwright cache, Emscripten 6.0.11, Boost 1.92 and b2 debug builds: + +| Run | Variant | Animation callbacks | Handlers | Full turns | Turn p95 (ms) | Maximum (ms) | +| --- | --- | --- | --- | --- | --- | --- | +| 1 | jspi | 60 | 1724312 | 1724 | 0.700 | 1.800 | +| 1 | asyncify | 61 | 652723 | 652 | 1.600 | 9.200 | +| 2 | jspi | 60 | 1734454 | 1734 | 0.700 | 1.800 | +| 2 | asyncify | 61 | 644126 | 644 | 1.600 | 9.200 | +| 3 | jspi | 60 | 1744071 | 1744 | 0.700 | 1.900 | +| 3 | asyncify | 61 | 653795 | 653 | 1.600 | 8.900 | + +Each run rebuilt the browser lane from scratch with `-a -j1`, using a +separate build directory. The programs self-post trivial handlers for one +second, with the then-default 1,000 handlers per turn. Callback entry times +come from `performance.now()`. Full turns end at the yield's message post; +the last partial turn is excluded. Both unbounded Boost controls had zero +animation callbacks in every run. These observations show animation +opportunities, not proof that particular pixels were painted. + +The three runs also passed idle and loader checks on both variants: one +`setTimeout(300000)` during each three-second idle observation, and three +handlers from the artifact actually selected by the loader. The JSPI +factory awaits `main`, so the test identifies the imported URL before +awaiting that factory; an intentionally idle main never returns. + +The p95 stayed below the task's 8 ms stop threshold, so that task retained +1,000 at the time. The maximum is recorded without hiding outliers. These are local +measurements, not a guarantee for heavy user handlers or other hardware. +The CI-pinned Chrome version was not executed in this session; no CI ran. +The driver fails when p95 exceeds 8 ms or no animation callbacks occur; +changing the default or replacing that witness requires the owner's decision. + +On 2026-10-15, the owner selected 100 as the new default after reviewing the +Release yield benchmark in doc/yield-cost.adoc. This favors more frequent +browser scheduling opportunities over throughput for trivial handlers; it is +not a measured optimum or a time bound. Keep the historical results above +unchanged. The compiler definition and per-context overrides remain supported. + +## Cobalt entry point and suspension stack + +Task 16 supplies `/webcpp/asio//cobalt`: Cobalt's ordinary `co_main` runs on +webcpp's context. The adapter replaces both `main_promise::run_main` and +`final_suspend` from Boost 1.92's main.cpp. Do not link the original runner +beside it. The source target's issue 287 warning still applies without exceptions. +The checked Cobalt common overlay supplies the required unhandled_exception +promise member when exceptions are disabled. Its unreachable exception path +calls std::terminate, without enabling exception handling or suppressing a +compiler diagnostic. + +The Cobalt stack probe measures real Asyncify unwinds from the runner through +the yield, a Cobalt timer wait and an Asio timer wait. The timer waits cannot +expire: only a JavaScript macrotask posts their cancellation, so the test must +reach a blocking reactor poll. Measurements on 2026-10-14, Emscripten 6.0.11: + +| Build | Exceptions | Yield bytes | Cobalt wait bytes | Asio wait bytes | +| --- | --- | ---: | ---: | ---: | +| Debug | on | 1016 | 1032 | 1032 | +| Debug | off | 684 | 700 | 700 | +| Release, default link | on | 968 | 1088 | 1088 | +| Release, default link | off | 748 | 956 | 956 | +| Release, link -O3 | on | 376 | 384 | 384 | +| Release, link -O3 | off | 228 | 228 | 228 | + +The existing 8192-byte stack remains sufficient for these paths with more than +half free. These measurements are suspension storage, not binary sizes or a +bound on arbitrary application frames. The ordinary run-family probe remains +in the suite and shares the observation helper in test/asyncify_watch.hpp. + +The cobalt and cobalt_asyncify local lanes check exact process statuses 7 and 0 +with a driver; run-fail alone would also accept a trap. Debug Asyncify's explicit +std::exit can emit Emscripten's runtime-retained notice under EXIT_RUNTIME=0. +The driver permits exactly that notice, not arbitrary stderr. This adapter +preserves the configured runtime lifetime instead of forcing shutdown. + +On WASIp3 the runner must not include or instantiate the POSIX signal service. +Initialize the upstream promise's `signal_set` pointer to null and omit its +cleanup there. Keep the executor, initial post, return status and internal +cancellation machinery. Automatic SIGINT/SIGTERM cancellation is unavailable; +host-driven graceful shutdown requires a separate application protocol. +The runner-only compile test is supplemented by public-target runtime tests: +`cobalt_wasi`, `cobalt_network_wasi`, `cobalt_io`, the `cobalt_wasip3` status +lane and the recurring `threads` lane in the cooperative profile. + +## WASIp2 port + +The owner approved P2 Asio core and supplied-stream WebSocket on 2026-11-03. +`/webcpp/asio//asio` supports `threading=single`, EH on/off, through the shared +checked Boost overlay. P2 now also supplies the source-built OpenSSL/CA targets, +Cobalt and its SSL wrapper; preserve their dedicated EH-on/off peer and +cancellation tests in `test/wasip2_tls_cobalt`. P2 threading remains unavailable +in the pinned SDK. Never infer new feature support from core support alone. +The P2 reactor reuses libc select/poll and omits the unavailable pipe interrupter. +`tools/boost/asio-wasip2` owns the checked SDK 34.0 private descriptor-table bridge +and the asynchronous DNS extension. Revalidate its libc ABI before changing SDKs. +Preserve deferred initiation, handler associations, operation cancellation and +resource cleanup. DNS must not start a worker or block inside async initiation. +The P2 CLI stream requests output flush before switching protocol direction; +keep the real large-frame regression. Cancellation cannot preempt blocking host +imports. Run `libs/asio/test/wasip2` and its `supplied-stream` lane in both exception +profiles, plus native/P3 regressions. Keep the feature matrix and AsciiDoc guide +consistent with actual runtime evidence. + +## WASIp3 port + +`/webcpp/asio//asio` applies the superproject's checked Boost 1.92 patch from +`tools/boost/asio-wasip3` to private build headers. Never edit installed Boost. +Native/browser consumers must not see this overlay. Rebase and verify the +patch and its hash manifest explicitly when changing Boost versions. + +`threading=single` disables Asio threads and accepts exceptions on/off. +`threading=multi` selects wasi-sdk's experimental cooperative sysroot with +`-pthread`; SDK 34.0 provides only its no-exceptions C++ runtime. Use Wasmtime +50.0.1, the project-wide runtime; earlier tests found that 47.0.3 cannot load +the cooperative binary. +Cooperative threads do not promise CPU parallelism. + +Preserve datagram boundaries: WASIp3 `send_to` and `async_send_to` concatenate +multiple nonempty UDP buffers into one datagram until wasi-libc provides +`sendmsg`. Gather before Asio's native iovec limit, use the context allocator +for synchronous storage and the handler's associated allocator for asynchronous +storage, and release operation storage before invoking the handler. Connected +`send`/`async_send` use the same gather path; multi-buffer receives scatter one +received datagram, retaining truncation semantics. The scalar/empty-buffer path +must work without heap scratch buffers. TCP partial transfers remain valid. +Both P3 thread profiles use native asynchronous DNS and the checked private +waitable-descriptor bridge. Never block initiation or use a polling timer for +lookup progress. Validate the SDK/libc ABI snapshot before using the bridge. +Keep deferred initiation, cancellation, associated executors and allocator +release-before-callback witnesses in `test/capability_wasi`. + +Keep `doc/capabilities.adoc` current for every feature/target/variant change. +`/webcpp/asio//cobalt` supports WASIp3 through the superproject's checked +`tools/boost/cobalt-wasip3` overlay. Headers and compiled sources must receive +the same Asio configuration. Unsupported signal, serial and seqpacket APIs are +omitted; `boost::cobalt::thread` is available only with Asio thread support. +The exception-free issue-287 warning remains non-fatal. TLS uses Asio/OpenSSL +streams with Cobalt tokens and `/webcpp/asio//tls`. The optional +`/webcpp/asio//cobalt_ssl` target adds Cobalt's own SSL wrapper and the CA factory. +Its shared private patch in `tools/boost/cobalt-ssl` fixes handshake state and +verification callbacks and adds the borrowed `native_ssl_handle()` accessor. +Plaintext is allowed only before the first TLS attempt; handshake failure or +cancellation and completed shutdown block application I/O. Preserve handler associations. +Run `cobalt_ssl_client` and `cobalt_ssl_state` with `tools/openssl/test/tls.py` +for normal/buffered TLS, SNI, peer rejection, STARTTLS and coroutine cancellation. +Run `cobalt_ssl_cancel` with the same `--state-test` harness for pending +read_some/write_some, partial composed read/write, truncated TLS shutdown and +shutdown cancellation. The shared `tools/boost/cobalt-common` patch connects +composition cancellation to the caller for compiled code and public headers. +The separate WASIp3 endpoint/acceptor object targets must explicitly depend on +the common overlay: free include flags on their parent archive do not propagate. +Keep `cobalt_accept_cancel` as the end-to-end witness for composed `accept()`. +Transfer cancellation is terminal in these checks: close the connection, do not +infer rollback of transmitted bytes or safe reuse from `secure()` remaining true. +OpenSSL is built from the pinned superproject source through +`/webcpp/third_party//openssl`; `/webcpp/asio//openssl` forwards that dependency +and defines `WEBCPP_ASIO_HAS_OPENSSL`. Native and WASIp3 consumers must use the +matching generated headers and archives. Browser consumers retain the settings +adapter and must not link this target. Run `tools/openssl/test/run.py` in the +superproject for real TLS and entropy checks; never infer entropy quality from +random-byte uniqueness. Do not add a second OpenSSL copy or a system fallback. +The commands in `doc/wasip3.adoc` run local tests only. + +## Embedded TLS trust + +`/webcpp/asio//tls` adds the digest-pinned Mozilla/curl CA data target and the +`tls_client_context.hpp` factory. The factory returns errors as values, enables +peer verification and TLS >= 1.2, and never imports system roots. A supplied PEM +set replaces public roots completely; reject empty, malformed and partially +invalid sets without returning a usable context. Keep hostname/SNI requirements +explicit in examples. Emscripten returns `unsupported_target`. + +Run `tools/ca_certificates/run.py --fresh` locally for the native/WASIp3 matrix. +Its WASIp3 clients have no certificate filesystem grants. Preserve that witness. +Embedded updates require rebuilding and redeploying. Do not silently download +roots during builds or runtime, or present a PEM export as Firefox's full policy. + +## Windows context-owned thread allocations + +The checked Boost 1.92 overlay in tools/boost/asio-windows forwards the context +allocator into both IOCP-owned thread constructors, including the lazily started +timer thread. It is selected only for target-os=windows and reaches compiled +Cobalt sources as well as consumers. Keep its original and patched byte hashes +pinned. Do not replace the allocation regression with a warm-up or an allowance +for extra global allocations. + +## Joint Asio and Beast closure + +Preserve deferred initiation and owning resolver input lifetimes. Resolver host +and service storage uses the initiating token's associated allocator; an allocator +bound only when a deferred operation is launched cannot retroactively own that +captured storage. Keep the positive controls for unbound handlers and runtime +allocation attribution; never replace them with a permitted allocation count. + +The owner clarified on 2026-11-03 that Asio and Beast are intended foundations +for a later Trystero migration. Never ban their combination to avoid a dependency +conflict. All native consumers, including libdatachannel, use the same pinned +source-built OpenSSL provider. Trystero's current native backend requires threads. + +The `tls-integration` own lane runs real native and WASIp3 TLS peers, state and +cancellation checks. The native `openssl-upstream` lane additionally requests +`webcpp-openssl-tests=on` to test the exact source-built archives before use. +OpenSSL's native Perl harness is not evidence for its WASI configuration. + +Use the repository's `webcpp-documentation` skill for Diataxis organization, +AsciiDoc and generated MrDocs reference. The maintained `doc/changelog.adoc` +is the final appendix; never edit generated reference or matrix files by hand. + +## Capability completion and browser workers (2026-11-03) + +`config.hpp` owns read-only numeric `WEBCPP_ASIO_HAS_*` capabilities. Optional +`WEBCPP_ASIO_REQUIRE_*` switches assert compile-visible requirements without +banning portable headers. Selected `WEBCPP_ASIO_HAS_OPENSSL=1` remains distinct +from platform `HAS_OPENSSL_BACKEND`. Runtime network grants, TLS identities, +page isolation and blocking host imports are not compile-time facts. + +Emscripten explicitly supports S and M with JSPI/Asyncify and both EH choices. +Only S disables Asio threads. The M poll wrapper preserves suspension on the +actual main thread; do not silently enable PROXY_TO_PTHREAD. Run a browser +context only on its creator thread, post between threads, and keep DOM values +on main. `browser::main_thread_context` callbacks are nonsuspending. Its context +must outlive executor calls. See the public worker guide and the real-browser +`browser-workers` lane. The versioned raw pthread-return probe documents the +pinned Asyncify SDK limitation; it is not a passing feature test. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/README.md b/libraries/asio/openspec/changes/genesis/reference/source/README.md index 391ad4d..a6b3584 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/README.md +++ b/libraries/asio/openspec/changes/genesis/reference/source/README.md @@ -9,10 +9,72 @@ lacks there, the configuration Asio needs to build, what wakes `run` from a browser event, and a limit on the handlers one turn runs, so that the page keeps rendering. The program's code runs only when the browser delivers an event (a message, a promise, a timer), never by polling, and its stack and -objects stay as they were. Timers are Boost's on both targets, so that a +objects stay as they were. Timers are Boost's on these targets, so that a library written on asio, and every Boost library built on Asio, never knows where it runs. +WASIp3 has a minimal port for timers and plain TCP/UDP, with single-thread and +experimental cooperative-thread profiles. See the [capability matrix](doc/capabilities.adoc) +and [WASIp3 build instructions](doc/wasip3.adoc) for exception settings, SDK/runtime +requirements and unsupported operations. `/webcpp/asio//cobalt` supports the same +WASIp3 profiles with its normal `co_main`, timers and IP socket APIs. +OpenSSL is built from pinned sources for +native and WASIp3 targets through `/webcpp/asio//openssl`. +For embedded Mozilla CA roots and an error-returning TLS client factory, use +`/webcpp/asio//tls` and ``. +Its replacement overload trusts only the authorities supplied by the application; +see [trusted certificate authorities](doc/building.adoc#asio-ca-certificates). + +## First program + +Schedule a message and a timer, then run their context. The complete +[tutorial](doc/html/index.html#asio-quick-start) walks through this program +natively and with both WebAssembly variants. + + +```cpp +#include +#include + +#include + +#include + +#include +#include + +namespace asio = webcpp::asio; +using namespace std::chrono_literals; + +int main() { + asio::io_context io; + asio::steady_timer timer(io); + + boost::asio::post(io, [&timer] { + std::puts("posted"); + timer.expires_after(50ms); + timer.async_wait([](boost::system::error_code ec) { + if (ec) { + std::printf("timer error: %d\n", ec.value()); + } else { + std::puts("timer fired"); + } + }); + }); + + const auto handlers = io.run(); // lint-run: main owns the program's event loop + std::printf("run returned %zu handlers\n", handlers); + return webcpp::test::exit_status(0); +} +``` + + +```text +posted +timer fired +run returned 2 handlers +``` + ## Building and testing asio is developed inside the webcpp superproject, as a Boost library is @@ -26,7 +88,8 @@ asio's tests and examples: b2 libs/asio/test libs/asio/example b2 toolset=emscripten libs/asio/test libs/asio/example - b2 toolset=emscripten libs/asio/test//asyncify libs/asio/example//asyncify + b2 toolset=emscripten libs/asio/test//asyncify + b2 toolset=emscripten webcpp-suspend=asyncify libs/asio/example b2 toolset=emscripten libs/asio/test/browser//browser The first builds them natively, runs every test and every example, and @@ -34,19 +97,51 @@ compares each example's output with the `.expected` file beside it. The second does the same on emscripten, run by node, with the toolset that `user-config.jam` registers against emsdk, in the default suspension variant, JSPI. The third, the lane `asyncify`, runs every browser test again -under Asyncify, the other variant, and writes the size table of both. The -fourth, the lane `browser`, runs the loader that picks a variant under node, -and in headless Chrome checks that a page program never polls, that the -page keeps rendering, and that the loader picks the variant. b2 compares timestamps, so a +under Asyncify, the other variant. +The extra `webcpp-suspend=asyncify` command also executes all guide examples +under Asyncify. The lane `browser` runs the loader that picks a variant under node, +loading both built artifacts and checking their output. It also runs idle, +animation and loader checks in headless Chrome, on JSPI and Asyncify. +`CHROME` names the executable; on macOS the driver can use the newest +Playwright headless shell already installed in its cache. b2 compares timestamps, so a result that counts is built from scratch, with `b2 -a`, and the CI gives each lane a `--build-dir` of its own. A b2 project uses asio through `/webcpp/asio//asio`. +A page imports `load` from `webcpp-asio-loader.mjs`, shipped in +`include/webcpp/asio/`, and calls `load('page_program.variants.json')`. +The loader detects JSPI support, selects JSPI or Asyncify from the build's +manifest and returns `{variant, module}` when its factory resolves. A JSPI +factory can await `main`, so an indefinitely running program must expose +its readiness through its module callbacks instead of awaiting `load`. The manifest +and its artifacts keep the relative layout produced by `webcpp.variants`. + +The documented binary-size table uses optimized release builds only. Build +both page variants and measure their uncompressed `.wasm` files with: + + b2 -a toolset=emscripten variant=release cxxflags=-O3 linkflags=-O3 libs/asio/example//asyncify + +The link flag is required because the current b2 Emscripten toolset does not +forward the compilation optimization level to the link. The guide records +the toolchain and six profiles: `-O2`, `-O3`, `-Os`, `-Oz`, `-O3 -flto` +and `-Oz -flto`. It reports Wasm and JavaScript bytes separately for both +suspension variants, with exceptions on and off. It also records complete +build durations and separate module-initialization and example-execution +times, including sample counts and variability. Timer waits are included +in execution time; these examples do not measure throw/catch latency or +CPU-only throughput. Use the same flags for compilation and link, with a +separate build directory per profile and exception setting. Runtime memory and transfer +compression are outside the tables. + ## Documentation asio's page, with its API reference, is published at ; `b2 libs/asio/doc` builds -it into `doc/html/index.html`. +it into `doc/html/index.html`. The guide uses Diataxis to distinguish +learning tutorials, practical instructions, explanations and reference. +Its AsciiDoc includes the API reference generated by MrDocs from the C++ +Doc Comments. All shown programs and outputs are checked against their +compiled examples and `.expected` files. ## License diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/Jamfile new file mode 100644 index 0000000..0e5c099 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/Jamfile @@ -0,0 +1,13 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +import webcpp ; + +webcpp.targets emscripten ; + +# Manual benchmark only. No CI lane runs it. +webcpp.variants yield_program : yield_program.cpp + : /webcpp/asio//asio ../../../../tools/node-test/include ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/README.adoc b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/README.adoc new file mode 100644 index 0000000..b9373ca --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/README.adoc @@ -0,0 +1,112 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + += Manual browser-yield benchmark + +This benchmark measures the actual asio yield and callback-boundary gaps, +not callback batch duration. See `../../doc/yield-cost.adoc` for methodology, +results and limitations. It is a manual target, with no CI lane. + +== Build and run + +Run from the webcpp superproject root with its configured Emscripten toolset. +The recorded session used `.local/review-b2` below, a machine-local wrapper +around `b2 --user-config=.local/user-config.jam` which also clears compiler +include-path environment overrides and selects the local Emscripten cache. +On another configured checkout, substitute the corresponding `b2` command. +Complete both builds before starting the browser; do not compile concurrently +with measurement. + +[source,shell] +---- +.local/review-b2 -j4 -d2 --build-dir=bin/yield-benchmark-on \ + toolset=emscripten variant=release exception-handling=on \ + cxxflags=-O3 linkflags=-O3 \ + libs/asio/bench/yield//yield_program.variants.json + +.local/review-b2 -j4 -d2 --build-dir=bin/yield-benchmark-off \ + toolset=emscripten variant=release exception-handling=off \ + cxxflags=-O3 linkflags=-O3 \ + libs/asio/bench/yield//yield_program.variants.json + +python3 -B libs/asio/bench/yield/make_cases.py bin .local/yield-cases.json +node libs/asio/bench/yield/run.mjs \ + .local/yield-cases.json .local/yield-results +python3 -B libs/asio/bench/yield/analyze_test.py +python3 -B libs/asio/bench/yield/analyze.py \ + .local/yield-results .local/yield-summary +---- + +Node must support built-in WebSocket and fetch. Node 26.7 was used. +Set `CHROME` to a Chrome executable if the macOS Playwright headless-shell +cache is unavailable. The driver uses only a loopback HTTP server and browser +control connection. It starts and terminates its own browser/profile, opens +one fresh foreground page per case, runs cases sequentially and writes each +result before starting the next. Progress goes to the terminal, with no polling +timer in the measured page. Startup, HTTP requests and browser commands have +deadlines. A case can contain up to 100,000 timing pairs. + +The {cpp} program accepts `mode limit samples work control`. Modes are `direct`, +`chain`, `clock` and `sync`. `control=1` disables periodic yields in chain mode, +while preserving the same number of callbacks and timing boundaries. +The browser additionally supports the JavaScript-only `js-direct` control. +`trace=1` installs the timestamp observer; its discarded warmup uses the same +observer code. `isolate=1` enables COOP/COEP headers for the page. These options +are specified by the generated case JSON, not by changing the production library. + +The page supports validation-only `delay_us=2000` in traced cases. It inserts +a known busy wait into the observed message handler. Exclude such cases from +the actual benchmark; the generated matrix never enables this option. +A 256-sample validation of both variants located the delay in that segment. + +`analyze.py` validates completion, counts, checksum, clock correspondence, +trace order and additive decomposition before producing CSV and JSON. +It expects exactly the cases declared by the saved environment manifest. +Do not run it with Python optimization (`-O`), which disables its assertions. +Checksums transported as signed i32 values are compared as 32-bit bit patterns. +Nearest-rank percentiles avoid interpolating nonexistent clock precision. +Summary means/percentiles use independent-run medians; trace component means +use arithmetic means so their sum matches the traced arithmetic mean. + +== Recorded run + +`results/2026-10-15/` contains `runs.csv`, `summary.json` and `build.json`. +The first two are outputs of the analyzer; regenerate them from timestamp +arrays rather than editing observations. Build metadata includes source and +linked artifact SHA-256 hashes. The library baseline was `3817dc9`, and the +superproject baseline was `8829e99`. + +The local raw archive is +`../../.local/yield-benchmark-2026-10-15.tar.gz`, relative to the library +root (`libs/asio`). It retains all timestamp arrays, case order, environment, +validation controls, build logs and benchmark source. A sibling `.sha256` +file identifies the archive. The archive is local and is not a tracked binary +asset. Copy it with the report when sharing measurements outside this checkout. + +There are seven primary repetitions and three secondary-control repetitions. +All 442 cases passed, totaling 970,139,132 operations and 9,429,856 pairs. +Measurements are for this warmup protocol and browser/hardware combination. +There is no assumption that 512 warmup yields establish universal steady state. +The default turn limit remains 1,000; running this benchmark does not change it. + +== Plot the recorded observations + +The optional plotting tool needs Matplotlib and NumPy in a separate local +Python environment. The recorded figures used Matplotlib 3.11.2 and NumPy 2.5.4. +It does not rebuild or execute the benchmark: + +[source,shell] +---- +python3 -B libs/asio/bench/yield/plot_results.py \ + libs/asio/bench/yield/results/2026-10-15 \ + libs/asio/bench/yield/results/2026-10-15/figures +---- + +The output contains four figures as PNG and SVG, a combined PDF, a flattened +CSV preserving all 102 configuration summaries, and the renderer version. +`runs.csv` retains the original 442 independent run summaries. Source observations +are never modified. Labels in the figures distinguish measured gaps, derived +amortization, observer overhead, whole-program controls and clock quantization. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/analyze.py b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/analyze.py new file mode 100644 index 0000000..e6d3d19 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/analyze.py @@ -0,0 +1,168 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Validate every case, retain per-run statistics, and summarize independent repetitions.""" + +import argparse +from collections import defaultdict +import csv +import json +import math +from pathlib import Path +import statistics as stats +from typing import Any + +KEYS = ('group', 'variant', 'mode', 'limit', 'trace', 'control', 'exceptions', + 'isolate', 'work') +PARTS = ('entry', 'channel_create', 'handler_setup', 'post_message', + 'post_to_delivery', 'message_handler', 'resume') + + +def expected_checksum(steps): + """Compose the affine LCG in logarithmic time, without rerunning the CPU workload.""" + multiplier, increment, value = 1664525, 1013904223, 1 + mask = (1 << 32) - 1 + while steps: + if steps & 1: + value = (multiplier * value + increment) & mask + increment = (multiplier * increment + increment) & mask + multiplier = (multiplier * multiplier) & mask + steps >>= 1 + return value + + +def percentile(ordered, fraction): + # Nearest rank: no interpolation that suggests finer clock resolution. + return ordered[max(0, math.ceil(len(ordered) * fraction) - 1)] + + +def analyze_case(case, data): + samples = case['samples'] + pairs = data['pairs'] + assert data['status'] == 0 and data['completions'] == 1 + assert len(pairs) == 2 * samples + assert data['environment']['visibility'] == 'visible' + assert data['environment']['isolated'] == bool(case['isolate']) + for key, value in case.items(): + assert str(value) == data['parameters'][key], (case['id'], key) + expected_ops = samples * case['limit'] + 1 if case['mode'] == 'chain' else samples + assert data['operations'] == expected_ops + assert data['sync_calls'] == (samples if case['mode'] == 'sync' else 0) + if case['mode'] == 'chain': + # An i32 EM_JS argument preserves the bits but can arrive signed. + assert data['checksum'] & 0xffffffff == expected_checksum(expected_ops * case['work']) + durations = [(b - a) * 1000 for a, b in zip(pairs[::2], pairs[1::2])] + assert all(math.isfinite(x) and x >= 0 for x in durations) + ordered = sorted(durations) + row = {key: case[key] for key in KEYS} + row.update(id=case['id'], rep=case['rep'], samples=samples, + operations=expected_ops, elapsed_ms=data['elapsed_ms'], + mean_us=stats.mean(durations), p50_us=percentile(ordered, 0.5), + p95_us=percentile(ordered, 0.95), p99_us=percentile(ordered, 0.99), + max_us=max(durations), zero_percent=100 * durations.count(0) / samples, + million_ops_per_second=expected_ops / data['elapsed_ms'] / 1000, + js_elapsed_ms=data['js_elapsed_ms'], wall_elapsed_ms=data['wall_elapsed_ms'], + clock_step_us=data['performance_clock']['minimum_positive_ms'] * 1000, + js_to_cpp_sync_ns=data.get('js_wasm_sync_ns_per_call', 0)) + for clock in ('performance_clock', 'cpp_clock', 'wall_clock'): + if clock in data: + row[clock + '_loop_ns'] = data[clock]['observed_loop_ns_per_read'] + for check in data['clock_checks']: + assert check['max_outside_bracket_ms'] < 0.002 + assert check['wall_max_outside_bracket_ms'] < 1.01 + if case['trace']: + trace = data['trace'] + expected = 0 if case['control'] or case['mode'] in ('clock', 'sync') else samples + assert len(trace) == 6 * expected + if expected: + components = [[] for _ in PARTS] + for i in range(samples): + ticks = [pairs[2 * i], *trace[6 * i:6 * i + 6], pairs[2 * i + 1]] + for j, values in enumerate(components): + delta = (ticks[j + 1] - ticks[j]) * 1000 + # C++ rounds milliseconds to integer nanoseconds and back. + assert delta >= -0.001, (case['id'], i, j, delta) + values.append(delta) + for name, values in zip(PARTS, components): + row[name + '_us'] = stats.mean(values) + assert abs(sum(row[name + '_us'] for name in PARTS) - row['mean_us']) < 1e-6 + return row + + +def summarize(rows): + grouped = defaultdict(list) + indexed = {} + for row in rows: + key = tuple(row[name] for name in KEYS) + grouped[key].append(row) + indexed[(key, row['rep'])] = row + output = [] + for key, values in sorted(grouped.items()): + group: dict[str, Any] = dict(zip(KEYS, key)) + group['repetitions'] = len(values) + group['total_samples'] = sum(row['samples'] for row in values) + for metric in ('mean_us', 'p50_us', 'p95_us', 'p99_us', 'max_us', 'elapsed_ms', + 'million_ops_per_second', 'zero_percent', 'clock_step_us', + 'js_to_cpp_sync_ns', 'performance_clock_loop_ns', + 'cpp_clock_loop_ns', 'wall_clock_loop_ns'): + observed = [row[metric] for row in values if metric in row] + if observed: + group[metric] = dict(median=stats.median(observed), min=min(observed), + max=max(observed), mean=stats.mean(observed)) + if PARTS[0] + '_us' in values[0]: + # Means add to the mean round trip; medians generally do not. + group['component_means_us'] = { + name: stats.mean(row[name + '_us'] for row in values) for name in PARTS} + if group['mode'] == 'chain' and not group['control'] and not group['trace']: + controls = list(key) + controls[KEYS.index('control')] = 1 + ratios, net = [], [] + for row in values: + control = indexed[(tuple(controls), row['rep'])] + ratios.append(row['elapsed_ms'] / control['elapsed_ms']) + net.append((row['elapsed_ms'] - control['elapsed_ms']) * 1000 / row['samples']) + group['paired_slowdown'] = dict(median=stats.median(ratios), + min=min(ratios), max=max(ratios)) + group['paired_net_us_per_yield'] = dict(median=stats.median(net), + min=min(net), max=max(net)) + output.append(group) + return output + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('input', type=Path) + parser.add_argument('output', type=Path) + args = parser.parse_args() + environment = json.loads((args.input / 'environment.json').read_text()) + cases = environment['config']['cases'] + expected = {case['id'] + '.json' for case in cases} | {'environment.json'} + assert {p.name for p in args.input.glob('*.json')} == expected + rows = [analyze_case(case, json.loads((args.input / (case['id'] + '.json')).read_text())) + for case in cases] + args.output.mkdir(parents=True, exist_ok=True) + with (args.output / 'runs.csv').open('w', newline='') as stream: + fields = list(dict.fromkeys(key for row in rows for key in row)) + writer = csv.DictWriter(stream, fieldnames=fields) + writer.writeheader() + writer.writerows(rows) + summary = dict(browser=environment['version']['Browser'], started=environment['started'], + seed=environment['config']['seed'], cases=len(rows), + total_operations=sum(row['operations'] for row in rows), + total_samples=sum(row['samples'] for row in rows), groups=summarize(rows)) + (args.output / 'summary.json').write_text(json.dumps(summary, indent=2) + '\n') + print(f'Validated {len(rows)} cases; {summary["total_operations"]:,} operations; ' + f'{summary["total_samples"]:,} timing pairs.') + for group in summary['groups']: + if group['group'] == 'primary' and not group['trace'] and not group['control']: + print(group['variant'], group['mode'], group['limit'], + 'mean us', round(group['mean_us']['median'], 3), + 'p95 us', round(group['p95_us']['median'], 3), + 'slowdown', round(group.get('paired_slowdown', {}).get('median', 0), 3)) + + +if __name__ == '__main__': + main() diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/analyze_test.py b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/analyze_test.py new file mode 100644 index 0000000..409907b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/analyze_test.py @@ -0,0 +1,67 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Check units, checksum transport and rejection of incomplete or misaligned observations.""" + +import copy +import unittest +from typing import Any + +from analyze import analyze_case, expected_checksum, percentile + + +class AnalysisTest(unittest.TestCase): + def fixture(self): + case: dict[str, Any] = dict(group='test', variant='jspi', mode='chain', limit=1, trace=0, + control=0, exceptions='on', isolate=1, work=1, samples=2, rep=1, id='test') + data: dict[str, Any] = dict(status=0, completions=1, + pairs=[1, 1.005, 2, 2.010], operations=3, + checksum=-2129264258, sync_calls=0, elapsed_ms=1.02, + environment=dict(visibility='visible', isolated=True), + parameters={key: str(value) for key, value in case.items()}, + js_elapsed_ms=1.02, wall_elapsed_ms=1, clock_checks=[], + performance_clock=dict(minimum_positive_ms=0.005, + observed_loop_ns_per_read=20)) + return case, data + + def test_milliseconds_become_microseconds_and_signed_checksum_keeps_bits(self): + case, data = self.fixture() + result = analyze_case(case, data) + self.assertAlmostEqual(result['mean_us'], 7.5) + self.assertAlmostEqual(result['p95_us'], 10) + self.assertEqual(expected_checksum(3), 2165703038) + + def test_affine_checksum_matches_sequential_reference(self): + value = 1 + for i in range(1001): + self.assertEqual(expected_checksum(i), value) + value = (value * 1664525 + 1013904223) & 0xffffffff + + def test_missing_sample_and_incorrect_work_are_rejected(self): + case, original = self.fixture() + for key, invalid in [('pairs', original['pairs'][:-1]), ('checksum', 1), + ('operations', 2), ('completions', 0)]: + with self.subTest(field=key): + data = copy.deepcopy(original) + data[key] = invalid + with self.assertRaises(AssertionError): + analyze_case(case, data) + + def test_misaligned_trace_is_rejected(self): + case, data = self.fixture() + case['trace'] = 1 + data['parameters']['trace'] = '1' + data['trace'] = [1.001, 1.002, 1.003, 1.004, 1.005, 1.006] * 2 + with self.assertRaises(AssertionError): + analyze_case(case, data) + + def test_nearest_rank_does_not_invent_sub_resolution_percentiles(self): + self.assertEqual(percentile([0, 0, 5, 10], 0.5), 0) + self.assertEqual(percentile([0, 0, 5, 10], 0.95), 10) + + +if __name__ == '__main__': + unittest.main() diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/make_cases.py b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/make_cases.py new file mode 100644 index 0000000..02703e2 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/make_cases.py @@ -0,0 +1,78 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Prepare reproducible, shuffled browser cases after both Release builds finish.""" + +import argparse +import json +from pathlib import Path +import random + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument('build_root', type=Path) +parser.add_argument('output', type=Path) +parser.add_argument('--seed', type=int, default=20261015) +args = parser.parse_args() +root = args.build_root.resolve() +scripts = {} +for exceptions in ('on', 'off'): + manifests = list((root / f'yield-benchmark-{exceptions}').rglob('*.variants.json')) + if len(manifests) != 1: + raise SystemExit(f'expected one manifest for exceptions={exceptions}, got {manifests}') + manifest = manifests[0] + for variant, entry in json.loads(manifest.read_text()).items(): + scripts[exceptions, variant] = '/build/' + str( + (manifest.parent / entry['script']).relative_to(root)) + +cases = [] +limits = (1, 10, 100, 1000, 5000, 10000) + + +def add(group, rep, variant, mode, *, limit=1, trace=0, control=0, + exceptions='on', isolate=1, work=0, samples=10000): + case = dict(group=group, rep=rep, variant=variant, mode=mode, limit=limit, + trace=trace, control=control, exceptions=exceptions, isolate=isolate, + work=work, samples=samples) + case['id'] = '-'.join(str(value) for value in case.values()) + if variant != 'js': + case['script'] = scripts[exceptions, variant] + cases.append(case) + + +for rep in range(1, 8): + for variant in ('jspi', 'asyncify'): + for trace in (0, 1): + add('primary', rep, variant, 'direct', trace=trace) + for mode in ('clock', 'sync'): + add('primary', rep, variant, mode, samples=100000) + for limit in limits: + # At least 100,000 handlers and 1,024 yield samples per chain. + samples = max(1024, (100000 + limit - 1) // limit) + for control in (0, 1): + add('primary', rep, variant, 'chain', limit=limit, + samples=samples, control=control) + for trace in (0, 1): + add('js-control', rep, 'js', 'js-direct', trace=trace, exceptions='na') + +for rep in range(1, 4): + for variant in ('jspi', 'asyncify'): + for trace in (0, 1): + add('no-exceptions', rep, variant, 'direct', exceptions='off', trace=trace) + add('ordinary-page', rep, variant, 'direct', isolate=0, trace=trace) + for limit in limits: + add('chain-trace', rep, variant, 'chain', limit=limit, trace=1, samples=1024) + samples = max(1024, (100000 + limit - 1) // limit) + for control in (0, 1): + add('no-exceptions', rep, variant, 'chain', limit=limit, + exceptions='off', samples=samples, control=control) + add('work-64', rep, variant, 'chain', limit=limit, work=64, + samples=samples, control=control) + +random.Random(args.seed).shuffle(cases) +args.output.parent.mkdir(parents=True, exist_ok=True) +args.output.write_text(json.dumps(dict(build_root=str(root), seed=args.seed, + cases=cases), indent=2) + '\n') +print(f'Prepared {len(cases)} cases, seed {args.seed}.') diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/page.html b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/page.html new file mode 100644 index 0000000..73706c4 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/page.html @@ -0,0 +1,11 @@ + + + +Asio yield latency benchmark + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/page.mjs b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/page.mjs new file mode 100644 index 0000000..e135813 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/page.mjs @@ -0,0 +1,193 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +const q = new URLSearchParams(location.search) +const mode = q.get('mode') +const samples = Number(q.get('samples')) +const traceEnabled = q.get('trace') === '1' +const injectedDelayMs = Number(q.get('delay_us') ?? 0) / 1000 +const state = {active: false, count: 0, trace: new Float64Array(samples * 6)} +window.benchmark = {done: false, error: null} +window.benchSyncCalls = 0 +const result = { + environment: {userAgent: navigator.userAgent, isolated: crossOriginIsolated, + visibility: document.visibilityState, timeOrigin: performance.timeOrigin}, + parameters: Object.fromEntries(q), + clock_checks: [] +} +const require = (condition, message) => { if (!condition) throw new Error(message) } + +function clockStudy(read, count = 100000) { + let previous = read() + let positive = 0 + let minimum = Infinity + let backwards = 0 + const start = performance.now() + for (let i = 0; i < count; ++i) { + const current = read() + const delta = current - previous + if (delta > 0) { positive++; minimum = Math.min(minimum, delta) } + if (delta < 0) backwards++ + previous = current + } + return {count, positive, minimum_positive_ms: positive ? minimum : null, + backwards, observed_loop_ns_per_read: (performance.now() - start) * 1e6 / count} +} + +function clocks(module, label) { + let maxOutside = 0 + let maxWallOutside = 0 + let offsetMin = Infinity + let offsetMax = -Infinity + for (let i = 0; i < 2000; ++i) { + const before = performance.now() + const cpp = module._bench_cpp_now() + const after = performance.now() + maxOutside = Math.max(maxOutside, before - cpp, cpp - after) + const offset = cpp - (before + after) / 2 + offsetMin = Math.min(offsetMin, offset) + offsetMax = Math.max(offsetMax, offset) + const wallBefore = Date.now() + const cppWall = module._bench_cpp_wall() + const wallAfter = Date.now() + maxWallOutside = Math.max(maxWallOutside, wallBefore - cppWall, cppWall - wallAfter) + } + result.clock_checks.push({label, max_outside_bracket_ms: maxOutside, + wall_max_outside_bracket_ms: maxWallOutside, midpoint_offset_min_ms: offsetMin, + midpoint_offset_max_ms: offsetMax}) + require(maxOutside < 0.002, 'C++ monotonic clock does not match performance.now') + require(maxWallOutside < 1.01, 'C++ wall clock does not match Date.now') +} + +if (traceEnabled) { + const NativeChannel = MessageChannel + const descriptor = Object.getOwnPropertyDescriptor(MessagePort.prototype, 'onmessage') + window.MessageChannel = class { + constructor() { + // Exercise the same observer during warmup, discarding its samples. + const index = state.active ? state.count++ * 6 : 0 + require(index < state.trace.length, 'too many observed yields') + state.trace[index] = performance.now() + const channel = new NativeChannel() + state.trace[index + 1] = performance.now() + const post = channel.port2.postMessage.bind(channel.port2) + channel.port2.postMessage = value => { + state.trace[index + 2] = performance.now() + post(value) + state.trace[index + 3] = performance.now() + } + Object.defineProperty(channel.port1, 'onmessage', { + get() { return descriptor.get.call(this) }, + set(handler) { + descriptor.set.call(this, event => { + state.trace[index + 4] = performance.now() + // Validation only: a known delay must appear in the handler segment. + if (injectedDelayMs > 0) { + const until = performance.now() + injectedDelayMs + while (performance.now() < until) {} + } + handler.call(channel.port1, event) + state.trace[index + 5] = performance.now() + }) + } + }) + return channel + } + } +} + +function phase(active) { + state.active = active + if (active) { + state.count = 0 + state.jsStart = performance.now() + state.wallStart = Date.now() + } else { + result.js_elapsed_ms = performance.now() - state.jsStart + result.wall_elapsed_ms = Date.now() - state.wallStart + } +} + +async function jsYield() { + await new Promise(resolve => { + const channel = new MessageChannel() + channel.port1.onmessage = () => { channel.port1.close(); resolve() } + channel.port2.postMessage(0) + }) +} + +try { + result.performance_clock = clockStudy(() => performance.now()) + result.wall_clock = clockStudy(() => Date.now()) + require(result.performance_clock.backwards === 0, 'nonmonotonic performance clock') + if (mode === 'js-direct') { + for (let i = 0; i < 512; ++i) await jsYield() + const pairs = new Float64Array(samples * 2) + phase(true) + const start = performance.now() + for (let i = 0; i < samples; ++i) { + pairs[2 * i] = performance.now() + await jsYield() + pairs[2 * i + 1] = performance.now() + } + result.elapsed_ms = performance.now() - start + phase(false) + result.pairs = Array.from(pairs) + result.operations = samples + result.status = 0 + result.completions = 1 + } else { + const {default: createModule} = await import(q.get('script')) + let module + let completed = false + let factoryDone = false + const done = new Promise((resolve, reject) => { + createModule({ + arguments: [mode, q.get('limit'), String(samples), q.get('work'), q.get('control')], + onRuntimeInitialized() { + module = this + clocks(this, 'before') + result.cpp_clock = clockStudy(() => this._bench_cpp_now()) + let value = 0 + for (let i = 0; i < 10000; ++i) value = this._bench_cpp_touch(value) + const start = performance.now() + for (let i = 0; i < 1000000; ++i) value = this._bench_cpp_touch(value) + result.js_wasm_sync_ns_per_call = (performance.now() - start) * 1e6 / 1000000 + require(value === 1010000, 'JS to Wasm control was not executed') + }, + benchPhase: phase, + benchData: data => Object.assign(result, data), + webcppTestFinished(status) { + result.status = status + result.completions = (result.completions ?? 0) + 1 + completed = true + if (factoryDone) resolve() + }, + print: line => { (result.stdout ??= []).push(line) }, + printErr: line => { (result.stderr ??= []).push(line) }, + onAbort: value => reject(new Error(String(value))) + }).then(() => { factoryDone = true; if (completed) resolve() }, reject) + }) + await done + clocks(module, 'after') + require(result.status === 0 && result.completions === 1, 'C++ failed or did not complete once') + require(!result.stderr?.length && !result.stdout?.length, 'unexpected program output') + } + if (traceEnabled) { + const expected = q.get('control') === '1' || mode === 'clock' || mode === 'sync' ? 0 : samples + require(state.count === expected, `observed ${state.count} yields, expected ${expected}`) + result.trace = Array.from(state.trace.slice(0, state.count * 6)) + } + result.sync_calls = window.benchSyncCalls + require(result.pairs.length === samples * 2, 'incomplete sample array') + for (let i = 0; i < samples; ++i) { + require(Number.isFinite(result.pairs[2 * i]) && result.pairs[2 * i + 1] >= result.pairs[2 * i], + 'invalid C++ timing pair') + } + window.benchmark = {done: true, result} +} catch (error) { + window.benchmark = {done: true, error: error.stack ?? String(error)} +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/plot_results.py b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/plot_results.py new file mode 100644 index 0000000..237d0d0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/plot_results.py @@ -0,0 +1,300 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Plot existing benchmark observations; never runs or changes the benchmark.""" + +import argparse +import csv +import json +import re +from importlib import import_module +from pathlib import Path + +# Optional dependencies of this manual visualization tool, not of the library. +try: + matplotlib = import_module('matplotlib') + matplotlib.use('Agg') + plt = import_module('matplotlib.pyplot') + PdfPages = import_module('matplotlib.backends.backend_pdf').PdfPages + np = import_module('numpy') +except ModuleNotFoundError as error: + raise SystemExit('Install matplotlib in a local environment before plotting.') from error + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument('results', type=Path) +parser.add_argument('output', type=Path) +args = parser.parse_args() +data = json.loads((args.results / 'summary.json').read_text()) +groups = data['groups'] +assert len(groups) == 102 and data['cases'] == 442 +args.output.mkdir(parents=True, exist_ok=True) +limits = [1, 10, 100, 1000, 5000, 10000] +x = np.arange(len(limits)) +colors = {'jspi': '#2266A5', 'asyncify': '#C25C16', 'js': '#29805F'} +plt.rcParams.update({'font.family': 'DejaVu Sans', 'font.size': 11, + 'axes.titlesize': 14, 'axes.labelsize': 11, + 'axes.spines.top': False, 'axes.spines.right': False, + 'figure.facecolor': 'white', 'axes.facecolor': 'white', + 'svg.fonttype': 'none', 'pdf.fonttype': 42, + 'savefig.facecolor': 'white'}) +pdf = PdfPages(args.output / 'yield-benchmark-charts.pdf') + + +def get(group, variant, mode='direct', limit=1, trace=0, control=0): + match = dict(group=group, variant=variant, mode=mode, limit=limit, + trace=trace, control=control) + found = [g for g in groups if all(g[k] == v for k, v in match.items())] + assert len(found) == 1, match + return found[0] + + +def frame(ax, title, ylabel=None, settings=False): + ax.set_title(title, loc='left', pad=13, fontweight='bold') + if ylabel: + ax.set_ylabel(ylabel) + ax.grid(axis='y', color='#E2E6EA', linewidth=0.7) + ax.set_axisbelow(True) + if settings: + ax.set_xticks(x, ['1', '10', '100', '1,000', '5,000', '10,000']) + ax.set_xlabel('Handlers per turn (tested settings)') + + +def heading(fig, title, subtitle): + fig.suptitle(title, x=0.06, y=0.975, ha='left', fontsize=21, fontweight='bold') + fig.text(0.06, 0.925, subtitle, fontsize=11, color='#475569') + + +def save(fig, name, note): + fig.text(0.06, 0.025, note, fontsize=9, color='#475569', va='bottom') + fig.canvas.draw() + renderer = fig.canvas.get_renderer() + width, height = fig.canvas.get_width_height() + for text in fig.texts: + box = text.get_window_extent(renderer) + assert box.x0 >= 0 and box.y0 >= 0 and box.x1 <= width and box.y1 <= height + fig.savefig(args.output / (name + '.png'), dpi=150) + svg_path = args.output / (name + '.svg') + fig.savefig(svg_path) + # Namespace SVG IDs so multiple inline figures can share one document. + svg = svg_path.read_text() + svg = re.sub(r'id="([^"]+)"', lambda m: f'id="{name}-{m[1]}"', svg) + svg = re.sub(r'url\(#([^)]+)\)', lambda m: f'url(#{name}-{m[1]})', svg) + svg = re.sub(r'xlink:href="#([^"]+)"', lambda m: f'xlink:href="#{name}-{m[1]}"', svg) + svg_path.write_text(svg) + pdf.savefig(fig) + plt.close(fig) + + +# Figure 1: actual gaps and their explicitly derived per-handler amortization. +fig, axs = plt.subplots(1, 2, figsize=(16, 8)) +fig.subplots_adjust(left=0.07, right=0.97, top=0.81, bottom=0.16, wspace=0.25) +heading(fig, 'Yield latency and turn limits', + 'Release -O3 | Exceptions enabled | Isolated page | Seven repetitions per setting') +for variant in ('jspi', 'asyncify'): + records = [get('primary', variant, 'chain', n) for n in limits] + means = np.array([g['mean_us']['median'] for g in records]) + low = means - np.array([g['mean_us']['min'] for g in records]) + high = np.array([g['mean_us']['max'] for g in records]) - means + axs[0].errorbar(x, means, yerr=[low, high], color=colors[variant], + marker='o' if variant == 'jspi' else 's', capsize=4, + linewidth=2, label=variant.upper()) + amortized = means * 1000 / np.array(limits) + axs[1].plot(x, amortized, color=colors[variant], linewidth=2, + marker='o' if variant == 'jspi' else 's', label=variant.upper()) + for i, value in enumerate(means): + anchor = records[i]['mean_us']['max' if variant == 'asyncify' else 'min'] + axs[0].annotate(f'{value:.2f}', (i, anchor), xytext=(0, 8 if variant == 'asyncify' + else -18), textcoords='offset points', ha='center', + color=colors[variant], fontsize=10) +frame(axs[0], 'Measured boundary gap: excludes callback batch work', + 'Microseconds per yield gap', True) +axs[0].set_ylim(0, 8) +frame(axs[1], 'Derived scheduling cost per callback', + 'Nanoseconds per callback (log scale)', True) +axs[1].set_yscale('log') +axs[0].legend(loc='upper left', frameon=False) +axs[1].legend(loc='upper right', frameon=False) +save(fig, '01-yield-latency', + 'Dots: median of per-run means. Error bars: range of run means, not confidence intervals.\n' + 'Amortization = measured gap / turn limit. ' + 'Gaps include small dispatcher return/reentry costs.') + +# Figure 2: every direct control, and all traced direct paths. +fig, axs = plt.subplots(1, 2, figsize=(17, 11)) +fig.subplots_adjust(left=0.20, right=0.97, top=0.85, bottom=0.24, wspace=0.65) +heading(fig, 'Direct round trips and observed phases', + 'Same Promise / MessageChannel mechanism | ' + 'Untraced and traced measurements kept separate') +direct = [] +for group, suffix in [('primary', 'EH on'), ('no-exceptions', 'EH off'), + ('ordinary-page', 'ordinary page')]: + for variant in ('jspi', 'asyncify'): + for trace in (0, 1): + direct.append((f'{variant.upper()} / {suffix}' + (' / traced' if trace else ''), + get(group, variant, trace=trace))) +for trace in (0, 1): + direct.append(('JavaScript only' + (' / traced' if trace else ''), + get('js-control', 'js', 'js-direct', trace=trace))) +for i, (label, g) in enumerate(direct): + m = g['mean_us'] + axs[0].barh(i, m['median'], color=colors[g['variant']], + alpha=0.5 if g['trace'] else 1, height=0.65) + axs[0].errorbar(m['median'], i, xerr=[[m['median'] - m['min']], + [m['max'] - m['median']]], color='#283544', capsize=3, fmt='none') + axs[0].text(m['max'] + 0.07, i, f"{m['median']:.2f}", va='center', fontsize=10) +axs[0].set_yticks(range(len(direct)), [label for label, _ in direct], fontsize=10) +axs[0].invert_yaxis() +axs[0].set_xlim(0, 6.4) +axs[0].set_xlabel('Microseconds per round trip') +frame(axs[0], 'Direct latency: median of run means') +parts = ['entry', 'channel_create', 'handler_setup', 'post_message', + 'post_to_delivery', 'message_handler', 'resume'] +part_labels = ['Caller entry', 'Channel construction', 'Handler + observer setup', + 'postMessage', 'Post return to delivery', 'Close port + resolve', 'Resume'] +part_colors = ['#5965A7', '#2B79A1', '#319B9A', '#A3BF69', '#E6B651', '#DA8150', '#AE5B79'] +traced = [(label.replace(' / traced', ''), g) for label, g in direct if g['trace']] +left = np.zeros(len(traced)) +for part, label, color in zip(parts, part_labels, part_colors): + values = np.array([g['component_means_us'][part] for _, g in traced]) + axs[1].barh(range(len(traced)), values, left=left, label=label, color=color, height=0.6) + left += values +for i, value in enumerate(left): + axs[1].text(value + 0.06, i, f'{value:.2f}', va='center', fontsize=10) +axs[1].set_yticks(range(len(traced)), [label for label, _ in traced], fontsize=10) +axs[1].invert_yaxis() +axs[1].set_xlim(0, 6.5) +axs[1].set_xlabel('Microseconds, arithmetic means of traced runs') +frame(axs[1], 'Instrumented phases: means add to the total') +axs[1].legend(loc='upper center', bbox_to_anchor=(0.42, -0.12), ncol=2, + frameon=False, fontsize=10) +save(fig, '02-direct-and-phases', + 'Primary and JS-only controls: 7 runs; EH-off and ordinary-page controls: 3 runs.\n' + 'The observer adds cost. Post-to-delivery includes suspension and scheduling, ' + 'not pure queue wait.\n' + 'Sub-resolution phase values are aggregate estimates; individual clock steps are 5 or 100 us.') + +# Figure 3: all chain comparison groups and paired whole-run controls. +fig, axs = plt.subplots(2, 2, figsize=(16, 12)) +fig.subplots_adjust(left=0.08, right=0.97, top=0.85, bottom=0.13, hspace=0.55, wspace=0.22) +heading(fig, 'Chain controls and whole-program comparisons', + 'All six turn limits | Same callback and timestamp counts within each control pair') +styles = [('primary', 'EH on, untraced', '#2266A5', 'o'), + ('no-exceptions', 'EH off, untraced', '#29805F', 's'), + ('work-64', '64 source-level LCG updates', '#C25C16', '^'), + ('chain-trace', 'EH on, traced', '#8960A5', 'D')] +for column, variant in enumerate(('jspi', 'asyncify')): + for group, label, color, marker in styles: + records = [get(group, variant, 'chain', n, trace=int(group == 'chain-trace')) + for n in limits] + axs[0, column].plot(x, [g['mean_us']['median'] for g in records], + color=color, marker=marker, linewidth=1.8, label=label) + if group != 'chain-trace': + ratios = [g['paired_slowdown'] for g in records] + m = np.array([r['median'] for r in ratios]) + axs[1, column].errorbar(x, m, + yerr=[m - np.array([r['min'] for r in ratios]), + np.array([r['max'] for r in ratios]) - m], + color=color, marker=marker, capsize=3, linewidth=1.8, label=label) + frame(axs[0, column], variant.upper() + ': measured yield boundary gaps', + 'Microseconds (median of run means)', True) + axs[0, column].set_ylim(0, 10) + axs[0, column].legend(frameon=False, fontsize=9, loc='upper left') + frame(axs[1, column], variant.upper() + ': elapsed-time ratio vs no periodic yields', + 'Whole-run ratio (log scale)', True) + axs[1, column].set_yscale('log') + axs[1, column].axhline(1, color='#687483', linestyle='--', linewidth=1) + axs[1, column].set_ylim(0.5, 30) +save(fig, '03-chain-controls', + 'Ratios below 1 are observed whole-program outcomes, not negative yield costs. ' + 'Runtime effects confound subtraction.\n' + 'Primary: 7 runs; other groups: 3. Error bars show the range of paired ratios.\n' + 'LCG updates are source-level work, not a guarantee of 64 instructions after optimization.') + +# Figure 4: tails, clock read controls, resolution and quantized zeros. +fig, axs = plt.subplots(2, 2, figsize=(16, 12)) +fig.subplots_adjust(left=0.10, right=0.97, top=0.85, bottom=0.12, hspace=0.65, wspace=0.42) +heading(fig, 'Tails, clocks and measurement resolution', + 'Extreme observations are retained | ' + 'A quantized zero is not proof of a zero-cost operation') +for variant in ('jspi', 'asyncify'): + records = [get('primary', variant, 'chain', n) for n in limits] + for metric, aggregate, style, suffix in [('max_us', 'max', '-', 'maximum'), + ('p99_us', 'median', '--', 'p99')]: + axs[0, 0].plot(x, [g[metric][aggregate] for g in records], linestyle=style, + marker='o' if variant == 'jspi' else 's', color=colors[variant], + label=variant.upper() + ' ' + suffix) +frame(axs[0, 0], 'Chain tails: p99 and largest observed gap', + 'Microseconds (log scale)', True) +axs[0, 0].set_yscale('log') +axs[0, 0].legend(frameon=False, fontsize=9) +metrics = [('direct', 'js_to_cpp_sync_ns', 'JS to Wasm increment loop', 1), + ('direct', 'performance_clock_loop_ns', 'JS monotonic clock study', 1), + ('direct', 'cpp_clock_loop_ns', 'Wasm clock via JS study', 1), + ('direct', 'wall_clock_loop_ns', 'JS wall-clock study', 1), + ('clock', 'mean_us', 'Adjacent Wasm timestamps', 1000), + ('sync', 'mean_us', 'Wasm to JS + timestamps', 1000)] +y = np.arange(len(metrics)) +for offset, variant in [(-0.18, 'jspi'), (0.18, 'asyncify')]: + values = [get('primary', variant, mode)[metric]['median'] * factor + for mode, metric, _, factor in metrics] + axs[0, 1].barh(y + offset, values, height=0.32, color=colors[variant], + label=variant.upper()) +axs[0, 1].set_yticks(y, [label for _, _, label, _ in metrics], fontsize=9) +axs[0, 1].invert_yaxis() +axs[0, 1].set_xscale('log') +axs[0, 1].set_xlabel('Nanoseconds per iteration (log scale)') +frame(axs[0, 1], 'Synchronous and clock-read controls') +axs[0, 1].legend(frameon=False, fontsize=9) +axs[1, 0].bar(['Isolated monotonic', 'Ordinary monotonic', 'Wall clock'], + [5, 100, 1000], color=['#2266A5', '#8960A5', '#687483'], width=0.55) +axs[1, 0].set_yscale('log') +for i, value in enumerate([5, 100, 1000]): + axs[1, 0].text(i, value * 1.15, f'{value:,} us', ha='center') +axs[1, 0].set_ylim(1, 3000) +frame(axs[1, 0], 'Observed positive clock steps', 'Microseconds (log scale)') +for offset, variant in [(-0.18, 'jspi'), (0.18, 'asyncify')]: + values = [get(group, variant)['zero_percent']['median'] + for group in ['primary', 'ordinary-page']] + axs[1, 1].bar(np.arange(2) + offset, values, width=0.32, + color=colors[variant], label=variant.upper()) + for i, value in enumerate(values): + axs[1, 1].text(i + offset, value + 2, f'{value:.1f}%', ha='center', fontsize=10) +axs[1, 1].set_xticks([0, 1], ['Isolated page', 'Ordinary page']) +axs[1, 1].set_ylim(0, 108) +frame(axs[1, 1], 'Direct samples recorded as zero', 'Percent of samples') +axs[1, 1].legend(frameon=False, loc='center left') +save(fig, '04-tails-and-clocks', + 'Clock studies include loop overhead; the trivial synchronous export may be inlined. ' + 'Wall-clock step: where observed.\n' + 'Wasm and JS monotonic clocks share performance.now(). ' + 'Maximums are observations, not guaranteed latency bounds.') +pdf.close() + + +# Preserve every aggregate field, including repeat ranges and traced components. +def flatten(value, prefix=''): + result = {} + for key, item in value.items(): + label = prefix + key + if isinstance(item, dict): + result.update(flatten(item, label + '.')) + else: + result[label] = item + return result + + +rows = [flatten(g) for g in groups] +fields = list(dict.fromkeys(key for row in rows for key in row)) +with (args.output / 'all-configurations.csv').open('w', newline='') as stream: + writer = csv.DictWriter(stream, fieldnames=fields, lineterminator='\n') + writer.writeheader() + writer.writerows(rows) +manifest = dict(source='summary.json', configurations=len(rows), runs=data['cases'], + matplotlib=matplotlib.__version__, + charts=['01-yield-latency', '02-direct-and-phases', + '03-chain-controls', '04-tails-and-clocks']) +(args.output / 'figures.json').write_text(json.dumps(manifest, indent=2) + '\n') +print(f'Created 4 figures (PNG/SVG), a 4-page PDF and {len(rows)} complete aggregate rows.') diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/build.json b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/build.json new file mode 100644 index 0000000..6c5edb8 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/build.json @@ -0,0 +1,31 @@ +{ + "cpu": "Apple M5 Max", + "memory_bytes": 137438953472, + "os": "macOS 27.0 (26A428)", + "emscripten": "6.0.11", + "boost": "1.92.0", + "node": "26.7.0", + "optimization": "Release: compile -O3, link -O3", + "library_base": "3817dc9", + "superproject_base": "8829e99", + "sha256": { + "libs/asio/bench/yield/yield_program.cpp": "29702bad54ebc3208abfa8e055fef4a219ed175fbed08ec2e7d1564c1ded39c4", + "libs/asio/bench/yield/run.mjs": "27caf006698a43b20bba3340b57b1ce5a1358dbc0e045ad30ab69460768e0aca", + "libs/asio/bench/yield/page.mjs": "41b38c8e242ec19cee4df6510c4b6dcb5fc3c9b2824c712db77305211c211405", + "libs/asio/bench/yield/Jamfile": "8f2c04e621c12f1fb8d345a870d3492a28bd133cd93e247da0ce85e056214132", + "bin/yield-benchmark-on/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/link-static/target-os-none/yield_program-60-jspi.js": "4c2c6e319be6e8b964d3e80b5b0ca32ad1156309dc1ba9fc38d72c3289a58d31", + "bin/yield-benchmark-on/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/link-static/target-os-none/webcpp-suspend-asyncify/yield_program-60-asyncify.js": "183fed06598de0a4a4e6b034ab2d1a3d517957e2dbf2f59ec09dfa442cb80240", + "bin/yield-benchmark-on/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/link-static/target-os-none/yield_program-60-jspi.wasm": "e7c92c2ca5e767a9bbbea148e735e67e24aa8f6728971785be42f9918bf4c0b0", + "bin/yield-benchmark-on/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/link-static/target-os-none/webcpp-suspend-asyncify/yield_program-60-asyncify.wasm": "6440a6257a19afd5cd85f660e9cb7f6a4798fe4a5362e6d198bb15eabe66a060", + "bin/yield-benchmark-off/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/exception-handling-off/link-static/target-os-none/yield_program-60-jspi.js": "aa036a958e78419a48282c8ce67d8ed645ec5b5e0b6bd5484bfd6c70125233fc", + "bin/yield-benchmark-off/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/exception-handling-off/link-static/target-os-none/webcpp-suspend-asyncify/yield_program-60-asyncify.js": "8bcbde6e1c55cce3c7c4a46eac066b3f7860a1033aa92af079d36d993caad805", + "bin/yield-benchmark-off/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/exception-handling-off/link-static/target-os-none/yield_program-60-jspi.wasm": "c2f7edfa9ef1403f9e589fd724fb498a66887c4bf4151d39a5e59caf7bf7ba37", + "bin/yield-benchmark-off/webcpp/bin/libs/asio/bench/yield/emscripten-6.0.11/release/address-model-32/cxxstd-20-iso/exception-handling-off/link-static/target-os-none/webcpp-suspend-asyncify/yield_program-60-asyncify.wasm": "76184f37ad6c1bd5528e83ba46f9a5ecd845e4f3005d3ee245754f8de860054b" + }, + "notes": [ + "No CI was run.", + "Headless Chrome, fresh foreground page per case.", + "Builds finished before timing began; cases ran sequentially.", + "Machine was not isolated from all other OS activity." + ] +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/01-yield-latency.png b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/01-yield-latency.png new file mode 100644 index 0000000..047d683 Binary files /dev/null and b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/01-yield-latency.png differ diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/01-yield-latency.svg b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/01-yield-latency.svg new file mode 100644 index 0000000..6135b4e --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/01-yield-latency.svg @@ -0,0 +1,1025 @@ + + + + + + + + 2026-10-15T03:06:30.693620 + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 3 + + + + + + + + + + + + + 4 + + + + + + + + + + + + + 5 + + + + + + + + + + + + + 6 + + + + + + + + + + + + + 7 + + + + + + + + + + + + + 8 + + + + Microseconds per yield gap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.18 + + + 4.15 + + + 4.40 + + + 4.64 + + + 4.82 + + + 4.86 + + + 4.85 + + + 4.98 + + + 5.45 + + + 5.73 + + + 6.40 + + + 6.93 + + + Measured boundary gap: excludes callback batch work + + + + + + + + + + + + + + + + + + + + + + + + + JSPI + + + + + + + + + + + + + + + + + + + + + + + + ASYNCIFY + + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + + + + 1 + 0 + 0 + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + + + + 1 + 0 + 2 + + + + + + + + + + + + + + + + + + 1 + 0 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Nanoseconds per callback (log scale) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Derived scheduling cost per callback + + + + + + + + + + JSPI + + + + + + + + + ASYNCIFY + + + + + Yield latency and turn limits + + + Release -O3 | Exceptions enabled | Isolated page | Seven repetitions per setting + + + Dots: median of per-run means. Error bars: range of run means, not confidence intervals. + Amortization = measured gap / turn limit. Gaps include small dispatcher return/reentry costs. + + + + + + + + + + + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/02-direct-and-phases.png b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/02-direct-and-phases.png new file mode 100644 index 0000000..ea7d25a Binary files /dev/null and b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/02-direct-and-phases.png differ diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/02-direct-and-phases.svg b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/02-direct-and-phases.svg new file mode 100644 index 0000000..b4656e7 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/02-direct-and-phases.svg @@ -0,0 +1,1437 @@ + + + + + + + + 2026-10-15T03:06:31.033565 + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + 1 + + + + + + + + + + 2 + + + + + + + + + + 3 + + + + + + + + + + 4 + + + + + + + + + + 5 + + + + + + + + + + 6 + + + + Microseconds per round trip + + + + + + + + + + + + + + + + + JSPI / EH on + + + + + + + + + + + + + JSPI / EH on / traced + + + + + + + + + + + + + ASYNCIFY / EH on + + + + + + + + + + + + + ASYNCIFY / EH on / traced + + + + + + + + + + + + + JSPI / EH off + + + + + + + + + + + + + JSPI / EH off / traced + + + + + + + + + + + + + ASYNCIFY / EH off + + + + + + + + + + + + + ASYNCIFY / EH off / traced + + + + + + + + + + + + + JSPI / ordinary page + + + + + + + + + + + + + JSPI / ordinary page / traced + + + + + + + + + + + + + ASYNCIFY / ordinary page + + + + + + + + + + + + + ASYNCIFY / ordinary page / traced + + + + + + + + + + + + + JavaScript only + + + + + + + + + + + + + JavaScript only / traced + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.06 + + + 4.85 + + + 4.74 + + + 5.57 + + + 4.03 + + + 4.92 + + + 4.43 + + + 5.31 + + + 4.03 + + + 4.83 + + + 4.73 + + + 5.56 + + + 3.93 + + + 4.83 + + + Direct latency: median of run means + + + + + + + + + + + + + + + 0 + + + + + + + + + + 1 + + + + + + + + + + 2 + + + + + + + + + + 3 + + + + + + + + + + 4 + + + + + + + + + + 5 + + + + + + + + + + 6 + + + + Microseconds, arithmetic means of traced runs + + + + + + + + + + + + + + JSPI / EH on + + + + + + + + + + + + + ASYNCIFY / EH on + + + + + + + + + + + + + JSPI / EH off + + + + + + + + + + + + + ASYNCIFY / EH off + + + + + + + + + + + + + JSPI / ordinary page + + + + + + + + + + + + + ASYNCIFY / ordinary page + + + + + + + + + + + + + JavaScript only + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.83 + + + 5.59 + + + 4.89 + + + 5.31 + + + 4.84 + + + 5.56 + + + 4.82 + + + Instrumented phases: means add to the total + + + + + + + Caller entry + + + + + + Channel construction + + + + + + Handler + observer setup + + + + + + postMessage + + + + + + Post return to delivery + + + + + + Close port + resolve + + + + + + Resume + + + + + Direct round trips and observed phases + + + Same Promise / MessageChannel mechanism | Untraced and traced measurements kept separate + + + Primary and JS-only controls: 7 runs; EH-off and ordinary-page controls: 3 runs. + The observer adds cost. Post-to-delivery includes suspension and scheduling, not pure queue wait. + Sub-resolution phase values are aggregate estimates; individual clock steps are 5 or 100 us. + + + + + + + + + + + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/03-chain-controls.png b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/03-chain-controls.png new file mode 100644 index 0000000..3e9bb47 Binary files /dev/null and b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/03-chain-controls.png differ diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/03-chain-controls.svg b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/03-chain-controls.svg new file mode 100644 index 0000000..4a49b22 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/03-chain-controls.svg @@ -0,0 +1,1561 @@ + + + + + + + + 2026-10-15T03:06:31.421396 + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 4 + + + + + + + + + + + + + 6 + + + + + + + + + + + + + 8 + + + + + + + + + + + + + 10 + + + + Microseconds (median of run means) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JSPI: measured yield boundary gaps + + + + + + + + + + EH on, untraced + + + + + + + + + EH off, untraced + + + + + + + + + 64 source-level LCG updates + + + + + + + + + EH on, traced + + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 4 + + + + + + + + + + + + + 6 + + + + + + + + + + + + + 8 + + + + + + + + + + + + + 10 + + + + Microseconds (median of run means) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ASYNCIFY: measured yield boundary gaps + + + + + + + + + + EH on, untraced + + + + + + + + + EH off, untraced + + + + + + + + + 64 source-level LCG updates + + + + + + + + + EH on, traced + + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + + + + 1 + 0 + 0 + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Whole-run ratio (log scale) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JSPI: elapsed-time ratio vs no periodic yields + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + + + + 1 + 0 + 0 + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Whole-run ratio (log scale) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ASYNCIFY: elapsed-time ratio vs no periodic yields + + + + Chain controls and whole-program comparisons + + + All six turn limits | Same callback and timestamp counts within each control pair + + + Ratios below 1 are observed whole-program outcomes, not negative yield costs. Runtime effects confound subtraction. + Primary: 7 runs; other groups: 3. Error bars show the range of paired ratios. + LCG updates are source-level work, not a guarantee of 64 instructions after optimization. + + + + + + + + + + + + + + + + + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.png b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.png new file mode 100644 index 0000000..93b821f Binary files /dev/null and b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.png differ diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.svg b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.svg new file mode 100644 index 0000000..a2e095a --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.svg @@ -0,0 +1,1577 @@ + + + + + + + + 2026-10-15T03:06:31.817794 + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + 100 + + + + + + + + + + 1,000 + + + + + + + + + + 5,000 + + + + + + + + + + 10,000 + + + + Handlers per turn (tested settings) + + + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + + + + 1 + 0 + 2 + + + + + + + + + + + + + + + + + + 1 + 0 + 3 + + + + + + + + + + + + + + + + + + 1 + 0 + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Microseconds (log scale) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Chain tails: p99 and largest observed gap + + + + + + + + + + JSPI maximum + + + + + + + + + JSPI p99 + + + + + + + + + ASYNCIFY maximum + + + + + + + + + ASYNCIFY p99 + + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + 1 + 0 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Nanoseconds per iteration (log scale) + + + + + + + + + + + + + + JS to Wasm increment loop + + + + + + + + + + + + + JS monotonic clock study + + + + + + + + + + + + + Wasm clock via JS study + + + + + + + + + + + + + JS wall-clock study + + + + + + + + + + + + + Adjacent Wasm timestamps + + + + + + + + + + + + + Wasm to JS + timestamps + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Synchronous and clock-read controls + + + + + + + JSPI + + + + + + ASYNCIFY + + + + + + + + + + + + + + + + Isolated monotonic + + + + + + + + + + Ordinary monotonic + + + + + + + + + + Wall clock + + + + + + + + + + + + + + + + + + 1 + 0 + 0 + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + + + + 1 + 0 + 2 + + + + + + + + + + + + + + + + + + 1 + 0 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Microseconds (log scale) + + + + + + + + + + + + + + + + + + + 5 us + + + 100 us + + + 1,000 us + + + Observed positive clock steps + + + + + + + + + + + + + + + Isolated page + + + + + + + + + + Ordinary page + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 100 + + + + Percent of samples + + + + + + + + + + + + + + + + + + + + + + 31.4% + + + 96.0% + + + 23.1% + + + 95.3% + + + Direct samples recorded as zero + + + + + + + JSPI + + + + + + ASYNCIFY + + + + + Tails, clocks and measurement resolution + + + Extreme observations are retained | A quantized zero is not proof of a zero-cost operation + + + Clock studies include loop overhead; the trivial synchronous export may be inlined. Wall-clock step: where observed. + Wasm and JS monotonic clocks share performance.now(). Maximums are observations, not guaranteed latency bounds. + + + + + + + + + + + + + + + + + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/all-configurations.csv b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/all-configurations.csv new file mode 100644 index 0000000..c4917ee --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/all-configurations.csv @@ -0,0 +1,103 @@ +group,variant,mode,limit,trace,control,exceptions,isolate,work,repetitions,total_samples,mean_us.median,mean_us.min,mean_us.max,mean_us.mean,p50_us.median,p50_us.min,p50_us.max,p50_us.mean,p95_us.median,p95_us.min,p95_us.max,p95_us.mean,p99_us.median,p99_us.min,p99_us.max,p99_us.mean,max_us.median,max_us.min,max_us.max,max_us.mean,elapsed_ms.median,elapsed_ms.min,elapsed_ms.max,elapsed_ms.mean,million_ops_per_second.median,million_ops_per_second.min,million_ops_per_second.max,million_ops_per_second.mean,zero_percent.median,zero_percent.min,zero_percent.max,zero_percent.mean,clock_step_us.median,clock_step_us.min,clock_step_us.max,clock_step_us.mean,js_to_cpp_sync_ns.median,js_to_cpp_sync_ns.min,js_to_cpp_sync_ns.max,js_to_cpp_sync_ns.mean,performance_clock_loop_ns.median,performance_clock_loop_ns.min,performance_clock_loop_ns.max,performance_clock_loop_ns.mean,cpp_clock_loop_ns.median,cpp_clock_loop_ns.min,cpp_clock_loop_ns.max,cpp_clock_loop_ns.mean,wall_clock_loop_ns.median,wall_clock_loop_ns.min,wall_clock_loop_ns.max,wall_clock_loop_ns.mean,component_means_us.entry,component_means_us.channel_create,component_means_us.handler_setup,component_means_us.post_message,component_means_us.post_to_delivery,component_means_us.message_handler,component_means_us.resume,paired_slowdown.median,paired_slowdown.min,paired_slowdown.max,paired_net_us_per_yield.median,paired_net_us_per_yield.min,paired_net_us_per_yield.max +chain-trace,asyncify,chain,1,1,0,on,1,0,3,3072,6.333007812499999,6.333007812499957,6.557617187499975,6.407877604166644,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,15.000000000000568,15.000000000000568,15.000000000000568,219.99999999999886,210.00000000000796,239.99999999999488,223.3333333333339,6.7549999999999955,6.720000000000013,6.930000000000007,6.801666666666672,0.15173945225758706,0.14790764790764777,0.1525297619047616,0.1507256206899988,12.5,11.5234375,12.890625,12.3046875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.075000047683716,4.059999942779541,4.9049999713897705,4.346666653951009,71.05000019073486,70.24999856948853,72.45000123977661,71.25,140.80000162124634,138.39999914169312,143.1500005722046,140.78333377838135,28.19999933242798,27.799999713897705,28.250000476837158,28.083333174387615,0.3531668769816652,1.1800140297661226,0.7845046153912941,0.5240896716713905,1.7171217283854883,1.0009761899709702,0.8480044919997135,,,,,, +chain-trace,asyncify,chain,10,1,0,on,1,0,3,3072,6.352539062500079,6.230468749999926,6.401367187499993,6.328124999999999,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,19.99999999999602,19.99999999999602,19.99999999999602,19.99999999999602,230.00000000000398,210.00000000000796,239.99999999999488,226.66666666666893,8.379999999999995,8.365000000000009,8.379999999999995,8.375,1.2220763723150365,1.2220763723150365,1.224267782426777,1.2228068423522833,12.98828125,11.23046875,14.35546875,12.858072916666666,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.1499998569488525,4.065000057220459,4.93999981880188,4.384999910990397,69.40000057220459,68.39999914169312,72.34999895095825,70.04999955495198,143.1500005722046,137.5,143.19999933242798,141.2833333015442,27.999999523162842,27.59999990463257,28.350000381469727,27.983333269755047,0.42486831235381367,1.0742190449188154,0.7291669026017189,0.5159503780305386,1.6748046036809683,1.0725903169562419,0.8365254414579026,,,,,, +chain-trace,asyncify,chain,100,1,0,on,1,0,3,3072,6.37695312500014,6.352539062500259,6.645507812499965,6.458333333333455,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,19.99999999999602,15.000000000000568,19.99999999999602,18.33333333333087,234.99999999999943,219.99999999999886,250.0,234.99999999999943,16.614999999999995,16.5,17.235,16.78333333333333,6.163165814023475,5.941456338845373,6.206121212121212,6.103581121663353,12.01171875,10.7421875,13.8671875,12.20703125,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.175000190734863,4.099999904632568,4.879999876022339,4.384999990463257,70,69.85000133514404,71.10000133514404,70.3166675567627,138.99999856948853,137.30000019073486,140.15000104904175,138.81666660308838,28.19999933242798,27.54999876022339,28.600001335144043,28.116666475931805,0.2832250048716983,1.1425781218955915,0.8593760430812836,0.553385199358066,1.7757161986082792,1.0400393512099981,0.8040134143085381,,,,,, +chain-trace,asyncify,chain,1000,1,0,on,1,0,3,3072,6.704101562500147,6.1865234374998685,6.982421875000353,6.6243489583334565,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000019327,10.000000000019327,10.000000000019327,10.000000000019327,20.000000000010232,19.99999999999602,20.000000000010232,20.000000000005496,219.99999999999886,199.99999999998863,245.00000000000455,221.666666666664,94.84,92.62499999999999,96.03,94.49833333333333,10.797142555883593,10.663344788087056,11.055341430499327,10.838609591489991,9.9609375,8.3984375,12.98828125,10.44921875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.059999942779541,3.990000009536743,4.985000133514404,4.3450000286102295,71.25,71.10000133514404,72.00000047683716,71.45000060399373,139.45000171661377,137.59999990463257,142.4500012397766,139.83333428700766,27.749998569488525,27.650001049041748,28.20000171661377,27.86666711171468,0.4231618003299233,1.1979157570749521,0.7112639335294565,0.514323745543758,1.8115217487017314,1.0074868332594633,0.9586751398941717,,,,,, +chain-trace,asyncify,chain,5000,1,0,on,1,0,3,3072,7.5830078125005835,7.167968750000448,7.646484375000553,7.4658203125005285,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,14.999999999986358,10.000000000047748,14.999999999986358,13.333333333340155,25.000000000005684,25.000000000005684,30.000000000001137,26.666666666670835,269.9999999999818,259.9999999999909,284.99999999996817,271.66666666664696,455.76,443.93,456.22,451.97,11.233984992101107,11.22265792819254,11.53335210506161,11.329998341785085,8.59375,6.4453125,9.765625,8.268229166666666,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.080000162124634,4.070000171661377,4.990000009536743,4.380000114440918,69.54999923706055,67.99999952316284,70.44999837875366,69.33333237965901,139.24999952316284,137.75000095367432,144.19999837875366,140.39999961853027,28.1499981880188,27.699999809265137,28.599998950958252,28.149998982747395,0.3434486128390396,1.3557950345178444,0.9521491980801026,0.6901051383465528,1.816405061011513,1.1116532453646262,1.1962640223408492,,,,,, +chain-trace,asyncify,chain,10000,1,0,on,1,0,3,3072,8.115234374999753,7.9687500000003295,8.261718749999952,8.11523437500001,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,14.999999999986358,14.999999999986358,14.999999999986358,14.999999999986358,25.000000000034106,25.000000000005684,29.999999999972715,26.666666666670835,350.00000000002274,299.9999999999545,370.00000000000455,339.9999999999939,888.69,879.465,902.915,890.3566666666667,11.52257930211885,11.34104649939363,11.64344345710176,11.50235641953808,6.8359375,6.0546875,8.59375,7.161458333333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.09499979019165,4.0899999141693115,4.110000133514404,4.098333279291789,68.80000114440918,68.65000009536743,71.50000095367432,69.65000073115031,143.35000038146973,141.94999933242798,151.95000171661377,145.75000047683716,28.19999933242798,27.999999523162842,28.399999141693115,28.19999933242798,0.36298852413898614,1.5852863434702158,0.818685395643115,0.7242830470204353,2.2460924616704383,1.0628253997613986,1.3150732032954222,,,,,, +chain-trace,jspi,chain,1,1,0,on,1,0,3,3072,5.131835937499981,5.07812500000003,5.151367187500034,5.120442708333348,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,14.999999999986358,15.000000000000568,14.999999999995831,234.99999999999943,230.00000000000398,239.99999999999488,234.99999999999943,5.474999999999994,5.445000000000007,5.515000000000001,5.478333333333334,0.18721461187214633,0.18585675430643697,0.18824609733700617,0.18710582117186317,21.484375,20.1171875,21.58203125,21.061197916666668,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3000001907348633,2.0999999046325684,2.430000066757202,2.2766667207082114,71.00000143051147,68.70000123977661,73.25000047683716,70.98333438237508,117.14999914169312,115.9500002861023,119.34999942779541,117.4833329518636,27.850000858306885,27.849998474121094,28.19999933242798,27.966666221618652,0.24904296112555438,1.0563150669137638,0.7405596940467755,0.5094395795216163,1.246746319035689,1.0546866493920486,0.2636524382979011,,,,,, +chain-trace,jspi,chain,10,1,0,on,1,0,3,3072,5.229492187500032,5.224609375000008,5.356445312499944,5.270182291666662,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,13.333333333335418,230.00000000000398,230.00000000000398,254.99999999999545,238.33333333333448,6.045000000000002,5.904999999999987,6.064999999999998,6.0049999999999955,1.6941273779983452,1.6885408079142628,1.7342929720575821,1.7056537193233967,18.84765625,18.359375,19.3359375,18.84765625,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.434999942779541,2.180000066757202,2.505000114440918,2.3733333746592202,68.80000114440918,66.84999942779541,71.44999980926514,69.03333346048991,114.80000019073486,113.4500002861023,119.0499997138977,115.76666673024495,27.800002098083496,27.799999713897705,28.250000476837158,27.950000762939453,0.29947712396576065,1.158855389803648,0.815430578465263,0.5371089403827985,1.1783847585320473,1.018881021688382,0.262044478828762,,,,,, +chain-trace,jspi,chain,100,1,0,on,1,0,3,3072,5.219726562499916,5.180664062500117,5.283203124999941,5.227864583333325,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,13.333333333335418,245.00000000000455,219.99999999999886,250.0,238.33333333333448,9.075000000000003,9.054999999999993,9.090000000000003,9.073333333333332,11.283856749311292,11.26523652365236,11.308779679734961,11.285957650899539,18.9453125,18.359375,19.04296875,18.782552083333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.424999952316284,2.190000057220459,2.4700000286102295,2.361666679382324,70.65000057220459,67.85000085830688,73.25000047683716,70.58333396911621,117.2000002861023,116.64999961853027,119.60000038146973,117.8166667620341,28.05000066757202,27.799999713897705,28.399999141693115,28.083333174387615,0.24249706727763146,1.0237636355062325,0.8610015890250603,0.5371100269258022,1.2467434474577506,1.0498042684048414,0.26694454873600615,,,,,, +chain-trace,jspi,chain,1000,1,0,on,1,0,3,3072,5.395507812499992,5.351562499999796,5.566406249999795,5.4378255208331945,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,15.000000000000568,15.000000000000568,15.000000000000568,230.00000000000398,225.00000000000853,234.99999999999943,230.00000000000398,37.32499999999999,37.16499999999999,37.425,37.30499999999999,27.434722036168797,27.361416165664664,27.552831965558997,27.44965672246415,18.06640625,17.28515625,18.45703125,17.936197916666668,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.325000047683716,2.1599998474121094,2.440000057220459,2.3083333174387612,70.89999914169312,70.79999923706055,72.65000104904175,71.44999980926514,117.99999952316284,117.35000133514404,118.59999895095825,117.98333326975505,28.000001907348633,27.54999876022339,28.20000171661377,27.916667461395264,0.20347531264024166,1.1865245178341866,0.8170569781213999,0.5631504269937674,1.3720712934931119,1.0074869884798925,0.28806000327059417,,,,,, +chain-trace,jspi,chain,5000,1,0,on,1,0,3,3072,5.600585937500332,5.581054687500461,6.24023437499989,5.807291666666894,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000019327,10.000000000019327,10.000000000019327,10.000000000019327,15.00000000001478,15.00000000001478,20.000000000010232,16.66666666667993,260.0000000000193,240.0000000000091,269.9999999999818,256.6666666666701,161.51,160.6,169.13,163.74666666666667,31.700829669989474,30.272577307396677,31.880454545454548,31.284620507613567,16.9921875,14.74609375,18.65234375,16.796875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.505000114440918,2.2149999141693115,2.674999952316284,2.4649999936421714,71.80000066757202,69.55000162124634,72.1999979019165,71.18333339691162,117.95000076293945,117.85000085830688,120,118.60000054041545,27.799999713897705,27.750000953674316,28.15000057220459,27.90000041325887,0.1888463180513648,1.2955725348244111,0.779622777675589,0.5908207191775242,1.5673825206855934,1.0856122244149446,0.29943457183746747,,,,,, +chain-trace,jspi,chain,10000,1,0,on,1,0,3,3072,6.181640624999887,6.010742187499959,6.269531249999682,6.15397135416651,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000019327,10.000000000019327,10.000000000047748,10.0000000000288,15.000000000043201,15.000000000043201,20.000000000010232,16.666666666698877,305.0000000000068,264.99999999998636,345.0000000000273,305.0000000000068,314.505,313.78,367.13,331.805,32.559103988807806,27.892030071091984,32.6343329721461,31.028489010681962,15.0390625,14.2578125,15.72265625,15.006510416666666,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.384999990463257,2.179999828338623,2.615000009536743,2.3933332761128745,69.75000143051147,67.59999990463257,72.59999990463257,69.98333374659221,119.0499997138977,117.40000009536743,120.99999904632568,119.14999961853027,27.799999713897705,27.649998664855957,28.19999933242798,27.88333257039388,0.35643927132097036,1.367187515522043,0.9065747726708651,0.5940750706940889,1.4990241422007482,1.1409504804760218,0.28972010128177256,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,7,70000,3.92549991607666,3.849999761581421,4.008000087738037,3.929785714830671,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,9.999990463256836,9.999990463256836,9.999990463256836,9.999990463256836,9.999990463256836,9.999990463256836,9.999990463256836,9.999990463256836,265.0001049041748,254.99987602233887,285.0000858306885,269.2857129233224,40.13000011444092,39.38000011444092,41.00500011444092,40.1728572504861,0.24919013136014087,0.2438726977707837,0.2539360073879972,0.24896194494779247,32.88,32.36,34.15,33.004285714285714,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,0,0,0,0,70.89999914169312,67.95000076293945,72.04999923706055,70.37857191903251,,,,,28.19999933242798,27.799999713897705,28.550000190734863,28.20714235305786,,,,,,,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,7,70000,4.8289999723434445,4.77900002002716,4.885000109672546,4.821714210510254,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,9.999990463256836,9.999990463256836,9.999990463256836,9.999990463256836,10.000228881835938,10.000228881835938,10.000228881835938,10.000228881835938,454.9999237060547,445.00017166137695,480.0000190734863,457.8572000776018,49.105000019073486,48.59000015258789,49.75499987602234,49.08928574834551,0.20364524989544394,0.20098482614647029,0.20580366265891856,0.20372223384884416,22.8,22.5,23.36,22.858571428571427,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,0,0,0,0,71.29999876022339,70.2999997138977,71.84999942779541,71.22142825807843,,,,,27.949998378753662,27.650001049041748,28.65000009536743,27.99285752432687,0.21564278943198067,1.075000044277736,0.6972144365310669,0.4723570142473493,1.1878570829119002,1.0169284105300904,0.15671443258013043,,,,,, +no-exceptions,asyncify,chain,1,0,0,off,1,0,3,300000,4.425450000000001,4.37324999999999,4.8842000000000025,4.560966666666665,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,9.999999999990905,9.999999999990905,9.999999999990905,9.999999999990905,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,4250.0,4195.000000000022,39495.00000000001,15980.00000000001,456.205,450.75,501.69000000000005,469.54833333333335,0.2192018938854243,0.19932827044589285,0.2218546866333888,0.21346161698823532,27.831,27.643,28.233,27.902333333333335,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.954999923706055,4.009999990463257,5.044999837875366,4.669999917348226,69.54999923706055,68.19999933242798,70.80000162124634,69.51666673024495,123.59999895095825,121.19999885559082,130.2999997138977,125.0333325068156,27.650001049041748,27.249999046325684,28.09999942779541,27.666666507720947,,,,,,,,18.379204892966367,18.157412935323382,20.38561560341325,4.3108,4.26225,4.7708 +no-exceptions,asyncify,chain,1,0,1,off,1,0,3,300000,0.1397499999999991,0.1358000000000034,0.14054999999999468,0.13869999999999905,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,134.9999999999909,109.99999999999943,140.00000000000057,128.3333333333303,24.61,24.52499999999999,25.125,24.75333333333333,4.06342950020317,3.980139303482587,4.077512742099899,4.040360515261885,97.24,97.22,97.323,97.261,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.829999923706055,4.099999904632568,4.9049999713897705,4.611666599909465,70.39999961853027,67.74999856948853,72.95000076293945,70.36666631698608,122.30000019073486,122.14999914169312,124.49999809265137,122.98333247502644,27.899999618530273,27.700002193450928,28.450000286102295,28.016667366027832,,,,,,,,,,,,, +no-exceptions,asyncify,chain,10,0,0,off,1,0,3,30000,4.578999999999986,4.568500000000034,4.596500000000004,4.581333333333341,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,250.0,245.00000000000455,259.9999999999909,251.66666666666515,50.004999999999995,49.705,50.08,49.93,1.9998200179982004,1.9968250798722045,2.0118901518961874,2.0028450832555307,25.32,25.11,25.33,25.253333333333334,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.090000152587891,4.034999847412109,4.9649999141693115,4.3633333047231035,71.10000133514404,69.84999895095825,71.74999952316284,70.89999993642171,124.50000047683716,123.65000009536743,125,124.38333352406819,28.15000057220459,27.5,28.400001525878906,28.016667366027832,,,,,,,,7.758727695888276,7.600152905198786,7.800623052959499,4.355999999999999,4.3165000000000004,4.366 +no-exceptions,asyncify,chain,10,0,1,off,1,0,3,30000,0.16000000000000797,0.13650000000002507,0.16050000000000467,0.1523333333333459,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,125.0,5.000000000009663,155.00000000000114,95.0000000000036,6.445000000000007,6.420000000000002,6.539999999999992,6.468333333333334,15.516058960434428,15.290672782874637,15.576479750778812,15.461070498029292,97.11,97.05,97.27,97.14333333333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.074999809265137,4.049999952316284,4.884999990463257,4.336666584014893,71.94999933242798,68.70000123977661,72.69999980926514,71.11666679382324,123.90000104904175,123.59999895095825,124.75000143051147,124.08333381017049,28.19999933242798,27.749998569488525,28.299999237060547,28.083332379659016,,,,,,,,,,,,, +no-exceptions,asyncify,chain,100,0,0,off,1,0,3,3072,4.829101562500132,4.794921874999789,4.863281250000018,4.82910156249998,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,174.99999999999716,149.99999999999147,180.00000000000682,168.3333333333318,8.310000000000002,8.280000000000001,8.33999999999999,8.309999999999997,12.322623345367024,12.278297362110328,12.367270531400964,12.322730412959439,24.609375,21.97265625,25.5859375,24.055989583333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.9100000858306885,4.039999961853027,4.945000171661377,4.631666739781697,71.09999895095825,68.65000009536743,72.40000009536743,70.71666638056438,124.24999952316284,123.39999914169312,124.74999904632568,124.13333257039388,28.20000171661377,27.59999990463257,28.550000190734863,28.1166672706604,,,,,,,,1.8512763596004433,1.8026030368763564,1.9255813953488388,3.745117187499994,3.6132812500000027,3.886718750000004 +no-exceptions,asyncify,chain,100,0,1,off,1,0,3,3072,0.14160156249998224,0.10742187499997169,0.19042968749999334,0.14648437499998243,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,4.5049999999999955,4.299999999999997,4.609999999999999,4.471666666666664,22.730521642619337,22.212798264642085,23.814186046511644,22.91916865125769,97.16796875,96.19140625,97.8515625,97.0703125,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.945000171661377,4.819999933242798,5.069999933242798,4.945000012715657,69.7000002861023,69.45000171661377,71.60000085830688,70.25000095367432,124.90000009536743,123.99999856948853,125.20000219345093,124.7000002861023,28.1499981880188,27.59999990463257,28.499999046325684,28.083332379659016,,,,,,,,,,,,, +no-exceptions,asyncify,chain,1000,0,0,off,1,0,3,3072,4.941406249999572,4.892578125000102,5.029296874999853,4.954427083333176,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,13.333333333335418,174.99999999999716,160.0000000000108,179.9999999999926,171.66666666666686,32.685,32.455,33.035,32.725,31.329386568762427,30.997457242318756,31.551409644122632,31.292751151734606,21.6796875,21.38671875,21.77734375,21.614583333333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.055000066757202,4.0350000858306885,4.955000162124634,4.348333438237508,70.05000114440918,69.6500015258789,70.9500002861023,70.21666765213013,121.49999856948853,120.65000057220459,123.65000009536743,121.93333307902019,28.19999933242798,27.850000858306885,28.450000286102295,28.166666825612385,,,,,,,,0.8616053776196125,0.8481641186462825,0.8739417989417989,-5.126953125,-5.673828125000002,-4.653320312500001 +no-exceptions,asyncify,chain,1000,0,1,off,1,0,3,3072,0.12207031249995837,0.11230468749989786,0.1269531249999678,0.12044270833327468,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000004927,37.935,37.8,38.265,38.0,26.993567945169367,26.76077355285509,27.089973544973546,26.94810501433267,97.55859375,97.4609375,97.75390625,97.59114583333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.015000104904175,3.9800000190734863,5.059999942779541,4.351666688919067,71.79999828338623,69.34999942779541,72.14999914169312,71.09999895095825,123.89999866485596,122.35000133514404,126.25,124.16666666666667,27.950000762939453,27.750000953674316,28.19999933242798,27.966667016347248,,,,,,,,,,,,, +no-exceptions,asyncify,chain,5000,0,0,off,1,0,3,3072,4.98535156249981,4.907226562500034,5.083007812500082,4.991861979166642,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,15.000000000000568,15.000000000000568,15.000000000000568,165.00000000000625,165.00000000000625,165.00000000000625,165.00000000000625,139.115,134.38,140.955,138.15,36.80409014125004,36.32365648611259,38.10091531477899,37.07622064738054,22.94921875,22.0703125,24.21875,23.079427083333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.875,3.9800000190734863,4.894999980926514,4.583333333333333,68.30000162124634,67.7999997138977,71.5499997138977,69.21666701634724,122.85000085830688,120.89999914169312,126.80000066757202,123.51666688919067,28.250000476837158,27.950000762939453,28.550000190734863,28.250000476837158,,,,,,,,0.7358246059452026,0.7229395308801377,0.7491429938082964,-48.77441406249999,-50.29296875,-46.093749999999986 +no-exceptions,asyncify,chain,5000,0,1,off,1,0,3,3072,0.1220703125,0.12207031249991673,0.17578125000003442,0.13997395833331705,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,5.000000000023874,5.000000000009663,5.000000000023874,5.000000000019138,188.155,185.88,189.06,187.69833333333332,27.211612766070527,27.081355125357028,27.544657843770175,27.279208578399242,97.55859375,96.484375,97.55859375,97.20052083333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.09499979019165,3.9649999141693115,5.055000066757202,4.371666590372722,70.70000171661377,67.99999952316284,72.65000104904175,70.45000076293945,123.65000009536743,123.15000057220459,125.04999876022339,123.94999980926514,28.15000057220459,27.850000858306885,28.350000381469727,28.1166672706604,,,,,,,,,,,,, +no-exceptions,asyncify,chain,10000,0,0,off,1,0,3,3072,5.473632812500323,5.380859374999964,5.63476562500001,5.4964192708334325,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000019327,10.000000000019327,10.000000000019327,10.000000000019327,19.99999999998181,15.000000000043201,19.99999999999602,18.333333333340345,180.00000000000682,180.00000000000682,210.00000000000796,190.0000000000072,271.815,269.55,274.21,271.85833333333335,37.67268546621783,37.34364538127713,37.98924503802634,37.668525295173765,19.3359375,18.75,20.5078125,19.53125,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.059999942779541,4.015000104904175,4.950000047683716,4.3416666984558105,72.44999885559082,69.7000002861023,72.70000219345093,71.61666711171468,123.65000009536743,123.15000057220459,125.24999856948853,124.01666641235352,28.19999933242798,28.15000057220459,28.70000123977661,28.350000381469727,,,,,,,,0.749645409795033,0.7404789146779994,0.7656182379137523,-87.91015624999999,-93.03222656249999,-81.97753906250004 +no-exceptions,asyncify,chain,10000,0,1,off,1,0,3,3072,0.16113281249993672,0.14648437500004718,0.16601562500008493,0.1578776041666896,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000052296,5.000000000052296,5.000000000052296,5.000000000052296,359.57,358.15500000000003,367.08,361.6016666666667,28.478463164335178,27.895829247030623,28.590975974089428,28.321756128485077,96.77734375,96.6796875,97.0703125,96.84244791666667,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.0899999141693115,4.019999980926514,4.954999923706055,4.354999939600627,69.0499997138977,68.55000019073486,69.85000133514404,69.15000041325887,121.80000066757202,121.60000085830688,126.5500020980835,123.31666787465413,28.05000066757202,27.750000953674316,28.84999990463257,28.21666717529297,,,,,,,,,,,,, +no-exceptions,asyncify,direct,1,0,0,off,1,0,3,30000,4.4290000000000065,4.380999999999981,4.576500000000005,4.462166666666664,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,280.00000000000114,265.00000000000057,284.9999999999966,276.6666666666661,45.5,45.19499999999999,47.290000000000006,45.995,0.21978021978021978,0.21146119687037426,0.22126341409447953,0.21750161024835785,26.99,25.48,27.22,26.563333333333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,3.9850001335144043,3.929999828338623,3.990000009536743,3.9683333237965903,69.34999942779541,67.69999980926514,71.25,69.43333307902019,122.99999952316284,122.5,123.69999885559082,123.06666612625122,28.09999942779541,27.900002002716064,28.299999237060547,28.100000222524006,,,,,,,,,,,,, +no-exceptions,asyncify,direct,1,1,0,off,1,0,3,30000,5.308000000000014,5.308000000000011,5.3144999999999865,5.310166666666671,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,384.9999999999909,364.9999999999949,385.0000000000051,378.3333333333303,54.33,54.245000000000005,54.375,54.31666666666667,0.18406037180195106,0.1839080459770115,0.18434878790671952,0.1841057352285607,18.03,17.71,18.29,18.01,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.0350000858306885,3.9700000286102295,4.9100000858306885,4.305000066757202,69.50000047683716,68.70000123977661,71.29999876022339,69.83333349227905,124.24999952316284,123.04999828338623,125.45000076293945,124.24999952316284,28.15000057220459,27.5,28.399999141693115,28.016666571299236,0.23500955804190796,1.0708333571751913,0.6878330866495769,0.4943335294723511,1.409332799911499,1.0190003633499145,0.39382397206623004,,,,,, +no-exceptions,jspi,chain,1,0,0,off,1,0,3,300000,4.171700000000003,4.167849999999996,4.232099999999989,4.1905499999999964,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,9.999999999990905,9.999999999990905,9.999999999990905,9.999999999990905,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,4269.999999999982,4245.000000000005,4329.999999999984,4281.666666666657,430.76,430.62,436.64,432.67333333333335,0.23215015321756893,0.22902390985709054,0.23222562816404255,0.23113323041290068,30.963,30.323,31.096,30.794,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.174999952316284,2.1550002098083496,2.2149999141693115,2.181666692097982,70.59999942779541,69.90000009536743,71.49999856948853,70.66666603088379,118.1000018119812,116.39999866485596,118.35000038146973,117.61666695276897,27.850000858306885,27.699999809265137,27.999999523162842,27.85000006357829,,,,,,,,17.36935483870968,17.20415501398322,17.95394736842105,4.0596,4.0559,4.1232 +no-exceptions,jspi,chain,1,0,1,off,1,0,3,300000,0.1348500000000024,0.13474999999999626,0.1350499999999984,0.13488333333333236,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,15.000000000000568,15.000000000000568,134.9999999999909,54.99999999999735,24.799999999999997,24.32,25.03,24.716666666666665,4.032298387096775,3.9952457051538155,4.11188322368421,4.046475771978267,97.309,97.303,97.346,97.31933333333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.375,2.194999933242798,2.4200000762939453,2.3300000031789145,71.19999885559082,70.44999837875366,71.84999942779541,71.16666555404663,116.94999933242798,116.20000123977661,119.94999885559082,117.69999980926514,28.15000057220459,28.05000066757202,28.350000381469727,28.18333387374878,,,,,,,,,,,,, +no-exceptions,jspi,chain,10,0,0,off,1,0,3,30000,4.167500000000021,4.113000000000007,4.2264999999999855,4.169000000000004,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,269.999999999996,269.999999999996,280.00000000000114,273.33333333333104,45.78,45.620000000000005,46.599999999999994,46.0,2.1843818261249455,2.145944206008584,2.1920429636124505,2.174122998581993,30.49,29.48,30.68,30.216666666666665,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4549999237060547,2.1649999618530273,2.5400002002716064,2.386666695276896,70.09999990463257,69.6500015258789,70.79999923706055,70.18333355585735,117.10000038146973,116.25,118.55000019073486,117.30000019073486,27.899999618530273,27.899999618530273,28.499999046325684,28.09999942779541,,,,,,,,8.62164662349677,8.34639927073838,8.789980732177268,4.043000000000001,4.0295,4.1195 +no-exceptions,jspi,chain,10,0,1,off,1,0,3,30000,0.13949999999998824,0.1365000000000066,0.1410000000000018,0.13899999999999887,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000002558,4.999999999997821,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,5.404999999999994,5.189999999999998,5.484999999999999,5.359999999999997,18.501572617946366,18.231722880583412,19.268015414258198,18.667103637595993,97.21,97.18,97.27,97.22,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3350000381469727,2.2049999237060547,2.434999942779541,2.324999968210856,70.59999942779541,67.74999856948853,70.85000038146973,69.73333279291789,116.15000009536743,114.34999942779541,117.94999837875366,116.14999930063884,28.19999933242798,28.05000066757202,28.249998092651367,28.16666603088379,,,,,,,,,,,,, +no-exceptions,jspi,chain,100,0,0,off,1,0,3,3072,4.340820312500076,4.077148437499817,4.501953124999972,4.306640624999955,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,170.0000000000017,45.000000000001705,194.99999999999318,136.66666666666552,7.7250000000000085,7.594999999999999,8.170000000000002,7.830000000000003,13.255792880258884,12.53378212974296,13.482685977616855,13.090753662539566,28.3203125,27.44140625,29.8828125,28.548177083333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4200000762939453,2.319999933242798,2.565000057220459,2.435000022252401,69.29999828338623,68.50000143051147,71.25,69.6833332379659,118.39999914169312,115.89999914169312,118.4499979019165,117.58333206176758,28.05000066757202,27.899999618530273,28.15000057220459,28.033333619435627,,,,,,,,2.220760233918132,2.157821229050283,2.330955777460774,4.077148437500004,4.04785156250001,4.555664062500006 +no-exceptions,jspi,chain,100,0,1,off,1,0,3,3072,0.14648437499996392,0.14160156249995448,0.16601562499996003,0.15136718749995948,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,3.5049999999999955,3.4199999999999946,3.5799999999999983,3.501666666666663,29.215691868758952,28.60363128491621,29.941812865497123,29.253712006390764,97.0703125,96.6796875,97.16796875,96.97265625,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2249999046325684,2.2149999141693115,2.384999990463257,2.2749999364217124,69.85000133514404,69.54999923706055,72.10000038146973,70.50000031789143,116.90000057220459,116.8500018119812,119.14999961853027,117.63333400090535,28.600001335144043,28.19999933242798,28.65000009536743,28.483333587646484,,,,,,,,,,,,, +no-exceptions,jspi,chain,1000,0,0,off,1,0,3,3072,4.438476562499627,4.277343750000079,4.482421875000531,4.399414062500079,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,11.666666666670267,195.0000000000074,190.00000000001194,225.00000000000853,203.3333333333426,31.97500000000001,31.654999999999994,32.870000000000005,32.16666666666667,32.02505082095386,31.153057499239424,32.348791660085304,31.842299993426195,27.9296875,27.83203125,30.17578125,28.645833333333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.305000066757202,2.1700000762939453,2.365000009536743,2.2800000508626304,69.75000143051147,69.0999984741211,71.69999837875366,70.18333276112874,118.84999990463257,117.00000047683716,120.35000085830688,118.73333374659221,28.15000057220459,27.55000114440918,28.499999046325684,28.066666920979817,,,,,,,,1.1836017027577272,1.1159880133967919,1.2133628645256553,4.843750000000001,3.212890624999999,5.644531250000001 +no-exceptions,jspi,chain,1000,0,1,off,1,0,3,3072,0.11230468750005052,0.09277343749998501,0.13183593750003275,0.11230468750002276,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000004927,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,27.090000000000003,27.015000000000008,28.364999999999995,27.490000000000002,37.79996308600959,36.100863740525305,37.904904682583734,37.26857716970621,97.75390625,97.36328125,98.14453125,97.75390625,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.25,2.1649999618530273,2.3550000190734863,2.256666660308838,70.79999923706055,70.49999952316284,71.45000219345093,70.9166669845581,116.00000143051147,115.39999961853027,116.64999961853027,116.01666688919067,28.05000066757202,27.950000762939453,28.550000190734863,28.18333387374878,,,,,,,,,,,,, +no-exceptions,jspi,chain,5000,0,0,off,1,0,3,3072,4.643554687500148,4.624023437500069,4.750976562499912,4.6728515625000435,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,15.000000000000568,15.00000000001478,15.000000000005306,200.00000000001705,190.00000000002615,210.00000000000796,200.00000000001705,140.44,137.66,140.715,139.605,36.456857020791794,36.385609210105535,37.19309167514165,36.678519302012994,26.66015625,25.390625,27.5390625,26.529947916666668,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.180000066757202,2.1499998569488525,2.375,2.234999974568685,69.80000019073486,67.14999914169312,73.05000066757202,70.0,117.59999990463257,116.50000095367432,117.74999856948853,117.28333314259847,27.950000762939453,27.749998569488525,28.550000190734863,28.083333174387615,,,,,,,,1.0419474268789337,1.0288490284005978,1.0677006120044097,5.532226562499992,3.769531249999986,8.696289062500028 +no-exceptions,jspi,chain,5000,0,1,off,1,0,3,3072,0.12207031249997224,0.11230468750000888,0.19042968750006273,0.14160156250001463,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,5.000000000023874,5.000000000023874,5.000000000023874,5.000000000023874,133.8,131.53499999999997,135.05,133.46166666666667,38.26607623318385,37.911891891891884,38.92500855285666,38.36765889264413,97.55859375,96.19140625,97.75390625,97.16796875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.6449999809265137,2.2799999713897705,2.7099997997283936,2.544999917348226,70.59999942779541,69.10000085830688,71.25,70.3166667620341,117.75000095367432,115.05000114440918,118.80000114440918,117.20000108083089,27.899999618530273,27.649998664855957,28.64999771118164,28.066665331522625,,,,,,,,,,,,, +no-exceptions,jspi,chain,10000,0,0,off,1,0,3,3072,5.239257812499412,4.892578124999644,5.312499999999804,5.148111979166287,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000019327,10.000000000009853,15.00000000001478,15.000000000000568,19.99999999998181,16.66666666666572,235.00000000001364,204.99999999998408,305.0000000000068,248.33333333333485,277.995,273.09499999999997,282.79499999999996,277.96166666666664,36.83519847479271,36.209978960024046,37.49611307420495,36.84709683634057,24.0234375,20.41015625,25.5859375,23.33984375,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3550000190734863,2.174999952316284,2.5950000286102295,2.375,68.70000123977661,68.15000057220459,69.25000190734863,68.70000123977661,118.05000066757202,117.05000162124634,119.64999914169312,118.25000047683716,28.15000057220459,27.59999990463257,28.349997997283936,28.03333282470703,,,,,,,,1.024601003605007,1.0095373639169731,1.0278029392735002,6.6308593749999645,2.5195312499999845,7.343749999999982 +no-exceptions,jspi,chain,10000,0,1,off,1,0,3,3072,0.13671874999994504,0.10742187499994393,0.14648437499999167,0.13020833333329354,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000023874,5.000000000023874,5.000000000052296,5.000000000033348,270.515,270.475,276.005,272.33166666666665,37.85372715006562,37.10078078295683,37.859325261114705,37.60461106471239,97.265625,97.0703125,97.8515625,97.39583333333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.450000047683716,2.43999981880188,2.565000057220459,2.484999974568685,68.65000009536743,68.05000066757202,70.9499979019165,69.21666622161865,117.85000085830688,116.70000076293945,118.99999856948853,117.85000006357829,28.449997901916504,28.250000476837158,28.550000190734863,28.41666618982951,,,,,,,,,,,,, +no-exceptions,jspi,direct,1,0,0,off,1,0,3,30000,4.028000000000001,3.990500000000007,4.0749999999999975,4.031166666666668,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,260.0000000000051,260.0000000000051,275.0000000000057,265.0000000000053,41.37,41.105000000000004,42.2,41.55833333333334,0.24172105390379503,0.23696682464454974,0.24327940639824838,0.24065576164886437,31.64,31.46,32.77,31.956666666666667,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.494999885559082,2.4549999237060547,2.5299999713897705,2.4933332602183023,68.94999980926514,68.84999990463257,68.99999856948853,68.93333276112874,118.05000066757202,117.89999961853027,119.0499997138977,118.33333333333333,27.999999523162842,27.749998569488525,28.299999237060547,28.016665776570637,,,,,,,,,,,,, +no-exceptions,jspi,direct,1,1,0,off,1,0,3,30000,4.920500000000006,4.796500000000012,4.95350000000001,4.890166666666676,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,379.99999999999545,370.00000000000455,400.0000000000057,383.33333333333525,50.54,49.15500000000001,50.79,50.16166666666667,0.19786307874950534,0.19688915140775742,0.2034381039568711,0.19939677803804462,21.42,21.04,22.52,21.66,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3399999141693115,2.1700000762939453,2.359999895095825,2.2899999618530273,68.94999980926514,67.14999914169312,71.49999856948853,69.19999917348225,118.35000038146973,115.75000047683716,118.99999856948853,117.69999980926514,27.850000858306885,27.799999713897705,27.999999523162842,27.88333336512248,0.20944915771482944,1.0919998645782472,0.6698334058125813,0.494500199953715,1.2021662791570027,1.011333378156026,0.2108843812942742,,,,,, +ordinary-page,asyncify,direct,1,0,0,on,0,0,3,30000,4.73,4.669999999999999,4.759999999999997,4.719999999999999,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,100.00000000000853,100.00000000000853,100.00000000000853,100.00000000000853,299.99999999999716,299.99999999999716,299.99999999999716,299.99999999999716,48.599999999999994,48.199999999999996,48.900000000000006,48.56666666666666,0.20576131687242802,0.20449897750511245,0.20746887966804983,0.20590972468186344,95.34,95.32,95.4,95.35333333333334,99.99990463256836,99.99990463256836,99.99990463256836,99.99990463256836,4.099999904632568,4.099999904632568,4.099999904632568,4.099999904632568,70.99999904632568,68.00000190734863,70.99999904632568,70.0,140.99999904632568,138.99999856948853,141.00000143051147,140.3333330154419,28.000001907348633,26.999998092651367,29.000000953674316,28.000000317891438,,,,,,,,,,,,, +ordinary-page,asyncify,direct,1,1,0,on,0,0,3,30000,5.559999999999997,5.49,5.62,5.556666666666666,0,0.0,0.0,0.0,99.99999999999432,99.99999999999432,99.99999999999432,99.99999999999432,100.00000000000853,100.00000000000853,100.00000000000853,100.00000000000853,400.0000000000057,399.9999999999915,400.0000000000057,400.00000000000097,56.7,56.300000000000004,57.099999999999994,56.7,0.1763668430335097,0.17513134851138354,0.17761989342806392,0.1763726949909857,94.6,94.52,94.64,94.58666666666666,99.99990463256836,99.99990463256836,99.99990463256836,99.99990463256836,5,4.1000001430511475,5.099999904632568,4.733333349227905,69.00000095367432,68.99999856948853,70.99999904632568,69.66666618982951,135,134.00000095367432,136.00000143051147,135.0000007947286,27.999999523162842,27.999999523162842,27.999999523162842,27.999999523162842,0.20330028851831017,1.1666666587193808,0.6833333412806193,0.48000006675720214,1.5666666746139526,1.023333239555359,0.43336639722184195,,,,,, +ordinary-page,jspi,direct,1,0,0,on,0,0,3,30000,4.030000000000003,4.029999999999999,4.049999999999995,4.036666666666666,0.0,0,0,0.0,0.0,0.0,0.0,0.0,100.00000000000142,100.00000000000142,100.00000000000142,100.00000000000142,299.99999999999716,299.99999999999716,300.00000000001137,300.0000000000019,41.7,41.50000000000001,42.300000000000004,41.833333333333336,0.2398081534772182,0.23640661938534277,0.2409638554216867,0.2390595427614159,96.04,96.04,96.05,96.04333333333334,99.99990463256836,99.99990463256836,99.99990463256836,99.99990463256836,2.299999952316284,2.200000047683716,2.5,2.3333333333333335,70.99999904632568,70,72.99999952316284,71.33333285649617,112.00000047683716,111.00000143051147,113.00000190734863,112.00000127156575,27.999999523162842,27.000000476837158,29.000000953674316,28.000000317891438,,,,,,,,,,,,, +ordinary-page,jspi,direct,1,1,0,on,0,0,3,30000,4.830000000000002,4.790000000000001,4.890000000000001,4.836666666666668,0.0,0.0,0.0,0.0,0.0,0,0,0.0,100.00000000000142,100.00000000000142,100.00000000000142,100.00000000000142,400.0000000000057,399.9999999999915,400.0000000000057,400.00000000000097,49.6,49.599999999999994,49.7,49.63333333333333,0.20161290322580644,0.20120724346076457,0.20161290322580647,0.20147768330412583,95.3,95.22,95.32,95.28,99.99990463256836,99.99990463256836,99.99990463256836,99.99990463256836,2.6000001430511475,2.299999952316284,2.700000047683716,2.5333333810170493,70,67.00000047683716,70.99999904632568,69.33333317438762,111.99999809265137,110.99999904632568,112.00000047683716,111.66666587193806,29.000000953674316,26.999998092651367,30,28.666666348775227,0.20334917545317618,1.0199999968210856,0.6333333412806192,0.4133333444595337,1.3300000588099163,1.0399999698003133,0.19665078004202363,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,7,700000,4.849999999999997,4.831200000000004,5.320599999999979,4.927699999999996,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,9.999999999990905,9.999999999990905,9.999999999990905,9.999999999990905,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,4425.000000000011,3939.9999999999977,39720.00000000003,9399.285714285721,499.33000000000004,497.385,546.24,506.89714285714285,0.20027036228546252,0.18307154364381956,0.20105350985654977,0.1974742532152993,22.624,21.601,22.721,22.387285714285714,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.930000066757202,4.115000009536743,4.980000019073486,4.705000025885446,70.09999990463257,67.55000114440918,72.45000123977661,70.1142862864903,141.39999866485596,140.79999923706055,145.75000047683716,142.21428564616613,28.05000066757202,27.650001049041748,28.350000381469727,28.02142892565046,,,,,,,,14.49433962264151,14.290091638029782,16.19688658265382,4.6488000000000005,4.62825,5.12515 +primary,asyncify,chain,1,0,1,on,1,0,7,700000,0.21849999999999808,0.20955000000000126,0.22399999999999964,0.21865000000000023,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,140.00000000000057,19.99999999999602,150.00000000000568,105.71428571428295,34.45,33.36500000000001,34.92,34.20857142857143,2.9027866473149486,2.8637170675830466,2.997182676457365,2.923921579938907,95.655,95.567,95.816,95.67071428571428,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.119999885559082,4.039999961853027,5.019999980926514,4.339999948229108,69.3999981880188,67.40000009536743,72.75000095367432,69.585713999612,143.59999895095825,137.69999980926514,150.55000066757202,143.192857333592,28.1000018119812,27.849998474121094,28.599998950958252,28.23571409497942,,,,,,,,,,,,, +primary,asyncify,chain,10,0,0,on,1,0,7,70000,4.980500000000045,4.835500000000006,5.025500000000006,4.944642857142863,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000019327,10.000000000019327,10.000000000019327,10.000000000019327,245.00000000000455,240.0000000000091,275.0000000000057,252.14285714285924,61.30000000000001,59.250000000000014,61.44500000000001,60.80428571428572,1.6313376835236537,1.627487997396045,1.6877805907172991,1.6448877050463937,21.01,20.57,22.2,21.124285714285715,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.045000076293945,3.995000123977661,5.055000066757202,4.188571487154279,71.8500018119812,69.19999837875366,73.25000047683716,71.52142831257412,141.09999895095825,136.8999981880188,145.0499987602234,141.00714240755354,27.999999523162842,27.799999713897705,28.69999885559082,28.114285469055176,,,,,,,,4.674400912894634,4.57705677867903,4.923952826352176,4.82,4.630500000000002,4.848000000000001 +primary,asyncify,chain,10,0,1,on,1,0,7,70000,0.24699999999998568,0.22399999999998385,0.25099999999999767,0.24257142857142455,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,20.000000000010232,9.999999999990905,140.00000000000057,68.57142857143117,13.049999999999997,12.295000000000002,13.225000000000009,12.945714285714288,7.662911877394637,7.561512287334589,8.133468889792598,7.728611954042006,95.32,95.01,95.53,95.28857142857143,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.169999837875366,4.055000066757202,5.015000104904175,4.484285729272025,70.9500002861023,67.85000085830688,72.2000002861023,70.54999998637608,141.64999961853027,140.19999980926514,145.39999961853027,141.85714278902327,28.250000476837158,27.750000953674316,28.350000381469727,28.10000044958932,,,,,,,,,,,,, +primary,asyncify,chain,100,0,0,on,1,0,7,7168,5.4541015625001465,5.336914062500378,5.517578125000047,5.433872767857227,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,14.285714285715503,155.00000000000114,150.00000000000568,180.00000000000682,159.2857142857176,15.86,15.594999999999999,16.28,15.868571428571427,6.456557377049181,6.289987714987714,6.566271240782303,6.454282377731332,18.75,16.9921875,20.01953125,18.498883928571427,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.109999895095825,4.075000047683716,5.039999961853027,4.483571427209037,71.25,67.69999980926514,72.44999885559082,70.8071425982884,140.54999828338623,137.89999961853027,142.8499984741211,140.03571374075753,28.05000066757202,27.649998664855957,29.650001525878906,28.321428639548166,,,,,,,,1.4281135531135527,1.3943724877177301,1.5030732860520086,4.721679687499994,4.311523437499992,5.195312499999993 +primary,asyncify,chain,100,0,1,on,1,0,7,7168,0.214843749999985,0.18554687500001166,0.23925781250000444,0.21693638392856643,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000007633,5.000000000009663,5.000000000009663,19.99999999999602,7.142857142864857,10.989999999999995,10.575000000000003,11.445000000000007,11.029285714285717,9.317652411282989,8.947225862822188,9.683309692671392,9.289289544057237,95.703125,95.21484375,96.2890625,95.703125,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.8999998569488525,4.015000104904175,4.990000009536743,4.680714300700596,69.34999942779541,68.30000162124634,70.89999914169312,69.34285742895943,142.2000002861023,136.94999933242798,145.9500002861023,141.7214288030352,27.899999618530273,27.649998664855957,28.65000009536743,27.957142761775426,,,,,,,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,7,7168,5.732421874999824,5.605468749999856,5.903320312499918,5.743582589285528,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000019327,10.000000000007146,15.00000000001478,15.000000000000568,19.99999999999602,17.142857142857792,159.9999999999966,144.99999999999602,195.0000000000074,164.2857142857151,93.58000000000001,91.3,95.61000000000001,93.54642857142858,10.942519769181448,10.710187218910153,11.215783132530122,10.949250047472058,16.50390625,14.35546875,18.26171875,16.015625,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.105000019073486,3.984999895095825,5.025000095367432,4.425000020435879,70.04999876022339,67.05000162124634,72.95000076293945,70.24285725184849,139.9500012397766,135.6500005722046,143.7999987602234,139.81428623199463,27.999999523162842,27.799999713897705,28.09999942779541,27.964285441807338,,,,,,,,1.0528748590755355,1.0188026558053895,1.0895726495726497,4.580078124999998,1.6455078124999885,7.675781250000013 +primary,asyncify,chain,1000,0,1,on,1,0,7,7168,0.24414062499998612,0.20019531249997058,0.2685546875001027,0.23716517857144284,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,1.4285714285701292,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000007633,5.000000000023874,5.000000000023874,5.000000000023874,5.000000000023874,88.70000000000002,86.11,90.255,88.62,11.544543404735059,11.345642900670324,11.89177795842527,11.557469931774694,95.1171875,94.62890625,95.99609375,95.25669642857143,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.115000009536743,4.0350000858306885,4.995000123977661,4.230000087193081,69.50000047683716,68.49999904632568,71.64999961853027,69.5928566796439,142.59999990463257,138.25000047683716,149.60000038146973,142.7214285305568,27.950000762939453,27.650001049041748,28.70000123977661,28.10000044958932,,,,,,,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,7,7168,6.401367187499493,5.986328125000134,6.777343749999873,6.38602120535687,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000047748,10.000000000019327,14.999999999986358,10.714285714320633,20.000000000010232,19.99999999999602,24.999999999991473,21.42857142857224,185.00000000000227,160.000000000025,194.99999999999318,184.2857142857172,446.52500000000003,436.28499999999997,451.11499999999995,445.335,11.466325513689043,11.349658069450141,11.735450450966686,11.498815720644803,12.79296875,11.328125,15.8203125,13.462611607142858,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.889999866485596,4.079999923706055,4.990000009536743,4.597142832619803,68.94999980926514,67.7999997138977,72.04999923706055,69.37142848968506,141.94999933242798,138.25000047683716,148.94999980926514,142.74999959128243,28.20000171661377,27.699999809265137,30.400002002716064,28.41428620474679,,,,,,,,0.9948505899217112,0.9578567128236002,1.0479784936138243,-2.280273437500091,-18.798828125,19.956054687500057 +primary,asyncify,chain,5000,0,1,on,1,0,7,7168,0.25390624999996336,0.16601562500007105,0.292968750000025,0.23507254464287727,0.0,0.0,0.0,0.0,4.9999999999954525,0.0,4.9999999999954525,2.8571428571402584,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000052296,5.000000000052296,10.000000000047748,6.428571428614305,449.94999999999993,425.91999999999996,456.775,446.58714285714285,11.379044338259808,11.209021947348258,12.021039162283998,11.47096058855468,94.921875,94.140625,96.6796875,95.32645089285714,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.099999904632568,3.990000009536743,4.115000009536743,4.079285757882254,72.30000019073486,67.59999990463257,72.75000095367432,71.51428529194423,141.5499997138977,136.99999809265137,142.64999866485596,140.66428559167045,28.04999828338623,27.849998474121094,28.450000286102295,28.135713509150914,,,,,,,,,,,,, +primary,asyncify,chain,10000,0,0,on,1,0,7,7168,6.928710937499291,6.538085937499841,7.1386718749984475,6.8952287946425255,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000047748,10.000000000047748,14.999999999986358,11.428571428609757,20.000000000095497,19.99999999999602,25.000000000005684,22.142857142867456,230.0000000000182,204.99999999998408,299.9999999999545,251.42857142855388,887.9849999999999,849.33,1112.595,914.0814285714285,11.531727450351076,9.203709346168193,12.056563408804585,11.287259332977705,11.328125,10.25390625,13.28125,11.495535714285714,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.170000076293945,4.055000066757202,5.020000219345093,4.378571476255145,71.19999885559082,68.49999904632568,73.15000057220459,70.91428518295288,139.90000009536743,137.05000162124634,141.94999933242798,140.1142862864903,28.350000381469727,27.55000114440918,29.100000858306885,28.350000040871755,,,,,,,,1.016751492806476,0.9087193533373634,1.225817646961609,14.287109374999885,-83.31542968749994,200.15625000000003 +primary,asyncify,chain,10000,0,1,on,1,0,7,7168,0.21972656249993894,0.18066406250004385,0.2441406249999306,0.21763392857139321,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000109139,5.000000000052296,14.999999999986358,7.857142857200675,896.74,873.355,934.645,899.0264285714286,11.419141557196067,10.956032504319822,11.724901099781874,11.398163302406527,95.60546875,95.1171875,96.38671875,95.703125,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.954999923706055,4.120000123977661,5.090000152587891,4.770714317049299,70.45000076293945,68.15000057220459,72.54999876022339,70.37857157843453,140.79999923706055,139.50000047683716,142.7999997138977,141.0285714694432,28.000001907348633,27.950000762939453,28.299999237060547,28.05000032697405,,,,,,,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,7,700000,0.11395000000000025,0.10944999999999752,0.11575000000000472,0.11278571428571407,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,34.99999999999659,10.000000000005116,45.000000000001705,31.428571428571267,23.015,22.325000000000003,23.385000000000005,22.944285714285716,4.344992396263306,4.276245456489201,4.479283314669652,4.359676662868472,97.738,97.7,97.819,97.75500000000001,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.125,4.0249998569488525,4.889999866485596,4.225714240755353,69.60000038146973,67.89999961853027,72.40000009536743,69.80714321136475,142.5499987602234,140.09999990463257,146.9000005722046,143.50714308874947,28.15000057220459,27.850000858306885,28.899998664855957,28.235714435577393,,,,,,,,,,,,, +primary,asyncify,direct,1,0,0,on,1,0,7,70000,4.7364999999999835,4.585499999999996,4.937499999999988,4.748999999999999,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,14.999999999986358,10.71428571428815,255.00000000000966,230.00000000000398,805.0000000000068,330.00000000000233,48.735000000000014,47.215,51.06999999999999,48.95857142857143,0.2051913409254129,0.19580967299784613,0.2117970983797522,0.20436768687883689,23.13,22.09,24.97,23.228571428571428,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.120000123977661,4.0299999713897705,4.549999952316284,4.177142824445452,71.50000095367432,66.50000095367432,73.35000038146973,70.75000047683716,141.74999952316284,138.89999866485596,147.99999952316284,142.1428564616612,28.19999933242798,27.849998474121094,28.450000286102295,28.12142848968506,,,,,,,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,7,70000,5.567500000000001,5.5270000000000055,5.708500000000012,5.591357142857148,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,12.857142857145375,390.00000000000057,375.0,420.0000000000017,391.4285714285707,57.11,56.39,58.52499999999999,57.302142857142854,0.17510068289266328,0.1708671507902606,0.17733640716439084,0.17453352744715847,15.43,14.8,16.29,15.505714285714285,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.125,4.0899999141693115,4.169999837875366,4.130714212145124,70.75000047683716,69.80000019073486,72.74999856948853,71.07857125146049,143.05000066757202,139.0499997138977,145.80000162124634,142.34999997275216,28.15000057220459,28.09999942779541,29.149999618530273,28.421428544180735,0.26381318092346523,1.1185713461467197,0.6977143594196864,0.5007857050214495,1.5185715300696236,1.0248572179249356,0.4670438033512677,,,,,, +primary,asyncify,sync,1,0,0,on,1,0,7,700000,0.13539999999999877,0.13099999999999923,0.1365000000000019,0.1343642857142851,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,159.9999999999966,149.99999999999147,174.99999999999716,161.4285714285708,24.88499999999999,24.52000000000001,25.394999999999996,24.892142857142858,4.0184850311432605,3.9377830281551494,4.078303425774876,4.01789584866913,97.358,97.323,97.422,97.36471428571429,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.2099997997283936,4.034999847412109,5.205000162124634,4.497857093811035,70.54999828338623,67.59999990463257,71.74999952316284,69.64999914169312,140.5999994277954,137.24999904632568,142.8000020980835,140.06428582327706,28.09999942779541,27.750000953674316,28.450000286102295,28.12142883028303,,,,,,,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,7,700000,4.183950000000005,4.171800000000004,4.216200000000001,4.186850000000001,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,9.999999999990905,9.999999999990905,9.999999999990905,9.999999999990905,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,4324.999999999989,4169.999999999987,5009.999999999991,4383.571428571421,431.485,430.69500000000005,434.955,432.15357142857147,0.2317600843598271,0.22991114023289766,0.2321851890548996,0.23140401780774894,30.982,30.378,31.117,30.841857142857144,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4549999237060547,2.234999895095825,2.680000066757202,2.445714235305786,68.39999914169312,67.5,73.94999980926514,69.99285697937012,116.15000009536743,115.39999961853027,120.55000066757202,116.61428553717477,27.950000762939453,27.55000114440918,28.399999141693115,28.028571605682373,,,,,,,,17.28999400838825,16.666859903381642,17.7092140365278,4.0712,4.049550000000001,4.0985 +primary,jspi,chain,1,0,1,on,1,0,7,700000,0.14185000000000159,0.134049999999999,0.14330000000000012,0.14018571428571444,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,90.00000000000341,19.99999999999602,144.99999999999602,93.57142857142671,25.10499999999999,24.36500000000001,25.875,25.250714285714285,3.983310097590123,3.8647729468599032,4.1042889390519175,3.9619376380818303,97.195,97.162,97.343,97.22271428571429,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2750000953674316,2.1599998474121094,2.4600000381469727,2.307142870766776,69.24999952316284,67.30000019073486,69.84999895095825,68.97142853055682,116.80000066757202,114.75000143051147,120.80000162124634,117.8285721370152,27.899999618530273,27.59999990463257,28.75,27.97142846243722,,,,,,,,,,,,, +primary,jspi,chain,10,0,0,on,1,0,7,70000,4.149500000000027,4.079499999999964,4.230000000000037,4.151642857142854,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,274.9999999999915,254.99999999999545,304.9999999999926,274.2857142857125,46.69,45.545,47.349999999999994,46.5,2.141807667594774,2.1119535374868006,2.195652651224064,2.150932555367389,30.49,29.38,31.29,30.38285714285714,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2149999141693115,2.109999895095825,2.5249998569488525,2.257857084274292,70.09999990463257,67.40000009536743,72.59999990463257,69.79285717010498,116.40000104904175,115.2999997138977,120.59999942779541,117.18571424484253,28.1000018119812,27.799999713897705,28.65000009536743,28.12857219151088,,,,,,,,7.676935886761037,7.585950413223145,8.039383561643831,4.0555,3.970999999999999,4.125499999999999 +primary,jspi,chain,10,0,1,on,1,0,7,70000,0.14350000000000165,0.12699999999999106,0.15099999999999766,0.14285714285714407,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,4.999999999997483,5.000000000009663,5.000000000009663,15.000000000000568,7.857142857149922,6.049999999999997,5.835000000000008,6.134999999999991,6.011428571428569,16.529090909090915,16.300081499592526,17.138131962296463,16.64154382686012,97.13,96.99,97.46,97.15,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2649998664855957,2.200000047683716,2.455000162124634,2.291428600038801,70.19999980926514,68.65000009536743,71.05000019073486,70.05000012261527,117.64999866485596,116.39999866485596,117.99999952316284,117.39999941417149,28.249998092651367,28.05000066757202,28.300001621246338,28.20000035422189,,,,,,,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,7,7168,4.404296875000033,4.37988281250011,4.497070312500198,4.421037946428587,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,190.00000000001194,170.0000000000017,209.99999999999375,190.0000000000018,8.239999999999995,7.905000000000001,8.36,8.19142857142857,12.427305825242726,12.248923444976077,12.953953194180896,12.505464347829854,28.02734375,25.390625,28.61328125,27.608816964285715,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4049999713897705,2.1649999618530273,2.619999885559082,2.4107142857142856,70.49999952316284,67.7999997138977,72.7999997138977,70.65714257104057,116.84999942779541,115.24999856948853,119.24999952316284,117.24285704748971,27.949998378753662,27.699999809265137,28.19999933242798,27.97142812183925,,,,,,,,2.093994778067885,1.8557158712541637,2.2168674698795185,4.125976562499995,3.764648437500004,4.438476562500002 +primary,jspi,chain,100,0,1,on,1,0,7,7168,0.14160156250002387,0.11718750000000444,0.1660156249999878,0.14369419642856365,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,4.999999999999512,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,3.885000000000005,3.7349999999999994,4.5049999999999955,3.9585714285714286,26.358043758043724,22.730521642619337,27.416599732262387,25.954524705012254,97.16796875,96.6796875,97.65625,97.12611607142857,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3350000381469727,2.200000047683716,2.6649999618530273,2.385714360645839,71.5499997138977,67.95000076293945,72.75000095367432,70.4428574017116,116.60000085830688,114.90000009536743,119.85000133514404,116.85714312962124,28.19999933242798,27.799999713897705,28.550000190734863,28.221428394317627,,,,,,,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,7,7168,4.638671874999903,4.3066406249999964,4.731445312500194,4.607282366071368,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,14.285714285715503,189.99999999999773,35.0000000000108,210.00000000000796,172.14285714285893,36.69,35.89000000000001,37.32000000000001,36.61,27.909539384028346,27.438397642014998,28.53165227082752,27.9753098537306,26.07421875,24.4140625,28.515625,26.395089285714285,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4749999046325684,2.1599998474121094,2.684999942779541,2.399285691125052,71.64999961853027,67.1500015258789,72.95000076293945,71.00000074931553,116.40000104904175,115.39999961853027,119.14999961853027,117.03571455819267,27.950000762939453,27.749998569488525,28.250000476837158,28.014285564422607,,,,,,,,1.1459288537549406,1.0975172001196531,1.1944986979166663,4.506835937499995,3.183593750000005,5.834960937499995 +primary,jspi,chain,1000,0,1,on,1,0,7,7168,0.1464843749999778,0.11230468750002276,0.19531249999997502,0.1492745535714415,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000001543,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,32.03,30.720000000000013,33.42999999999999,31.937142857142856,31.970059319388074,30.63119952138798,33.33336588541665,32.08095830292321,97.0703125,96.09375,97.75390625,97.01450892857143,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.1649999618530273,2.0850000381469727,2.615000009536743,2.224285738808768,69.0499997138977,67.14999914169312,72.69999980926514,69.36428546905518,116.79999828338623,114.90000009536743,118.4500002861023,116.71428578240531,27.750000953674316,27.650001049041748,28.15000057220459,27.828571455819265,,,,,,,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,7,7168,4.819335937499655,4.667968750000265,5.249023437499667,4.876534598214089,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000019327,10.000000000007146,15.000000000000568,14.999999999986358,20.000000000010232,16.4285714285707,204.99999999998408,50.00000000001137,259.9999999999909,200.00000000000082,162.07,158.06,164.86,161.42785714285714,31.59129388535818,31.056660196530384,32.392768568897885,31.723151678050662,24.21875,22.16796875,26.07421875,24.260602678571427,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4850001335144043,2.2200000286102295,2.6050000190734863,2.461428608213152,69.80000019073486,67.65000104904175,72.04999923706055,70.2285715511867,118.25000047683716,116.90000057220459,120.35000085830688,118.52857146944318,28.05000066757202,27.699999809265137,28.949999809265137,28.214285714285715,,,,,,,,1.0330496226112094,1.0076822543113066,1.050565556794647,5.02441406250001,1.1767578125000122,7.749023437500002 +primary,jspi,chain,5000,0,1,on,1,0,7,7168,0.15625000000005218,0.14160156249992673,0.19042968750003497,0.16183035714288047,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,4.999999999999512,5.000000000023874,5.000000000009663,5.000000000023874,5.000000000021844,156.855,154.42499999999998,159.75,156.58642857142857,32.64161805489147,32.05008450704226,33.1552598348713,32.70078720128848,96.875,96.19140625,97.16796875,96.76339285714286,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2300000190734863,2.1549999713897705,2.615000009536743,2.3378571442195346,69.80000019073486,68.29999923706055,73.25000047683716,70.13571398598808,117.40000009536743,115.19999980926514,118.49999904632568,117.07142761775425,28.350000381469727,27.699999809265137,28.70000123977661,28.264285836900985,,,,,,,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,7,7168,4.858398437500814,4.7607421874999165,5.170898437499558,4.959542410714363,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,9.999999999990905,10.000000000019327,10.000000000007146,15.000000000000568,14.999999999986358,15.00000000001478,14.999999999998538,235.00000000001364,85.00000000000796,245.00000000000455,210.71428571430116,314.505,307.935,318.725,313.41714285714284,32.559103988807806,32.128013177504116,33.253774335492885,32.676439228276664,23.14453125,21.2890625,25.29296875,23.200334821428573,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2750000953674316,2.1500000953674316,2.5899999141693115,2.320000035422189,71.40000104904175,67.34999895095825,72.05000162124634,70.40714366095406,116.94999933242798,115.9500002861023,117.69999980926514,116.74999952316284,28.05000066757202,27.750000953674316,28.450000286102295,28.035714626312256,,,,,,,,1.0100534654114868,0.8485081057790705,1.034232723326592,2.993164062499998,-54.93652343749994,10.166015624999968 +primary,jspi,chain,10000,0,1,on,1,0,7,7168,0.15136718750002887,0.1269531250000927,0.23437499999995337,0.1660156249999977,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,4.999999999997483,5.000000000052296,5.000000000009663,5.000000000052296,5.0000000000401155,310.035,304.095,371.34,319.96785714285716,33.02853226248649,27.57580923143211,33.6736907874184,32.139484740920864,96.97265625,95.3125,97.4609375,96.6796875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.315000057220459,2.125,2.5250000953674316,2.330000025885446,69.84999895095825,67.14999914169312,72.10000038146973,69.87142835344586,116.25,115.75000047683716,119.60000038146973,116.87857151031494,28.15000057220459,27.899999618530273,28.450000286102295,28.164285591670446,,,,,,,,,,,,, +primary,jspi,clock,1,0,0,on,1,0,7,700000,0.10910000000000317,0.10340000000000145,0.10979999999999883,0.10747142857142945,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,40.00000000000625,15.000000000000568,54.99999999999261,37.85714285714294,21.53,21.019999999999996,21.68,21.457857142857144,4.644681839294009,4.612546125461255,4.757373929590867,4.660784811846449,97.843,97.815,97.948,97.863,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.325000047683716,2.200000047683716,2.444999933242798,2.3107143470219205,70.45000076293945,67.99999952316284,72.35000133514404,70.77857153756278,118.09999942779541,116.44999980926514,120.39999961853027,118.10000010899135,27.999999523162842,27.750000953674316,28.350000381469727,28.028571265084402,,,,,,,,,,,,, +primary,jspi,direct,1,0,0,on,1,0,7,70000,4.062000000000011,3.984500000000002,4.145500000000002,4.074357142857144,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,259.9999999999909,250.0,310.0000000000023,263.5714285714284,41.97,41.065,42.73499999999999,42.02428571428571,0.2382654276864427,0.23400023400023404,0.24351637647631805,0.238003336717656,31.36,29.75,32.63,31.21857142857143,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.330000162124634,2.174999952316284,2.4749999046325684,2.323571409497942,69.64999914169312,68.04999828338623,71.60000085830688,69.80714218957084,118.59999895095825,117.05000162124634,119.80000019073486,118.46428564616612,27.999999523162842,27.749998569488525,28.500001430511475,28.049999986376083,,,,,,,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,7,70000,4.851000000000019,4.763999999999995,4.900499999999997,4.832428571428576,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,379.99999999999545,370.00000000000455,459.99999999999375,392.14285714285575,49.81999999999999,48.985,50.17999999999999,49.59785714285714,0.2007226013649137,0.19928258270227184,0.20414412575278146,0.2016398235116768,22.23,21.29,23.33,22.257142857142856,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.509999990463257,2.1550002098083496,2.690000057220459,2.455000025885446,69.94999885559082,68.79999876022339,71.05000019073486,70.05714246204921,118.1000018119812,116.84999942779541,118.4000015258789,117.778571333204,28.19999933242798,27.999999523162842,28.350000381469727,28.17857129233224,0.2117062109538448,1.058357262611389,0.666214268548148,0.4739284481321062,1.1993572235107421,1.0110713992800031,0.2117937583923421,,,,,, +primary,jspi,sync,1,0,0,on,1,0,7,700000,0.11114999999999597,0.11009999999999934,0.11434999999999995,0.11171428571428499,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,79.9999999999983,74.99999999999574,85.00000000000085,79.9999999999993,21.654999999999994,21.495000000000005,22.525,21.79142857142857,4.617871161394598,4.439511653718091,4.652244708071644,4.590079889112346,97.806,97.758,97.83,97.79785714285714,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3450000286102295,2.115000009536743,2.615000009536743,2.3478571006229947,70.14999866485596,67.5,71.09999895095825,69.82857159205845,117.8499984741211,115.09999990463257,120.05000114440918,117.64999968664986,28.09999942779541,27.749998569488525,31.700000762939453,28.492857388087682,,,,,,,,,,,,, +work-64,asyncify,chain,1,0,0,on,1,64,3,300000,4.862849999999996,4.8150999999999895,4.917199999999983,4.865049999999989,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,9.999999999990905,9.999999999990905,9.999999999990905,9.999999999990905,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,4204.999999999984,4074.9999999999886,4425.000000000011,4234.9999999999945,500.78999999999996,496.08000000000004,505.60999999999996,500.82666666666665,0.199686495337367,0.1977828761298234,0.2015824060635381,0.19968392584357617,22.247,21.957,22.897,22.367,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.109999895095825,4.0899999141693115,5.0350000858306885,4.411666631698608,68.4500002861023,66.94999933242798,71.5499997138977,68.98333311080933,140.69999933242798,140.2999997138977,141.09999895095825,140.69999933242798,27.950000762939453,27.799999713897705,28.999998569488525,28.249999682108562,,,,,,,,14.89781347612673,14.63147028461879,14.938986556359875,4.671749999999999,4.6217500000000005,4.71765 +work-64,asyncify,chain,1,0,1,on,1,64,3,300000,0.21315000000000112,0.211099999999999,0.21470000000000142,0.21298333333333386,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,34.99999999999659,30.000000000001137,115.0000000000091,60.000000000002274,33.845,33.614999999999995,33.905,33.788333333333334,2.954675727581622,2.949446984220616,2.9748921612375434,2.9596716243465937,95.758,95.741,95.797,95.76533333333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,5.109999895095825,5.059999942779541,5.229999780654907,5.133333206176758,72.54999876022339,68.80000114440918,72.7999997138977,71.38333320617676,145,141.2000012397766,145.15000104904175,143.7833340962728,28.450000286102295,27.55000114440918,28.450000286102295,28.15000057220459,,,,,,,,,,,,, +work-64,asyncify,chain,10,0,0,on,1,64,3,30000,5.010499999999946,4.9474999999999785,5.025499999999984,4.994499999999969,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000019327,10.000000000019327,10.000000000019327,10.000000000019327,235.00000000001364,234.99999999999943,240.0000000000091,236.66666666667405,61.730000000000004,61.46499999999999,62.02000000000001,61.73833333333334,1.6199740806739023,1.6123992260561106,1.626958431627756,1.6197772461192563,20.32,19.99,21.19,20.5,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.849999904632568,4.105000019073486,4.9700000286102295,4.641666650772095,72.2000002861023,68.15000057220459,73.04999828338623,71.13333304723103,144.7000002861023,144.14999961853027,145.35000085830688,144.73333358764648,27.950000762939453,27.899999618530273,28.350000381469727,28.066666920979817,,,,,,,,4.822706065318819,4.7702755141637585,4.830203442879499,4.895,4.858,4.916 +work-64,asyncify,chain,10,0,1,on,1,64,3,30000,0.22000000000001307,0.21249999999999858,0.24450000000000216,0.22566666666667126,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,10.000000000005116,5.000000000009663,125.0,46.666666666671595,12.86,12.780000000000001,12.884999999999991,12.841666666666663,7.7761275272161745,7.761039968956156,7.824804381846635,7.7873239593396555,95.6,95.35,95.77,95.57333333333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.120000123977661,4.099999904632568,4.909999847412109,4.376666625340779,69.10000085830688,67.59999990463257,72.24999904632568,69.64999993642171,141.94999933242798,141.15000009536743,147.99999952316284,143.69999965031943,28.20000171661377,27.649998664855957,28.450000286102295,28.100000222524006,,,,,,,,,,,,, +work-64,asyncify,chain,100,0,0,on,1,64,3,3072,5.556640625000192,5.527343750000205,5.561523437499813,5.548502604166736,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,19.99999999999602,15.000000000000568,19.99999999999602,18.33333333333087,180.00000000000682,150.00000000000568,195.0000000000074,175.00000000000662,16.180000000000007,15.974999999999994,16.185000000000002,16.113333333333333,6.328862793572309,6.326907630522088,6.410078247261348,6.355282890451915,17.578125,16.2109375,17.67578125,17.154947916666668,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.039999961853027,4.0299999713897705,4.115000009536743,4.061666647593181,69.50000047683716,69.3500018119812,72.7999997138977,70.55000066757202,142.2000002861023,141.95000171661377,144.7000002861023,142.95000076293945,28.1000018119812,27.950000762939453,28.19999933242798,28.08333396911621,,,,,,,,1.495841035120149,1.4784821841739921,1.4981481481481491,5.239257812500009,5.048828124999988,5.25390625000001 +work-64,asyncify,chain,100,0,1,on,1,64,3,3072,0.234374999999995,0.21972656249992506,0.24902343749992617,0.23437499999994874,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000004927,10.000000000005116,5.000000000009663,15.000000000000568,10.000000000005116,10.805000000000007,10.799999999999997,10.819999999999993,10.808333333333332,9.477186487737153,9.464048059149729,9.481574074074077,9.47426954032032,95.5078125,95.1171875,95.60546875,95.41015625,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.085000038146973,4.085000038146973,4.144999980926514,4.105000019073486,71.90000057220459,69.90000009536743,72.39999771118164,71.39999945958455,140.85000038146973,139.24999952316284,141.70000076293945,140.60000022252402,27.850000858306885,27.44999885559082,28.350000381469727,27.88333336512248,,,,,,,,,,,,, +work-64,asyncify,chain,1000,0,0,on,1,64,3,3072,5.85937499999957,5.7128906249999805,5.913085937499895,5.828450520833148,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000019327,10.000000000005116,10.000000000019327,10.00000000001459,19.99999999998181,15.00000000001478,19.99999999999602,18.33333333333087,179.9999999999926,165.00000000000625,189.99999999999773,178.3333333333322,96.015,94.86999999999999,97.41000000000001,96.09833333333333,10.665010675415301,10.512278000205317,10.793728259723833,10.657005645114817,14.84375,14.35546875,17.1875,15.462239583333334,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.1000001430511475,4.070000171661377,4.130000114440918,4.1000001430511475,72.89999961853027,70.65000057220459,73.79999876022339,72.44999965031941,141.94999933242798,141.44999980926514,143.90000104904175,142.43333339691162,27.949998378753662,27.55000114440918,27.950000762939453,27.8166667620341,,,,,,,,1.0469569055895822,1.0377117289868967,1.0749552171965964,4.155273437499996,3.457031249999992,6.538085937499993 +work-64,asyncify,chain,1000,0,1,on,1,64,3,3072,0.26855468750001943,0.19531249999996114,0.28320312499997835,0.24902343749998632,0.0,0.0,0.0,0.0,4.9999999999954525,0.0,4.9999999999954525,3.3333333333303017,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000004927,5.000000000023874,5.000000000023874,5.000000000023874,5.000000000023874,90.615,89.32000000000001,93.87000000000002,91.26833333333335,11.30056833857529,10.908714179183974,11.464408866995072,11.224563794918112,94.62890625,94.3359375,96.09375,95.01953125,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.215000152587891,4.110000133514404,5.009999990463257,4.4450000921885175,70.85000038146973,69.54999923706055,72.89999961853027,71.09999974568684,142.40000009536743,138.29999923706055,143.54999780654907,141.41666571299234,28.05000066757202,27.699999809265137,28.19999933242798,27.983333269755047,,,,,,,,,,,,, +work-64,asyncify,chain,5000,0,0,on,1,64,3,3072,6.396484374999095,6.3916015624997105,6.5234374999995905,6.437174479166132,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,19.99999999999602,19.99999999999602,24.999999999977263,21.666666666656436,180.00000000000682,174.99999999998295,195.0000000000216,183.33333333333712,443.08000000000004,443.08000000000004,458.5,448.22,11.555477566128014,11.166850599781897,11.555477566128014,11.425935244012642,13.28125,12.98828125,13.4765625,13.248697916666666,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.079999923706055,4.069999933242798,4.085000038146973,4.078333298365275,71.70000076293945,67.89999961853027,72.04999923706055,70.54999987284343,140.69999933242798,139.74999904632568,143.7999987602234,141.41666571299234,28.499999046325684,28.250000476837158,28.69999885559082,28.48333279291789,,,,,,,,1.0156910839341182,0.998377647589004,1.1077153521858352,6.684570312500027,-0.7031250000000266,43.54003906249998 +work-64,asyncify,chain,5000,0,1,on,1,64,3,3072,0.2832031249998812,0.24414062500002776,0.2880859375000294,0.2718098958333128,0.0,0.0,0.0,0.0,4.9999999999954525,0.0,4.9999999999954525,3.3333333333303017,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,5.000000000052296,5.000000000052296,9.999999999990905,6.666666666698499,436.235,413.915,443.80000000000007,431.3166666666667,11.736795534516947,11.536730509238394,12.36969184494401,11.88107262956645,94.3359375,94.3359375,95.1171875,94.59635416666667,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.174999952316284,4.0350000858306885,5,4.403333346048991,68.05000066757202,67.65000104904175,69.3500018119812,68.35000117619832,140.85000038146973,138.80000114440918,143.29999923706055,140.98333358764648,28.000001907348633,27.950000762939453,28.19999933242798,28.05000066757202,,,,,,,,,,,,, +work-64,asyncify,chain,10000,0,0,on,1,64,3,3072,6.879882812500348,6.708984374999879,6.914062500000387,6.834309895833538,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000104592,10.000000000104592,10.000000000104592,10.000000000104592,25.000000000005684,20.000000000010232,25.000000000005684,23.333333333340533,284.99999999996817,269.9999999999818,295.00000000007276,283.33333333334093,882.175,867.585,888.9000000000001,879.5533333333334,11.60767534786182,11.519857126785913,11.802879256787518,11.643470577145084,12.40234375,12.3046875,12.890625,12.532552083333334,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.894999980926514,4.159999847412109,4.925000190734863,4.660000006357829,72.75000095367432,68.94999980926514,73.19999933242798,71.63333336512248,142.1500015258789,138.29999923706055,143.0999994277954,141.18333339691162,28.399999141693115,28.19999933242798,28.399999141693115,28.333332538604736,,,,,,,,0.984145612364651,0.9790001071998826,1.0068824224300772,-13.984374999999938,-18.173828125000014,5.888671874999973 +work-64,asyncify,chain,10000,0,1,on,1,64,3,3072,0.23925781249992117,0.23437499999998113,0.2587890625000838,0.24414062499999536,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,1.6666666666651508,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000109139,5.000000000052296,9.999999999990905,6.666666666717447,886.195,876.145,903.22,888.52,11.555020057662253,11.337216846394012,11.687564273036998,11.52660039236442,95.21484375,94.921875,95.3125,95.14973958333333,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,4.924999952316284,4.125,4.980000019073486,4.676666657129924,71.19999885559082,67.64999866485596,72.00000047683716,70.28333266576131,140.79999923706055,140.45000076293945,143.84999990463257,141.69999996821085,28.15000057220459,27.849998474121094,28.299999237060547,28.09999942779541,,,,,,,,,,,,, +work-64,jspi,chain,1,0,0,on,1,64,3,300000,4.21314999999999,4.193799999999999,4.284250000000003,4.230399999999997,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,9.999999999990905,9.999999999990905,9.999999999990905,9.999999999990905,10.000000000047748,10.000000000047748,10.000000000047748,10.000000000047748,4189.999999999998,4015.0000000000146,4280.000000000001,4161.6666666666715,435.44000000000005,432.905,442.315,436.88666666666666,0.229655061546941,0.22608548206594847,0.23099987295134036,0.22891347218807662,30.434,29.386,30.632,30.150666666666666,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3449997901916504,2.2250001430511475,2.440000057220459,2.3366666634877524,70.25000095367432,68.59999895095825,72.40000009536743,70.41666666666667,117.14999914169312,115.65000057220459,118.55000019073486,117.11666663487752,28.15000057220459,27.900002002716064,29.650001525878906,28.566668033599854,,,,,,,,16.950078308535627,16.288528816055972,17.255399247077474,4.10205,4.07365,4.151599999999999 +work-64,jspi,chain,1,0,1,on,1,64,3,300000,0.14169999999999974,0.1388000000000001,0.15935000000000044,0.14661666666666676,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,129.99999999999545,75.00000000000284,135.00000000000512,113.33333333333447,25.540000000000006,25.235,27.155,25.97666666666667,3.915465935787,3.682599889523108,3.9627897761046165,3.8536185338049083,97.188,96.855,97.259,97.10066666666667,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2250001430511475,2.2049999237060547,2.2750000953674316,2.2350000540415444,70.15000104904175,68.35000038146973,70.20000219345093,69.56666787465413,118.80000114440918,114.3999981880188,119.54999923706055,117.58333285649617,28.349997997283936,28.300001621246338,28.65000009536743,28.4333332379659,,,,,,,,,,,,, +work-64,jspi,chain,10,0,0,on,1,64,3,30000,4.119000000000009,4.105500000000011,4.15600000000001,4.126833333333344,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,285.0000000000108,270.00000000001023,285.0000000000108,280.00000000001063,46.25,46.06,46.605000000000004,46.305,2.162183783783784,2.145713979186782,2.1711029092488054,2.1596668907397905,30.81,30.54,30.96,30.77,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.365000009536743,2.1549999713897705,2.4100000858306885,2.310000022252401,70.6000018119812,69.50000047683716,72.5,70.86666742960612,118.09999942779541,117.30000019073486,118.80000114440918,118.06666692097981,27.899999618530273,27.750000953674316,28.599998950958252,28.083333174387615,,,,,,,,7.658997534921948,7.581967213114761,7.715242881072029,4.015000000000001,4.009,4.0520000000000005 +work-64,jspi,chain,10,0,1,on,1,64,3,30000,0.1349999999999966,0.13250000000000667,0.13500000000000084,0.13416666666666804,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,6.084999999999994,5.969999999999999,6.099999999999994,6.051666666666662,16.434018077239127,16.393606557377066,16.75058626465662,16.526070299757603,97.3,97.3,97.35,97.31666666666666,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.4600000381469727,2.245000123977661,2.504999876022339,2.4033333460489907,68.94999980926514,66.90000057220459,69.75000143051147,68.53333393732707,115.04999876022339,114.40000057220459,116.84999942779541,115.43333292007446,27.59999990463257,27.40000009536743,28.1499981880188,27.71666606267293,,,,,,,,,,,,, +work-64,jspi,chain,100,0,0,on,1,64,3,3072,4.428710937500038,4.394531249999723,4.648437500000186,4.490559895833315,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,209.99999999999375,200.00000000000284,215.0000000000034,208.33333333333334,8.375,8.370000000000005,8.53500000000001,8.426666666666671,12.226985074626866,11.997773872290553,12.234289127837508,12.153016024918308,28.125,25.87890625,29.00390625,27.669270833333332,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.2200000286102295,2.2049999237060547,2.3549997806549072,2.259999910990397,70.14999866485596,69.44999933242798,70.75000047683716,70.11666615804036,117.64999866485596,116.34999990463257,118.00000190734863,117.33333349227905,28.1000018119812,27.899999618530273,28.350000381469727,28.1166672706604,,,,,,,,2.09375,2.0492196878751496,2.1243654822335047,4.2724609375,4.267578125000004,4.326171875000007 +work-64,jspi,chain,100,0,1,on,1,64,3,3072,0.15136718749998723,0.1464843749999778,0.17578125000002054,0.15787760416666186,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,5.000000000009663,5.000000000000189,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,4,3.9399999999999977,4.165000000000006,4.035000000000001,25.60025,24.58607442977187,25.990101522842654,25.39214198420484,96.97265625,96.484375,97.0703125,96.84244791666667,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.434999942779541,2.375,2.6449999809265137,2.484999974568685,68.49999904632568,67.90000200271606,71.45000219345093,69.28333441416423,116.39999866485596,113.69999885559082,117.99999952316284,116.03333234786987,28.450000286102295,27.899999618530273,28.599998950958252,28.31666628519694,,,,,,,,,,,,, +work-64,jspi,chain,1000,0,0,on,1,64,3,3072,4.511718749999817,4.423828124999862,4.760742187499889,4.565429687499856,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000005116,15.000000000000568,13.333333333335418,209.99999999999375,45.000000000001705,225.00000000000853,160.00000000000134,38.379999999999995,37.089999999999996,38.38000000000001,37.95,26.68058884835852,26.680588848358514,27.60854677810731,26.989908158274783,26.171875,24.90234375,27.1484375,26.07421875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.190000057220459,2.129999876022339,2.504999876022339,2.2749999364217124,70.9499979019165,67.59999990463257,72.2000002861023,70.24999936421712,115.55000066757202,115.19999980926514,116.80000066757202,115.85000038146973,28.299999237060547,27.950000762939453,28.350000381469727,28.200000127156574,,,,,,,,1.1353350096139625,1.1005934718100887,1.1574185765983112,4.467773437500003,3.310546874999994,5.097656249999999 +work-64,jspi,chain,1000,0,1,on,1,64,3,3072,0.15625000000001055,0.1562499999999689,0.17089843749999722,0.16113281249999223,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000004927,5.000000000009663,5.000000000009663,5.000000000009663,5.000000000009663,33.7,33.16,33.80500000000001,33.555,30.385786350148365,30.291406596657293,30.880609167671896,30.519267371492518,96.875,96.58203125,96.875,96.77734375,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.434999942779541,2.2800002098083496,2.6499998569488525,2.4550000031789145,71.84999942779541,69.54999923706055,72.59999990463257,71.33333285649617,117.00000047683716,116.94999933242798,119.85000133514404,117.93333371480306,28.09999942779541,27.899999618530273,28.15000057220459,28.049999872843426,,,,,,,,,,,,, +work-64,jspi,chain,5000,0,0,on,1,64,3,3072,4.838867187500026,4.453124999999766,5.063476562500169,4.785156249999987,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000005116,10.000000000005116,10.000000000005116,10.000000000005116,15.000000000000568,10.000000000019327,15.00000000001478,13.333333333344891,199.99999999998863,199.99999999998863,250.0,216.6666666666591,171.72,167.28000000000003,172.09499999999997,170.365,29.81598532494759,29.751015427525502,30.607370875179335,30.058123875884142,23.046875,22.4609375,28.80859375,24.772135416666668,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.255000114440918,2.190000057220459,2.259999990463257,2.2350000540415444,68.94999980926514,67.7999997138977,71.05000019073486,69.26666657129924,117.34999895095825,117.04999923706055,117.95000076293945,117.44999965031941,28.350000381469727,28.250000476837158,28.600001335144043,28.40000073115031,,,,,,,,1.0235525024533856,1.000747808919865,1.031506232166992,3.86718749999998,0.12207031250002776,5.122070312500004 +work-64,jspi,chain,5000,0,1,on,1,64,3,3072,0.14648437499996392,0.1367187500000977,0.21484375000001277,0.16601562500002479,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.000000000009663,4.9999999999954525,5.000000000009663,5.000000000004927,5.000000000023874,5.000000000023874,5.000000000023874,5.000000000023874,167.155,166.475,168.135,167.255,30.63025934013341,30.451726291373003,30.75537468088302,30.612453437463145,97.0703125,95.703125,97.265625,96.6796875,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.179999828338623,2.1600000858306885,2.455000162124634,2.265000025431315,68.84999990463257,66.34999990463257,68.84999990463257,68.01666657129924,115.35000085830688,115.3000020980835,117.35000133514404,116.00000143051147,27.950000762939453,27.850000858306885,28.450000286102295,28.08333396911621,,,,,,,,,,,,, +work-64,jspi,chain,10000,0,0,on,1,64,3,3072,5.307617187499808,4.902343750000246,5.351562500000767,5.1871744791669405,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,10.000000000019327,10.000000000005116,10.000000000019327,10.00000000001459,15.000000000043201,15.00000000001478,19.99999999998181,16.66666666667993,295.0000000000159,234.9999999999568,324.99999999998863,284.9999999999871,339.855,334.875,340.14,338.29,30.13049977196157,30.10525371905686,30.578577081000375,30.27144352400627,23.828125,22.16796875,24.8046875,23.600260416666668,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.6050000190734863,2.134999990463257,2.690000057220459,2.4766666889190674,69.10000085830688,67.94999837875366,71.29999876022339,69.44999933242798,117.05000162124634,117.00000047683716,118.49999904632568,117.5166670481364,27.900002002716064,27.750000953674316,28.70000123977661,28.116668065388996,,,,,,,,1.0227313729027603,1.0014653767363968,1.0247090393776759,7.382812500000002,0.4785156250000089,8.002929687499993 +work-64,jspi,chain,10000,0,1,on,1,64,3,3072,0.14648437500001943,0.1416015625000655,0.1562499999999689,0.14811197916668462,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.9999999999954525,4.9999999999954525,4.9999999999954525,4.9999999999954525,5.000000000052296,5.000000000023874,5.000000000052296,5.000000000042822,332.58,331.66,334.385,332.875,30.789587467676952,30.623386216486985,30.87499547729602,30.76265638715332,97.0703125,96.875,97.16796875,97.03776041666667,4.999876022338867,4.999876022338867,4.999876022338867,4.999876022338867,2.3350000381469727,2.184999942779541,2.4749999046325684,2.331666628519694,72.30000019073486,71.69999837875366,72.75000095367432,72.24999984105428,118.05000066757202,117.00000047683716,120.55000066757202,118.53333393732707,28.1499981880188,27.750000953674316,28.399999141693115,28.09999942779541,,,,,,,,,,,,, diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/figures.json b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/figures.json new file mode 100644 index 0000000..a69b3ff --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/figures.json @@ -0,0 +1,12 @@ +{ + "source": "summary.json", + "configurations": 102, + "runs": 442, + "matplotlib": "3.11.2", + "charts": [ + "01-yield-latency", + "02-direct-and-phases", + "03-chain-controls", + "04-tails-and-clocks" + ] +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/yield-benchmark-charts.pdf b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/yield-benchmark-charts.pdf new file mode 100644 index 0000000..45fee70 Binary files /dev/null and b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/figures/yield-benchmark-charts.pdf differ diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/runs.csv b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/runs.csv new file mode 100644 index 0000000..be70c23 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/runs.csv @@ -0,0 +1,443 @@ +group,variant,mode,limit,trace,control,exceptions,isolate,work,id,rep,samples,operations,elapsed_ms,mean_us,p50_us,p95_us,p99_us,max_us,zero_percent,million_ops_per_second,js_elapsed_ms,wall_elapsed_ms,clock_step_us,js_to_cpp_sync_ns,performance_clock_loop_ns,cpp_clock_loop_ns,wall_clock_loop_ns,entry_us,channel_create_us,handler_setup_us,post_message_us,post_to_delivery_us,message_handler_us,resume_us +primary,asyncify,chain,100,0,1,on,1,0,primary-4-asyncify-chain-100-0-1-on-1-0-1024,4,1024,102401,10.575000000000003,0.23925781250000444,0.0,0.0,5.000000000009663,5.000000000009663,95.21484375,9.683309692671392,10.575000047683716,10,4.999876022338867,4.940000057220459,69.34999942779541,139.00000095367432,27.699999809265137,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-2-jspi-chain-1000-0-1-on-1-0-1024,2,1024,1024001,30.720000000000013,0.13671874999998668,0.0,0.0,4.9999999999954525,5.000000000009663,97.265625,33.33336588541665,30.72000002861023,31,4.999876022338867,2.615000009536743,71.60000085830688,114.90000009536743,27.749998569488525,,,,,,, +no-exceptions,asyncify,chain,1,0,1,off,1,0,no-exceptions-1-asyncify-chain-1-0-1-off-1-0-100000,1,100000,100001,24.61,0.1358000000000034,0.0,0.0,4.9999999999954525,140.00000000000057,97.323,4.06342950020317,24.615000009536743,24,4.999876022338867,4.9049999713897705,72.95000076293945,124.49999809265137,27.700002193450928,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-1-jspi-chain-10000-0-0-on-1-0-1024,1,1024,10240001,308.805,4.7607421874999165,4.9999999999954525,9.999999999990905,14.999999999986358,225.00000000002274,24.8046875,33.160088081475365,308.80999994277954,309,4.999876022338867,2.1500000953674316,68.95000219345093,115.9500002861023,27.750000953674316,,,,,,, +primary,asyncify,chain,5000,0,1,on,1,0,primary-7-asyncify-chain-5000-0-1-on-1-0-1024,7,1024,5120001,425.91999999999996,0.16601562500007105,0.0,0.0,4.9999999999954525,5.000000000052296,96.6796875,12.021039162283998,425.9249999523163,426,4.999876022338867,4.099999904632568,67.59999990463257,136.99999809265137,27.849998474121094,,,,,,, +ordinary-page,asyncify,direct,1,1,0,on,0,0,ordinary-page-3-asyncify-direct-1-1-0-on-0-0-10000,3,10000,10000,56.300000000000004,5.49,0.0,99.99999999999432,100.00000000000853,400.0000000000057,94.64,0.17761989342806392,56.30000019073486,56,99.99990463256836,5,69.00000095367432,134.00000095367432,27.999999523162842,0.2499982643128682,1.0800000190734864,0.6400000095367432,0.5900001525878906,1.529999804496765,0.9299999237060547,0.4700018262861924 +no-exceptions,jspi,chain,10,0,1,off,1,0,no-exceptions-2-jspi-chain-10-0-1-off-1-0-10000,2,10000,100001,5.404999999999994,0.1365000000000066,0.0,0.0,4.9999999999954525,5.000000000009663,97.27,18.501572617946366,5.4049999713897705,5,4.999876022338867,2.434999942779541,67.74999856948853,114.34999942779541,28.19999933242798,,,,,,, +primary,asyncify,chain,1000,0,1,on,1,0,primary-4-asyncify-chain-1000-0-1-on-1-0-1024,4,1024,1024001,86.11,0.26855468750001943,0.0,4.9999999999954525,5.000000000009663,5.000000000023874,94.62890625,11.89177795842527,86.1100001335144,86,4.999876022338867,4.144999980926514,69.54999923706055,139.64999914169312,27.750000953674316,,,,,,, +primary,jspi,chain,10,0,0,on,1,0,primary-5-jspi-chain-10-0-0-on-1-0-10000,5,10000,100001,45.545,4.10399999999999,4.9999999999954525,10.000000000005116,10.000000000005116,265.00000000000057,31.29,2.195652651224064,45.55000019073486,45,4.999876022338867,2.179999828338623,70.19999980926514,115.49999952316284,28.65000009536743,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,primary-7-jspi-chain-1-0-0-on-1-0-100000,7,100000,100001,432.855,4.188949999999986,4.9999999999954525,9.999999999990905,10.000000000047748,4324.999999999989,30.818,0.23102655623707707,432.8599998950958,433,4.999876022338867,2.5199999809265137,67.55000114440918,116.34999990463257,27.699999809265137,,,,,,, +no-exceptions,asyncify,chain,10000,0,1,off,1,0,no-exceptions-1-asyncify-chain-10000-0-1-off-1-0-1024,1,1024,10240001,358.15500000000003,0.16601562500008493,0.0,0.0,4.9999999999954525,5.000000000052296,96.6796875,28.590975974089428,358.15499997138977,358,4.999876022338867,4.0899999141693115,69.85000133514404,126.5500020980835,28.84999990463257,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,js-control-5-js-js-direct-1-1-0-na-1-0-10000,5,10000,10000,48.59000015258789,4.782499885559082,4.999876022338867,9.999990463256836,10.000228881835938,454.9999237060547,22.79,0.20580366265891856,48.60000014305115,48,4.999876022338867,0,70.2999997138977,,28.65000009536743,0.19549992084503173,1.0015000343322753,0.7125003099441528,0.48249928951263427,1.2210002422332764,1.0215001583099366,0.1479999303817749 +primary,jspi,chain,5000,0,1,on,1,0,primary-6-jspi-chain-5000-0-1-on-1-0-1024,6,1024,5120001,156.925,0.14160156249999611,0.0,0.0,4.9999999999954525,5.000000000023874,97.16796875,32.6270575115501,156.92499995231628,157,4.999876022338867,2.615000009536743,68.79999876022339,115.19999980926514,28.599998950958252,,,,,,, +primary,asyncify,direct,1,0,0,on,1,0,primary-6-asyncify-direct-1-0-0-on-1-0-10000,6,10000,10000,48.44000000000001,4.707000000000012,4.9999999999954525,10.000000000005116,10.000000000005116,265.00000000000057,23.35,0.20644095788604455,48.46000003814697,48,4.999876022338867,4.139999866485596,69.6500015258789,141.74999952316284,28.19999933242798,,,,,,, +chain-trace,asyncify,chain,1,1,0,on,1,0,chain-trace-1-asyncify-chain-1-1-0-on-1-0-1024,1,1024,1025,6.7549999999999955,6.333007812499999,4.9999999999954525,10.000000000005116,15.000000000000568,239.99999999999488,12.890625,0.15173945225758706,6.759999990463257,7,4.999876022338867,4.059999942779541,70.24999856948853,140.80000162124634,28.19999933242798,0.3857025690376936,1.1132818181067705,0.8886717259883881,0.5712902639061213,1.6113277524709702,0.9667961858212948,0.795937497168761 +primary,asyncify,sync,1,0,0,on,1,0,primary-7-asyncify-sync-1-0-0-on-1-0-100000,7,100000,100000,24.52000000000001,0.13099999999999923,0.0,0.0,4.9999999999954525,149.99999999999147,97.422,4.078303425774876,24.52999997138977,25,4.999876022338867,4.0350000858306885,67.8499984741211,137.24999904632568,28.250000476837158,,,,,,, +primary,asyncify,direct,1,0,0,on,1,0,primary-3-asyncify-direct-1-0-0-on-1-0-10000,3,10000,10000,47.215,4.585499999999996,4.9999999999954525,10.000000000005116,10.000000000005116,240.0000000000091,24.97,0.2117970983797522,47.22499990463257,47,4.999876022338867,4.055000066757202,66.50000095367432,139.84999895095825,27.849998474121094,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,primary-3-jspi-chain-100-0-0-on-1-0-1024,3,1024,102401,8.019999999999996,4.462890625000063,4.9999999999954525,10.000000000005116,10.000000000005116,209.99999999999375,27.05078125,12.76820448877806,8.025000095367432,8,4.999876022338867,2.4049999713897705,72.7999997138977,115.24999856948853,27.799999713897705,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,primary-6-asyncify-clock-1-0-0-on-1-0-100000,6,100000,100000,22.614999999999995,0.10944999999999752,0.0,0.0,4.9999999999954525,45.000000000001705,97.819,4.4218439089100166,22.615000009536743,22,4.999876022338867,4.0899999141693115,71.5499997138977,145.20000219345093,27.850000858306885,,,,,,, +work-64,asyncify,chain,10000,0,1,on,1,64,work-64-3-asyncify-chain-10000-0-1-on-1-64-1024,3,1024,10240001,903.22,0.2587890625000838,0.0,4.9999999999954525,4.9999999999954525,9.999999999990905,94.921875,11.337216846394012,903.2250001430511,904,4.999876022338867,4.980000019073486,67.64999866485596,140.79999923706055,27.849998474121094,,,,,,, +primary,asyncify,chain,10000,0,0,on,1,0,primary-1-asyncify-chain-10000-0-0-on-1-0-1024,1,1024,10240001,849.33,6.806640624999777,4.9999999999954525,10.000000000047748,20.000000000095497,299.9999999999545,12.20703125,12.056563408804585,849.3450000286102,850,4.999876022338867,4.055000066757202,70.19999980926514,137.05000162124634,27.55000114440918,,,,,,, +chain-trace,asyncify,chain,5000,1,0,on,1,0,chain-trace-1-asyncify-chain-5000-1-0-on-1-0-1024,1,1024,5120001,443.93,7.167968750000448,4.9999999999954525,10.000000000047748,25.000000000005684,259.9999999999909,9.765625,11.53335210506161,443.9449999332428,444,4.999876022338867,4.990000009536743,70.44999837875366,137.75000095367432,27.699999809265137,0.44431635178625306,1.215820200741291,1.025390112772584,0.6591808050870895,1.7187509220093489,1.0400379542261362,1.0644724033777448 +no-exceptions,asyncify,chain,1,0,0,off,1,0,no-exceptions-3-asyncify-chain-1-0-0-off-1-0-100000,3,100000,100001,450.75,4.37324999999999,4.9999999999954525,9.999999999990905,10.000000000047748,4250.0,28.233,0.2218546866333888,450.75499987602234,451,4.999876022338867,4.954999923706055,69.54999923706055,123.59999895095825,27.249999046325684,,,,,,, +primary,asyncify,chain,100,0,1,on,1,0,primary-7-asyncify-chain-100-0-1-on-1-0-1024,7,1024,102401,10.989999999999995,0.19042968750003497,0.0,0.0,5.000000000009663,5.000000000009663,96.19140625,9.317652411282989,10.990000009536743,11,4.999876022338867,4.075000047683716,69.50000047683716,142.89999961853027,27.649998664855957,,,,,,, +work-64,jspi,chain,1000,0,0,on,1,64,work-64-3-jspi-chain-1000-0-0-on-1-64-1024,3,1024,1024001,37.089999999999996,4.511718749999817,4.9999999999954525,10.000000000005116,10.000000000005116,209.99999999999375,26.171875,27.60854677810731,37.09999990463257,37,4.999876022338867,2.190000057220459,67.59999990463257,115.19999980926514,27.950000762939453,,,,,,, +no-exceptions,jspi,chain,5000,0,1,off,1,0,no-exceptions-2-jspi-chain-5000-0-1-off-1-0-1024,2,1024,5120001,133.8,0.12207031249997224,0.0,0.0,4.9999999999954525,5.000000000023874,97.55859375,38.26607623318385,133.8050000667572,134,4.999876022338867,2.2799999713897705,69.10000085830688,117.75000095367432,27.899999618530273,,,,,,, +primary,jspi,sync,1,0,0,on,1,0,primary-1-jspi-sync-1-0-0-on-1-0-100000,1,100000,100000,21.549999999999997,0.11019999999999691,0.0,0.0,4.9999999999954525,79.9999999999983,97.819,4.640371229698377,21.549999952316284,21,4.999876022338867,2.115000009536743,70.05000114440918,115.89999914169312,28.15000057220459,,,,,,, +primary,asyncify,chain,10,0,1,on,1,0,primary-6-asyncify-chain-10-0-1-on-1-0-10000,6,10000,100001,12.295000000000002,0.24799999999999614,0.0,0.0,5.000000000009663,140.00000000000057,95.32,8.133468889792598,12.295000076293945,12,4.999876022338867,4.139999866485596,70.9500002861023,141.25,27.750000953674316,,,,,,, +primary,jspi,chain,1,0,1,on,1,0,primary-6-jspi-chain-1-0-1-on-1-0-100000,6,100000,100001,25.740000000000002,0.14214999999999967,0.0,0.0,4.9999999999954525,79.9999999999983,97.177,3.885042735042735,25.75,26,4.999876022338867,2.2149999141693115,67.30000019073486,116.80000066757202,27.899999618530273,,,,,,, +work-64,asyncify,chain,5000,0,1,on,1,64,work-64-1-asyncify-chain-5000-0-1-on-1-64-1024,1,1024,5120001,413.915,0.2880859375000294,0.0,4.9999999999954525,5.000000000009663,9.999999999990905,94.3359375,12.36969184494401,413.92000007629395,414,4.999876022338867,5,67.65000104904175,138.80000114440918,28.000001907348633,,,,,,, +primary,asyncify,chain,100,0,0,on,1,0,primary-5-asyncify-chain-100-0-0-on-1-0-1024,5,1024,102401,15.594999999999999,5.336914062500378,4.9999999999954525,10.000000000005116,15.000000000000568,180.00000000000682,20.01953125,6.566271240782303,15.599999904632568,16,4.999876022338867,4.945000171661377,71.79999828338623,140.6000018119812,27.950000762939453,,,,,,, +ordinary-page,jspi,direct,1,0,0,on,0,0,ordinary-page-2-jspi-direct-1-0-0-on-0-0-10000,2,10000,10000,41.50000000000001,4.030000000000003,0,0.0,100.00000000000142,299.99999999999716,96.04,0.2409638554216867,41.5,41,99.99990463256836,2.200000047683716,70,111.00000143051147,27.999999523162842,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,primary-7-asyncify-chain-1000-0-0-on-1-0-1024,7,1024,1024001,91.3,5.771484374999733,4.9999999999954525,10.000000000019327,15.00000000001478,174.99999999999716,18.26171875,11.215783132530122,91.30499982833862,91,4.999876022338867,4.830000162124634,69.44999933242798,138.05000066757202,28.05000066757202,,,,,,, +no-exceptions,asyncify,chain,5000,0,0,off,1,0,no-exceptions-1-asyncify-chain-5000-0-0-off-1-0-1024,1,1024,5120001,134.38,4.907226562500034,4.9999999999954525,10.000000000005116,15.000000000000568,165.00000000000625,24.21875,38.10091531477899,134.38500022888184,134,4.999876022338867,4.875,71.5499997138977,120.89999914169312,28.250000476837158,,,,,,, +work-64,jspi,chain,10,0,1,on,1,64,work-64-1-jspi-chain-10-0-1-on-1-64-10000,1,10000,100001,5.969999999999999,0.13250000000000667,0.0,0.0,4.9999999999954525,5.000000000009663,97.35,16.75058626465662,5.9700000286102295,6,4.999876022338867,2.245000123977661,66.90000057220459,115.04999876022339,27.40000009536743,,,,,,, +no-exceptions,jspi,chain,1000,0,0,off,1,0,no-exceptions-1-jspi-chain-1000-0-0-off-1-0-1024,1,1024,1024001,31.654999999999994,4.277343750000079,4.9999999999954525,10.000000000005116,10.000000000005116,225.00000000000853,30.17578125,32.348791660085304,31.66000008583069,31,4.999876022338867,2.305000066757202,69.0999984741211,117.00000047683716,27.55000114440918,,,,,,, +primary,jspi,chain,1,0,1,on,1,0,primary-5-jspi-chain-1-0-1-on-1-0-100000,5,100000,100001,24.36500000000001,0.134049999999999,0.0,0.0,4.9999999999954525,90.00000000000341,97.343,4.1042889390519175,24.365000009536743,24,4.999876022338867,2.4600000381469727,68.05000066757202,114.75000143051147,27.650001049041748,,,,,,, +no-exceptions,jspi,chain,1000,0,1,off,1,0,no-exceptions-2-jspi-chain-1000-0-1-off-1-0-1024,2,1024,1024001,27.015000000000008,0.13183593750003275,0.0,0.0,5.000000000009663,5.000000000009663,97.36328125,37.904904682583734,27.019999980926514,27,4.999876022338867,2.1649999618530273,70.49999952316284,116.00000143051147,27.950000762939453,,,,,,, +work-64,jspi,chain,100,0,1,on,1,64,work-64-2-jspi-chain-100-0-1-on-1-64-1024,2,1024,102401,3.9399999999999977,0.15136718749998723,0.0,0.0,4.9999999999954525,5.000000000009663,96.97265625,25.990101522842654,3.93999981880188,4,4.999876022338867,2.375,67.90000200271606,113.69999885559082,28.450000286102295,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-6-asyncify-chain-1-0-1-on-1-0-100000,6,100000,100001,33.724999999999994,0.21849999999999808,0.0,0.0,5.000000000009663,104.99999999998977,95.675,2.9651890289103044,33.730000019073486,33,4.999876022338867,4.119999885559082,69.60000038146973,138.84999990463257,28.09999942779541,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,primary-4-asyncify-chain-1000-0-0-on-1-0-1024,4,1024,1024001,93.58000000000001,5.605468749999856,4.9999999999954525,10.000000000005116,19.99999999999602,150.00000000000568,16.50390625,10.942519769181448,93.58000016212463,93,4.999876022338867,3.984999895095825,67.05000162124634,135.6500005722046,27.799999713897705,,,,,,, +work-64,jspi,chain,1000,0,1,on,1,64,work-64-2-jspi-chain-1000-0-1-on-1-64-1024,2,1024,1024001,33.16,0.1562499999999689,0.0,0.0,4.9999999999954525,5.000000000009663,96.875,30.880609167671896,33.15999984741211,33,4.999876022338867,2.2800002098083496,71.84999942779541,117.00000047683716,27.899999618530273,,,,,,, +no-exceptions,asyncify,chain,10000,0,1,off,1,0,no-exceptions-3-asyncify-chain-10000-0-1-off-1-0-1024,3,1024,10240001,359.57,0.14648437500004718,0.0,0.0,4.9999999999954525,5.000000000052296,97.0703125,28.478463164335178,359.5699999332428,359,4.999876022338867,4.019999980926514,69.0499997138977,121.80000066757202,27.750000953674316,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-1-jspi-direct-1-1-0-on-1-0-10000,1,10000,10000,48.985,4.763999999999995,4.9999999999954525,10.000000000005116,10.000000000005116,390.00000000000057,23.33,0.20414412575278146,48.984999895095825,49,4.999876022338867,2.615000009536743,69.90000009536743,116.84999942779541,28.19999933242798,0.23896170806885095,1.036000418663025,0.6274999618530274,0.4599997282028198,1.2050004243850707,0.9859994411468506,0.21053831768035067 +chain-trace,jspi,chain,10,1,0,on,1,0,chain-trace-2-jspi-chain-10-1-0-on-1-0-1024,2,1024,10241,6.064999999999998,5.356445312499944,4.9999999999954525,10.000000000005116,15.000000000000568,254.99999999999545,19.3359375,1.6885408079142628,6.070000171661377,6,4.999876022338867,2.434999942779541,66.84999942779541,113.4500002861023,28.250000476837158,0.17589374445360628,1.1035148054361343,1.0791050735861063,0.5029307212680578,1.1718741152435541,1.0400398168712854,0.28308703564119964 +work-64,jspi,chain,5000,0,0,on,1,64,work-64-2-jspi-chain-5000-0-0-on-1-64-1024,2,1024,5120001,167.28000000000003,4.453124999999766,4.9999999999954525,10.000000000005116,15.000000000000568,199.99999999998863,28.80859375,30.607370875179335,167.27999997138977,167,4.999876022338867,2.255000114440918,67.7999997138977,117.34999895095825,28.250000476837158,,,,,,, +primary,asyncify,sync,1,0,0,on,1,0,primary-3-asyncify-sync-1-0-0-on-1-0-100000,3,100000,100000,24.55000000000001,0.13215000000000302,0.0,0.0,4.9999999999954525,159.9999999999966,97.414,4.073319755600813,24.555000066757202,24,4.999876022338867,4.119999885559082,68.34999799728394,138.39999914169312,28.15000057220459,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-5-asyncify-chain-1-0-1-on-1-0-100000,5,100000,100001,33.36500000000001,0.20955000000000126,0.0,0.0,5.000000000009663,19.99999999999602,95.816,2.997182676457365,33.36500000953674,34,4.999876022338867,4.879999876022339,70.89999914169312,137.69999980926514,28.1000018119812,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,primary-4-jspi-chain-1-0-0-on-1-0-100000,4,100000,100001,432.97,4.198549999999999,4.9999999999954525,9.999999999990905,10.000000000047748,4340.000000000004,30.542,0.23096519389334133,432.97500014305115,433,4.999876022338867,2.494999885559082,68.39999914169312,115.49999952316284,28.399999141693115,,,,,,, +work-64,jspi,chain,1,0,1,on,1,64,work-64-2-jspi-chain-1-0-1-on-1-64-100000,2,100000,100001,27.155,0.15935000000000044,0.0,0.0,5.000000000009663,129.99999999999545,96.855,3.682599889523108,27.16000008583069,27,4.999876022338867,2.2750000953674316,68.35000038146973,114.3999981880188,28.65000009536743,,,,,,, +no-exceptions,jspi,chain,1000,0,1,off,1,0,no-exceptions-3-jspi-chain-1000-0-1-off-1-0-1024,3,1024,1024001,27.090000000000003,0.11230468750005052,0.0,0.0,5.000000000009663,5.000000000009663,97.75390625,37.79996308600959,27.09500002861023,27,4.999876022338867,2.25,70.79999923706055,116.64999961853027,28.05000066757202,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-2-jspi-chain-10000-0-0-on-1-0-1024,2,1024,10240001,307.935,4.858398437500814,4.9999999999954525,10.000000000005116,15.00000000001478,235.00000000001364,23.14453125,33.253774335492885,307.9449999332428,308,4.999876022338867,2.2899999618530273,71.70000076293945,115.99999904632568,27.899999618530273,,,,,,, +primary,jspi,sync,1,0,0,on,1,0,primary-3-jspi-sync-1-0-0-on-1-0-100000,3,100000,100000,21.665,0.11009999999999934,0.0,0.0,4.9999999999954525,74.99999999999574,97.83,4.6157396722824835,21.670000076293945,21,4.999876022338867,2.2200000286102295,67.5,115.09999990463257,27.749998569488525,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,primary-6-jspi-chain-1-0-0-on-1-0-100000,6,100000,100001,430.69500000000005,4.171800000000004,4.9999999999954525,9.999999999990905,10.000000000047748,5009.999999999991,31.117,0.2321851890548996,430.6949999332428,431,4.999876022338867,2.3299999237060547,72.00000047683716,116.80000066757202,27.949998378753662,,,,,,, +work-64,jspi,chain,10,0,0,on,1,64,work-64-1-jspi-chain-10-0-0-on-1-64-10000,1,10000,100001,46.06,4.105500000000011,4.9999999999954525,10.000000000005116,10.000000000005116,270.00000000001023,30.81,2.1711029092488054,46.06500005722046,46,4.999876022338867,2.1549999713897705,69.50000047683716,117.30000019073486,27.750000953674316,,,,,,, +work-64,asyncify,chain,10000,0,0,on,1,64,work-64-2-asyncify-chain-10000-0-0-on-1-64-1024,2,1024,10240001,867.585,6.708984374999879,4.9999999999954525,10.000000000104592,20.000000000010232,295.00000000007276,12.40234375,11.802879256787518,867.5949997901917,868,4.999876022338867,4.925000190734863,68.94999980926514,138.29999923706055,28.399999141693115,,,,,,, +ordinary-page,jspi,direct,1,1,0,on,0,0,ordinary-page-1-jspi-direct-1-1-0-on-0-0-10000,1,10000,10000,49.599999999999994,4.790000000000001,0.0,0,100.00000000000142,400.0000000000057,95.32,0.20161290322580647,49.59999990463257,49,99.99990463256836,2.6000001430511475,67.00000047683716,111.99999809265137,30,0.23995070457457715,1.0,0.5800001621246338,0.43000001907348634,1.2799999475479127,1.059999942779541,0.20004922389985041 +no-exceptions,jspi,chain,100,0,0,off,1,0,no-exceptions-1-jspi-chain-100-0-0-off-1-0-1024,1,1024,102401,7.594999999999999,4.077148437499817,4.9999999999954525,10.000000000005116,10.000000000005116,45.000000000001705,29.8828125,13.482685977616855,7.5950000286102295,8,4.999876022338867,2.565000057220459,68.50000143051147,115.89999914169312,28.05000066757202,,,,,,, +work-64,asyncify,chain,1,0,0,on,1,64,work-64-1-asyncify-chain-1-0-0-on-1-64-100000,1,100000,100001,496.08000000000004,4.8150999999999895,4.9999999999954525,9.999999999990905,10.000000000047748,4425.000000000011,22.897,0.2015824060635381,496.085000038147,496,4.999876022338867,4.109999895095825,66.94999933242798,140.69999933242798,27.799999713897705,,,,,,, +primary,jspi,direct,1,0,0,on,1,0,primary-7-jspi-direct-1-0-0-on-1-0-10000,7,10000,10000,41.065,3.984500000000002,4.9999999999954525,10.000000000005116,10.000000000005116,260.0000000000051,32.63,0.24351637647631805,41.0699999332428,42,4.999876022338867,2.305000066757202,70.79999923706055,117.05000162124634,27.999999523162842,,,,,,, +primary,jspi,sync,1,0,0,on,1,0,primary-6-jspi-sync-1-0-0-on-1-0-100000,6,100000,100000,21.654999999999994,0.11434999999999995,0.0,0.0,4.9999999999954525,85.00000000000085,97.758,4.617871161394598,21.664999961853027,22,4.999876022338867,2.615000009536743,71.09999895095825,117.40000009536743,27.799999713897705,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,primary-2-jspi-chain-1-0-0-on-1-0-100000,2,100000,100001,431.255,4.175100000000008,4.9999999999954525,9.999999999990905,10.000000000047748,4169.999999999987,31.007,0.23188368830506315,431.2650001049042,431,4.999876022338867,2.680000066757202,72.64999866485596,116.15000009536743,28.300001621246338,,,,,,, +primary,jspi,sync,1,0,0,on,1,0,primary-7-jspi-sync-1-0-0-on-1-0-100000,7,100000,100000,21.495000000000005,0.11114999999999597,0.0,0.0,4.9999999999954525,85.00000000000085,97.806,4.652244708071644,21.49500012397766,22,4.999876022338867,2.3450000286102295,70.15000104904175,118.25000047683716,28.1000018119812,,,,,,, +primary,jspi,chain,10,0,0,on,1,0,primary-2-jspi-chain-10-0-0-on-1-0-10000,2,10000,100001,45.895,4.079499999999964,4.9999999999954525,10.000000000005116,10.000000000005116,304.9999999999926,31.14,2.178908377818934,45.90000009536743,46,4.999876022338867,2.5249998569488525,67.40000009536743,115.2999997138977,27.850000858306885,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,primary-5-jspi-chain-1-0-0-on-1-0-100000,5,100000,100001,431.485,4.183950000000005,4.9999999999954525,9.999999999990905,10.000000000047748,4240.000000000009,30.982,0.2317600843598271,431.49000000953674,432,4.999876022338867,2.234999895095825,67.5,115.54999828338623,27.950000762939453,,,,,,, +primary,asyncify,chain,1000,0,1,on,1,0,primary-5-asyncify-chain-1000-0-1-on-1-0-1024,5,1024,1024001,88.70000000000002,0.20507812500000777,0.0,0.0,5.000000000009663,5.000000000023874,95.8984375,11.544543404735059,88.70499992370605,89,4.999876022338867,4.090000152587891,69.0499997138977,138.25000047683716,27.650001049041748,,,,,,, +chain-trace,asyncify,chain,100,1,0,on,1,0,chain-trace-1-asyncify-chain-100-1-0-on-1-0-1024,1,1024,102401,16.614999999999995,6.37695312500014,4.9999999999954525,10.000000000005116,19.99999999999602,234.99999999999943,13.8671875,6.163165814023475,16.62000012397766,16,4.999876022338867,4.879999876022339,71.10000133514404,138.99999856948853,28.19999933242798,0.3076173923909492,1.0986328125,0.7031275890767574,0.5566412582993507,1.953123603016138,0.9326150175184011,0.8251954521985433 +primary,jspi,chain,1,0,0,on,1,0,primary-1-jspi-chain-1-0-0-on-1-0-100000,1,100000,100001,430.86,4.173400000000004,4.9999999999954525,9.999999999990905,10.000000000047748,4204.999999999984,31.049,0.23209627257113677,430.86500000953674,431,4.999876022338867,2.4049999713897705,67.89999961853027,115.39999961853027,27.55000114440918,,,,,,, +no-exceptions,jspi,chain,10,0,1,off,1,0,no-exceptions-3-jspi-chain-10-0-1-off-1-0-10000,3,10000,100001,5.189999999999998,0.1410000000000018,0.0,0.0,5.000000000002558,5.000000000009663,97.18,19.268015414258198,5.18999981880188,5,4.999876022338867,2.2049999237060547,70.85000038146973,116.15000009536743,28.249998092651367,,,,,,, +chain-trace,jspi,chain,1000,1,0,on,1,0,chain-trace-1-jspi-chain-1000-1-0-on-1-0-1024,1,1024,1024001,37.16499999999999,5.351562499999796,4.9999999999954525,10.000000000005116,15.000000000000568,225.00000000000853,18.06640625,27.552831965558997,37.170000076293945,37,4.999876022338867,2.440000057220459,70.79999923706055,117.99999952316284,28.20000171661377,0.15143242664621137,1.1767589021474123,0.9716805070638657,0.5322275683283806,1.2890647631138563,1.0058602783828974,0.2245380543171721 +work-64,jspi,chain,1,0,0,on,1,64,work-64-3-jspi-chain-1-0-0-on-1-64-100000,3,100000,100001,435.44000000000005,4.21314999999999,4.9999999999954525,9.999999999990905,10.000000000047748,4189.999999999998,30.434,0.229655061546941,435.4449999332428,436,4.999876022338867,2.440000057220459,70.25000095367432,115.65000057220459,29.650001525878906,,,,,,, +chain-trace,jspi,chain,1,1,0,on,1,0,chain-trace-2-jspi-chain-1-1-0-on-1-0-1024,2,1024,1025,5.515000000000001,5.151367187500034,4.9999999999954525,10.000000000005116,14.999999999986358,239.99999999999488,21.484375,0.18585675430643697,5.514999866485596,6,4.999876022338867,2.0999999046325684,73.25000047683716,115.9500002861023,27.849998474121094,0.3858399484305136,1.0595675557851791,0.6298848893493414,0.5126954056322575,1.2255855835974216,1.0888671968132257,0.2489266078920943 +primary,jspi,sync,1,0,0,on,1,0,primary-2-jspi-sync-1-0-0-on-1-0-100000,2,100000,100000,21.595,0.11105000000000004,0.0,0.0,4.9999999999954525,79.9999999999983,97.806,4.6307015512850205,21.59500002861023,21,4.999876022338867,2.4799997806549072,70.45000076293945,117.8499984741211,27.850000858306885,,,,,,, +ordinary-page,asyncify,direct,1,0,0,on,0,0,ordinary-page-3-asyncify-direct-1-0-0-on-0-0-10000,3,10000,10000,48.599999999999994,4.759999999999997,0.0,0.0,100.00000000000853,299.99999999999716,95.32,0.20576131687242802,48.60000014305115,48,99.99990463256836,4.099999904632568,70.99999904632568,138.99999856948853,28.000001907348633,,,,,,, +primary,jspi,chain,10000,0,1,on,1,0,primary-4-jspi-chain-10000-0-1-on-1-0-1024,4,1024,10240001,308.25,0.151367187500015,0.0,0.0,4.9999999999954525,5.000000000052296,96.97265625,33.21979237631792,308.25499987602234,308,4.999876022338867,2.125,69.95000123977661,116.00000143051147,28.15000057220459,,,,,,, +chain-trace,asyncify,chain,10,1,0,on,1,0,chain-trace-3-asyncify-chain-10-1-0-on-1-0-1024,3,1024,10241,8.365000000000009,6.230468749999926,4.9999999999954525,10.000000000005116,19.99999999999602,210.00000000000796,14.35546875,1.224267782426777,8.370000123977661,8,4.999876022338867,4.065000057220459,68.39999914169312,137.5,27.59999990463257,0.5127236992119588,1.127929426729679,0.683594262227416,0.4931644070893526,1.5087893698364496,1.0351554956287146,0.8691120892763554 +work-64,jspi,chain,10,0,1,on,1,64,work-64-3-jspi-chain-10-0-1-on-1-64-10000,3,10000,100001,6.084999999999994,0.1349999999999966,0.0,0.0,4.9999999999954525,5.000000000009663,97.3,16.434018077239127,6.085000038146973,6,4.999876022338867,2.504999876022339,68.94999980926514,114.40000057220459,27.59999990463257,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,primary-2-asyncify-chain-5000-0-0-on-1-0-1024,2,1024,5120001,436.28499999999997,6.235351562500199,4.9999999999954525,10.000000000047748,19.99999999999602,185.00000000000227,14.55078125,11.735450450966686,436.289999961853,436,4.999876022338867,4.174999952316284,70.70000171661377,138.25000047683716,27.699999809265137,,,,,,, +work-64,jspi,chain,100,0,1,on,1,64,work-64-3-jspi-chain-100-0-1-on-1-64-1024,3,1024,102401,4.165000000000006,0.1464843749999778,0.0,0.0,4.9999999999954525,5.000000000009663,97.0703125,24.58607442977187,4.164999961853027,5,4.999876022338867,2.434999942779541,71.45000219345093,116.39999866485596,27.899999618530273,,,,,,, +no-exceptions,jspi,chain,1,0,0,off,1,0,no-exceptions-3-jspi-chain-1-0-0-off-1-0-100000,3,100000,100001,430.76,4.171700000000003,4.9999999999954525,9.999999999990905,10.000000000047748,4245.000000000005,30.963,0.23215015321756893,430.7650001049042,431,4.999876022338867,2.2149999141693115,70.59999942779541,116.39999866485596,27.699999809265137,,,,,,, +primary,asyncify,chain,100,0,1,on,1,0,primary-5-asyncify-chain-100-0-1-on-1-0-1024,5,1024,102401,10.920000000000002,0.21484374999994338,0.0,0.0,4.9999999999954525,5.000000000009663,95.703125,9.37738095238095,10.924999952316284,11,4.999876022338867,4.865000009536743,69.45000171661377,145.9500002861023,27.999999523162842,,,,,,, +primary,jspi,chain,100,0,1,on,1,0,primary-4-jspi-chain-100-0-1-on-1-0-1024,4,1024,102401,3.7349999999999994,0.1660156249999878,0.0,0.0,4.9999999999954525,5.000000000009663,96.6796875,27.416599732262387,3.740000009536743,4,4.999876022338867,2.2300000190734863,67.95000076293945,116.29999876022339,28.19999933242798,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,primary-4-jspi-chain-100-0-0-on-1-0-1024,4,1024,102401,8.280000000000001,4.394531249999931,4.9999999999954525,10.000000000005116,10.000000000005116,180.00000000000682,28.41796875,12.367270531400964,8.28499984741211,8,4.999876022338867,2.359999895095825,69.40000057220459,118.50000143051147,27.899999618530273,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-7-asyncify-chain-1-0-0-on-1-0-100000,7,100000,100001,499.01,4.848049999999996,4.9999999999954525,9.999999999990905,10.000000000047748,4600.000000000023,22.624,0.20039878960341476,499.0199999809265,499,4.999876022338867,4.950000047683716,67.55000114440918,141.8499994277954,27.899999618530273,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,primary-6-jspi-chain-100-0-0-on-1-0-1024,6,1024,102401,7.905000000000001,4.389648437499699,4.9999999999954525,10.000000000005116,10.000000000005116,185.00000000000227,28.02734375,12.953953194180896,7.9049999713897705,8,4.999876022338867,2.5250000953674316,70.49999952316284,116.84999942779541,27.699999809265137,,,,,,, +primary,jspi,chain,5000,0,1,on,1,0,primary-4-jspi-chain-5000-0-1-on-1-0-1024,4,1024,5120001,154.42499999999998,0.15625000000005218,0.0,0.0,4.9999999999954525,5.000000000023874,96.875,33.1552598348713,154.42499995231628,154,4.999876022338867,2.1549999713897705,72.00000047683716,118.29999923706055,28.70000123977661,,,,,,, +primary,asyncify,chain,10,0,0,on,1,0,primary-5-asyncify-chain-10-0-0-on-1-0-10000,5,10000,100001,59.250000000000014,4.835500000000006,4.9999999999954525,10.000000000005116,10.000000000019327,254.99999999999545,22.2,1.6877805907172991,59.25999999046326,59,4.999876022338867,5.055000066757202,73.25000047683716,136.8999981880188,27.899999618530273,,,,,,, +primary,asyncify,chain,10000,0,0,on,1,0,primary-2-asyncify-chain-10000-0-0-on-1-0-1024,2,1024,10240001,859.4649999999999,6.987304687500889,4.9999999999954525,10.000000000104592,20.000000000010232,225.00000000002274,11.328125,11.914389765726353,859.4700000286102,859,4.999876022338867,4.200000047683716,72.85000085830688,141.70000076293945,27.750000953674316,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-3-jspi-direct-1-1-0-on-1-0-10000,3,10000,10000,49.06499999999999,4.79050000000001,4.9999999999954525,10.000000000005116,10.000000000005116,379.99999999999545,23.03,0.20381127076327327,49.07499980926514,49,4.999876022338867,2.2749998569488525,71.05000019073486,118.19999933242798,27.999999523162842,0.22489522457126085,1.0530000448226928,0.6780001878738403,0.4880000114440918,1.1599994897842407,1.0015004396438598,0.18510460186002362 +work-64,jspi,chain,1000,0,0,on,1,64,work-64-2-jspi-chain-1000-0-0-on-1-64-1024,2,1024,1024001,38.379999999999995,4.760742187499889,4.9999999999954525,10.000000000005116,15.000000000000568,225.00000000000853,24.90234375,26.68058884835852,38.390000104904175,39,4.999876022338867,2.129999876022339,70.9499979019165,115.55000066757202,28.299999237060547,,,,,,, +work-64,jspi,chain,100,0,0,on,1,64,work-64-2-jspi-chain-100-0-0-on-1-64-1024,2,1024,102401,8.370000000000005,4.394531249999723,4.9999999999954525,10.000000000005116,10.000000000005116,200.00000000000284,29.00390625,12.234289127837508,8.375,9,4.999876022338867,2.3549997806549072,70.75000047683716,117.64999866485596,27.899999618530273,,,,,,, +work-64,jspi,chain,5000,0,1,on,1,64,work-64-1-jspi-chain-5000-0-1-on-1-64-1024,1,1024,5120001,166.475,0.14648437499996392,0.0,0.0,4.9999999999954525,5.000000000023874,97.0703125,30.75537468088302,166.47500014305115,166,4.999876022338867,2.455000162124634,66.34999990463257,115.3000020980835,28.450000286102295,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-4-jspi-chain-10000-0-0-on-1-0-1024,4,1024,10240001,312.825,5.112304687500541,4.9999999999954525,10.000000000019327,15.000000000000568,235.00000000001364,22.55859375,32.73395988172301,312.82999992370605,313,4.999876022338867,2.2750000953674316,69.6500015258789,116.99999809265137,28.15000057220459,,,,,,, +no-exceptions,asyncify,direct,1,0,0,off,1,0,no-exceptions-1-asyncify-direct-1-0-0-off-1-0-10000,1,10000,10000,45.19499999999999,4.380999999999981,4.9999999999954525,10.000000000005116,10.000000000005116,284.9999999999966,27.22,0.22126341409447953,45.204999923706055,45,4.999876022338867,3.929999828338623,67.69999980926514,122.99999952316284,28.09999942779541,,,,,,, +chain-trace,asyncify,chain,1000,1,0,on,1,0,chain-trace-1-asyncify-chain-1000-1-0-on-1-0-1024,1,1024,1024001,92.62499999999999,6.1865234374998685,4.9999999999954525,10.000000000019327,20.000000000010232,199.99999999998863,12.98828125,11.055341430499327,92.63499999046326,92,4.999876022338867,4.059999942779541,71.10000133514404,137.59999990463257,27.650001049041748,0.31240475364019415,1.1181645095348358,0.5908196326345205,0.5273441784083843,1.8212869763374329,0.937499338760972,0.8790040481835293 +no-exceptions,jspi,direct,1,1,0,off,1,0,no-exceptions-3-jspi-direct-1-1-0-off-1-0-10000,3,10000,10000,49.15500000000001,4.796500000000012,4.9999999999954525,10.000000000005116,10.000000000005116,400.0000000000057,22.52,0.2034381039568711,49.16000008583069,49,4.999876022338867,2.359999895095825,67.14999914169312,115.75000047683716,27.850000858306885,0.20292354679106026,1.069500732421875,0.634000039100647,0.4925005674362183,1.229498314857483,0.9725001811981201,0.1955766181946089 +primary,jspi,chain,1,0,1,on,1,0,primary-7-jspi-chain-1-0-1-on-1-0-100000,7,100000,100001,25.03500000000001,0.13849999999999996,0.0,0.0,4.9999999999954525,19.99999999999602,97.237,3.9944477731176335,25.045000076293945,25,4.999876022338867,2.2750000953674316,69.24999952316284,115.9500002861023,27.850000858306885,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-7-jspi-chain-1000-0-1-on-1-0-1024,7,1024,1024001,32.03999999999999,0.1464843749999778,0.0,0.0,4.9999999999954525,5.000000000009663,97.0703125,31.960081148564303,32.03999996185303,32,4.999876022338867,2.0850000381469727,69.14999961853027,116.90000057220459,27.799999713897705,,,,,,, +work-64,jspi,chain,10000,0,0,on,1,64,work-64-3-jspi-chain-10000-0-0-on-1-64-1024,3,1024,10240001,340.14,5.307617187499808,4.9999999999954525,10.000000000019327,15.000000000043201,324.99999999998863,23.828125,30.10525371905686,340.1399998664856,340,4.999876022338867,2.690000057220459,71.29999876022339,118.49999904632568,27.900002002716064,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,primary-5-asyncify-direct-1-1-0-on-1-0-10000,5,10000,10000,56.39,5.5270000000000055,4.9999999999954525,10.000000000005116,15.000000000000568,375.0,16.29,0.17733640716439084,56.40000009536743,56,4.999876022338867,4.169999837875366,70.2999997138977,141.25,28.15000057220459,0.2579438667297566,1.1099993228912353,0.6339997768402099,0.5159998178482056,1.519500470161438,0.98650062084198,0.5030561246871799 +no-exceptions,jspi,chain,5000,0,0,off,1,0,no-exceptions-2-jspi-chain-5000-0-0-off-1-0-1024,2,1024,5120001,137.66,4.643554687500148,4.9999999999954525,10.000000000005116,15.000000000000568,210.00000000000796,27.5390625,37.19309167514165,137.66499996185303,138,4.999876022338867,2.1499998569488525,67.14999914169312,116.50000095367432,27.749998569488525,,,,,,, +chain-trace,asyncify,chain,1000,1,0,on,1,0,chain-trace-2-asyncify-chain-1000-1-0-on-1-0-1024,2,1024,1024001,94.84,6.704101562500147,4.9999999999954525,10.000000000019327,19.99999999999602,219.99999999999886,9.9609375,10.797142555883593,94.83999991416931,95,4.999876022338867,4.985000133514404,71.25,139.45000171661377,27.749998569488525,0.37607543170463387,1.162107102572918,0.7275394164025784,0.527344411239028,1.8554672133177519,1.0937475599348545,0.9618204273283831 +primary,asyncify,chain,10,0,0,on,1,0,primary-1-asyncify-chain-10-0-0-on-1-0-10000,1,10000,100001,60.405,4.904999999999989,4.9999999999954525,10.000000000005116,10.000000000019327,259.9999999999909,21.57,1.6555086499461966,60.40499997138977,60,4.999876022338867,4.079999923706055,69.74999904632568,137.10000038146973,28.09999942779541,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-3-jspi-chain-10000-0-0-on-1-0-1024,3,1024,10240001,314.505,4.838867187500165,4.9999999999954525,10.000000000005116,15.000000000000568,85.00000000000796,23.92578125,32.559103988807806,314.5050001144409,314,4.999876022338867,2.190000057220459,71.74999952316284,117.69999980926514,27.750000953674316,,,,,,, +primary,jspi,chain,10,0,1,on,1,0,primary-6-jspi-chain-10-0-1-on-1-0-10000,6,10000,100001,6.094999999999999,0.1384999999999934,0.0,0.0,4.9999999999954525,15.000000000000568,97.26,16.407054963084498,6.099999904632568,6,4.999876022338867,2.2649998664855957,69.10000085830688,117.24999904632568,28.300001621246338,,,,,,, +no-exceptions,asyncify,chain,1,0,1,off,1,0,no-exceptions-3-asyncify-chain-1-0-1-off-1-0-100000,3,100000,100001,24.52499999999999,0.14054999999999468,0.0,0.0,4.9999999999954525,134.9999999999909,97.22,4.077512742099899,24.52999997138977,25,4.999876022338867,4.829999923706055,70.39999961853027,122.30000019073486,28.450000286102295,,,,,,, +chain-trace,jspi,chain,10,1,0,on,1,0,chain-trace-1-jspi-chain-10-1-0-on-1-0-1024,1,1024,10241,5.904999999999987,5.229492187500032,4.9999999999954525,10.000000000005116,15.000000000000568,230.00000000000398,18.84765625,1.7342929720575821,5.909999847412109,6,4.999876022338867,2.180000066757202,68.80000114440918,114.80000019073486,27.800002098083496,0.35642370581626115,1.2109405361115932,0.7080074865370989,0.5371070001274347,1.1230453383177519,0.9960948955267668,0.29787322506312497 +js-control,js,js-direct,1,1,0,na,1,0,js-control-2-js-js-direct-1-1-0-na-1-0-10000,2,10000,10000,48.89500021934509,4.78899986743927,4.999876022338867,9.999990463256836,10.000228881835938,455.0001621246338,23.36,0.20451988864177453,48.90499997138977,49,4.999876022338867,0,71.84999942779541,,27.699999809265137,0.2015002727508545,1.0790000438690186,0.7079998016357422,0.4669992923736572,1.173499298095703,1.0145010948181152,0.1455000638961792 +chain-trace,jspi,chain,100,1,0,on,1,0,chain-trace-1-jspi-chain-100-1-0-on-1-0-1024,1,1024,102401,9.054999999999993,5.219726562499916,4.9999999999954525,10.000000000005116,10.000000000005116,219.99999999999886,18.9453125,11.308779679734961,9.055000066757202,9,4.999876022338867,2.424999952316284,73.25000047683716,119.60000038146973,27.799999713897705,0.16115200705822674,0.9863274171948433,0.9423829615116119,0.4785163328051567,1.362303737550974,1.000977586954832,0.288066519424271 +no-exceptions,jspi,chain,5000,0,1,off,1,0,no-exceptions-1-jspi-chain-5000-0-1-off-1-0-1024,1,1024,5120001,135.05,0.11230468750000888,0.0,0.0,4.9999999999954525,5.000000000023874,97.75390625,37.911891891891884,135.0550000667572,135,4.999876022338867,2.6449999809265137,70.59999942779541,115.05000114440918,27.649998664855957,,,,,,, +work-64,asyncify,chain,10,0,1,on,1,64,work-64-2-asyncify-chain-10-0-1-on-1-64-10000,2,10000,100001,12.780000000000001,0.21249999999999858,0.0,0.0,5.000000000009663,10.000000000005116,95.77,7.824804381846635,12.785000085830688,13,4.999876022338867,4.909999847412109,69.10000085830688,141.15000009536743,27.649998664855957,,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,js-control-4-js-js-direct-1-0-0-na-1-0-10000,4,10000,10000,39.90000009536743,3.911000061035156,4.999876022338867,9.999990463256836,9.999990463256836,284.9998474121094,32.88,0.2506265658170022,39.90999984741211,40,4.999876022338867,0,69.30000066757202,,27.949998378753662,,,,,,, +primary,jspi,chain,1,0,1,on,1,0,primary-4-jspi-chain-1-0-1-on-1-0-100000,4,100000,100001,24.919999999999987,0.1392000000000013,0.0,0.0,4.9999999999954525,144.99999999999602,97.256,4.012881219903694,24.920000076293945,25,4.999876022338867,2.1599998474121094,69.80000019073486,116.70000076293945,27.59999990463257,,,,,,, +primary,asyncify,chain,10000,0,1,on,1,0,primary-7-asyncify-chain-10000-0-1-on-1-0-1024,7,1024,10240001,873.355,0.21972656249993894,0.0,0.0,4.9999999999954525,14.999999999986358,95.80078125,11.724901099781874,873.3599998950958,874,4.999876022338867,5.090000152587891,68.15000057220459,139.50000047683716,27.999999523162842,,,,,,, +ordinary-page,asyncify,direct,1,0,0,on,0,0,ordinary-page-2-asyncify-direct-1-0-0-on-0-0-10000,2,10000,10000,48.199999999999996,4.73,0.0,0.0,100.00000000000853,299.99999999999716,95.34,0.20746887966804983,48.299999952316284,49,99.99990463256836,4.099999904632568,70.99999904632568,140.99999904632568,29.000000953674316,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,primary-5-asyncify-chain-1000-0-0-on-1-0-1024,5,1024,1024001,93.39000000000001,5.732421874999824,4.9999999999954525,10.000000000005116,19.99999999998181,195.0000000000074,16.796875,10.964782096584214,93.3899998664856,93,4.999876022338867,4.105000019073486,71.70000076293945,141.40000104904175,28.09999942779541,,,,,,, +work-64,jspi,chain,10000,0,0,on,1,64,work-64-1-jspi-chain-10000-0-0-on-1-64-1024,1,1024,10240001,334.875,4.902343750000246,4.9999999999954525,10.000000000005116,15.00000000001478,234.9999999999568,24.8046875,30.578577081000375,334.875,335,4.999876022338867,2.134999990463257,67.94999837875366,117.05000162124634,27.750000953674316,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,primary-5-asyncify-chain-5000-0-0-on-1-0-1024,5,1024,5120001,437.525,6.284179687499128,4.9999999999954525,10.000000000047748,20.000000000038654,185.00000000000227,15.4296875,11.702190731958176,437.52999997138977,437,4.999876022338867,4.079999923706055,68.94999980926514,141.94999933242798,27.899999618530273,,,,,,, +primary,jspi,clock,1,0,0,on,1,0,primary-7-jspi-clock-1-0-0-on-1-0-100000,7,100000,100000,21.28,0.10340000000000145,0.0,0.0,4.9999999999954525,45.000000000001705,97.948,4.699248120300752,21.289999961853027,22,4.999876022338867,2.325000047683716,70.25000095367432,116.70000076293945,28.350000381469727,,,,,,, +primary,asyncify,chain,5000,0,1,on,1,0,primary-6-asyncify-chain-5000-0-1-on-1-0-1024,6,1024,5120001,447.84499999999997,0.26855468750019984,0.0,4.9999999999954525,4.9999999999954525,5.000000000052296,94.62890625,11.432529111634606,447.85000014305115,447,4.999876022338867,3.990000009536743,72.74999856948853,141.70000076293945,27.950000762939453,,,,,,, +chain-trace,asyncify,chain,1,1,0,on,1,0,chain-trace-3-asyncify-chain-1-1-0-on-1-0-1024,3,1024,1025,6.720000000000013,6.333007812499957,4.9999999999954525,10.000000000005116,15.000000000000568,210.00000000000796,12.5,0.1525297619047616,6.724999904632568,6,4.999876022338867,4.075000047683716,71.05000019073486,138.39999914169312,27.799999713897705,0.19042968749992395,1.1718771420419216,0.8447233121842146,0.5224619526416063,1.7773439176380634,1.0351568926125765,0.7910149078816514 +primary,jspi,chain,10,0,1,on,1,0,primary-5-jspi-chain-10-0-1-on-1-0-10000,5,10000,100001,5.835000000000008,0.14350000000000165,0.0,0.0,4.9999999999954525,5.000000000009663,97.13,17.138131962296463,5.840000152587891,6,4.999876022338867,2.2300000190734863,70.75000047683716,117.8499984741211,28.05000066757202,,,,,,, +no-exceptions,jspi,chain,10000,0,0,off,1,0,no-exceptions-2-jspi-chain-10000-0-0-off-1-0-1024,2,1024,10240001,277.995,4.892578124999644,4.9999999999954525,10.000000000005116,15.000000000000568,235.00000000001364,25.5859375,36.83519847479271,278,278,4.999876022338867,2.5950000286102295,69.25000190734863,117.05000162124634,27.59999990463257,,,,,,, +work-64,asyncify,chain,1000,0,1,on,1,64,work-64-3-asyncify-chain-1000-0-1-on-1-64-1024,3,1024,1024001,89.32000000000001,0.19531249999996114,0.0,0.0,4.9999999999954525,5.000000000023874,96.09375,11.464408866995072,89.32500004768372,89,4.999876022338867,4.110000133514404,72.89999961853027,138.29999923706055,28.05000066757202,,,,,,, +primary,jspi,chain,10,0,1,on,1,0,primary-1-jspi-chain-10-0-1-on-1-0-10000,1,10000,100001,6.11999999999999,0.14699999999999563,0.0,0.0,4.9999999999954525,5.000000000009663,97.06,16.340032679738588,6.120000123977661,6,4.999876022338867,2.200000047683716,70.79999923706055,117.99999952316284,28.05000066757202,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,primary-6-asyncify-chain-1000-0-0-on-1-0-1024,6,1024,1024001,91.845,5.708007812499777,4.9999999999954525,10.000000000005116,15.00000000001478,159.9999999999966,14.84375,11.149229680439872,91.84999990463257,92,4.999876022338867,4.859999895095825,68.24999809265137,138.7000012397766,28.09999942779541,,,,,,, +primary,jspi,clock,1,0,0,on,1,0,primary-3-jspi-clock-1-0-0-on-1-0-100000,3,100000,100000,21.53,0.10979999999999741,0.0,0.0,4.9999999999954525,45.000000000001705,97.815,4.644681839294009,21.539999961853027,22,4.999876022338867,2.2100000381469727,70.45000076293945,118.70000123977661,27.849998474121094,,,,,,, +no-exceptions,asyncify,direct,1,1,0,off,1,0,no-exceptions-1-asyncify-direct-1-1-0-off-1-0-10000,1,10000,10000,54.245000000000005,5.308000000000014,4.9999999999954525,10.000000000005116,10.000000000005116,384.9999999999909,18.29,0.18434878790671952,54.25,55,4.999876022338867,4.9100000858306885,68.70000123977661,124.24999952316284,28.15000057220459,0.23605772495271396,1.0869992256164551,0.6839998960494995,0.4835001707077026,1.3570000648498535,1.0180005073547362,0.442442410469053 +primary,jspi,chain,5000,0,0,on,1,0,primary-4-jspi-chain-5000-0-0-on-1-0-1024,4,1024,5120001,158.615,4.746093750000194,4.9999999999954525,10.000000000005116,19.99999999999602,50.00000000001137,25.1953125,32.27942502285408,158.61500000953674,159,4.999876022338867,2.3350000381469727,71.44999980926514,118.25000047683716,27.899999618530273,,,,,,, +no-exceptions,asyncify,chain,1,0,0,off,1,0,no-exceptions-2-asyncify-chain-1-0-0-off-1-0-100000,2,100000,100001,456.205,4.425450000000001,4.9999999999954525,9.999999999990905,10.000000000047748,4195.000000000022,27.831,0.2192018938854243,456.2150001525879,456,4.999876022338867,4.009999990463257,70.80000162124634,121.19999885559082,27.650001049041748,,,,,,, +primary,asyncify,chain,10000,0,1,on,1,0,primary-4-asyncify-chain-10000-0-1-on-1-0-1024,4,1024,10240001,896.74,0.19531249999996114,0.0,0.0,4.9999999999954525,10.000000000047748,96.19140625,11.419141557196067,896.7400000095367,897,4.999876022338867,4.929999828338623,72.10000038146973,140.55000066757202,27.950000762939453,,,,,,, +chain-trace,jspi,chain,100,1,0,on,1,0,chain-trace-3-jspi-chain-100-1-0-on-1-0-1024,3,1024,102401,9.090000000000003,5.180664062500117,4.9999999999954525,10.000000000005116,15.000000000000568,245.00000000000455,18.359375,11.26523652365236,9.089999914169312,9,4.999876022338867,2.4700000286102295,67.85000085830688,116.64999961853027,28.05000066757202,0.20012764260177174,0.9765643626451492,0.8691400289535522,0.5761738866567612,1.2792935594916344,1.0253891814500093,0.2539754007012396 +primary,jspi,chain,100,0,1,on,1,0,primary-3-jspi-chain-100-0-1-on-1-0-1024,3,1024,102401,3.8299999999999983,0.13183593749999112,0.0,0.0,4.9999999999954525,5.000000000009663,97.36328125,26.73655352480419,3.830000162124634,4,4.999876022338867,2.6649999618530273,71.5499997138977,114.90000009536743,28.550000190734863,,,,,,, +no-exceptions,jspi,chain,5000,0,1,off,1,0,no-exceptions-3-jspi-chain-5000-0-1-off-1-0-1024,3,1024,5120001,131.53499999999997,0.19042968750006273,0.0,0.0,5.000000000009663,5.000000000023874,96.19140625,38.92500855285666,131.5350000858307,132,4.999876022338867,2.7099997997283936,71.25,118.80000114440918,28.64999771118164,,,,,,, +primary,jspi,direct,1,0,0,on,1,0,primary-4-jspi-direct-1-0-0-on-1-0-10000,4,10000,10000,41.905,4.061999999999989,4.9999999999954525,10.000000000005116,10.000000000005116,250.0,31.46,0.23863500775563776,41.91499996185303,42,4.999876022338867,2.4749999046325684,68.49999904632568,118.59999895095825,27.899999618530273,,,,,,, +work-64,jspi,chain,1000,0,1,on,1,64,work-64-1-jspi-chain-1000-0-1-on-1-64-1024,1,1024,1024001,33.80500000000001,0.17089843749999722,0.0,0.0,5.000000000009663,5.000000000009663,96.58203125,30.291406596657293,33.8050000667572,34,4.999876022338867,2.434999942779541,69.54999923706055,116.94999933242798,28.09999942779541,,,,,,, +no-exceptions,jspi,chain,100,0,0,off,1,0,no-exceptions-3-jspi-chain-100-0-0-off-1-0-1024,3,1024,102401,7.7250000000000085,4.340820312500076,4.9999999999954525,10.000000000005116,10.000000000005116,170.0000000000017,28.3203125,13.255792880258884,7.730000019073486,8,4.999876022338867,2.4200000762939453,71.25,118.4499979019165,27.899999618530273,,,,,,, +chain-trace,jspi,chain,10000,1,0,on,1,0,chain-trace-3-jspi-chain-10000-1-0-on-1-0-1024,3,1024,10240001,313.78,6.010742187499959,4.9999999999954525,10.000000000019327,15.000000000043201,305.0000000000068,15.72265625,32.6343329721461,313.7849998474121,314,4.999876022338867,2.615000009536743,72.59999990463257,120.99999904632568,27.649998664855957,0.49309559166471617,1.362307695671916,0.7177728693932295,0.5322261713445187,1.5332023613154888,1.0595680214464664,0.3125694766636239 +primary,asyncify,direct,1,0,0,on,1,0,primary-4-asyncify-direct-1-0-0-on-1-0-10000,4,10000,10000,51.06999999999999,4.937499999999988,4.9999999999954525,10.000000000005116,14.999999999986358,805.0000000000068,22.45,0.19580967299784613,51.08500003814697,51,4.999876022338867,4.120000123977661,72.35000133514404,138.89999866485596,27.850000858306885,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-4-jspi-chain-1000-0-0-on-1-0-1024,4,1024,1024001,35.89000000000001,4.3066406249999964,4.9999999999954525,10.000000000005116,15.000000000000568,35.0000000000108,28.515625,28.53165227082752,35.889999866485596,36,4.999876022338867,2.1700000762939453,67.1500015258789,116.25,27.949998378753662,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-7-jspi-chain-10000-0-0-on-1-0-1024,7,1024,10240001,316.03999999999996,5.170898437499558,4.9999999999954525,10.000000000005116,15.000000000000568,235.00000000001364,21.38671875,32.40096506771295,316.039999961853,317,4.999876022338867,2.5899999141693115,67.34999895095825,116.30000114440918,28.450000286102295,,,,,,, +no-exceptions,asyncify,direct,1,1,0,off,1,0,no-exceptions-2-asyncify-direct-1-1-0-off-1-0-10000,2,10000,10000,54.375,5.308000000000011,4.9999999999954525,10.000000000005116,10.000000000005116,385.0000000000051,17.71,0.1839080459770115,54.38000011444092,55,4.999876022338867,3.9700000286102295,69.50000047683716,125.45000076293945,27.5,0.22899055671694413,1.0255004644393921,0.7099994421005249,0.5085001230239868,1.4269993305206299,1.0390004873275758,0.3690095958709577 +primary,asyncify,chain,10,0,0,on,1,0,primary-6-asyncify-chain-10-0-0-on-1-0-10000,6,10000,100001,60.540000000000006,4.897499999999992,4.9999999999954525,10.000000000005116,10.000000000019327,245.00000000000455,21.15,1.6518169805087544,60.549999952316284,60,4.999876022338867,4.009999990463257,71.8500018119812,141.09999895095825,28.300001621246338,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,primary-2-asyncify-clock-1-0-0-on-1-0-100000,2,100000,100000,22.325000000000003,0.10974999999999596,0.0,0.0,4.9999999999954525,34.99999999999659,97.811,4.479283314669652,22.329999923706055,22,4.999876022338867,4.0249998569488525,67.90000200271606,146.9000005722046,28.400001525878906,,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,js-control-3-js-js-direct-1-0-0-na-1-0-10000,3,10000,10000,40.52500009536743,3.962500262260437,4.999876022338867,9.999990463256836,9.999990463256836,254.99987602233887,32.58,0.2467612579017153,40.53499984741211,41,4.999876022338867,0,71.10000133514404,,28.550000190734863,,,,,,, +no-exceptions,jspi,chain,1,0,1,off,1,0,no-exceptions-3-jspi-chain-1-0-1-off-1-0-100000,3,100000,100001,24.799999999999997,0.1350499999999984,0.0,0.0,4.9999999999954525,15.000000000000568,97.303,4.032298387096775,24.800000190734863,25,4.999876022338867,2.4200000762939453,70.44999837875366,116.94999933242798,28.15000057220459,,,,,,, +work-64,asyncify,chain,1,0,1,on,1,64,work-64-1-asyncify-chain-1-0-1-on-1-64-100000,1,100000,100001,33.905,0.21315000000000112,0.0,0.0,5.000000000009663,34.99999999999659,95.758,2.949446984220616,33.90499997138977,34,4.999876022338867,5.059999942779541,72.7999997138977,145,28.450000286102295,,,,,,, +no-exceptions,asyncify,chain,100,0,0,off,1,0,no-exceptions-2-asyncify-chain-100-0-0-off-1-0-1024,2,1024,102401,8.310000000000002,4.863281250000018,4.9999999999954525,10.000000000005116,10.000000000005116,149.99999999999147,21.97265625,12.322623345367024,8.315000057220459,9,4.999876022338867,4.945000171661377,71.09999895095825,124.24999952316284,27.59999990463257,,,,,,, +no-exceptions,asyncify,chain,1000,0,1,off,1,0,no-exceptions-3-asyncify-chain-1000-0-1-off-1-0-1024,3,1024,1024001,37.935,0.1269531249999678,0.0,0.0,4.9999999999954525,5.000000000009663,97.4609375,26.993567945169367,37.93500018119812,38,4.999876022338867,5.059999942779541,72.14999914169312,123.89999866485596,28.19999933242798,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-4-jspi-direct-1-1-0-on-1-0-10000,4,10000,10000,49.155,4.782000000000002,4.9999999999954525,10.000000000005116,10.000000000005116,375.0,22.68,0.20343810395687112,49.165000200271606,49,4.999876022338867,2.690000057220459,69.84999895095825,118.4000015258789,28.19999933242798,0.1535004653930386,1.0469998121261597,0.6815000534057617,0.457499623298645,1.193499779701233,1.0105004072189332,0.23849985885623112 +primary,jspi,chain,100,0,0,on,1,0,primary-2-jspi-chain-100-0-0-on-1-0-1024,2,1024,102401,8.239999999999995,4.37988281250011,4.9999999999954525,10.000000000005116,10.000000000005116,190.00000000001194,28.61328125,12.427305825242726,8.245000123977661,8,4.999876022338867,2.3400001525878906,69.80000019073486,118.55000019073486,28.19999933242798,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-1-jspi-chain-1000-0-1-on-1-0-1024,1,1024,1024001,32.17,0.11230468750002276,0.0,0.0,4.9999999999954525,5.000000000009663,97.75390625,31.830929437364002,32.170000076293945,32,4.999876022338867,2.194999933242798,67.54999876022339,116.79999828338623,27.650001049041748,,,,,,, +no-exceptions,asyncify,chain,5000,0,1,off,1,0,no-exceptions-1-asyncify-chain-5000-0-1-off-1-0-1024,1,1024,5120001,185.88,0.12207031249991673,0.0,0.0,4.9999999999954525,5.000000000009663,97.55859375,27.544657843770175,185.88499999046326,186,4.999876022338867,4.09499979019165,67.99999952316284,125.04999876022339,28.350000381469727,,,,,,, +work-64,jspi,chain,1000,0,1,on,1,64,work-64-3-jspi-chain-1000-0-1-on-1-64-1024,3,1024,1024001,33.7,0.15625000000001055,0.0,0.0,5.000000000009663,5.000000000009663,96.875,30.385786350148365,33.700000047683716,33,4.999876022338867,2.6499998569488525,72.59999990463257,119.85000133514404,28.15000057220459,,,,,,, +no-exceptions,jspi,chain,5000,0,0,off,1,0,no-exceptions-3-jspi-chain-5000-0-0-off-1-0-1024,3,1024,5120001,140.44,4.624023437500069,4.9999999999954525,10.000000000005116,15.00000000001478,200.00000000001705,26.66015625,36.456857020791794,140.44000005722046,140,4.999876022338867,2.180000066757202,69.80000019073486,117.59999990463257,28.550000190734863,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,primary-3-jspi-chain-5000-0-0-on-1-0-1024,3,1024,5120001,158.06,4.667968750000265,4.9999999999954525,10.000000000005116,15.000000000000568,200.00000000001705,26.07421875,32.392768568897885,158.05999994277954,158,4.999876022338867,2.5299999713897705,71.65000200271606,119.50000047683716,27.699999809265137,,,,,,, +ordinary-page,jspi,direct,1,1,0,on,0,0,ordinary-page-2-jspi-direct-1-1-0-on-0-0-10000,2,10000,10000,49.7,4.830000000000002,0.0,0.0,100.00000000000142,400.0000000000057,95.3,0.20120724346076457,49.700000047683716,49,99.99990463256836,2.700000047683716,70,110.99999904632568,29.000000953674316,0.19000143527979815,0.9399999856948853,0.6999998807907104,0.4400000095367432,1.3000001668930055,1.0399999856948852,0.2199985361099742 +work-64,jspi,chain,1,0,1,on,1,64,work-64-3-jspi-chain-1-0-1-on-1-64-100000,3,100000,100001,25.235,0.1388000000000001,0.0,0.0,4.9999999999954525,135.00000000000512,97.259,3.9627897761046165,25.234999895095825,25,4.999876022338867,2.2049999237060547,70.15000104904175,118.80000114440918,28.300001621246338,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,primary-7-jspi-chain-100-0-0-on-1-0-1024,7,1024,102401,8.309999999999988,4.404296875000033,4.9999999999954525,10.000000000005116,10.000000000005116,194.99999999999318,28.22265625,12.322623345367045,8.309999942779541,8,4.999876022338867,2.1649999618530273,67.7999997138977,115.89999914169312,28.05000066757202,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,primary-2-jspi-chain-5000-0-0-on-1-0-1024,2,1024,5120001,162.76999999999998,5.249023437499667,4.9999999999954525,10.000000000019327,20.000000000010232,259.9999999999909,22.16796875,31.455434048043255,162.77500009536743,163,4.999876022338867,2.4850001335144043,69.34999942779541,116.90000057220459,28.399999141693115,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-4-asyncify-chain-1-0-1-on-1-0-100000,4,100000,100001,34.515,0.2214000000000003,0.0,0.0,5.000000000009663,150.00000000000568,95.639,2.897320005794582,34.515000104904175,34,4.999876022338867,4.069999933242798,72.75000095367432,150.55000066757202,28.499999046325684,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,js-control-7-js-js-direct-1-1-0-na-1-0-10000,7,10000,10000,49.105000019073486,4.8289999723434445,4.999876022338867,9.999990463256836,10.000228881835938,480.0000190734863,22.8,0.20364524989544394,49.11999988555908,50,4.999876022338867,0,71.34999990463257,,27.949998378753662,0.24549970626831055,1.1080000400543213,0.6434998035430908,0.4860004186630249,1.167000651359558,0.9984989404678345,0.18050041198730468 +primary,jspi,chain,10000,0,1,on,1,0,primary-7-jspi-chain-10000-0-1-on-1-0-1024,7,1024,10240001,310.035,0.1269531250000927,0.0,0.0,4.9999999999954525,5.000000000052296,97.4609375,33.02853226248649,310.0350000858307,310,4.999876022338867,2.490000009536743,71.20000123977661,115.99999904632568,27.899999618530273,,,,,,, +primary,jspi,chain,10000,0,1,on,1,0,primary-3-jspi-chain-10000-0-1-on-1-0-1024,3,1024,10240001,304.095,0.15136718750002887,0.0,0.0,4.9999999999954525,5.000000000052296,96.97265625,33.6736907874184,304.1099998950958,305,4.999876022338867,2.194999933242798,69.19999837875366,116.25,28.05000066757202,,,,,,, +chain-trace,jspi,chain,100,1,0,on,1,0,chain-trace-2-jspi-chain-100-1-0-on-1-0-1024,2,1024,102401,9.075000000000003,5.283203124999941,4.9999999999954525,10.000000000005116,15.000000000000568,250.0,19.04296875,11.283856749311292,9.079999923706055,9,4.999876022338867,2.190000057220459,70.65000057220459,117.2000002861023,28.399999141693115,0.3662115521728959,1.1083991266787052,0.7714817766100168,0.5566398613154888,1.0986330453306437,1.1230460368096828,0.2587917260825079 +primary,asyncify,chain,10000,0,0,on,1,0,primary-4-asyncify-chain-10000-0-0-on-1-0-1024,4,1024,10240001,864.65,6.538085937499841,4.9999999999954525,10.000000000047748,19.99999999999602,230.0000000000182,13.28125,11.842943387497831,864.6549999713898,865,4.999876022338867,4.134999990463257,68.49999904632568,139.90000009536743,28.599998950958252,,,,,,, +no-exceptions,jspi,chain,10,0,0,off,1,0,no-exceptions-3-jspi-chain-10-0-0-off-1-0-10000,3,10000,100001,45.620000000000005,4.113000000000007,4.9999999999954525,10.000000000005116,10.000000000005116,280.00000000000114,30.68,2.1920429636124505,45.625,45,4.999876022338867,2.4549999237060547,70.79999923706055,116.25,27.899999618530273,,,,,,, +no-exceptions,asyncify,chain,1,0,0,off,1,0,no-exceptions-1-asyncify-chain-1-0-0-off-1-0-100000,1,100000,100001,501.69000000000005,4.8842000000000025,4.9999999999954525,9.999999999990905,10.000000000047748,39495.00000000001,27.643,0.19932827044589285,501.69000005722046,502,4.999876022338867,5.044999837875366,68.19999933242798,130.2999997138977,28.09999942779541,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-1-asyncify-chain-1-0-1-on-1-0-100000,1,100000,100001,33.925,0.22034999999999996,0.0,0.0,5.000000000009663,140.00000000000057,95.64,2.947708179808401,33.93499994277954,34,4.999876022338867,5.019999980926514,67.40000009536743,138.94999980926514,28.399999141693115,,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,js-control-1-js-js-direct-1-0-0-na-1-0-10000,1,10000,10000,40.13000011444092,3.92549991607666,4.999876022338867,9.999990463256836,9.999990463256836,265.0001049041748,32.9,0.24919013136014087,40.13499999046326,40,4.999876022338867,0,72.04999923706055,,28.349997997283936,,,,,,, +work-64,asyncify,chain,10000,0,0,on,1,64,work-64-1-asyncify-chain-10000-0-0-on-1-64-1024,1,1024,10240001,882.175,6.879882812500348,4.9999999999954525,10.000000000104592,25.000000000005684,269.9999999999818,12.890625,11.60767534786182,882.1850001811981,882,4.999876022338867,4.894999980926514,72.75000095367432,143.0999994277954,28.399999141693115,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-6-jspi-chain-10000-0-0-on-1-0-1024,6,1024,10240001,315.08500000000004,4.814453124999354,4.9999999999954525,10.000000000005116,14.999999999986358,245.00000000000455,25.29296875,32.49917006522049,315.085000038147,315,4.999876022338867,2.5399999618530273,71.40000104904175,117.34999895095825,28.19999933242798,,,,,,, +work-64,jspi,chain,5000,0,1,on,1,64,work-64-3-jspi-chain-5000-0-1-on-1-64-1024,3,1024,5120001,168.135,0.1367187500000977,0.0,0.0,5.000000000009663,5.000000000023874,97.265625,30.451726291373003,168.1399998664856,168,4.999876022338867,2.179999828338623,68.84999990463257,117.35000133514404,27.850000858306885,,,,,,, +work-64,jspi,chain,10,0,0,on,1,64,work-64-2-jspi-chain-10-0-0-on-1-64-10000,2,10000,100001,46.25,4.119000000000009,4.9999999999954525,10.000000000005116,10.000000000005116,285.0000000000108,30.96,2.162183783783784,46.25999999046326,47,4.999876022338867,2.365000009536743,70.6000018119812,118.80000114440918,27.899999618530273,,,,,,, +primary,jspi,chain,5000,0,1,on,1,0,primary-5-jspi-chain-5000-0-1-on-1-0-1024,5,1024,5120001,156.905,0.15136718750009825,0.0,0.0,5.000000000009663,5.000000000023874,96.97265625,32.63121634109812,156.90499997138977,157,4.999876022338867,2.190000057220459,68.29999923706055,115.3499984741211,28.450000286102295,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-3-asyncify-chain-1-0-0-on-1-0-100000,3,100000,100001,497.385,4.831200000000004,4.9999999999954525,9.999999999990905,10.000000000047748,4104.99999999999,22.721,0.20105350985654977,497.3900001049042,498,4.999876022338867,4.879999876022339,69.90000009536743,140.79999923706055,28.350000381469727,,,,,,, +no-exceptions,jspi,direct,1,0,0,off,1,0,no-exceptions-2-jspi-direct-1-0-0-off-1-0-10000,2,10000,10000,41.105000000000004,3.990500000000007,4.9999999999954525,10.000000000005116,10.000000000005116,260.0000000000051,32.77,0.24327940639824838,41.12000012397766,41,4.999876022338867,2.4549999237060547,68.99999856948853,117.89999961853027,28.299999237060547,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-6-jspi-chain-1000-0-1-on-1-0-1024,6,1024,1024001,33.42999999999999,0.19531249999997502,0.0,0.0,5.000000000009663,5.000000000009663,96.09375,30.63119952138798,33.44000005722046,33,4.999876022338867,2.25,68.35000038146973,116.34999990463257,27.750000953674316,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-4-jspi-chain-1000-0-1-on-1-0-1024,4,1024,1024001,31.545,0.1806640625000855,0.0,0.0,5.000000000009663,5.000000000009663,96.38671875,32.46159454747186,31.545000076293945,32,4.999876022338867,2.140000104904175,72.69999980926514,117.1500015258789,27.749998569488525,,,,,,, +ordinary-page,jspi,direct,1,1,0,on,0,0,ordinary-page-3-jspi-direct-1-1-0-on-0-0-10000,3,10000,10000,49.6,4.890000000000001,0.0,0,100.00000000000142,399.9999999999915,95.22,0.20161290322580644,49.59999990463257,49,99.99990463256836,2.299999952316284,70.99999904632568,112.00000047683716,26.999998092651367,0.18009538650515325,1.1200000047683716,0.6199999809265136,0.3700000047683716,1.4100000619888307,1.0199999809265137,0.16990458011624626 +chain-trace,jspi,chain,1,1,0,on,1,0,chain-trace-3-jspi-chain-1-1-0-on-1-0-1024,3,1024,1025,5.445000000000007,5.131835937499981,4.9999999999954525,10.000000000005116,15.000000000000568,234.99999999999943,21.58203125,0.18824609733700617,5.455000162124634,5,4.999876022338867,2.3000001907348633,68.70000123977661,117.14999914169312,27.850000858306885,0.2147951256483427,1.0351564269512892,0.6884757895022631,0.5224600899964571,1.3037151657044888,1.1181619483977556,0.24907139129938527 +primary,asyncify,chain,5000,0,0,on,1,0,primary-6-asyncify-chain-5000-0-0-on-1-0-1024,6,1024,5120001,451.09000000000003,5.986328125000134,4.9999999999954525,10.000000000019327,19.99999999999602,160.000000000025,15.8203125,11.350287082400408,451.10000014305115,451,4.999876022338867,4.990000009536743,72.04999923706055,140.54999828338623,27.950000762939453,,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,js-control-5-js-js-direct-1-0-0-na-1-0-10000,5,10000,10000,39.830000162124634,3.9005001306533815,4.999876022338867,9.999990463256836,9.999990463256836,285.0000858306885,33.59,0.2510670338763708,39.84500002861023,40,4.999876022338867,0,67.95000076293945,,27.799999713897705,,,,,,, +primary,asyncify,sync,1,0,0,on,1,0,primary-5-asyncify-sync-1-0-0-on-1-0-100000,5,100000,100000,24.75,0.13539999999999877,0.0,0.0,4.9999999999954525,170.0000000000017,97.358,4.04040404040404,24.75499987602234,25,4.999876022338867,4.2099997997283936,70.65000057220459,140.79999923706055,27.750000953674316,,,,,,, +primary,jspi,chain,10,0,1,on,1,0,primary-4-jspi-chain-10-0-1-on-1-0-10000,4,10000,100001,5.840000000000003,0.15049999999999528,0.0,0.0,4.9999999999954525,5.000000000009663,96.99,17.12345890410958,5.8399999141693115,6,4.999876022338867,2.455000162124634,69.80000019073486,116.90000057220459,28.299999237060547,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-5-jspi-chain-1000-0-0-on-1-0-1024,5,1024,1024001,36.239999999999995,4.580078124999942,4.9999999999954525,10.000000000005116,15.000000000000568,189.99999999999773,27.44140625,28.256098233995587,36.25,36,4.999876022338867,2.5799999237060547,72.00000047683716,115.39999961853027,27.749998569488525,,,,,,, +no-exceptions,asyncify,chain,10000,0,1,off,1,0,no-exceptions-2-asyncify-chain-10000-0-1-off-1-0-1024,2,1024,10240001,367.08,0.16113281249993672,0.0,0.0,4.9999999999954525,5.000000000052296,96.77734375,27.895829247030623,367.085000038147,367,4.999876022338867,4.954999923706055,68.55000019073486,121.60000085830688,28.05000066757202,,,,,,, +chain-trace,jspi,chain,5000,1,0,on,1,0,chain-trace-3-jspi-chain-5000-1-0-on-1-0-1024,3,1024,5120001,169.13,6.24023437499989,4.9999999999954525,10.000000000019327,20.000000000010232,269.9999999999818,14.74609375,30.272577307396677,169.14000010490417,169,4.999876022338867,2.2149999141693115,69.55000162124634,117.95000076293945,27.750000953674316,0.2343384176490826,1.3964821118861437,0.9619123302400112,0.7470706477761269,1.3964842073619366,1.1376971378922462,0.36624952219434237 +chain-trace,jspi,chain,1000,1,0,on,1,0,chain-trace-2-jspi-chain-1000-1-0-on-1-0-1024,2,1024,1024001,37.32499999999999,5.395507812499992,4.9999999999954525,10.000000000005116,15.000000000000568,234.99999999999943,18.45703125,27.434722036168797,37.32499980926514,37,4.999876022338867,2.325000047683716,70.89999914169312,118.59999895095825,28.000001907348633,0.19542514346547468,1.1084016878157854,0.8154280949383974,0.5957027897238731,1.298829447478056,1.0546853300184011,0.32703531906000394 +primary,asyncify,chain,1000,0,1,on,1,0,primary-7-asyncify-chain-1000-0-1-on-1-0-1024,7,1024,1024001,89.61500000000001,0.24902343750000944,0.0,0.0,5.000000000009663,5.000000000023874,95.01953125,11.426669642358979,89.61500000953674,89,4.999876022338867,4.115000009536743,68.75,145.09999990463257,27.950000762939453,,,,,,, +no-exceptions,jspi,chain,1,0,0,off,1,0,no-exceptions-2-jspi-chain-1-0-0-off-1-0-100000,2,100000,100001,430.62,4.167849999999996,4.9999999999954525,9.999999999990905,10.000000000047748,4329.999999999984,31.096,0.23222562816404255,430.625,430,4.999876022338867,2.1550002098083496,71.49999856948853,118.1000018119812,27.999999523162842,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,js-control-6-js-js-direct-1-1-0-na-1-0-10000,6,10000,10000,48.6949999332428,4.77900002002716,4.999876022338867,9.999990463256836,10.000228881835938,450.0000476837158,23.09,0.20535989349438857,48.704999923706055,49,4.999876022338867,0,70.9500002861023,,27.850000858306885,0.22799994945526122,1.058499813079834,0.7025003910064698,0.4629996299743652,1.178999948501587,1.0035000562667846,0.1445002317428589 +primary,jspi,chain,100,0,1,on,1,0,primary-5-jspi-chain-100-0-1-on-1-0-1024,5,1024,102401,4.5049999999999955,0.16113281250001998,0.0,0.0,5.000000000009663,5.000000000009663,96.77734375,22.730521642619337,4.515000104904175,5,4.999876022338867,2.445000171661377,71.84999942779541,115.65000057220459,28.1000018119812,,,,,,, +work-64,asyncify,chain,1000,0,0,on,1,64,work-64-3-asyncify-chain-1000-0-0-on-1-64-1024,3,1024,1024001,96.015,5.85937499999957,4.9999999999954525,10.000000000019327,19.99999999998181,165.00000000000625,14.84375,10.665010675415301,96.0149998664856,96,4.999876022338867,4.070000171661377,73.79999876022339,143.90000104904175,27.55000114440918,,,,,,, +work-64,jspi,chain,1000,0,0,on,1,64,work-64-1-jspi-chain-1000-0-0-on-1-64-1024,1,1024,1024001,38.38000000000001,4.423828124999862,4.9999999999954525,10.000000000005116,15.000000000000568,45.000000000001705,27.1484375,26.680588848358514,38.37999987602234,38,4.999876022338867,2.504999876022339,72.2000002861023,116.80000066757202,28.350000381469727,,,,,,, +chain-trace,jspi,chain,10000,1,0,on,1,0,chain-trace-2-jspi-chain-10000-1-0-on-1-0-1024,2,1024,10240001,367.13,6.181640624999887,4.9999999999954525,10.000000000047748,20.000000000010232,264.99999999998636,15.0390625,27.892030071091984,367.13499999046326,367,4.999876022338867,2.179999828338623,69.75000143051147,119.0499997138977,28.19999933242798,0.42967876419422457,1.4306616503745317,0.7226543966680765,0.620116014033556,1.4550811611115932,1.245121005922556,0.2783276326953493 +work-64,asyncify,chain,100,0,0,on,1,64,work-64-2-asyncify-chain-100-0-0-on-1-64-1024,2,1024,102401,16.185000000000002,5.561523437499813,4.9999999999954525,10.000000000005116,19.99999999999602,180.00000000000682,17.578125,6.326907630522088,16.18499994277954,16,4.999876022338867,4.115000009536743,72.7999997138977,141.95000171661377,28.1000018119812,,,,,,, +primary,jspi,chain,100,0,1,on,1,0,primary-7-jspi-chain-100-0-1-on-1-0-1024,7,1024,102401,3.9350000000000023,0.11718750000000444,0.0,0.0,4.9999999999954525,5.000000000009663,97.65625,26.023125794155003,3.940000057220459,4,4.999876022338867,2.330000162124634,68.35000038146973,117.89999961853027,28.19999933242798,,,,,,, +work-64,asyncify,chain,10000,0,1,on,1,64,work-64-2-asyncify-chain-10000-0-1-on-1-64-1024,2,1024,10240001,886.195,0.23437499999998113,0.0,0.0,4.9999999999954525,5.000000000109139,95.3125,11.555020057662253,886.204999923706,886,4.999876022338867,4.924999952316284,71.19999885559082,140.45000076293945,28.299999237060547,,,,,,, +primary,jspi,chain,10000,0,1,on,1,0,primary-2-jspi-chain-10000-0-1-on-1-0-1024,2,1024,10240001,304.87,0.18554687500013656,0.0,0.0,5.000000000009663,5.000000000052296,96.2890625,33.58809000557614,304.875,305,4.999876022338867,2.3499999046325684,67.14999914169312,116.44999980926514,27.999999523162842,,,,,,, +primary,asyncify,sync,1,0,0,on,1,0,primary-2-asyncify-sync-1-0-0-on-1-0-100000,2,100000,100000,25.394999999999996,0.13554999999999537,0.0,0.0,4.9999999999954525,174.99999999999716,97.342,3.9377830281551494,25.40499997138977,25,4.999876022338867,5.205000162124634,70.54999828338623,139.90000009536743,28.09999942779541,,,,,,, +work-64,asyncify,chain,100,0,1,on,1,64,work-64-3-asyncify-chain-100-0-1-on-1-64-1024,3,1024,102401,10.805000000000007,0.24902343749992617,0.0,0.0,5.000000000009663,10.000000000005116,95.1171875,9.477186487737153,10.805000066757202,11,4.999876022338867,4.085000038146973,72.39999771118164,141.70000076293945,27.44999885559082,,,,,,, +no-exceptions,asyncify,chain,10000,0,0,off,1,0,no-exceptions-3-asyncify-chain-10000-0-0-off-1-0-1024,3,1024,10240001,269.55,5.473632812500323,4.9999999999954525,10.000000000019327,19.99999999998181,180.00000000000682,19.3359375,37.98924503802634,269.5549998283386,269,4.999876022338867,4.015000104904175,72.44999885559082,123.65000009536743,28.70000123977661,,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,js-control-2-js-js-direct-1-0-0-na-1-0-10000,2,10000,10000,39.38000011444092,3.849999761581421,4.999876022338867,9.999990463256836,9.999990463256836,265.0001049041748,34.15,0.2539360073879972,39.390000104904175,39,4.999876022338867,0,71.80000066757202,,28.19999933242798,,,,,,, +chain-trace,asyncify,chain,10000,1,0,on,1,0,chain-trace-1-asyncify-chain-10000-1-0-on-1-0-1024,1,1024,10240001,879.465,8.261718749999952,4.9999999999954525,14.999999999986358,29.999999999972715,350.00000000002274,6.8359375,11.64344345710176,879.4700000286102,879,4.999876022338867,4.110000133514404,68.80000114440918,151.95000171661377,28.19999933242798,0.46879915520507687,1.6552733723074198,0.8593776728957891,0.6640604697167873,2.3339821491390467,1.0498033370822668,1.2304225936535658 +primary,asyncify,chain,10,0,1,on,1,0,primary-7-asyncify-chain-10-0-1-on-1-0-10000,7,10000,100001,12.86,0.22399999999998385,0.0,0.0,5.000000000009663,9.999999999990905,95.53,7.7761275272161745,12.859999895095825,13,4.999876022338867,4.875,67.85000085830688,140.19999980926514,27.850000858306885,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-3-jspi-chain-1000-0-1-on-1-0-1024,3,1024,1024001,32.03,0.15625000000006606,0.0,0.0,5.000000000009663,5.000000000009663,96.875,31.970059319388074,32.02999997138977,32,4.999876022338867,2.120000123977661,69.0499997138977,118.4500002861023,28.15000057220459,,,,,,, +work-64,asyncify,chain,100,0,1,on,1,64,work-64-2-asyncify-chain-100-0-1-on-1-64-1024,2,1024,102401,10.819999999999993,0.234374999999995,0.0,0.0,5.000000000009663,15.000000000000568,95.5078125,9.464048059149729,10.825000047683716,11,4.999876022338867,4.144999980926514,69.90000009536743,140.85000038146973,27.850000858306885,,,,,,, +work-64,jspi,chain,5000,0,0,on,1,64,work-64-1-jspi-chain-5000-0-0-on-1-64-1024,1,1024,5120001,171.72,4.838867187500026,4.9999999999954525,10.000000000005116,10.000000000019327,199.99999999998863,22.4609375,29.81598532494759,171.72500014305115,172,4.999876022338867,2.259999990463257,68.94999980926514,117.04999923706055,28.350000381469727,,,,,,, +chain-trace,asyncify,chain,10,1,0,on,1,0,chain-trace-2-asyncify-chain-10-1-0-on-1-0-1024,2,1024,10241,8.379999999999995,6.352539062500079,4.9999999999954525,10.000000000005116,19.99999999999602,239.99999999999488,12.98828125,1.2220763723150365,8.379999876022339,9,4.999876022338867,4.93999981880188,72.34999895095825,143.19999933242798,27.999999523162842,0.16611092723903265,0.9619153570383787,0.854492885991931,0.5126944743096828,1.9335928373038769,1.1376955080777407,0.7860370725394361 +no-exceptions,jspi,chain,10,0,1,off,1,0,no-exceptions-1-jspi-chain-10-0-1-off-1-0-10000,1,10000,100001,5.484999999999999,0.13949999999998824,0.0,0.0,4.9999999999954525,5.000000000009663,97.21,18.231722880583412,5.484999895095825,6,4.999876022338867,2.3350000381469727,70.59999942779541,117.94999837875366,28.05000066757202,,,,,,, +chain-trace,jspi,chain,1000,1,0,on,1,0,chain-trace-3-jspi-chain-1000-1-0-on-1-0-1024,3,1024,1024001,37.425,5.566406249999795,4.9999999999954525,10.000000000005116,15.000000000000568,230.00000000000398,17.28515625,27.361416165664664,37.4300000667572,38,4.999876022338867,2.1599998474121094,72.65000104904175,117.35000133514404,27.54999876022339,0.2635683678090389,1.274412963539362,0.6640623323619366,0.5615209229290485,1.5283196698874235,0.9619153570383787,0.3126066364346064 +work-64,jspi,chain,1,0,0,on,1,64,work-64-1-jspi-chain-1-0-0-on-1-64-100000,1,100000,100001,432.905,4.193799999999999,4.9999999999954525,9.999999999990905,10.000000000047748,4280.000000000001,30.632,0.23099987295134036,432.9099998474121,433,4.999876022338867,2.2250001430511475,72.40000009536743,118.55000019073486,27.900002002716064,,,,,,, +ordinary-page,asyncify,direct,1,1,0,on,0,0,ordinary-page-2-asyncify-direct-1-1-0-on-0-0-10000,2,10000,10000,56.7,5.559999999999997,0,99.99999999999432,100.00000000000853,400.0000000000057,94.6,0.1763668430335097,56.700000047683716,56,99.99990463256836,4.1000001430511475,68.99999856948853,135,27.999999523162842,0.20990300178527263,1.1900000333786012,0.7399999380111695,0.3999999284744263,1.570000123977661,0.9899999856948852,0.46009698867798077 +primary,asyncify,chain,10000,0,0,on,1,0,primary-7-asyncify-chain-10000-0-0-on-1-0-1024,7,1024,10240001,887.9849999999999,7.065429687499209,4.9999999999954525,10.000000000047748,24.999999999977263,230.0000000000182,10.25390625,11.531727450351076,887.9950001239777,888,4.999876022338867,4.170000076293945,73.15000057220459,141.8500018119812,28.949999809265137,,,,,,, +work-64,jspi,chain,100,0,0,on,1,64,work-64-3-jspi-chain-100-0-0-on-1-64-1024,3,1024,102401,8.53500000000001,4.648437500000186,4.9999999999954525,10.000000000005116,10.000000000005116,209.99999999999375,25.87890625,11.997773872290553,8.53499984741211,9,4.999876022338867,2.2049999237060547,69.44999933242798,116.34999990463257,28.1000018119812,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,js-control-4-js-js-direct-1-1-0-na-1-0-10000,4,10000,10000,49.22000002861023,4.840499925613403,4.999876022338867,9.999990463256836,10.000228881835938,470.0000286102295,22.52,0.2031694431976285,49.230000019073486,49,4.999876022338867,0,71.05000019073486,,27.650001049041748,0.27949979305267336,1.06850004196167,0.6765003681182862,0.4545003890991211,1.192999815940857,1.015999174118042,0.15250034332275392 +primary,jspi,clock,1,0,0,on,1,0,primary-1-jspi-clock-1-0-0-on-1-0-100000,1,100000,100000,21.580000000000005,0.10910000000000317,0.0,0.0,4.9999999999954525,54.99999999999261,97.843,4.633920296570898,21.585000038146973,21,4.999876022338867,2.385000228881836,70.2999997138977,118.39999914169312,27.999999523162842,,,,,,, +work-64,asyncify,chain,1,0,1,on,1,64,work-64-2-asyncify-chain-1-0-1-on-1-64-100000,2,100000,100001,33.614999999999995,0.211099999999999,0.0,0.0,5.000000000009663,30.000000000001137,95.797,2.9748921612375434,33.61999988555908,33,4.999876022338867,5.229999780654907,68.80000114440918,145.15000104904175,27.55000114440918,,,,,,, +primary,jspi,direct,1,0,0,on,1,0,primary-6-jspi-direct-1-0-0-on-1-0-10000,6,10000,10000,41.44,4.015999999999987,4.9999999999954525,10.000000000005116,10.000000000005116,250.0,31.68,0.24131274131274133,41.4449999332428,41,4.999876022338867,2.330000162124634,68.04999828338623,118.59999895095825,27.950000762939453,,,,,,, +primary,jspi,chain,1000,0,1,on,1,0,primary-5-jspi-chain-1000-0-1-on-1-0-1024,5,1024,1024001,31.625,0.11718749999997669,0.0,0.0,4.9999999999954525,5.000000000009663,97.65625,32.37947826086956,31.625,32,4.999876022338867,2.1649999618530273,67.14999914169312,116.44999980926514,27.950000762939453,,,,,,, +no-exceptions,asyncify,chain,1000,0,0,off,1,0,no-exceptions-1-asyncify-chain-1000-0-0-off-1-0-1024,1,1024,1024001,33.035,4.892578125000102,4.9999999999954525,10.000000000005116,10.000000000005116,174.99999999999716,21.77734375,30.997457242318756,33.03999996185303,33,4.999876022338867,4.0350000858306885,70.9500002861023,120.65000057220459,28.19999933242798,,,,,,, +primary,jspi,chain,10000,0,1,on,1,0,primary-6-jspi-chain-10000-0-1-on-1-0-1024,6,1024,10240001,371.34,0.23437499999995337,0.0,0.0,4.9999999999954525,5.000000000052296,95.3125,27.57580923143211,371.34500002861023,371,4.999876022338867,2.315000057220459,69.84999895095825,115.75000047683716,28.349997997283936,,,,,,, +primary,jspi,chain,100,0,1,on,1,0,primary-2-jspi-chain-100-0-1-on-1-0-1024,2,1024,102401,4.015000000000001,0.1513671874999456,0.0,0.0,4.9999999999954525,5.000000000009663,96.97265625,25.504607721046074,4.014999866485596,4,4.999876022338867,2.200000047683716,71.60000085830688,116.60000085830688,28.399999141693115,,,,,,, +no-exceptions,jspi,chain,1000,0,0,off,1,0,no-exceptions-2-jspi-chain-1000-0-0-off-1-0-1024,2,1024,1024001,31.97500000000001,4.438476562499627,4.9999999999954525,10.000000000005116,10.000000000005116,195.0000000000074,27.9296875,32.02505082095386,31.980000019073486,32,4.999876022338867,2.1700000762939453,69.75000143051147,120.35000085830688,28.15000057220459,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,primary-5-jspi-chain-100-0-0-on-1-0-1024,5,1024,102401,8.36,4.497070312500198,4.9999999999954525,10.000000000005116,10.000000000005116,170.0000000000017,25.390625,12.248923444976077,8.359999895095825,9,4.999876022338867,2.619999885559082,72.7999997138977,116.40000104904175,28.19999933242798,,,,,,, +no-exceptions,asyncify,chain,100,0,1,off,1,0,no-exceptions-1-asyncify-chain-100-0-1-off-1-0-1024,1,1024,102401,4.299999999999997,0.10742187499997169,0.0,0.0,4.9999999999954525,5.000000000009663,97.8515625,23.814186046511644,4.305000066757202,4,4.999876022338867,5.069999933242798,69.45000171661377,124.90000009536743,27.59999990463257,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-5-jspi-direct-1-1-0-on-1-0-10000,5,10000,10000,49.81999999999999,4.860999999999988,4.9999999999954525,10.000000000005116,10.000000000005116,390.00000000000057,22.23,0.2007226013649137,49.83500003814697,50,4.999876022338867,2.1550002098083496,68.79999876022339,118.35000038146973,28.09999942779541,0.18688561439514687,1.0679997205734253,0.7054998874664307,0.4700001239776611,1.1914995670318604,1.0555004358291626,0.18361465072630095 +primary,jspi,clock,1,0,0,on,1,0,primary-2-jspi-clock-1-0-0-on-1-0-100000,2,100000,100000,21.019999999999996,0.10365000000000066,0.0,0.0,4.9999999999954525,35.000000000003695,97.938,4.757373929590867,21.019999980926514,21,4.999876022338867,2.444999933242798,67.99999952316284,117.95000076293945,27.950000762939453,,,,,,, +primary,jspi,chain,5000,0,1,on,1,0,primary-1-jspi-chain-5000-0-1-on-1-0-1024,1,1024,5120001,155.67499999999998,0.18066406250000222,0.0,0.0,4.9999999999954525,5.000000000023874,96.38671875,32.88903806006103,155.67999982833862,156,4.999876022338867,2.195000171661377,70.09999990463257,118.1499981880188,28.350000381469727,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,js-control-1-js-js-direct-1-1-0-na-1-0-10000,1,10000,10000,49.36500000953674,4.84699969291687,4.999876022338867,9.999990463256836,10.000228881835938,445.00017166137695,22.95,0.20257267290728484,49.38000011444092,50,4.999876022338867,0,71.29999876022339,,28.15000057220459,0.1830000400543213,1.079000186920166,0.7420003175735473,0.4755001783370972,1.1854997158050538,1.0174992084503174,0.16450004577636718 +work-64,asyncify,chain,10000,0,1,on,1,64,work-64-1-asyncify-chain-10000-0-1-on-1-64-1024,1,1024,10240001,876.145,0.23925781249992117,0.0,0.0,4.9999999999954525,5.000000000052296,95.21484375,11.687564273036998,876.1549999713898,876,4.999876022338867,4.125,72.00000047683716,143.84999990463257,28.15000057220459,,,,,,, +primary,asyncify,chain,10000,0,1,on,1,0,primary-2-asyncify-chain-10000-0-1-on-1-0-1024,2,1024,10240001,929.575,0.2441406249999306,0.0,0.0,4.9999999999954525,9.999999999990905,95.21484375,11.015787860043567,929.5849997997284,930,4.999876022338867,4.120000123977661,72.54999876022339,139.94999885559082,27.999999523162842,,,,,,, +primary,jspi,chain,10,0,0,on,1,0,primary-7-jspi-chain-10-0-0-on-1-0-10000,7,10000,100001,46.099999999999994,4.122999999999971,4.9999999999954525,10.000000000005116,10.000000000005116,265.00000000000057,30.88,2.1692190889370937,46.09999990463257,46,4.999876022338867,2.109999895095825,70.09999990463257,118.39999914169312,28.1000018119812,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,primary-7-asyncify-direct-1-1-0-on-1-0-10000,7,10000,10000,57.11,5.549999999999988,4.9999999999954525,10.000000000005116,10.000000000005116,399.9999999999915,15.43,0.17510068289266328,57.11999988555908,57,4.999876022338867,4.125,70.39999961853027,139.0499997138977,29.149999618530273,0.2690863084792937,1.1179997205734253,0.7484992504119873,0.48000011444091795,1.4989998579025268,1.0195008754730224,0.415913872718815 +no-exceptions,jspi,chain,10,0,0,off,1,0,no-exceptions-1-jspi-chain-10-0-0-off-1-0-10000,1,10000,100001,45.78,4.167500000000021,4.9999999999954525,10.000000000005116,10.000000000005116,269.999999999996,30.49,2.1843818261249455,45.78499984741211,45,4.999876022338867,2.5400002002716064,70.09999990463257,117.10000038146973,27.899999618530273,,,,,,, +chain-trace,jspi,chain,10,1,0,on,1,0,chain-trace-3-jspi-chain-10-1-0-on-1-0-1024,3,1024,10241,6.045000000000002,5.224609375000008,4.9999999999954525,10.000000000005116,10.000000000005116,230.00000000000398,18.359375,1.6941273779983452,6.049999952316284,6,4.999876022338867,2.505000114440918,71.44999980926514,119.0499997138977,27.799999713897705,0.3661139216274145,1.1621108278632164,0.659179175272584,0.571289099752903,1.2402348220348358,1.0205083526670933,0.20517317578196137 +primary,jspi,clock,1,0,0,on,1,0,primary-6-jspi-clock-1-0-0-on-1-0-100000,6,100000,100000,21.660000000000004,0.10725000000000193,0.0,0.0,4.9999999999954525,40.00000000000625,97.862,4.616805170821791,21.670000076293945,22,4.999876022338867,2.3949999809265137,72.30000019073486,120.39999961853027,27.750000953674316,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,primary-5-jspi-chain-5000-0-0-on-1-0-1024,5,1024,5120001,162.8,5.009765624999399,4.9999999999954525,10.000000000005116,15.000000000000568,229.99999999998977,23.33984375,31.44963759213759,162.81000018119812,162,4.999876022338867,2.2200000286102295,69.80000019073486,120.35000085830688,28.949999809265137,,,,,,, +no-exceptions,jspi,chain,1,0,1,off,1,0,no-exceptions-1-jspi-chain-1-0-1-off-1-0-100000,1,100000,100001,24.32,0.13474999999999626,0.0,0.0,4.9999999999954525,15.000000000000568,97.309,4.11188322368421,24.320000171661377,24,4.999876022338867,2.194999933242798,71.19999885559082,116.20000123977661,28.05000066757202,,,,,,, +no-exceptions,asyncify,direct,1,0,0,off,1,0,no-exceptions-2-asyncify-direct-1-0-0-off-1-0-10000,2,10000,10000,45.5,4.4290000000000065,4.9999999999954525,10.000000000005116,10.000000000005116,280.00000000000114,26.99,0.21978021978021978,45.519999980926514,46,4.999876022338867,3.9850001335144043,71.25,123.69999885559082,27.900002002716064,,,,,,, +work-64,asyncify,chain,1000,0,1,on,1,64,work-64-2-asyncify-chain-1000-0-1-on-1-64-1024,2,1024,1024001,90.615,0.28320312499997835,0.0,4.9999999999954525,5.000000000009663,5.000000000023874,94.3359375,11.30056833857529,90.625,91,4.999876022338867,4.215000152587891,69.54999923706055,143.54999780654907,27.699999809265137,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,primary-4-asyncify-clock-1-0-0-on-1-0-100000,4,100000,100000,23.355000000000004,0.11520000000000195,0.0,0.0,4.9999999999954525,10.000000000005116,97.7,4.281738385784628,23.360000133514404,23,4.999876022338867,4.169999837875366,70.69999933242798,142.5,28.899998664855957,,,,,,, +chain-trace,jspi,chain,5000,1,0,on,1,0,chain-trace-1-jspi-chain-5000-1-0-on-1-0-1024,1,1024,5120001,161.51,5.581054687500461,4.9999999999954525,10.000000000019327,15.00000000001478,260.0000000000193,18.65234375,31.700829669989474,161.50999999046326,162,4.999876022338867,2.674999952316284,72.1999979019165,120,27.799999713897705,0.16122518107353212,1.166992587968707,0.7617201190441847,0.5322271026670933,1.699219224974513,1.0156247299164534,0.24404574185597772 +chain-trace,jspi,chain,10000,1,0,on,1,0,chain-trace-1-jspi-chain-10000-1-0-on-1-0-1024,1,1024,10240001,314.505,6.269531249999682,4.9999999999954525,10.000000000019327,15.000000000043201,345.0000000000273,14.2578125,32.559103988807806,314.50999999046326,314,4.999876022338867,2.384999990463257,67.59999990463257,117.40000009536743,27.799999713897705,0.1465434581039704,1.308593200519681,1.2792970519512892,0.6298830267041922,1.5087889041751623,1.118162414059043,0.2782631944863445 +primary,asyncify,direct,1,0,0,on,1,0,primary-7-asyncify-direct-1-0-0-on-1-0-10000,7,10000,10000,48.08,4.650000000000015,4.9999999999954525,10.000000000005116,10.000000000005116,230.00000000000398,23.59,0.2079866888519135,48.09500002861023,48,4.999876022338867,4.099999904632568,72.30000019073486,141.8499994277954,27.899999618530273,,,,,,, +no-exceptions,asyncify,chain,1000,0,0,off,1,0,no-exceptions-2-asyncify-chain-1000-0-0-off-1-0-1024,2,1024,1024001,32.455,4.941406249999572,4.9999999999954525,10.000000000005116,15.000000000000568,179.9999999999926,21.38671875,31.551409644122632,32.455000162124634,32,4.999876022338867,4.055000066757202,69.6500015258789,123.65000009536743,27.850000858306885,,,,,,, +no-exceptions,jspi,direct,1,0,0,off,1,0,no-exceptions-3-jspi-direct-1-0-0-off-1-0-10000,3,10000,10000,41.37,4.028000000000001,4.9999999999954525,10.000000000005116,10.000000000005116,275.0000000000057,31.64,0.24172105390379503,41.375,41,4.999876022338867,2.494999885559082,68.94999980926514,119.0499997138977,27.999999523162842,,,,,,, +no-exceptions,asyncify,direct,1,1,0,off,1,0,no-exceptions-3-asyncify-direct-1-1-0-off-1-0-10000,3,10000,10000,54.33,5.3144999999999865,4.9999999999954525,10.000000000005116,10.000000000005116,364.9999999999949,18.03,0.18406037180195106,54.34000015258789,54,4.999876022338867,4.0350000858306885,71.29999876022339,123.04999828338623,28.399999141693115,0.23998039245606578,1.1000003814697266,0.6694999217987061,0.49100029468536377,1.4439990043640136,1.0000000953674317,0.37001990985867933 +primary,asyncify,direct,1,1,0,on,1,0,primary-2-asyncify-direct-1-1-0-on-1-0-10000,2,10000,10000,57.035,5.567500000000001,4.9999999999954525,10.000000000005116,10.000000000005116,394.999999999996,15.74,0.17533093714385906,57.045000076293945,57,4.999876022338867,4.120000123977661,69.80000019073486,139.94999885559082,28.1499981880188,0.23061519145964268,1.075500202178955,0.7059997081756592,0.5160003185272217,1.4979995727539062,1.037499761581421,0.5038852453231953 +no-exceptions,asyncify,chain,5000,0,0,off,1,0,no-exceptions-3-asyncify-chain-5000-0-0-off-1-0-1024,3,1024,5120001,139.115,5.083007812500082,4.9999999999954525,10.000000000005116,15.000000000000568,165.00000000000625,22.0703125,36.80409014125004,139.11500000953674,140,4.999876022338867,4.894999980926514,68.30000162124634,122.85000085830688,28.550000190734863,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,primary-3-asyncify-chain-5000-0-0-on-1-0-1024,3,1024,5120001,448.45000000000005,6.455078125000069,4.9999999999954525,10.000000000047748,24.999999999991473,189.99999999999773,12.6953125,11.417105585907011,448.460000038147,448,4.999876022338867,4.924999952316284,69.0499997138977,144.49999809265137,28.20000171661377,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,primary-1-asyncify-chain-1000-0-0-on-1-0-1024,1,1024,1024001,95.395,5.610351562499519,4.9999999999954525,10.000000000005116,15.000000000000568,144.99999999999602,16.89453125,10.734325698411867,95.40000009536743,96,4.999876022338867,5.025000095367432,72.95000076293945,139.9500012397766,27.999999523162842,,,,,,, +no-exceptions,jspi,chain,100,0,1,off,1,0,no-exceptions-1-jspi-chain-100-0-1-off-1-0-1024,1,1024,102401,3.4199999999999946,0.14648437499996392,0.0,0.0,4.9999999999954525,5.000000000009663,97.0703125,29.941812865497123,3.424999952316284,3,4.999876022338867,2.2249999046325684,69.85000133514404,116.90000057220459,28.65000009536743,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-2-asyncify-chain-1-0-1-on-1-0-100000,2,100000,100001,34.45,0.21845000000000156,0.0,0.0,5.000000000009663,34.99999999999659,95.655,2.9027866473149486,34.455000162124634,34,4.999876022338867,4.039999961853027,69.3999981880188,143.59999895095825,28.599998950958252,,,,,,, +primary,asyncify,chain,5000,0,1,on,1,0,primary-4-asyncify-chain-5000-0-1-on-1-0-1024,4,1024,5120001,454.72,0.28320312499997835,0.0,4.9999999999954525,4.9999999999954525,5.000000000052296,94.3359375,11.25967848346235,454.72000002861023,455,4.999876022338867,4.055000066757202,71.5999984741211,141.5499997138977,28.450000286102295,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,primary-1-asyncify-chain-5000-0-0-on-1-0-1024,1,1024,5120001,451.11499999999995,6.5624999999991935,4.9999999999954525,10.000000000047748,19.99999999999602,185.00000000000227,11.62109375,11.349658069450141,451.1199998855591,451,4.999876022338867,4.889999866485596,68.89999866485596,141.60000085830688,30.400002002716064,,,,,,, +chain-trace,asyncify,chain,100,1,0,on,1,0,chain-trace-3-asyncify-chain-100-1-0-on-1-0-1024,3,1024,102401,17.235,6.645507812499965,4.9999999999954525,10.000000000005116,19.99999999999602,250.0,10.7421875,5.941456338845373,17.235000133514404,17,4.999876022338867,4.099999904632568,69.85000133514404,140.15000104904175,27.54999876022339,0.385694913566062,1.1132813524454832,0.8837892673909664,0.5517567042261362,1.7822273075580597,1.1474634520709515,0.781294815242306 +work-64,jspi,chain,10000,0,1,on,1,64,work-64-3-jspi-chain-10000-0-1-on-1-64-1024,3,1024,10240001,332.58,0.1562499999999689,0.0,0.0,4.9999999999954525,5.000000000023874,96.875,30.789587467676952,332.585000038147,333,4.999876022338867,2.3350000381469727,72.30000019073486,118.05000066757202,27.750000953674316,,,,,,, +work-64,jspi,chain,10,0,1,on,1,64,work-64-2-jspi-chain-10-0-1-on-1-64-10000,2,10000,100001,6.099999999999994,0.13500000000000084,0.0,0.0,4.9999999999954525,5.000000000009663,97.3,16.393606557377066,6.1000001430511475,6,4.999876022338867,2.4600000381469727,69.75000143051147,116.84999942779541,28.1499981880188,,,,,,, +work-64,asyncify,chain,10,0,0,on,1,64,work-64-1-asyncify-chain-10-0-0-on-1-64-10000,1,10000,100001,61.46499999999999,5.025499999999984,4.9999999999954525,10.000000000005116,10.000000000019327,240.0000000000091,20.32,1.626958431627756,61.47500014305115,62,4.999876022338867,4.105000019073486,73.04999828338623,145.35000085830688,27.899999618530273,,,,,,, +primary,asyncify,chain,1000,0,1,on,1,0,primary-2-asyncify-chain-1000-0-1-on-1-0-1024,2,1024,1024001,90.255,0.2685546875001027,0.0,4.9999999999954525,5.000000000009663,5.000000000023874,94.62890625,11.345642900670324,90.25999999046326,90,4.999876022338867,4.110000133514404,70.14999866485596,142.59999990463257,28.70000123977661,,,,,,, +primary,asyncify,chain,10000,0,0,on,1,0,primary-5-asyncify-chain-10000-0-0-on-1-0-1024,5,1024,10240001,933.4000000000001,6.801757812500226,4.9999999999954525,10.000000000047748,25.000000000005684,204.99999999998408,11.9140625,10.970646025283909,933.4100000858307,933,4.999876022338867,4.919999837875366,68.59999895095825,138.84999990463257,28.1499981880188,,,,,,, +no-exceptions,asyncify,chain,1,0,1,off,1,0,no-exceptions-2-asyncify-chain-1-0-1-off-1-0-100000,2,100000,100001,25.125,0.1397499999999991,0.0,0.0,4.9999999999954525,109.99999999999943,97.24,3.980139303482587,25.134999990463257,25,4.999876022338867,4.099999904632568,67.74999856948853,122.14999914169312,27.899999618530273,,,,,,, +primary,jspi,chain,100,0,0,on,1,0,primary-1-jspi-chain-100-0-0-on-1-0-1024,1,1024,102401,8.225000000000009,4.418945312500075,4.9999999999954525,10.000000000005116,10.000000000005116,200.00000000000284,27.5390625,12.449969604863208,8.225000143051147,8,4.999876022338867,2.4600000381469727,71.49999856948853,119.24999952316284,27.949998378753662,,,,,,, +no-exceptions,asyncify,chain,10,0,1,off,1,0,no-exceptions-3-asyncify-chain-10-0-1-off-1-0-10000,3,10000,100001,6.445000000000007,0.13650000000002507,0.0,0.0,5.000000000009663,5.000000000009663,97.27,15.516058960434428,6.444999933242798,6,4.999876022338867,4.074999809265137,71.94999933242798,123.59999895095825,28.19999933242798,,,,,,, +primary,asyncify,chain,100,0,1,on,1,0,primary-6-asyncify-chain-100-0-1-on-1-0-1024,6,1024,102401,10.939999999999998,0.23437499999998113,0.0,0.0,5.000000000009663,19.99999999999602,95.60546875,9.360237659963438,10.940000057220459,11,4.999876022338867,4.015000104904175,68.99999856948853,142.2000002861023,28.65000009536743,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-3-jspi-chain-1000-0-0-on-1-0-1024,3,1024,1024001,37.17,4.682617187499891,4.9999999999954525,10.000000000005116,15.000000000000568,189.99999999999773,26.07421875,27.549125638956145,37.170000076293945,37,4.999876022338867,2.4749999046325684,70.65000057220459,116.40000104904175,27.949998378753662,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,primary-6-asyncify-direct-1-1-0-on-1-0-10000,6,10000,10000,58.52499999999999,5.708500000000012,4.9999999999954525,10.000000000005116,15.000000000000568,390.00000000000057,15.27,0.1708671507902606,58.53999996185303,58,4.999876022338867,4.0899999141693115,71.05000019073486,143.05000066757202,28.15000057220459,0.3604044847488808,1.1524996519088746,0.6695004940032959,0.510500168800354,1.49550039768219,1.0454996347427368,0.4745951681136802 +js-control,js,js-direct,1,0,0,na,1,0,js-control-7-js-js-direct-1-0-0-na-1-0-10000,7,10000,10000,40.44000005722046,3.9509997844696043,4.999876022338867,9.999990463256836,9.999990463256836,269.9999809265137,32.57,0.24727992052053732,40.454999923706055,40,4.999876022338867,0,69.55000162124634,,28.19999933242798,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-3-asyncify-chain-1-0-1-on-1-0-100000,3,100000,100001,34.56,0.21830000000000083,0.0,0.0,5.000000000009663,149.99999999999147,95.703,2.8935474537037034,34.55999994277954,35,4.999876022338867,4.134999990463257,69.10000085830688,147.35000133514404,27.849998474121094,,,,,,, +primary,asyncify,chain,10,0,1,on,1,0,primary-3-asyncify-chain-10-0-1-on-1-0-10000,3,10000,100001,13.14500000000001,0.24949999999999192,0.0,0.0,5.000000000009663,135.00000000000512,95.28,7.607531380753132,13.144999980926514,13,4.999876022338867,4.1600000858306885,71.34999990463257,141.64999961853027,28.350000381469727,,,,,,, +work-64,jspi,chain,10,0,0,on,1,64,work-64-3-jspi-chain-10-0-0-on-1-64-10000,3,10000,100001,46.605000000000004,4.15600000000001,4.9999999999954525,10.000000000005116,10.000000000005116,285.0000000000108,30.54,2.145713979186782,46.605000019073486,47,4.999876022338867,2.4100000858306885,72.5,118.09999942779541,28.599998950958252,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-2-asyncify-chain-1-0-0-on-1-0-100000,2,100000,100001,499.33000000000004,4.849999999999997,4.9999999999954525,9.999999999990905,10.000000000047748,4364.999999999981,22.662,0.20027036228546252,499.3399999141693,499,4.999876022338867,4.930000066757202,70.09999990463257,143.35000038146973,27.650001049041748,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,primary-6-jspi-chain-5000-0-0-on-1-0-1024,6,1024,5120001,164.86,4.790039062499737,4.9999999999954525,10.000000000005116,15.000000000000568,255.00000000002387,24.90234375,31.056660196530384,164.86999988555908,165,4.999876022338867,2.6050000190734863,69.64999914169312,117.7999997138977,28.65000009536743,,,,,,, +no-exceptions,asyncify,chain,1000,0,1,off,1,0,no-exceptions-2-asyncify-chain-1000-0-1-off-1-0-1024,2,1024,1024001,38.265,0.11230468749989786,0.0,0.0,4.9999999999954525,4.9999999999954525,97.75390625,26.76077355285509,38.265000104904175,39,4.999876022338867,4.015000104904175,69.34999942779541,126.25,27.750000953674316,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,primary-7-asyncify-clock-1-0-0-on-1-0-100000,7,100000,100000,23.385000000000005,0.11460000000000051,0.0,0.0,4.9999999999954525,15.000000000000568,97.715,4.276245456489201,23.390000104904175,23,4.999876022338867,4.889999866485596,69.60000038146973,140.09999990463257,28.350000381469727,,,,,,, +no-exceptions,jspi,chain,10000,0,1,off,1,0,no-exceptions-1-jspi-chain-10000-0-1-off-1-0-1024,1,1024,10240001,270.515,0.10742187499994393,0.0,0.0,4.9999999999954525,5.000000000023874,97.8515625,37.85372715006562,270.5199999809265,271,4.999876022338867,2.450000047683716,68.05000066757202,117.85000085830688,28.250000476837158,,,,,,, +chain-trace,asyncify,chain,10,1,0,on,1,0,chain-trace-1-asyncify-chain-10-1-0-on-1-0-1024,1,1024,10241,8.379999999999995,6.401367187499993,4.9999999999954525,10.000000000005116,19.99999999999602,230.00000000000398,11.23046875,1.2220763723150365,8.390000104904175,8,4.999876022338867,4.1499998569488525,69.40000057220459,143.1500005722046,28.350000381469727,0.5957703106104495,1.132812350988388,0.6494135595858097,0.5419922526925802,1.5820316039025784,1.0449199471622705,0.8544271625579164 +primary,asyncify,clock,1,0,0,on,1,0,primary-1-asyncify-clock-1-0-0-on-1-0-100000,1,100000,100000,22.620000000000005,0.11079999999999757,0.0,0.0,4.9999999999954525,25.000000000005684,97.79,4.420866489832005,22.62999987602234,22,4.999876022338867,4.190000057220459,68.60000133514404,142.5499987602234,27.999999523162842,,,,,,, +work-64,jspi,chain,10000,0,1,on,1,64,work-64-1-jspi-chain-10000-0-1-on-1-64-1024,1,1024,10240001,334.385,0.1416015625000655,0.0,0.0,4.9999999999954525,5.000000000052296,97.16796875,30.623386216486985,334.38499999046326,335,4.999876022338867,2.4749999046325684,72.75000095367432,117.00000047683716,28.1499981880188,,,,,,, +primary,jspi,chain,10,0,0,on,1,0,primary-3-jspi-chain-10-0-0-on-1-0-10000,3,10000,100001,46.69,4.149500000000027,4.9999999999954525,10.000000000005116,10.000000000005116,274.9999999999915,30.49,2.141807667594774,46.68999981880188,46,4.999876022338867,2.259999990463257,72.59999990463257,116.40000104904175,28.05000066757202,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,primary-3-asyncify-clock-1-0-0-on-1-0-100000,3,100000,100000,23.295,0.11575000000000472,0.0,0.0,4.9999999999954525,45.000000000001705,97.712,4.2927666881304996,23.299999952316284,23,4.999876022338867,4.090000152587891,67.89999961853027,141.80000066757202,28.15000057220459,,,,,,, +primary,asyncify,chain,1000,0,1,on,1,0,primary-1-asyncify-chain-1000-0-1-on-1-0-1024,1,1024,1024001,88.305,0.24414062499998612,0.0,0.0,5.000000000009663,5.000000000023874,95.1171875,11.596183681558236,88.30999994277954,88,4.999876022338867,4.120000123977661,69.50000047683716,149.60000038146973,27.899999618530273,,,,,,, +work-64,asyncify,chain,5000,0,0,on,1,64,work-64-2-asyncify-chain-5000-0-0-on-1-64-1024,2,1024,5120001,443.08000000000004,6.3916015624997105,4.9999999999954525,10.000000000047748,19.99999999999602,195.0000000000216,13.28125,11.555477566128014,443.0899999141693,443,4.999876022338867,4.079999923706055,67.89999961853027,143.7999987602234,28.499999046325684,,,,,,, +primary,jspi,chain,5000,0,1,on,1,0,primary-3-jspi-chain-5000-0-1-on-1-0-1024,3,1024,5120001,156.855,0.14160156249992673,0.0,0.0,4.9999999999954525,5.000000000009663,97.16796875,32.64161805489147,156.85999989509583,156,4.999876022338867,2.2300000190734863,73.25000047683716,118.49999904632568,28.15000057220459,,,,,,, +primary,jspi,chain,1,0,0,on,1,0,primary-3-jspi-chain-1-0-0-on-1-0-100000,3,100000,100001,434.955,4.216200000000001,4.9999999999954525,9.999999999990905,10.000000000047748,4394.999999999982,30.378,0.22991114023289766,434.9649999141693,435,4.999876022338867,2.4549999237060547,73.94999980926514,120.55000066757202,28.350000381469727,,,,,,, +primary,jspi,chain,1,0,1,on,1,0,primary-3-jspi-chain-1-0-1-on-1-0-100000,3,100000,100001,25.10499999999999,0.14224999999999938,0.0,0.0,4.9999999999954525,109.99999999999943,97.195,3.983310097590123,25.104999780654907,25,4.999876022338867,2.2100000381469727,69.80000019073486,119.74999904632568,27.949998378753662,,,,,,, +primary,jspi,chain,1,0,1,on,1,0,primary-2-jspi-chain-1-0-1-on-1-0-100000,2,100000,100001,25.875,0.14330000000000012,0.0,0.0,4.9999999999954525,84.99999999999375,97.162,3.8647729468599032,25.875,26,4.999876022338867,2.3950002193450928,68.75,120.80000162124634,28.09999942779541,,,,,,, +no-exceptions,asyncify,chain,5000,0,1,off,1,0,no-exceptions-2-asyncify-chain-5000-0-1-off-1-0-1024,2,1024,5120001,188.155,0.1220703125,0.0,0.0,4.9999999999954525,5.000000000023874,97.55859375,27.211612766070527,188.15500020980835,188,4.999876022338867,5.055000066757202,72.65000104904175,123.15000057220459,27.850000858306885,,,,,,, +no-exceptions,asyncify,chain,10,0,0,off,1,0,no-exceptions-2-asyncify-chain-10-0-0-off-1-0-10000,2,10000,100001,49.705,4.568500000000034,4.9999999999954525,10.000000000005116,10.000000000005116,259.9999999999909,25.32,2.0118901518961874,49.704999923706055,50,4.999876022338867,4.090000152587891,71.10000133514404,123.65000009536743,27.5,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-6-jspi-direct-1-1-0-on-1-0-10000,6,10000,10000,50.010000000000005,4.878000000000018,4.9999999999954525,10.000000000005116,10.000000000005116,370.00000000000455,21.68,0.1999600079984003,50.019999980926514,50,4.999876022338867,2.2950000762939453,70.04999876022339,117.54999876022339,28.350000381469727,0.25351000404357793,1.0864998817443847,0.6274986982345581,0.47850005626678466,1.1640010595321655,1.0200003385543823,0.2479899616241646 +primary,asyncify,sync,1,0,0,on,1,0,primary-6-asyncify-sync-1-0-0-on-1-0-100000,6,100000,100000,24.88499999999999,0.1337999999999964,0.0,0.0,4.9999999999954525,150.00000000000568,97.367,4.0184850311432605,24.889999866485596,25,4.999876022338867,4.984999895095825,71.74999952316284,140.5999994277954,28.09999942779541,,,,,,, +primary,asyncify,chain,10,0,0,on,1,0,primary-4-asyncify-chain-10-0-0-on-1-0-10000,4,10000,100001,61.35000000000001,4.980500000000045,4.9999999999954525,10.000000000005116,10.000000000019327,245.00000000000455,20.76,1.63000814995925,61.355000019073486,61,4.999876022338867,4.045000076293945,71.49999856948853,144.24999952316284,28.69999885559082,,,,,,, +primary,asyncify,chain,100,0,1,on,1,0,primary-1-asyncify-chain-100-0-1-on-1-0-1024,1,1024,102401,11.195000000000007,0.214843749999985,0.0,0.0,5.000000000009663,5.000000000009663,95.703125,9.147029924073241,11.200000047683716,11,4.999876022338867,4.990000009536743,68.30000162124634,143.75,27.899999618530273,,,,,,, +no-exceptions,jspi,direct,1,1,0,off,1,0,no-exceptions-1-jspi-direct-1-1-0-off-1-0-10000,1,10000,10000,50.54,4.920500000000006,4.9999999999954525,10.000000000005116,10.000000000005116,379.99999999999545,21.04,0.19786307874950534,50.545000076293945,50,4.999876022338867,2.3399999141693115,71.49999856948853,118.35000038146973,27.999999523162842,0.20253770446776684,1.0920001983642578,0.6845004081726074,0.4875000476837158,1.2184998512268066,1.0259995698928832,0.2094622201919684 +work-64,asyncify,chain,100,0,1,on,1,64,work-64-1-asyncify-chain-100-0-1-on-1-64-1024,1,1024,102401,10.799999999999997,0.21972656249992506,0.0,0.0,4.9999999999954525,5.000000000009663,95.60546875,9.481574074074077,10.804999828338623,11,4.999876022338867,4.085000038146973,71.90000057220459,139.24999952316284,28.350000381469727,,,,,,, +primary,asyncify,chain,5000,0,1,on,1,0,primary-5-asyncify-chain-5000-0-1-on-1-0-1024,5,1024,5120001,456.775,0.292968750000025,0.0,4.9999999999954525,4.9999999999954525,5.000000000052296,94.140625,11.209021947348258,456.7850000858307,456,4.999876022338867,4.105000019073486,72.44999885559082,142.64999866485596,28.04999828338623,,,,,,, +work-64,jspi,chain,10000,0,1,on,1,64,work-64-2-jspi-chain-10000-0-1-on-1-64-1024,2,1024,10240001,331.66,0.14648437500001943,0.0,0.0,4.9999999999954525,5.000000000052296,97.0703125,30.87499547729602,331.6600000858307,331,4.999876022338867,2.184999942779541,71.69999837875366,120.55000066757202,28.399999141693115,,,,,,, +primary,asyncify,chain,10,0,1,on,1,0,primary-5-asyncify-chain-10-0-1-on-1-0-10000,5,10000,100001,12.944999999999993,0.25099999999999767,0.0,0.0,5.000000000009663,20.000000000010232,95.01,7.7250675936655115,12.950000047683716,13,4.999876022338867,4.169999837875366,70.99999904632568,141.8500018119812,28.299999237060547,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,primary-4-asyncify-chain-5000-0-0-on-1-0-1024,4,1024,5120001,446.52500000000003,6.401367187499493,4.9999999999954525,10.000000000047748,24.999999999977263,189.99999999999773,12.79296875,11.466325513689043,446.5349998474121,446,4.999876022338867,4.9700000286102295,67.7999997138977,148.94999980926514,28.20000171661377,,,,,,, +chain-trace,asyncify,chain,100,1,0,on,1,0,chain-trace-2-asyncify-chain-100-1-0-on-1-0-1024,2,1024,102401,16.5,6.352539062500259,4.9999999999954525,10.000000000005116,15.000000000000568,219.99999999999886,12.01171875,6.206121212121212,16.509999990463257,16,4.999876022338867,4.175000190734863,70,137.30000019073486,28.600001335144043,0.15636270865808377,1.215820200741291,0.9912112727761269,0.5517576355487108,1.59179768525064,1.0400395840406418,0.805549975484765 +primary,asyncify,chain,1000,0,0,on,1,0,primary-2-asyncify-chain-1000-0-0-on-1-0-1024,2,1024,1024001,93.705,5.903320312499918,4.9999999999954525,10.000000000005116,15.000000000000568,170.0000000000017,14.35546875,10.927922736246732,93.70500016212463,94,4.999876022338867,4.075000047683716,72.25000143051147,141.15000009536743,27.799999713897705,,,,,,, +no-exceptions,asyncify,chain,10000,0,0,off,1,0,no-exceptions-1-asyncify-chain-10000-0-0-off-1-0-1024,1,1024,10240001,274.21,5.380859374999964,4.9999999999954525,10.000000000019327,15.000000000043201,180.00000000000682,20.5078125,37.34364538127713,274.210000038147,274,4.999876022338867,4.059999942779541,72.70000219345093,125.24999856948853,28.15000057220459,,,,,,, +primary,jspi,chain,10000,0,0,on,1,0,primary-5-jspi-chain-10000-0-0-on-1-0-1024,5,1024,10240001,318.725,5.161132812500191,4.9999999999954525,10.000000000019327,15.000000000000568,215.00000000003183,21.2890625,32.128013177504116,318.72499990463257,319,4.999876022338867,2.205000162124634,72.05000162124634,116.94999933242798,28.05000066757202,,,,,,, +primary,jspi,chain,10,0,1,on,1,0,primary-3-jspi-chain-10-0-1-on-1-0-10000,3,10000,100001,6.134999999999991,0.15099999999999766,0.0,0.0,4.9999999999954525,15.000000000000568,97.0,16.300081499592526,6.144999980926514,6,4.999876022338867,2.3350000381469727,71.05000019073486,117.75000095367432,28.15000057220459,,,,,,, +primary,jspi,chain,10,0,1,on,1,0,primary-2-jspi-chain-10-0-1-on-1-0-10000,2,10000,100001,6.049999999999997,0.12699999999999106,0.0,0.0,4.9999999999954525,5.000000000009663,97.46,16.529090909090915,6.055000066757202,6,4.999876022338867,2.205000162124634,70.19999980926514,117.64999866485596,28.300001621246338,,,,,,, +primary,asyncify,chain,100,0,1,on,1,0,primary-2-asyncify-chain-100-0-1-on-1-0-1024,2,1024,102401,11.14,0.18554687500001166,0.0,0.0,5.000000000009663,5.000000000009663,96.2890625,9.192190305206463,11.139999866485596,11,4.999876022338867,4.8999998569488525,70.89999914169312,136.94999933242798,27.799999713897705,,,,,,, +primary,asyncify,chain,10000,0,1,on,1,0,primary-5-asyncify-chain-10000-0-1-on-1-0-1024,5,1024,10240001,875.52,0.18066406250004385,0.0,0.0,4.9999999999954525,5.000000000109139,96.38671875,11.6959075749269,875.5249998569489,876,4.999876022338867,4.954999923706055,71.90000057220459,140.9000015258789,28.000001907348633,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-6-asyncify-chain-1-0-0-on-1-0-100000,6,100000,100001,546.24,5.320599999999979,4.9999999999954525,9.999999999990905,10.000000000047748,39720.00000000003,22.279,0.18307154364381956,546.2450001239777,546,4.999876022338867,4.950000047683716,71.44999980926514,141.00000143051147,28.05000066757202,,,,,,, +primary,asyncify,direct,1,0,0,on,1,0,primary-5-asyncify-direct-1-0-0-on-1-0-10000,5,10000,10000,48.735000000000014,4.7364999999999835,4.9999999999954525,10.000000000005116,10.000000000005116,269.999999999996,23.02,0.2051913409254129,48.74000000953674,49,4.999876022338867,4.0299999713897705,73.35000038146973,147.99999952316284,28.299999237060547,,,,,,, +work-64,jspi,chain,5000,0,0,on,1,64,work-64-3-jspi-chain-5000-0-0-on-1-64-1024,3,1024,5120001,172.09499999999997,5.063476562500169,4.9999999999954525,10.000000000005116,15.00000000001478,250.0,23.046875,29.751015427525502,172.09999990463257,172,4.999876022338867,2.190000057220459,71.05000019073486,117.95000076293945,28.600001335144043,,,,,,, +work-64,jspi,chain,100,0,1,on,1,64,work-64-1-jspi-chain-100-0-1-on-1-64-1024,1,1024,102401,4,0.17578125000002054,0.0,0.0,5.000000000009663,5.000000000009663,96.484375,25.60025,4,3,4.999876022338867,2.6449999809265137,68.49999904632568,117.99999952316284,28.599998950958252,,,,,,, +work-64,asyncify,chain,100,0,0,on,1,64,work-64-1-asyncify-chain-100-0-0-on-1-64-1024,1,1024,102401,16.180000000000007,5.527343750000205,4.9999999999954525,10.000000000005116,19.99999999999602,150.00000000000568,17.67578125,6.328862793572309,16.18499994277954,16,4.999876022338867,4.039999961853027,69.50000047683716,144.7000002861023,27.950000762939453,,,,,,, +primary,asyncify,chain,100,0,1,on,1,0,primary-3-asyncify-chain-100-0-1-on-1-0-1024,3,1024,102401,11.445000000000007,0.23925781250000444,0.0,0.0,5.000000000009663,5.000000000009663,95.21484375,8.947225862822188,11.450000047683716,11,4.999876022338867,4.980000019073486,68.90000104904175,141.30000114440918,28.000001907348633,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-1-jspi-chain-1000-0-0-on-1-0-1024,1,1024,1024001,37.32000000000001,4.638671874999903,4.9999999999954525,10.000000000005116,15.000000000000568,200.00000000000284,26.07421875,27.438397642014998,37.325000047683716,37,4.999876022338867,2.240000009536743,71.64999961853027,119.14999961853027,28.05000066757202,,,,,,, +primary,jspi,chain,5000,0,1,on,1,0,primary-2-jspi-chain-5000-0-1-on-1-0-1024,2,1024,5120001,159.75,0.17089843750005274,0.0,0.0,4.9999999999954525,5.000000000023874,96.58203125,32.05008450704226,159.75999999046326,160,4.999876022338867,2.5999999046325684,69.80000019073486,117.40000009536743,27.699999809265137,,,,,,, +work-64,asyncify,chain,1000,0,1,on,1,64,work-64-1-asyncify-chain-1000-0-1-on-1-64-1024,1,1024,1024001,93.87000000000002,0.26855468750001943,0.0,4.9999999999954525,5.000000000009663,5.000000000023874,94.62890625,10.908714179183974,93.87000012397766,94,4.999876022338867,5.009999990463257,70.85000038146973,142.40000009536743,28.19999933242798,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-2-jspi-chain-1000-0-0-on-1-0-1024,2,1024,1024001,36.69500000000001,4.6777343749998535,4.9999999999954525,10.000000000005116,15.000000000000568,210.00000000000796,25.9765625,27.905736476359174,36.6949999332428,36,4.999876022338867,2.1599998474121094,70.15000104904175,116.05000019073486,28.250000476837158,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,primary-1-asyncify-direct-1-1-0-on-1-0-10000,1,10000,10000,57.27499999999999,5.58750000000002,4.9999999999954525,10.000000000005116,15.000000000000568,375.0,15.41,0.17459624618070715,57.28999996185303,57,4.999876022338867,4.159999847412109,70.75000047683716,145.80000162124634,28.350000381469727,0.17401895427703806,1.115000033378601,0.7255005359649658,0.49700031280517576,1.5794995307922364,0.9979997396469116,0.4984808931350912 +primary,asyncify,chain,100,0,0,on,1,0,primary-1-asyncify-chain-100-0-0-on-1-0-1024,1,1024,102401,15.61,5.356445312500041,4.9999999999954525,10.000000000005116,15.000000000000568,150.00000000000568,19.23828125,6.559961563100577,15.615000009536743,16,4.999876022338867,4.079999923706055,70.65000057220459,140.54999828338623,28.1499981880188,,,,,,, +primary,jspi,chain,10,0,0,on,1,0,primary-6-jspi-chain-10-0-0-on-1-0-10000,6,10000,100001,47.349999999999994,4.230000000000037,4.9999999999954525,10.000000000005116,10.000000000005116,275.0000000000057,29.38,2.1119535374868006,47.355000019073486,47,4.999876022338867,2.2149999141693115,67.75000095367432,115.9000015258789,28.20000171661377,,,,,,, +no-exceptions,asyncify,chain,100,0,1,off,1,0,no-exceptions-2-asyncify-chain-100-0-1-off-1-0-1024,2,1024,102401,4.609999999999999,0.14160156249998224,0.0,0.0,4.9999999999954525,5.000000000009663,97.16796875,22.212798264642085,4.615000009536743,5,4.999876022338867,4.819999933242798,71.60000085830688,125.20000219345093,28.1499981880188,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-7-jspi-direct-1-1-0-on-1-0-10000,7,10000,10000,49.97,4.851000000000019,4.9999999999954525,10.000000000005116,10.000000000005116,459.99999999999375,21.56,0.20012007204322593,49.980000019073486,50,4.999876022338867,2.509999990463257,70.80000162124634,116.99999809265137,28.15000057220459,0.2225860071181856,1.0500000953674316,0.6355010509490967,0.46700000762939453,1.254999828338623,1.013999080657959,0.2069139299393285 +primary,asyncify,chain,10,0,1,on,1,0,primary-2-asyncify-chain-10-0-1-on-1-0-10000,2,10000,100001,13.100000000000009,0.2445000000000121,0.0,0.0,5.000000000009663,140.00000000000057,95.39,7.633664122137399,13.105000019073486,13,4.999876022338867,4.9750001430511475,69.64999914169312,142.40000009536743,28.300001621246338,,,,,,, +primary,asyncify,chain,10000,0,0,on,1,0,primary-3-asyncify-chain-10000-0-0-on-1-0-1024,3,1024,10240001,1112.595,7.1386718749984475,4.9999999999954525,14.999999999986358,19.99999999999602,274.9999999998636,10.25390625,9.203709346168193,1112.6099998950958,1113,4.999876022338867,5.020000219345093,71.8999981880188,139.50000047683716,28.350000381469727,,,,,,, +primary,asyncify,chain,10,0,0,on,1,0,primary-2-asyncify-chain-10-0-0-on-1-0-10000,2,10000,100001,61.30000000000001,5.025500000000006,4.9999999999954525,10.000000000005116,10.000000000019327,245.00000000000455,20.61,1.6313376835236537,61.3050000667572,61,4.999876022338867,4.025000095367432,72.59999990463257,140.99999904632568,27.799999713897705,,,,,,, +no-exceptions,asyncify,chain,10,0,1,off,1,0,no-exceptions-1-asyncify-chain-10-0-1-off-1-0-10000,1,10000,100001,6.420000000000002,0.16050000000000467,0.0,0.0,4.9999999999954525,125.0,97.05,15.576479750778812,6.419999837875366,7,4.999876022338867,4.884999990463257,72.69999980926514,124.75000143051147,27.749998569488525,,,,,,, +no-exceptions,jspi,chain,1,0,0,off,1,0,no-exceptions-1-jspi-chain-1-0-0-off-1-0-100000,1,100000,100001,436.64,4.232099999999989,4.9999999999954525,9.999999999990905,10.000000000047748,4269.999999999982,30.323,0.22902390985709054,436.64999985694885,436,4.999876022338867,2.174999952316284,69.90000009536743,118.35000038146973,27.850000858306885,,,,,,, +chain-trace,asyncify,chain,1000,1,0,on,1,0,chain-trace-3-asyncify-chain-1000-1-0-on-1-0-1024,3,1024,1024001,96.03,6.982421875000353,4.9999999999954525,10.000000000019327,20.000000000010232,245.00000000000455,8.3984375,10.663344788087056,96.03499984741211,96,4.999876022338867,3.990000009536743,72.00000047683716,142.4500012397766,28.20000171661377,0.5810052156449419,1.3134756591171026,0.8154327515512705,0.4882826469838619,1.7578110564500093,0.9912136010825634,1.0352009441706027 +primary,asyncify,chain,5000,0,1,on,1,0,primary-2-asyncify-chain-5000-0-1-on-1-0-1024,2,1024,5120001,449.94999999999993,0.17089843750003886,0.0,0.0,4.9999999999954525,10.000000000047748,96.6796875,11.379044338259808,449.960000038147,449,4.999876022338867,4.115000009536743,72.75000095367432,138.05000066757202,27.899999618530273,,,,,,, +no-exceptions,jspi,direct,1,1,0,off,1,0,no-exceptions-2-jspi-direct-1-1-0-off-1-0-10000,2,10000,10000,50.79,4.95350000000001,4.9999999999954525,10.000000000005116,10.000000000005116,370.00000000000455,21.42,0.19688915140775742,50.795000076293945,51,4.999876022338867,2.1700000762939453,68.94999980926514,118.99999856948853,27.799999713897705,0.22288622188566123,1.1144986629486084,0.6909997701644898,0.5034999847412109,1.1585006713867188,1.0355003833770753,0.22761430549624534 +no-exceptions,asyncify,chain,1000,0,0,off,1,0,no-exceptions-3-asyncify-chain-1000-0-0-off-1-0-1024,3,1024,1024001,32.685,5.029296874999853,4.9999999999954525,10.000000000005116,15.000000000000568,160.0000000000108,21.6796875,31.329386568762427,32.69000005722046,33,4.999876022338867,4.955000162124634,70.05000114440918,121.49999856948853,28.450000286102295,,,,,,, +no-exceptions,jspi,chain,100,0,1,off,1,0,no-exceptions-3-jspi-chain-100-0-1-off-1-0-1024,3,1024,102401,3.5799999999999983,0.14160156249995448,0.0,0.0,4.9999999999954525,5.000000000009663,97.16796875,28.60363128491621,3.5899999141693115,3,4.999876022338867,2.384999990463257,69.54999923706055,119.14999961853027,28.600001335144043,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-7-jspi-chain-1000-0-0-on-1-0-1024,7,1024,1024001,36.265,4.731445312500194,4.9999999999954525,10.000000000005116,10.000000000005116,200.00000000000284,24.4140625,28.23661932993244,36.27500009536743,37,4.999876022338867,2.4850001335144043,72.45000123977661,118.4000015258789,28.20000171661377,,,,,,, +primary,asyncify,chain,1000,0,1,on,1,0,primary-3-asyncify-chain-1000-0-1-on-1-0-1024,3,1024,1024001,87.75,0.20019531249997058,0.0,0.0,4.9999999999954525,5.000000000023874,95.99609375,11.669527065527065,87.75499987602234,88,4.999876022338867,4.995000123977661,71.64999961853027,141.05000019073486,28.450000286102295,,,,,,, +no-exceptions,asyncify,chain,1000,0,1,off,1,0,no-exceptions-1-asyncify-chain-1000-0-1-off-1-0-1024,1,1024,1024001,37.8,0.12207031249995837,0.0,0.0,4.9999999999954525,5.000000000009663,97.55859375,27.089973544973546,37.80499982833862,38,4.999876022338867,3.9800000190734863,71.79999828338623,122.35000133514404,27.950000762939453,,,,,,, +chain-trace,asyncify,chain,1,1,0,on,1,0,chain-trace-2-asyncify-chain-1-1-0-on-1-0-1024,2,1024,1025,6.930000000000007,6.557617187499975,4.9999999999954525,10.000000000005116,15.000000000000568,219.99999999999886,11.5234375,0.14790764790764777,6.940000057220459,7,4.999876022338867,4.9049999713897705,72.45000123977661,143.1500005722046,28.250000476837158,0.483368374407378,1.2548831291496754,0.6201188080012798,0.478516798466444,1.762693515047431,1.0009754914790392,0.9570610709487282 +primary,jspi,direct,1,0,0,on,1,0,primary-5-jspi-direct-1-0-0-on-1-0-10000,5,10000,10000,41.97,4.062000000000011,4.9999999999954525,10.000000000005116,10.000000000005116,259.9999999999909,31.36,0.2382654276864427,41.97000002861023,42,4.999876022338867,2.174999952316284,69.64999914169312,118.69999885559082,27.749998569488525,,,,,,, +work-64,asyncify,chain,5000,0,1,on,1,64,work-64-3-asyncify-chain-5000-0-1-on-1-64-1024,3,1024,5120001,443.80000000000007,0.2832031249998812,0.0,4.9999999999954525,4.9999999999954525,5.000000000052296,94.3359375,11.536730509238394,443.8050000667572,444,4.999876022338867,4.0350000858306885,69.3500018119812,140.85000038146973,27.950000762939453,,,,,,, +no-exceptions,jspi,chain,1000,0,1,off,1,0,no-exceptions-1-jspi-chain-1000-0-1-off-1-0-1024,1,1024,1024001,28.364999999999995,0.09277343749998501,0.0,0.0,4.9999999999954525,5.000000000009663,98.14453125,36.100863740525305,28.365000009536743,29,4.999876022338867,2.3550000190734863,71.45000219345093,115.39999961853027,28.550000190734863,,,,,,, +primary,asyncify,chain,10,0,0,on,1,0,primary-7-asyncify-chain-10-0-0-on-1-0-10000,7,10000,100001,61.34,4.986000000000018,4.9999999999954525,10.000000000005116,10.000000000019327,275.0000000000057,21.01,1.6302738832735573,61.34499979019165,62,4.999876022338867,4.110000133514404,69.19999837875366,141.65000200271606,27.999999523162842,,,,,,, +no-exceptions,jspi,chain,100,0,0,off,1,0,no-exceptions-2-jspi-chain-100-0-0-off-1-0-1024,2,1024,102401,8.170000000000002,4.501953124999972,4.9999999999954525,10.000000000005116,10.000000000005116,194.99999999999318,27.44140625,12.53378212974296,8.170000076293945,8,4.999876022338867,2.319999933242798,69.29999828338623,118.39999914169312,28.15000057220459,,,,,,, +ordinary-page,jspi,direct,1,0,0,on,0,0,ordinary-page-3-jspi-direct-1-0-0-on-0-0-10000,3,10000,10000,41.7,4.049999999999995,0.0,0.0,100.00000000000142,300.00000000001137,96.04,0.2398081534772182,41.69999980926514,42,99.99990463256836,2.5,70.99999904632568,112.00000047683716,27.000000476837158,,,,,,, +primary,asyncify,chain,10,0,1,on,1,0,primary-4-asyncify-chain-10-0-1-on-1-0-10000,4,10000,100001,13.225000000000009,0.24699999999998568,0.0,0.0,5.000000000009663,15.000000000000568,95.14,7.561512287334589,13.230000019073486,13,4.999876022338867,4.055000066757202,72.2000002861023,140.24999856948853,28.250000476837158,,,,,,, +work-64,asyncify,chain,5000,0,1,on,1,64,work-64-2-asyncify-chain-5000-0-1-on-1-64-1024,2,1024,5120001,436.235,0.24414062500002776,0.0,0.0,4.9999999999954525,5.000000000052296,95.1171875,11.736795534516947,436.24000000953674,436,4.999876022338867,4.174999952316284,68.05000066757202,143.29999923706055,28.19999933242798,,,,,,, +primary,asyncify,clock,1,0,0,on,1,0,primary-5-asyncify-clock-1-0-0-on-1-0-100000,5,100000,100000,23.015,0.11395000000000025,0.0,0.0,4.9999999999954525,44.999999999987494,97.738,4.344992396263306,23.02500009536743,23,4.999876022338867,4.125,72.40000009536743,145.49999952316284,27.999999523162842,,,,,,, +no-exceptions,asyncify,chain,10000,0,0,off,1,0,no-exceptions-2-asyncify-chain-10000-0-0-off-1-0-1024,2,1024,10240001,271.815,5.63476562500001,4.9999999999954525,10.000000000019327,19.99999999999602,210.00000000000796,18.75,37.67268546621783,271.8199999332428,272,4.999876022338867,4.950000047683716,69.7000002861023,123.15000057220459,28.19999933242798,,,,,,, +work-64,asyncify,chain,5000,0,0,on,1,64,work-64-3-asyncify-chain-5000-0-0-on-1-64-1024,3,1024,5120001,443.08000000000004,6.396484374999095,4.9999999999954525,10.000000000047748,24.999999999977263,174.99999999998295,13.4765625,11.555477566128014,443.085000038147,443,4.999876022338867,4.069999933242798,72.04999923706055,139.74999904632568,28.250000476837158,,,,,,, +primary,jspi,sync,1,0,0,on,1,0,primary-4-jspi-sync-1-0-0-on-1-0-100000,4,100000,100000,22.525,0.11345000000000169,0.0,0.0,4.9999999999954525,75.00000000000284,97.767,4.439511653718091,22.53500008583069,23,4.999876022338867,2.444999933242798,69.40000057220459,118.99999856948853,28.09999942779541,,,,,,, +primary,jspi,chain,10000,0,1,on,1,0,primary-5-jspi-chain-10000-0-1-on-1-0-1024,5,1024,10240001,316.84,0.14648437499988065,0.0,0.0,4.9999999999954525,5.000000000009663,97.0703125,32.31915477843707,316.84500002861023,317,4.999876022338867,2.31000018119812,69.64999914169312,118.09999942779541,28.250000476837158,,,,,,, +chain-trace,asyncify,chain,10000,1,0,on,1,0,chain-trace-3-asyncify-chain-10000-1-0-on-1-0-1024,3,1024,10240001,902.915,7.9687500000003295,4.9999999999954525,14.999999999986358,25.000000000005684,370.00000000000455,8.59375,11.34104649939363,902.9299998283386,903,4.999876022338867,4.0899999141693115,71.50000095367432,143.35000038146973,28.399999141693115,0.2148365881299158,1.518552890047431,0.8251946419477463,0.8105461020022631,2.2851540707051754,1.059569651260972,1.2548960559068263 +no-exceptions,jspi,direct,1,0,0,off,1,0,no-exceptions-1-jspi-direct-1-0-0-off-1-0-10000,1,10000,10000,42.2,4.0749999999999975,4.9999999999954525,10.000000000005116,10.000000000005116,260.0000000000051,31.46,0.23696682464454974,42.204999923706055,42,4.999876022338867,2.5299999713897705,68.84999990463257,118.05000066757202,27.749998569488525,,,,,,, +primary,asyncify,chain,5000,0,0,on,1,0,primary-7-asyncify-chain-5000-0-0-on-1-0-1024,7,1024,5120001,446.355,6.777343749999873,4.9999999999954525,14.999999999986358,20.000000000010232,194.99999999999318,11.328125,11.47069261014215,446.3600001335144,446,4.999876022338867,4.150000095367432,68.15000057220459,143.4500002861023,28.549997806549072,,,,,,, +no-exceptions,jspi,chain,1,0,1,off,1,0,no-exceptions-2-jspi-chain-1-0-1-off-1-0-100000,2,100000,100001,25.03,0.1348500000000024,0.0,0.0,4.9999999999954525,134.9999999999909,97.346,3.9952457051538155,25.03500008583069,25,4.999876022338867,2.375,71.84999942779541,119.94999885559082,28.350000381469727,,,,,,, +primary,jspi,chain,10,0,1,on,1,0,primary-7-jspi-chain-10-0-1-on-1-0-10000,7,10000,100001,6.0049999999999955,0.14250000000003382,0.0,0.0,5.000000000009663,5.000000000009663,97.15,16.652955870108258,6.005000114440918,6,4.999876022338867,2.3499999046325684,68.65000009536743,116.39999866485596,28.249998092651367,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-4-asyncify-chain-1-0-0-on-1-0-100000,4,100000,100001,497.99499999999995,4.8394999999999975,4.9999999999954525,9.999999999990905,10.000000000047748,4640.000000000015,22.635,0.20080723702045203,498,498,4.999876022338867,4.980000019073486,72.45000123977661,141.39999866485596,28.09999942779541,,,,,,, +primary,jspi,chain,1000,0,0,on,1,0,primary-6-jspi-chain-1000-0-0-on-1-0-1024,6,1024,1024001,36.69,4.633789062499797,4.9999999999954525,10.000000000005116,15.000000000000568,179.9999999999926,26.26953125,27.909539384028346,36.69500017166138,37,4.999876022338867,2.684999942779541,72.95000076293945,117.59999990463257,27.950000762939453,,,,,,, +no-exceptions,jspi,chain,5000,0,0,off,1,0,no-exceptions-1-jspi-chain-5000-0-0-off-1-0-1024,1,1024,5120001,140.715,4.750976562499912,4.9999999999954525,10.000000000005116,15.000000000000568,190.00000000002615,25.390625,36.385609210105535,140.72500014305115,140,4.999876022338867,2.375,73.05000066757202,117.74999856948853,27.950000762939453,,,,,,, +primary,asyncify,chain,1000,0,1,on,1,0,primary-6-asyncify-chain-1000-0-1-on-1-0-1024,6,1024,1024001,89.60500000000002,0.22460937500000389,0.0,0.0,5.000000000009663,5.000000000023874,95.5078125,11.427944869147925,89.6100001335144,90,4.999876022338867,4.0350000858306885,68.49999904632568,142.7999997138977,28.299999237060547,,,,,,, +work-64,asyncify,chain,1000,0,0,on,1,64,work-64-2-asyncify-chain-1000-0-0-on-1-64-1024,2,1024,1024001,94.86999999999999,5.7128906249999805,4.9999999999954525,10.000000000019327,15.00000000001478,189.99999999999773,17.1875,10.793728259723833,94.86999988555908,95,4.999876022338867,4.1000001430511475,72.89999961853027,141.94999933242798,27.950000762939453,,,,,,, +primary,asyncify,direct,1,0,0,on,1,0,primary-1-asyncify-direct-1-0-0-on-1-0-10000,1,10000,10000,49.545,4.817,4.9999999999954525,10.000000000005116,10.000000000005116,244.99999999999034,23.13,0.20183671409829446,49.55999994277954,50,4.999876022338867,4.244999885559082,69.59999799728394,140.6500005722046,28.300001621246338,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-5-asyncify-chain-1-0-0-on-1-0-100000,5,100000,100001,501.07,4.8699499999999984,4.9999999999954525,9.999999999990905,10.000000000047748,3939.9999999999977,22.189,0.19957490969325645,501.0699999332428,501,4.999876022338867,4.115000009536743,70.35000085830688,145.75000047683716,28.05000066757202,,,,,,, +primary,asyncify,direct,1,0,0,on,1,0,primary-2-asyncify-direct-1-0-0-on-1-0-10000,2,10000,10000,49.625,4.8094999999999954,4.9999999999954525,10.000000000005116,10.000000000005116,255.00000000000966,22.09,0.20151133501259447,49.640000104904175,50,4.999876022338867,4.549999952316284,71.50000095367432,143.99999856948853,28.450000286102295,,,,,,, +no-exceptions,asyncify,chain,5000,0,0,off,1,0,no-exceptions-2-asyncify-chain-5000-0-0-off-1-0-1024,2,1024,5120001,140.955,4.98535156249981,4.9999999999954525,10.000000000005116,15.000000000000568,165.00000000000625,22.94921875,36.32365648611259,140.95500016212463,141,4.999876022338867,3.9800000190734863,67.7999997138977,126.80000066757202,27.950000762939453,,,,,,, +primary,jspi,direct,1,0,0,on,1,0,primary-3-jspi-direct-1-0-0-on-1-0-10000,3,10000,10000,42.72,4.139000000000014,4.9999999999954525,10.000000000005116,10.000000000005116,254.99999999999545,29.75,0.2340823970037453,42.72500014305115,43,4.999876022338867,2.359999895095825,71.60000085830688,117.7999997138977,28.500001430511475,,,,,,, +primary,asyncify,chain,100,0,0,on,1,0,primary-6-asyncify-chain-100-0-0-on-1-0-1024,6,1024,102401,16.00999999999999,5.43945312499991,4.9999999999954525,10.000000000005116,15.000000000000568,155.00000000000114,18.75,6.396064959400378,16.009999990463257,16,4.999876022338867,4.105000019073486,71.25,137.89999961853027,27.899999618530273,,,,,,, +primary,asyncify,chain,100,0,0,on,1,0,primary-4-asyncify-chain-100-0-0-on-1-0-1024,4,1024,102401,15.894999999999996,5.517578125000047,4.9999999999954525,10.000000000005116,15.000000000000568,160.0000000000108,16.9921875,6.442340358603336,15.899999856948853,16,4.999876022338867,4.109999895095825,72.44999885559082,142.8499984741211,29.650001525878906,,,,,,, +chain-trace,asyncify,chain,5000,1,0,on,1,0,chain-trace-2-asyncify-chain-5000-1-0-on-1-0-1024,2,1024,5120001,455.76,7.646484375000553,4.9999999999954525,14.999999999986358,25.000000000005684,284.99999999996817,6.4453125,11.233984992101107,455.7699999809265,456,4.999876022338867,4.070000171661377,69.54999923706055,144.19999837875366,28.1499981880188,0.1904386933897495,1.4208988286554813,1.0351575911045074,0.6689457222819328,1.9189438316971064,1.1669930536299944,1.2451066542417815 +primary,jspi,sync,1,0,0,on,1,0,primary-5-jspi-sync-1-0-0-on-1-0-100000,5,100000,100000,22.054999999999993,0.111700000000001,0.0,0.0,4.9999999999954525,79.9999999999983,97.799,4.534119247336206,22.06000018119812,22,4.999876022338867,2.2149999141693115,70.14999866485596,120.05000114440918,31.700000762939453,,,,,,, +work-64,asyncify,chain,5000,0,0,on,1,64,work-64-1-asyncify-chain-5000-0-0-on-1-64-1024,1,1024,5120001,458.5,6.5234374999995905,4.9999999999954525,10.000000000047748,19.99999999999602,180.00000000000682,12.98828125,11.166850599781897,458.5,458,4.999876022338867,4.085000038146973,71.70000076293945,140.69999933242798,28.69999885559082,,,,,,, +primary,asyncify,chain,1000,0,0,on,1,0,primary-3-asyncify-chain-1000-0-0-on-1-0-1024,3,1024,1024001,95.61000000000001,5.87402343750007,4.9999999999954525,10.000000000005116,19.99999999999602,155.00000000000114,14.453125,10.710187218910153,95.61500000953674,96,4.999876022338867,4.0950000286102295,70.04999876022339,143.7999987602234,27.899999618530273,,,,,,, +no-exceptions,asyncify,chain,100,0,0,off,1,0,no-exceptions-1-asyncify-chain-100-0-0-off-1-0-1024,1,1024,102401,8.280000000000001,4.794921874999789,4.9999999999954525,10.000000000005116,10.000000000005116,180.00000000000682,24.609375,12.367270531400964,8.27999997138977,8,4.999876022338867,4.9100000858306885,68.65000009536743,124.74999904632568,28.20000171661377,,,,,,, +ordinary-page,jspi,direct,1,0,0,on,0,0,ordinary-page-1-jspi-direct-1-0-0-on-0-0-10000,1,10000,10000,42.300000000000004,4.029999999999999,0.0,0.0,100.00000000000142,299.99999999999716,96.05,0.23640661938534277,42.299999952316284,43,99.99990463256836,2.299999952316284,72.99999952316284,113.00000190734863,29.000000953674316,,,,,,, +primary,jspi,chain,100,0,1,on,1,0,primary-1-jspi-chain-100-0-1-on-1-0-1024,1,1024,102401,3.885000000000005,0.14160156250002387,0.0,0.0,5.000000000009663,5.000000000009663,97.16796875,26.358043758043724,3.884999990463257,4,4.999876022338867,2.495000123977661,72.75000095367432,119.85000133514404,27.799999713897705,,,,,,, +chain-trace,jspi,chain,1,1,0,on,1,0,chain-trace-1-jspi-chain-1-1-0-on-1-0-1024,1,1024,1025,5.474999999999994,5.07812500000003,4.9999999999954525,10.000000000005116,15.000000000000568,230.00000000000398,20.1171875,0.18721461187214633,5.474999904632568,5,4.999876022338867,2.430000066757202,71.00000143051147,119.34999942779541,28.19999933242798,0.14649380929780687,1.0742212180048227,0.903318403288722,0.49316324293613434,1.2109382078051567,0.9570308029651642,0.29295931570222367 +primary,jspi,clock,1,0,0,on,1,0,primary-4-jspi-clock-1-0-0-on-1-0-100000,4,100000,100000,21.455,0.1093000000000027,0.0,0.0,4.9999999999954525,15.000000000000568,97.82,4.660918200885575,21.460000038146973,21,4.999876022338867,2.200000047683716,72.35000133514404,118.09999942779541,28.09999942779541,,,,,,, +work-64,asyncify,chain,10,0,1,on,1,64,work-64-1-asyncify-chain-10-0-1-on-1-64-10000,1,10000,100001,12.884999999999991,0.22000000000001307,0.0,0.0,5.000000000009663,5.000000000009663,95.6,7.761039968956156,12.890000104904175,13,4.999876022338867,4.099999904632568,67.59999990463257,141.94999933242798,28.20000171661377,,,,,,, +no-exceptions,jspi,chain,1000,0,0,off,1,0,no-exceptions-3-jspi-chain-1000-0-0-off-1-0-1024,3,1024,1024001,32.870000000000005,4.482421875000531,4.9999999999954525,10.000000000005116,15.000000000000568,190.00000000001194,27.83203125,31.153057499239424,32.875,32,4.999876022338867,2.365000009536743,71.69999837875366,118.84999990463257,28.499999046325684,,,,,,, +primary,asyncify,sync,1,0,0,on,1,0,primary-1-asyncify-sync-1-0-0-on-1-0-100000,1,100000,100000,24.980000000000004,0.13615000000000108,0.0,0.0,4.9999999999954525,159.9999999999966,97.327,4.00320256204964,24.980000019073486,25,4.999876022338867,4.894999980926514,67.59999990463257,140.70000171661377,28.450000286102295,,,,,,, +ordinary-page,asyncify,direct,1,0,0,on,0,0,ordinary-page-1-asyncify-direct-1-0-0-on-0-0-10000,1,10000,10000,48.900000000000006,4.669999999999999,0.0,0.0,100.00000000000853,299.99999999999716,95.4,0.20449897750511245,48.89999985694885,49,99.99990463256836,4.099999904632568,68.00000190734863,141.00000143051147,26.999998092651367,,,,,,, +primary,asyncify,chain,5000,0,1,on,1,0,primary-3-asyncify-chain-5000-0-1-on-1-0-1024,3,1024,5120001,437.45,0.25390624999996336,0.0,4.9999999999954525,4.9999999999954525,5.000000000052296,94.921875,11.704197051091555,437.4500000476837,437,4.999876022338867,4.080000162124634,71.15000009536743,142.25000143051147,28.349997997283936,,,,,,, +primary,jspi,direct,1,1,0,on,1,0,primary-2-jspi-direct-1-1-0-on-1-0-10000,2,10000,10000,50.17999999999999,4.900499999999997,4.9999999999954525,10.000000000005116,10.000000000005116,379.99999999999545,21.29,0.19928258270227184,50.18499994277954,50,4.999876022338867,2.6449999809265137,69.94999885559082,118.1000018119812,28.250000476837158,0.20160445308685268,1.068000864982605,0.7080000400543213,0.49649958610534667,1.2265004158020019,0.9899996519088745,0.20989498805999532 +chain-trace,asyncify,chain,10000,1,0,on,1,0,chain-trace-2-asyncify-chain-10000-1-0-on-1-0-1024,2,1024,10240001,888.69,8.115234374999753,4.9999999999954525,14.999999999986358,25.000000000034106,299.9999999999545,6.0546875,11.52257930211885,888.6949999332428,888,4.999876022338867,4.09499979019165,68.65000009536743,141.94999933242798,27.999999523162842,0.4053298290819657,1.5820327680557966,0.7714838720858097,0.6982425693422556,2.1191411651670933,1.079103210940957,1.4599009603258746 +primary,asyncify,chain,100,0,0,on,1,0,primary-2-asyncify-chain-100-0-0-on-1-0-1024,2,1024,102401,15.86,5.458984374999975,4.9999999999954525,10.000000000005116,10.000000000005116,159.9999999999966,18.5546875,6.456557377049181,15.869999885559082,15,4.999876022338867,4.075000047683716,70.05000114440918,139.0499997138977,28.05000066757202,,,,,,, +work-64,asyncify,chain,1,0,0,on,1,64,work-64-3-asyncify-chain-1-0-0-on-1-64-100000,3,100000,100001,505.60999999999996,4.917199999999983,4.9999999999954525,9.999999999990905,10.000000000047748,4074.9999999999886,21.957,0.1977828761298234,505.61500000953674,506,4.999876022338867,4.0899999141693115,71.5499997138977,140.2999997138977,28.999998569488525,,,,,,, +work-64,asyncify,chain,1,0,1,on,1,64,work-64-3-asyncify-chain-1-0-1-on-1-64-100000,3,100000,100001,33.845,0.21470000000000142,0.0,0.0,5.000000000009663,115.0000000000091,95.741,2.954675727581622,33.84500002861023,34,4.999876022338867,5.109999895095825,72.54999876022339,141.2000012397766,28.450000286102295,,,,,,, +primary,asyncify,chain,100,0,0,on,1,0,primary-7-asyncify-chain-100-0-0-on-1-0-1024,7,1024,102401,15.829999999999998,5.4541015625001465,4.9999999999954525,10.000000000005116,15.000000000000568,155.00000000000114,18.75,6.468793430195832,15.830000162124634,16,4.999876022338867,5.039999961853027,67.69999980926514,138.65000009536743,27.649998664855957,,,,,,, +no-exceptions,jspi,chain,10000,0,1,off,1,0,no-exceptions-2-jspi-chain-10000-0-1-off-1-0-1024,2,1024,10240001,270.475,0.13671874999994504,0.0,0.0,4.9999999999954525,5.000000000023874,97.265625,37.859325261114705,270.4800000190735,270,4.999876022338867,2.43999981880188,68.65000009536743,118.99999856948853,28.550000190734863,,,,,,, +chain-trace,asyncify,chain,5000,1,0,on,1,0,chain-trace-3-asyncify-chain-5000-1-0-on-1-0-1024,3,1024,5120001,456.22,7.5830078125005835,4.9999999999954525,14.999999999986358,30.000000000001137,269.9999999999818,8.59375,11.22265792819254,456.2300000190735,456,4.999876022338867,4.080000162124634,67.99999952316284,139.24999952316284,28.599998950958252,0.39559079334111624,1.4306660741567612,0.7958998903632164,0.7421888876706362,1.811520429328084,1.1279287282377481,1.2792130094030214 +chain-trace,jspi,chain,5000,1,0,on,1,0,chain-trace-2-jspi-chain-5000-1-0-on-1-0-1024,2,1024,5120001,160.6,5.600585937500332,4.9999999999954525,10.000000000019327,15.00000000001478,240.0000000000091,16.9921875,31.880454545454548,160.6049997806549,161,4.999876022338867,2.505000114440918,71.80000066757202,117.85000085830688,28.15000057220459,0.17097535543147968,1.3232429046183825,0.6152358837425709,0.4931644070893526,1.6064441297203302,1.1035148054361343,0.2880084514620823 +primary,jspi,chain,10,0,0,on,1,0,primary-1-jspi-chain-10-0-0-on-1-0-10000,1,10000,100001,46.97,4.205999999999984,4.9999999999954525,10.000000000005116,10.000000000005116,280.00000000000114,29.65,2.1290398126463703,46.97000002861023,47,4.999876022338867,2.2100000381469727,71.34999990463257,118.19999933242798,27.799999713897705,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,primary-3-asyncify-direct-1-1-0-on-1-0-10000,3,10000,10000,57.705,5.642500000000005,4.9999999999954525,10.000000000005116,15.000000000000568,385.0000000000051,14.8,0.17329520838748808,57.72000002861023,58,4.999876022338867,4.1549999713897705,72.74999856948853,143.7000012397766,28.09999942779541,0.3045189800262378,1.1580003023147583,0.6955004930496216,0.5094990015029908,1.4865006685256958,1.0384997844696044,0.4499807701110967 +primary,jspi,chain,5000,0,1,on,1,0,primary-7-jspi-chain-5000-0-1-on-1-0-1024,7,1024,5120001,155.57,0.19042968750003497,0.0,0.0,5.000000000009663,5.000000000023874,96.19140625,32.91123609950505,155.57500004768372,156,4.999876022338867,2.379999876022339,68.69999885559082,116.5999984741211,27.899999618530273,,,,,,, +work-64,asyncify,chain,10000,0,0,on,1,64,work-64-3-asyncify-chain-10000-0-0-on-1-64-1024,3,1024,10240001,888.9000000000001,6.914062500000387,4.9999999999954525,10.000000000104592,25.000000000005684,284.99999999996817,12.3046875,11.519857126785913,888.914999961853,889,4.999876022338867,4.159999847412109,73.19999933242798,142.1500015258789,28.19999933242798,,,,,,, +ordinary-page,asyncify,direct,1,1,0,on,0,0,ordinary-page-1-asyncify-direct-1-1-0-on-0-0-10000,1,10000,10000,57.099999999999994,5.62,0.0,99.99999999999432,100.00000000000853,399.9999999999915,94.52,0.17513134851138354,57.19999980926514,57,99.99990463256836,5.099999904632568,70.99999904632568,136.00000143051147,27.999999523162842,0.14999959945678967,1.2299999237060546,0.6700000762939453,0.45000011920928956,1.6000000953674316,1.1499998092651367,0.3700003767013527 +primary,jspi,direct,1,0,0,on,1,0,primary-1-jspi-direct-1-0-0-on-1-0-10000,1,10000,10000,42.73499999999999,4.145500000000002,4.9999999999954525,10.000000000005116,10.000000000005116,310.0000000000023,30.73,0.23400023400023404,42.74000000953674,42,4.999876022338867,2.384999990463257,69.60000038146973,119.80000019073486,28.19999933242798,,,,,,, +work-64,asyncify,chain,100,0,0,on,1,64,work-64-3-asyncify-chain-100-0-0-on-1-64-1024,3,1024,102401,15.974999999999994,5.556640625000192,4.9999999999954525,10.000000000005116,15.000000000000568,195.0000000000074,16.2109375,6.410078247261348,15.980000019073486,16,4.999876022338867,4.0299999713897705,69.3500018119812,142.2000002861023,28.19999933242798,,,,,,, +primary,asyncify,chain,10,0,1,on,1,0,primary-1-asyncify-chain-10-0-1-on-1-0-10000,1,10000,100001,13.049999999999997,0.2340000000000046,0.0,0.0,5.000000000009663,20.000000000010232,95.35,7.662911877394637,13.059999942779541,13,4.999876022338867,5.015000104904175,70.85000038146973,145.39999961853027,27.899999618530273,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,primary-1-jspi-chain-5000-0-0-on-1-0-1024,1,1024,5120001,160.82,4.819335937499655,4.9999999999954525,10.000000000005116,14.999999999986358,199.99999999998863,24.21875,31.836842432533267,160.82500004768372,161,4.999876022338867,2.5850000381469727,72.04999923706055,119.49999809265137,28.05000066757202,,,,,,, +primary,asyncify,chain,10,0,0,on,1,0,primary-3-asyncify-chain-10-0-0-on-1-0-10000,3,10000,100001,61.44500000000001,4.98249999999999,4.9999999999954525,10.000000000005116,10.000000000019327,240.0000000000091,20.57,1.627487997396045,61.454999923706055,62,4.999876022338867,3.995000123977661,72.5,145.0499987602234,27.999999523162842,,,,,,, +primary,asyncify,chain,10000,0,0,on,1,0,primary-6-asyncify-chain-10000-0-0-on-1-0-1024,6,1024,10240001,891.145,6.928710937499291,4.9999999999954525,14.999999999986358,24.999999999991473,295.0000000000159,11.23046875,11.490835947011991,891.1549999713898,891,4.999876022338867,4.150000095367432,71.19999885559082,141.94999933242798,29.100000858306885,,,,,,, +no-exceptions,jspi,chain,10,0,0,off,1,0,no-exceptions-2-jspi-chain-10-0-0-off-1-0-10000,2,10000,100001,46.599999999999994,4.2264999999999855,4.9999999999954525,10.000000000005116,10.000000000005116,269.999999999996,29.48,2.145944206008584,46.609999895095825,46,4.999876022338867,2.1649999618530273,69.6500015258789,118.55000019073486,28.499999046325684,,,,,,, +no-exceptions,asyncify,direct,1,0,0,off,1,0,no-exceptions-3-asyncify-direct-1-0-0-off-1-0-10000,3,10000,10000,47.290000000000006,4.576500000000005,4.9999999999954525,10.000000000005116,10.000000000005116,265.00000000000057,25.48,0.21146119687037426,47.30499982833862,47,4.999876022338867,3.990000009536743,69.34999942779541,122.5,28.299999237060547,,,,,,, +primary,asyncify,sync,1,0,0,on,1,0,primary-4-asyncify-sync-1-0-0-on-1-0-100000,4,100000,100000,25.164999999999992,0.1365000000000019,0.0,0.0,4.9999999999954525,165.00000000000625,97.323,3.9737730975561307,25.174999952316284,26,4.999876022338867,4.034999847412109,70.79999923706055,142.8000020980835,28.05000066757202,,,,,,, +work-64,asyncify,chain,1,0,0,on,1,64,work-64-2-asyncify-chain-1-0-0-on-1-64-100000,2,100000,100001,500.78999999999996,4.862849999999996,4.9999999999954525,9.999999999990905,10.000000000047748,4204.999999999984,22.247,0.199686495337367,500.789999961853,500,4.999876022338867,5.0350000858306885,68.4500002861023,141.09999895095825,27.950000762939453,,,,,,, +primary,jspi,chain,100,0,1,on,1,0,primary-6-jspi-chain-100-0-1-on-1-0-1024,6,1024,102401,3.8049999999999997,0.1367187499999728,0.0,0.0,4.9999999999954525,5.000000000009663,97.265625,26.912220762155062,3.805000066757202,4,4.999876022338867,2.3350000381469727,69.0499997138977,116.80000066757202,28.299999237060547,,,,,,, +primary,jspi,direct,1,0,0,on,1,0,primary-2-jspi-direct-1-0-0-on-1-0-10000,2,10000,10000,42.33500000000001,4.111500000000006,4.9999999999954525,10.000000000005116,10.000000000005116,260.0000000000051,30.92,0.23621117278847284,42.34999990463257,42,4.999876022338867,2.234999895095825,70.44999837875366,118.70000123977661,28.05000066757202,,,,,,, +primary,jspi,clock,1,0,0,on,1,0,primary-5-jspi-clock-1-0-0-on-1-0-100000,5,100000,100000,21.68,0.10979999999999883,0.0,0.0,4.9999999999954525,29.99999999999403,97.815,4.612546125461255,21.69000005722046,21,4.999876022338867,2.2150001525878906,71.79999828338623,116.44999980926514,28.19999933242798,,,,,,, +work-64,jspi,chain,10000,0,0,on,1,64,work-64-2-jspi-chain-10000-0-0-on-1-64-1024,2,1024,10240001,339.855,5.351562500000767,4.9999999999954525,10.000000000019327,19.99999999998181,295.0000000000159,22.16796875,30.13049977196157,339.8550000190735,340,4.999876022338867,2.6050000190734863,69.10000085830688,117.00000047683716,28.70000123977661,,,,,,, +primary,asyncify,chain,10000,0,1,on,1,0,primary-1-asyncify-chain-10000-0-1-on-1-0-1024,1,1024,10240001,934.645,0.2441406249999306,0.0,0.0,4.9999999999954525,5.000000000109139,95.1171875,10.956032504319822,934.6549999713898,935,4.999876022338867,4.18500018119812,68.29999923706055,142.69999980926514,28.299999237060547,,,,,,, +primary,asyncify,chain,100,0,0,on,1,0,primary-3-asyncify-chain-100-0-0-on-1-0-1024,3,1024,102401,16.28,5.473632812500087,4.9999999999954525,10.000000000005116,15.000000000000568,155.00000000000114,17.1875,6.289987714987714,16.28499984741211,16,4.999876022338867,5.0299999713897705,71.74999952316284,140.6499981880188,28.900001049041748,,,,,,, +no-exceptions,asyncify,chain,10,0,0,off,1,0,no-exceptions-1-asyncify-chain-10-0-0-off-1-0-10000,1,10000,100001,50.08,4.596500000000004,4.9999999999954525,10.000000000005116,10.000000000005116,245.00000000000455,25.11,1.9968250798722045,50.08500003814697,50,4.999876022338867,4.9649999141693115,71.74999952316284,125,28.400001525878906,,,,,,, +no-exceptions,asyncify,chain,10,0,0,off,1,0,no-exceptions-3-asyncify-chain-10-0-0-off-1-0-10000,3,10000,100001,50.004999999999995,4.578999999999986,4.9999999999954525,10.000000000005116,10.000000000005116,250.0,25.33,1.9998200179982004,50.00999999046326,50,4.999876022338867,4.034999847412109,69.84999895095825,124.50000047683716,28.15000057220459,,,,,,, +primary,asyncify,chain,5000,0,1,on,1,0,primary-1-asyncify-chain-5000-0-1-on-1-0-1024,1,1024,5120001,453.45000000000005,0.20996093749986455,0.0,0.0,4.9999999999954525,9.999999999990905,95.8984375,11.291214025802184,453.44999980926514,454,4.999876022338867,4.110000133514404,72.30000019073486,141.44999980926514,28.399999141693115,,,,,,, +work-64,asyncify,chain,10,0,0,on,1,64,work-64-2-asyncify-chain-10-0-0-on-1-64-10000,2,10000,100001,61.730000000000004,4.9474999999999785,4.9999999999954525,10.000000000005116,10.000000000019327,234.99999999999943,21.19,1.6199740806739023,61.74500012397766,62,4.999876022338867,4.9700000286102295,68.15000057220459,144.7000002861023,28.350000381469727,,,,,,, +work-64,jspi,chain,100,0,0,on,1,64,work-64-1-jspi-chain-100-0-0-on-1-64-1024,1,1024,102401,8.375,4.428710937500038,4.9999999999954525,10.000000000005116,10.000000000005116,215.0000000000034,28.125,12.226985074626866,8.380000114440918,8,4.999876022338867,2.2200000286102295,70.14999866485596,118.00000190734863,28.350000381469727,,,,,,, +no-exceptions,jspi,chain,10000,0,0,off,1,0,no-exceptions-3-jspi-chain-10000-0-0-off-1-0-1024,3,1024,10240001,282.79499999999996,5.312499999999804,4.9999999999954525,10.000000000005116,19.99999999998181,204.99999999998408,20.41015625,36.209978960024046,282.7999999523163,283,4.999876022338867,2.3550000190734863,68.15000057220459,118.05000066757202,28.349997997283936,,,,,,, +primary,asyncify,direct,1,1,0,on,1,0,primary-4-asyncify-direct-1-1-0-on-1-0-10000,4,10000,10000,57.075,5.556500000000002,4.9999999999954525,10.000000000005116,10.000000000005116,420.0000000000017,15.6,0.17520805957074023,57.10000014305115,57,4.999876022338867,4.09499979019165,72.5,143.64999771118164,28.900001049041748,0.250104480743407,1.101000189781189,0.7050002574920654,0.47650020122528075,1.5520002126693726,1.0485001087188721,0.4233945493698158 +primary,asyncify,chain,10000,0,1,on,1,0,primary-6-asyncify-chain-10000-0-1-on-1-0-1024,6,1024,10240001,875.715,0.21972656249991118,0.0,0.0,4.9999999999954525,5.000000000052296,95.60546875,11.693303186538998,875.7150001525879,875,4.999876022338867,5.080000162124634,70.45000076293945,142.7999997138977,28.05000066757202,,,,,,, +no-exceptions,asyncify,chain,5000,0,1,off,1,0,no-exceptions-3-asyncify-chain-5000-0-1-off-1-0-1024,3,1024,5120001,189.06,0.17578125000003442,0.0,0.0,5.000000000009663,5.000000000023874,96.484375,27.081355125357028,189.05999994277954,189,4.999876022338867,3.9649999141693115,70.70000171661377,123.65000009536743,28.15000057220459,,,,,,, +no-exceptions,asyncify,chain,100,0,1,off,1,0,no-exceptions-3-asyncify-chain-100-0-1-off-1-0-1024,3,1024,102401,4.5049999999999955,0.19042968749999334,0.0,0.0,5.000000000009663,5.000000000009663,96.19140625,22.730521642619337,4.505000114440918,4,4.999876022338867,4.945000171661377,69.7000002861023,123.99999856948853,28.499999046325684,,,,,,, +no-exceptions,jspi,chain,100,0,1,off,1,0,no-exceptions-2-jspi-chain-100-0-1-off-1-0-1024,2,1024,102401,3.5049999999999955,0.16601562499996003,0.0,0.0,4.9999999999954525,5.000000000009663,96.6796875,29.215691868758952,3.505000114440918,3,4.999876022338867,2.2149999141693115,72.10000038146973,116.8500018119812,28.19999933242798,,,,,,, +no-exceptions,jspi,chain,10000,0,1,off,1,0,no-exceptions-3-jspi-chain-10000-0-1-off-1-0-1024,3,1024,10240001,276.005,0.14648437499999167,0.0,0.0,4.9999999999954525,5.000000000052296,97.0703125,37.10078078295683,276.0050001144409,276,4.999876022338867,2.565000057220459,70.9499979019165,116.70000076293945,28.449997901916504,,,,,,, +no-exceptions,asyncify,chain,10,0,1,off,1,0,no-exceptions-2-asyncify-chain-10-0-1-off-1-0-10000,2,10000,100001,6.539999999999992,0.16000000000000797,0.0,0.0,4.9999999999954525,155.00000000000114,97.11,15.290672782874637,6.545000076293945,7,4.999876022338867,4.049999952316284,68.70000123977661,123.90000104904175,28.299999237060547,,,,,,, +work-64,jspi,chain,5000,0,1,on,1,64,work-64-2-jspi-chain-5000-0-1-on-1-64-1024,2,1024,5120001,167.155,0.21484375000001277,0.0,0.0,5.000000000009663,5.000000000023874,95.703125,30.63025934013341,167.15499997138977,167,4.999876022338867,2.1600000858306885,68.84999990463257,115.35000085830688,27.950000762939453,,,,,,, +work-64,asyncify,chain,1000,0,0,on,1,64,work-64-1-asyncify-chain-1000-0-0-on-1-64-1024,1,1024,1024001,97.41000000000001,5.913085937499895,4.9999999999954525,10.000000000005116,19.99999999999602,179.9999999999926,14.35546875,10.512278000205317,97.40999984741211,97,4.999876022338867,4.130000114440918,70.65000057220459,141.44999980926514,27.949998378753662,,,,,,, +js-control,js,js-direct,1,0,0,na,1,0,js-control-6-js-js-direct-1-0-0-na-1-0-10000,6,10000,10000,41.00500011444092,4.008000087738037,4.999876022338867,9.999990463256836,9.999990463256836,259.99999046325684,32.36,0.2438726977707837,41.014999866485596,41,4.999876022338867,0,70.89999914169312,,28.400001525878906,,,,,,, +primary,jspi,chain,5000,0,0,on,1,0,primary-7-jspi-chain-5000-0-0-on-1-0-1024,7,1024,5120001,162.07,4.853515624999708,4.9999999999954525,10.000000000005116,15.000000000000568,204.99999999998408,23.92578125,31.59129388535818,162.0699999332428,162,4.999876022338867,2.4700000286102295,67.65000104904175,117.40000009536743,27.850000858306885,,,,,,, +no-exceptions,asyncify,chain,100,0,0,off,1,0,no-exceptions-3-asyncify-chain-100-0-0-off-1-0-1024,3,1024,102401,8.33999999999999,4.829101562500132,4.9999999999954525,10.000000000005116,10.000000000005116,174.99999999999716,25.5859375,12.278297362110328,8.34500002861023,9,4.999876022338867,4.039999961853027,72.40000009536743,123.39999914169312,28.550000190734863,,,,,,, +no-exceptions,jspi,chain,10000,0,0,off,1,0,no-exceptions-1-jspi-chain-10000-0-0-off-1-0-1024,1,1024,10240001,273.09499999999997,5.239257812499412,4.9999999999954525,10.000000000019327,15.00000000001478,305.0000000000068,24.0234375,37.49611307420495,273.09499979019165,273,4.999876022338867,2.174999952316284,68.70000123977661,119.64999914169312,28.15000057220459,,,,,,, +primary,asyncify,chain,10000,0,1,on,1,0,primary-3-asyncify-chain-10000-0-1-on-1-0-1024,3,1024,10240001,907.635,0.21972656250003608,0.0,0.0,4.9999999999954525,5.000000000109139,95.60546875,11.282069334038463,907.6449999809265,908,4.999876022338867,5.034999847412109,69.20000076293945,140.79999923706055,28.05000066757202,,,,,,, +work-64,jspi,chain,1,0,0,on,1,64,work-64-2-jspi-chain-1-0-0-on-1-64-100000,2,100000,100001,442.315,4.284250000000003,4.9999999999954525,9.999999999990905,10.000000000047748,4015.0000000000146,29.386,0.22608548206594847,442.3250000476837,442,4.999876022338867,2.3449997901916504,68.59999895095825,117.14999914169312,28.15000057220459,,,,,,, +primary,jspi,chain,10000,0,1,on,1,0,primary-1-jspi-chain-10000-0-1-on-1-0-1024,1,1024,10240001,324.345,0.16601562499987677,0.0,0.0,4.9999999999954525,5.000000000009663,96.6796875,31.571323744777935,324.3550000190735,324,4.999876022338867,2.5250000953674316,72.10000038146973,119.60000038146973,28.450000286102295,,,,,,, +primary,asyncify,chain,1,0,0,on,1,0,primary-1-asyncify-chain-1-0-0-on-1-0-100000,1,100000,100001,507.25,4.9346000000000005,4.9999999999954525,9.999999999990905,10.000000000047748,4425.000000000011,21.601,0.19714342040413996,507.25,507,4.999876022338867,4.130000114440918,69.00000095367432,141.34999990463257,28.05000066757202,,,,,,, +work-64,asyncify,chain,10,0,1,on,1,64,work-64-3-asyncify-chain-10-0-1-on-1-64-10000,3,10000,100001,12.86,0.24450000000000216,0.0,0.0,5.000000000009663,125.0,95.35,7.7761275272161745,12.860000133514404,12,4.999876022338867,4.120000123977661,72.24999904632568,147.99999952316284,28.450000286102295,,,,,,, +work-64,asyncify,chain,10,0,0,on,1,64,work-64-3-asyncify-chain-10-0-0-on-1-64-10000,3,10000,100001,62.02000000000001,5.010499999999946,4.9999999999954525,10.000000000005116,10.000000000019327,235.00000000001364,19.99,1.6123992260561106,62.019999980926514,62,4.999876022338867,4.849999904632568,72.2000002861023,144.14999961853027,27.950000762939453,,,,,,, +primary,jspi,chain,1,0,1,on,1,0,primary-1-jspi-chain-1-0-1-on-1-0-100000,1,100000,100001,25.715000000000003,0.14185000000000159,0.0,0.0,4.9999999999954525,125.0,97.189,3.888819755006805,25.72000002861023,26,4.999876022338867,2.434999942779541,69.84999895095825,120.05000114440918,28.75,,,,,,, +work-64,jspi,chain,1,0,1,on,1,64,work-64-1-jspi-chain-1-0-1-on-1-64-100000,1,100000,100001,25.540000000000006,0.14169999999999974,0.0,0.0,4.9999999999954525,75.00000000000284,97.188,3.915465935787,25.545000076293945,26,4.999876022338867,2.2250001430511475,70.20000219345093,119.54999923706055,28.349997997283936,,,,,,, +primary,asyncify,chain,1,0,1,on,1,0,primary-7-asyncify-chain-1-0-1-on-1-0-100000,7,100000,100001,34.92,0.22399999999999964,0.0,0.0,5.000000000009663,140.00000000000057,95.567,2.8637170675830466,34.924999952316284,35,4.999876022338867,4.115000009536743,67.94999837875366,145.35000085830688,28.1000018119812,,,,,,, +js-control,js,js-direct,1,1,0,na,1,0,js-control-3-js-js-direct-1-1-0-na-1-0-10000,3,10000,10000,49.75499987602234,4.885000109672546,4.999876022338867,9.999990463256836,10.000228881835938,450.0000476837158,22.5,0.20098482614647029,49.765000104904175,49,4.999876022338867,0,71.74999952316284,,28.000001907348633,0.1764998435974121,1.1305001497268676,0.6955000638961792,0.4779999017715454,1.1959999084472657,1.047000241279602,0.1615000009536743 +primary,jspi,chain,10,0,0,on,1,0,primary-4-jspi-chain-10-0-0-on-1-0-10000,4,10000,100001,46.95,4.169500000000006,4.9999999999954525,10.000000000005116,10.000000000005116,254.99999999999545,29.85,2.129946751863685,46.950000047683716,47,4.999876022338867,2.305000066757202,69.14999961853027,120.59999942779541,28.250000476837158,,,,,,, diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/summary.json b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/summary.json new file mode 100644 index 0000000..006d184 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/results/2026-10-15/summary.json @@ -0,0 +1,9811 @@ +{ + "browser": "HeadlessChrome/153.0.8010.12", + "started": "2026-10-15T05:52:13.371Z", + "seed": 20261015, + "cases": 442, + "total_operations": 970139132, + "total_samples": 9429856, + "groups": [ + { + "group": "chain-trace", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.333007812499999, + "min": 6.333007812499957, + "max": 6.557617187499975, + "mean": 6.407877604166644 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 15.000000000000568, + "max": 15.000000000000568, + "mean": 15.000000000000568 + }, + "max_us": { + "median": 219.99999999999886, + "min": 210.00000000000796, + "max": 239.99999999999488, + "mean": 223.3333333333339 + }, + "elapsed_ms": { + "median": 6.7549999999999955, + "min": 6.720000000000013, + "max": 6.930000000000007, + "mean": 6.801666666666672 + }, + "million_ops_per_second": { + "median": 0.15173945225758706, + "min": 0.14790764790764777, + "max": 0.1525297619047616, + "mean": 0.1507256206899988 + }, + "zero_percent": { + "median": 12.5, + "min": 11.5234375, + "max": 12.890625, + "mean": 12.3046875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.075000047683716, + "min": 4.059999942779541, + "max": 4.9049999713897705, + "mean": 4.346666653951009 + }, + "performance_clock_loop_ns": { + "median": 71.05000019073486, + "min": 70.24999856948853, + "max": 72.45000123977661, + "mean": 71.25 + }, + "cpp_clock_loop_ns": { + "median": 140.80000162124634, + "min": 138.39999914169312, + "max": 143.1500005722046, + "mean": 140.78333377838135 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.799999713897705, + "max": 28.250000476837158, + "mean": 28.083333174387615 + }, + "component_means_us": { + "entry": 0.3531668769816652, + "channel_create": 1.1800140297661226, + "handler_setup": 0.7845046153912941, + "post_message": 0.5240896716713905, + "post_to_delivery": 1.7171217283854883, + "message_handler": 1.0009761899709702, + "resume": 0.8480044919997135 + } + }, + { + "group": "chain-trace", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.352539062500079, + "min": 6.230468749999926, + "max": 6.401367187499993, + "mean": 6.328124999999999 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 19.99999999999602, + "min": 19.99999999999602, + "max": 19.99999999999602, + "mean": 19.99999999999602 + }, + "max_us": { + "median": 230.00000000000398, + "min": 210.00000000000796, + "max": 239.99999999999488, + "mean": 226.66666666666893 + }, + "elapsed_ms": { + "median": 8.379999999999995, + "min": 8.365000000000009, + "max": 8.379999999999995, + "mean": 8.375 + }, + "million_ops_per_second": { + "median": 1.2220763723150365, + "min": 1.2220763723150365, + "max": 1.224267782426777, + "mean": 1.2228068423522833 + }, + "zero_percent": { + "median": 12.98828125, + "min": 11.23046875, + "max": 14.35546875, + "mean": 12.858072916666666 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.1499998569488525, + "min": 4.065000057220459, + "max": 4.93999981880188, + "mean": 4.384999910990397 + }, + "performance_clock_loop_ns": { + "median": 69.40000057220459, + "min": 68.39999914169312, + "max": 72.34999895095825, + "mean": 70.04999955495198 + }, + "cpp_clock_loop_ns": { + "median": 143.1500005722046, + "min": 137.5, + "max": 143.19999933242798, + "mean": 141.2833333015442 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.59999990463257, + "max": 28.350000381469727, + "mean": 27.983333269755047 + }, + "component_means_us": { + "entry": 0.42486831235381367, + "channel_create": 1.0742190449188154, + "handler_setup": 0.7291669026017189, + "post_message": 0.5159503780305386, + "post_to_delivery": 1.6748046036809683, + "message_handler": 1.0725903169562419, + "resume": 0.8365254414579026 + } + }, + { + "group": "chain-trace", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.37695312500014, + "min": 6.352539062500259, + "max": 6.645507812499965, + "mean": 6.458333333333455 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 19.99999999999602, + "min": 15.000000000000568, + "max": 19.99999999999602, + "mean": 18.33333333333087 + }, + "max_us": { + "median": 234.99999999999943, + "min": 219.99999999999886, + "max": 250.0, + "mean": 234.99999999999943 + }, + "elapsed_ms": { + "median": 16.614999999999995, + "min": 16.5, + "max": 17.235, + "mean": 16.78333333333333 + }, + "million_ops_per_second": { + "median": 6.163165814023475, + "min": 5.941456338845373, + "max": 6.206121212121212, + "mean": 6.103581121663353 + }, + "zero_percent": { + "median": 12.01171875, + "min": 10.7421875, + "max": 13.8671875, + "mean": 12.20703125 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.175000190734863, + "min": 4.099999904632568, + "max": 4.879999876022339, + "mean": 4.384999990463257 + }, + "performance_clock_loop_ns": { + "median": 70, + "min": 69.85000133514404, + "max": 71.10000133514404, + "mean": 70.3166675567627 + }, + "cpp_clock_loop_ns": { + "median": 138.99999856948853, + "min": 137.30000019073486, + "max": 140.15000104904175, + "mean": 138.81666660308838 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.54999876022339, + "max": 28.600001335144043, + "mean": 28.116666475931805 + }, + "component_means_us": { + "entry": 0.2832250048716983, + "channel_create": 1.1425781218955915, + "handler_setup": 0.8593760430812836, + "post_message": 0.553385199358066, + "post_to_delivery": 1.7757161986082792, + "message_handler": 1.0400393512099981, + "resume": 0.8040134143085381 + } + }, + { + "group": "chain-trace", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.704101562500147, + "min": 6.1865234374998685, + "max": 6.982421875000353, + "mean": 6.6243489583334565 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000019327, + "min": 10.000000000019327, + "max": 10.000000000019327, + "mean": 10.000000000019327 + }, + "p99_us": { + "median": 20.000000000010232, + "min": 19.99999999999602, + "max": 20.000000000010232, + "mean": 20.000000000005496 + }, + "max_us": { + "median": 219.99999999999886, + "min": 199.99999999998863, + "max": 245.00000000000455, + "mean": 221.666666666664 + }, + "elapsed_ms": { + "median": 94.84, + "min": 92.62499999999999, + "max": 96.03, + "mean": 94.49833333333333 + }, + "million_ops_per_second": { + "median": 10.797142555883593, + "min": 10.663344788087056, + "max": 11.055341430499327, + "mean": 10.838609591489991 + }, + "zero_percent": { + "median": 9.9609375, + "min": 8.3984375, + "max": 12.98828125, + "mean": 10.44921875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.059999942779541, + "min": 3.990000009536743, + "max": 4.985000133514404, + "mean": 4.3450000286102295 + }, + "performance_clock_loop_ns": { + "median": 71.25, + "min": 71.10000133514404, + "max": 72.00000047683716, + "mean": 71.45000060399373 + }, + "cpp_clock_loop_ns": { + "median": 139.45000171661377, + "min": 137.59999990463257, + "max": 142.4500012397766, + "mean": 139.83333428700766 + }, + "wall_clock_loop_ns": { + "median": 27.749998569488525, + "min": 27.650001049041748, + "max": 28.20000171661377, + "mean": 27.86666711171468 + }, + "component_means_us": { + "entry": 0.4231618003299233, + "channel_create": 1.1979157570749521, + "handler_setup": 0.7112639335294565, + "post_message": 0.514323745543758, + "post_to_delivery": 1.8115217487017314, + "message_handler": 1.0074868332594633, + "resume": 0.9586751398941717 + } + }, + { + "group": "chain-trace", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 7.5830078125005835, + "min": 7.167968750000448, + "max": 7.646484375000553, + "mean": 7.4658203125005285 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 14.999999999986358, + "min": 10.000000000047748, + "max": 14.999999999986358, + "mean": 13.333333333340155 + }, + "p99_us": { + "median": 25.000000000005684, + "min": 25.000000000005684, + "max": 30.000000000001137, + "mean": 26.666666666670835 + }, + "max_us": { + "median": 269.9999999999818, + "min": 259.9999999999909, + "max": 284.99999999996817, + "mean": 271.66666666664696 + }, + "elapsed_ms": { + "median": 455.76, + "min": 443.93, + "max": 456.22, + "mean": 451.97 + }, + "million_ops_per_second": { + "median": 11.233984992101107, + "min": 11.22265792819254, + "max": 11.53335210506161, + "mean": 11.329998341785085 + }, + "zero_percent": { + "median": 8.59375, + "min": 6.4453125, + "max": 9.765625, + "mean": 8.268229166666666 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.080000162124634, + "min": 4.070000171661377, + "max": 4.990000009536743, + "mean": 4.380000114440918 + }, + "performance_clock_loop_ns": { + "median": 69.54999923706055, + "min": 67.99999952316284, + "max": 70.44999837875366, + "mean": 69.33333237965901 + }, + "cpp_clock_loop_ns": { + "median": 139.24999952316284, + "min": 137.75000095367432, + "max": 144.19999837875366, + "mean": 140.39999961853027 + }, + "wall_clock_loop_ns": { + "median": 28.1499981880188, + "min": 27.699999809265137, + "max": 28.599998950958252, + "mean": 28.149998982747395 + }, + "component_means_us": { + "entry": 0.3434486128390396, + "channel_create": 1.3557950345178444, + "handler_setup": 0.9521491980801026, + "post_message": 0.6901051383465528, + "post_to_delivery": 1.816405061011513, + "message_handler": 1.1116532453646262, + "resume": 1.1962640223408492 + } + }, + { + "group": "chain-trace", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 8.115234374999753, + "min": 7.9687500000003295, + "max": 8.261718749999952, + "mean": 8.11523437500001 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 14.999999999986358, + "min": 14.999999999986358, + "max": 14.999999999986358, + "mean": 14.999999999986358 + }, + "p99_us": { + "median": 25.000000000034106, + "min": 25.000000000005684, + "max": 29.999999999972715, + "mean": 26.666666666670835 + }, + "max_us": { + "median": 350.00000000002274, + "min": 299.9999999999545, + "max": 370.00000000000455, + "mean": 339.9999999999939 + }, + "elapsed_ms": { + "median": 888.69, + "min": 879.465, + "max": 902.915, + "mean": 890.3566666666667 + }, + "million_ops_per_second": { + "median": 11.52257930211885, + "min": 11.34104649939363, + "max": 11.64344345710176, + "mean": 11.50235641953808 + }, + "zero_percent": { + "median": 6.8359375, + "min": 6.0546875, + "max": 8.59375, + "mean": 7.161458333333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.09499979019165, + "min": 4.0899999141693115, + "max": 4.110000133514404, + "mean": 4.098333279291789 + }, + "performance_clock_loop_ns": { + "median": 68.80000114440918, + "min": 68.65000009536743, + "max": 71.50000095367432, + "mean": 69.65000073115031 + }, + "cpp_clock_loop_ns": { + "median": 143.35000038146973, + "min": 141.94999933242798, + "max": 151.95000171661377, + "mean": 145.75000047683716 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.999999523162842, + "max": 28.399999141693115, + "mean": 28.19999933242798 + }, + "component_means_us": { + "entry": 0.36298852413898614, + "channel_create": 1.5852863434702158, + "handler_setup": 0.818685395643115, + "post_message": 0.7242830470204353, + "post_to_delivery": 2.2460924616704383, + "message_handler": 1.0628253997613986, + "resume": 1.3150732032954222 + } + }, + { + "group": "chain-trace", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.131835937499981, + "min": 5.07812500000003, + "max": 5.151367187500034, + "mean": 5.120442708333348 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 14.999999999986358, + "max": 15.000000000000568, + "mean": 14.999999999995831 + }, + "max_us": { + "median": 234.99999999999943, + "min": 230.00000000000398, + "max": 239.99999999999488, + "mean": 234.99999999999943 + }, + "elapsed_ms": { + "median": 5.474999999999994, + "min": 5.445000000000007, + "max": 5.515000000000001, + "mean": 5.478333333333334 + }, + "million_ops_per_second": { + "median": 0.18721461187214633, + "min": 0.18585675430643697, + "max": 0.18824609733700617, + "mean": 0.18710582117186317 + }, + "zero_percent": { + "median": 21.484375, + "min": 20.1171875, + "max": 21.58203125, + "mean": 21.061197916666668 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3000001907348633, + "min": 2.0999999046325684, + "max": 2.430000066757202, + "mean": 2.2766667207082114 + }, + "performance_clock_loop_ns": { + "median": 71.00000143051147, + "min": 68.70000123977661, + "max": 73.25000047683716, + "mean": 70.98333438237508 + }, + "cpp_clock_loop_ns": { + "median": 117.14999914169312, + "min": 115.9500002861023, + "max": 119.34999942779541, + "mean": 117.4833329518636 + }, + "wall_clock_loop_ns": { + "median": 27.850000858306885, + "min": 27.849998474121094, + "max": 28.19999933242798, + "mean": 27.966666221618652 + }, + "component_means_us": { + "entry": 0.24904296112555438, + "channel_create": 1.0563150669137638, + "handler_setup": 0.7405596940467755, + "post_message": 0.5094395795216163, + "post_to_delivery": 1.246746319035689, + "message_handler": 1.0546866493920486, + "resume": 0.2636524382979011 + } + }, + { + "group": "chain-trace", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.229492187500032, + "min": 5.224609375000008, + "max": 5.356445312499944, + "mean": 5.270182291666662 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 13.333333333335418 + }, + "max_us": { + "median": 230.00000000000398, + "min": 230.00000000000398, + "max": 254.99999999999545, + "mean": 238.33333333333448 + }, + "elapsed_ms": { + "median": 6.045000000000002, + "min": 5.904999999999987, + "max": 6.064999999999998, + "mean": 6.0049999999999955 + }, + "million_ops_per_second": { + "median": 1.6941273779983452, + "min": 1.6885408079142628, + "max": 1.7342929720575821, + "mean": 1.7056537193233967 + }, + "zero_percent": { + "median": 18.84765625, + "min": 18.359375, + "max": 19.3359375, + "mean": 18.84765625 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.434999942779541, + "min": 2.180000066757202, + "max": 2.505000114440918, + "mean": 2.3733333746592202 + }, + "performance_clock_loop_ns": { + "median": 68.80000114440918, + "min": 66.84999942779541, + "max": 71.44999980926514, + "mean": 69.03333346048991 + }, + "cpp_clock_loop_ns": { + "median": 114.80000019073486, + "min": 113.4500002861023, + "max": 119.0499997138977, + "mean": 115.76666673024495 + }, + "wall_clock_loop_ns": { + "median": 27.800002098083496, + "min": 27.799999713897705, + "max": 28.250000476837158, + "mean": 27.950000762939453 + }, + "component_means_us": { + "entry": 0.29947712396576065, + "channel_create": 1.158855389803648, + "handler_setup": 0.815430578465263, + "post_message": 0.5371089403827985, + "post_to_delivery": 1.1783847585320473, + "message_handler": 1.018881021688382, + "resume": 0.262044478828762 + } + }, + { + "group": "chain-trace", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.219726562499916, + "min": 5.180664062500117, + "max": 5.283203124999941, + "mean": 5.227864583333325 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 13.333333333335418 + }, + "max_us": { + "median": 245.00000000000455, + "min": 219.99999999999886, + "max": 250.0, + "mean": 238.33333333333448 + }, + "elapsed_ms": { + "median": 9.075000000000003, + "min": 9.054999999999993, + "max": 9.090000000000003, + "mean": 9.073333333333332 + }, + "million_ops_per_second": { + "median": 11.283856749311292, + "min": 11.26523652365236, + "max": 11.308779679734961, + "mean": 11.285957650899539 + }, + "zero_percent": { + "median": 18.9453125, + "min": 18.359375, + "max": 19.04296875, + "mean": 18.782552083333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.424999952316284, + "min": 2.190000057220459, + "max": 2.4700000286102295, + "mean": 2.361666679382324 + }, + "performance_clock_loop_ns": { + "median": 70.65000057220459, + "min": 67.85000085830688, + "max": 73.25000047683716, + "mean": 70.58333396911621 + }, + "cpp_clock_loop_ns": { + "median": 117.2000002861023, + "min": 116.64999961853027, + "max": 119.60000038146973, + "mean": 117.8166667620341 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.799999713897705, + "max": 28.399999141693115, + "mean": 28.083333174387615 + }, + "component_means_us": { + "entry": 0.24249706727763146, + "channel_create": 1.0237636355062325, + "handler_setup": 0.8610015890250603, + "post_message": 0.5371100269258022, + "post_to_delivery": 1.2467434474577506, + "message_handler": 1.0498042684048414, + "resume": 0.26694454873600615 + } + }, + { + "group": "chain-trace", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.395507812499992, + "min": 5.351562499999796, + "max": 5.566406249999795, + "mean": 5.4378255208331945 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 15.000000000000568, + "max": 15.000000000000568, + "mean": 15.000000000000568 + }, + "max_us": { + "median": 230.00000000000398, + "min": 225.00000000000853, + "max": 234.99999999999943, + "mean": 230.00000000000398 + }, + "elapsed_ms": { + "median": 37.32499999999999, + "min": 37.16499999999999, + "max": 37.425, + "mean": 37.30499999999999 + }, + "million_ops_per_second": { + "median": 27.434722036168797, + "min": 27.361416165664664, + "max": 27.552831965558997, + "mean": 27.44965672246415 + }, + "zero_percent": { + "median": 18.06640625, + "min": 17.28515625, + "max": 18.45703125, + "mean": 17.936197916666668 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.325000047683716, + "min": 2.1599998474121094, + "max": 2.440000057220459, + "mean": 2.3083333174387612 + }, + "performance_clock_loop_ns": { + "median": 70.89999914169312, + "min": 70.79999923706055, + "max": 72.65000104904175, + "mean": 71.44999980926514 + }, + "cpp_clock_loop_ns": { + "median": 117.99999952316284, + "min": 117.35000133514404, + "max": 118.59999895095825, + "mean": 117.98333326975505 + }, + "wall_clock_loop_ns": { + "median": 28.000001907348633, + "min": 27.54999876022339, + "max": 28.20000171661377, + "mean": 27.916667461395264 + }, + "component_means_us": { + "entry": 0.20347531264024166, + "channel_create": 1.1865245178341866, + "handler_setup": 0.8170569781213999, + "post_message": 0.5631504269937674, + "post_to_delivery": 1.3720712934931119, + "message_handler": 1.0074869884798925, + "resume": 0.28806000327059417 + } + }, + { + "group": "chain-trace", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.600585937500332, + "min": 5.581054687500461, + "max": 6.24023437499989, + "mean": 5.807291666666894 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000019327, + "min": 10.000000000019327, + "max": 10.000000000019327, + "mean": 10.000000000019327 + }, + "p99_us": { + "median": 15.00000000001478, + "min": 15.00000000001478, + "max": 20.000000000010232, + "mean": 16.66666666667993 + }, + "max_us": { + "median": 260.0000000000193, + "min": 240.0000000000091, + "max": 269.9999999999818, + "mean": 256.6666666666701 + }, + "elapsed_ms": { + "median": 161.51, + "min": 160.6, + "max": 169.13, + "mean": 163.74666666666667 + }, + "million_ops_per_second": { + "median": 31.700829669989474, + "min": 30.272577307396677, + "max": 31.880454545454548, + "mean": 31.284620507613567 + }, + "zero_percent": { + "median": 16.9921875, + "min": 14.74609375, + "max": 18.65234375, + "mean": 16.796875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.505000114440918, + "min": 2.2149999141693115, + "max": 2.674999952316284, + "mean": 2.4649999936421714 + }, + "performance_clock_loop_ns": { + "median": 71.80000066757202, + "min": 69.55000162124634, + "max": 72.1999979019165, + "mean": 71.18333339691162 + }, + "cpp_clock_loop_ns": { + "median": 117.95000076293945, + "min": 117.85000085830688, + "max": 120, + "mean": 118.60000054041545 + }, + "wall_clock_loop_ns": { + "median": 27.799999713897705, + "min": 27.750000953674316, + "max": 28.15000057220459, + "mean": 27.90000041325887 + }, + "component_means_us": { + "entry": 0.1888463180513648, + "channel_create": 1.2955725348244111, + "handler_setup": 0.779622777675589, + "post_message": 0.5908207191775242, + "post_to_delivery": 1.5673825206855934, + "message_handler": 1.0856122244149446, + "resume": 0.29943457183746747 + } + }, + { + "group": "chain-trace", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.181640624999887, + "min": 6.010742187499959, + "max": 6.269531249999682, + "mean": 6.15397135416651 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000019327, + "min": 10.000000000019327, + "max": 10.000000000047748, + "mean": 10.0000000000288 + }, + "p99_us": { + "median": 15.000000000043201, + "min": 15.000000000043201, + "max": 20.000000000010232, + "mean": 16.666666666698877 + }, + "max_us": { + "median": 305.0000000000068, + "min": 264.99999999998636, + "max": 345.0000000000273, + "mean": 305.0000000000068 + }, + "elapsed_ms": { + "median": 314.505, + "min": 313.78, + "max": 367.13, + "mean": 331.805 + }, + "million_ops_per_second": { + "median": 32.559103988807806, + "min": 27.892030071091984, + "max": 32.6343329721461, + "mean": 31.028489010681962 + }, + "zero_percent": { + "median": 15.0390625, + "min": 14.2578125, + "max": 15.72265625, + "mean": 15.006510416666666 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.384999990463257, + "min": 2.179999828338623, + "max": 2.615000009536743, + "mean": 2.3933332761128745 + }, + "performance_clock_loop_ns": { + "median": 69.75000143051147, + "min": 67.59999990463257, + "max": 72.59999990463257, + "mean": 69.98333374659221 + }, + "cpp_clock_loop_ns": { + "median": 119.0499997138977, + "min": 117.40000009536743, + "max": 120.99999904632568, + "mean": 119.14999961853027 + }, + "wall_clock_loop_ns": { + "median": 27.799999713897705, + "min": 27.649998664855957, + "max": 28.19999933242798, + "mean": 27.88333257039388 + }, + "component_means_us": { + "entry": 0.35643927132097036, + "channel_create": 1.367187515522043, + "handler_setup": 0.9065747726708651, + "post_message": 0.5940750706940889, + "post_to_delivery": 1.4990241422007482, + "message_handler": 1.1409504804760218, + "resume": 0.28972010128177256 + } + }, + { + "group": "js-control", + "variant": "js", + "mode": "js-direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "na", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 3.92549991607666, + "min": 3.849999761581421, + "max": 4.008000087738037, + "mean": 3.929785714830671 + }, + "p50_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "p95_us": { + "median": 9.999990463256836, + "min": 9.999990463256836, + "max": 9.999990463256836, + "mean": 9.999990463256836 + }, + "p99_us": { + "median": 9.999990463256836, + "min": 9.999990463256836, + "max": 9.999990463256836, + "mean": 9.999990463256836 + }, + "max_us": { + "median": 265.0001049041748, + "min": 254.99987602233887, + "max": 285.0000858306885, + "mean": 269.2857129233224 + }, + "elapsed_ms": { + "median": 40.13000011444092, + "min": 39.38000011444092, + "max": 41.00500011444092, + "mean": 40.1728572504861 + }, + "million_ops_per_second": { + "median": 0.24919013136014087, + "min": 0.2438726977707837, + "max": 0.2539360073879972, + "mean": 0.24896194494779247 + }, + "zero_percent": { + "median": 32.88, + "min": 32.36, + "max": 34.15, + "mean": 33.004285714285714 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 0, + "min": 0, + "max": 0, + "mean": 0 + }, + "performance_clock_loop_ns": { + "median": 70.89999914169312, + "min": 67.95000076293945, + "max": 72.04999923706055, + "mean": 70.37857191903251 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.799999713897705, + "max": 28.550000190734863, + "mean": 28.20714235305786 + } + }, + { + "group": "js-control", + "variant": "js", + "mode": "js-direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "na", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 4.8289999723434445, + "min": 4.77900002002716, + "max": 4.885000109672546, + "mean": 4.821714210510254 + }, + "p50_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "p95_us": { + "median": 9.999990463256836, + "min": 9.999990463256836, + "max": 9.999990463256836, + "mean": 9.999990463256836 + }, + "p99_us": { + "median": 10.000228881835938, + "min": 10.000228881835938, + "max": 10.000228881835938, + "mean": 10.000228881835938 + }, + "max_us": { + "median": 454.9999237060547, + "min": 445.00017166137695, + "max": 480.0000190734863, + "mean": 457.8572000776018 + }, + "elapsed_ms": { + "median": 49.105000019073486, + "min": 48.59000015258789, + "max": 49.75499987602234, + "mean": 49.08928574834551 + }, + "million_ops_per_second": { + "median": 0.20364524989544394, + "min": 0.20098482614647029, + "max": 0.20580366265891856, + "mean": 0.20372223384884416 + }, + "zero_percent": { + "median": 22.8, + "min": 22.5, + "max": 23.36, + "mean": 22.858571428571427 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 0, + "min": 0, + "max": 0, + "mean": 0 + }, + "performance_clock_loop_ns": { + "median": 71.29999876022339, + "min": 70.2999997138977, + "max": 71.84999942779541, + "mean": 71.22142825807843 + }, + "wall_clock_loop_ns": { + "median": 27.949998378753662, + "min": 27.650001049041748, + "max": 28.65000009536743, + "mean": 27.99285752432687 + }, + "component_means_us": { + "entry": 0.21564278943198067, + "channel_create": 1.075000044277736, + "handler_setup": 0.6972144365310669, + "post_message": 0.4723570142473493, + "post_to_delivery": 1.1878570829119002, + "message_handler": 1.0169284105300904, + "resume": 0.15671443258013043 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 4.425450000000001, + "min": 4.37324999999999, + "max": 4.8842000000000025, + "mean": 4.560966666666665 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 9.999999999990905, + "min": 9.999999999990905, + "max": 9.999999999990905, + "mean": 9.999999999990905 + }, + "p99_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "max_us": { + "median": 4250.0, + "min": 4195.000000000022, + "max": 39495.00000000001, + "mean": 15980.00000000001 + }, + "elapsed_ms": { + "median": 456.205, + "min": 450.75, + "max": 501.69000000000005, + "mean": 469.54833333333335 + }, + "million_ops_per_second": { + "median": 0.2192018938854243, + "min": 0.19932827044589285, + "max": 0.2218546866333888, + "mean": 0.21346161698823532 + }, + "zero_percent": { + "median": 27.831, + "min": 27.643, + "max": 28.233, + "mean": 27.902333333333335 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.954999923706055, + "min": 4.009999990463257, + "max": 5.044999837875366, + "mean": 4.669999917348226 + }, + "performance_clock_loop_ns": { + "median": 69.54999923706055, + "min": 68.19999933242798, + "max": 70.80000162124634, + "mean": 69.51666673024495 + }, + "cpp_clock_loop_ns": { + "median": 123.59999895095825, + "min": 121.19999885559082, + "max": 130.2999997138977, + "mean": 125.0333325068156 + }, + "wall_clock_loop_ns": { + "median": 27.650001049041748, + "min": 27.249999046325684, + "max": 28.09999942779541, + "mean": 27.666666507720947 + }, + "paired_slowdown": { + "median": 18.379204892966367, + "min": 18.157412935323382, + "max": 20.38561560341325 + }, + "paired_net_us_per_yield": { + "median": 4.3108, + "min": 4.26225, + "max": 4.7708 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 0.1397499999999991, + "min": 0.1358000000000034, + "max": 0.14054999999999468, + "mean": 0.13869999999999905 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 134.9999999999909, + "min": 109.99999999999943, + "max": 140.00000000000057, + "mean": 128.3333333333303 + }, + "elapsed_ms": { + "median": 24.61, + "min": 24.52499999999999, + "max": 25.125, + "mean": 24.75333333333333 + }, + "million_ops_per_second": { + "median": 4.06342950020317, + "min": 3.980139303482587, + "max": 4.077512742099899, + "mean": 4.040360515261885 + }, + "zero_percent": { + "median": 97.24, + "min": 97.22, + "max": 97.323, + "mean": 97.261 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.829999923706055, + "min": 4.099999904632568, + "max": 4.9049999713897705, + "mean": 4.611666599909465 + }, + "performance_clock_loop_ns": { + "median": 70.39999961853027, + "min": 67.74999856948853, + "max": 72.95000076293945, + "mean": 70.36666631698608 + }, + "cpp_clock_loop_ns": { + "median": 122.30000019073486, + "min": 122.14999914169312, + "max": 124.49999809265137, + "mean": 122.98333247502644 + }, + "wall_clock_loop_ns": { + "median": 27.899999618530273, + "min": 27.700002193450928, + "max": 28.450000286102295, + "mean": 28.016667366027832 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.578999999999986, + "min": 4.568500000000034, + "max": 4.596500000000004, + "mean": 4.581333333333341 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 250.0, + "min": 245.00000000000455, + "max": 259.9999999999909, + "mean": 251.66666666666515 + }, + "elapsed_ms": { + "median": 50.004999999999995, + "min": 49.705, + "max": 50.08, + "mean": 49.93 + }, + "million_ops_per_second": { + "median": 1.9998200179982004, + "min": 1.9968250798722045, + "max": 2.0118901518961874, + "mean": 2.0028450832555307 + }, + "zero_percent": { + "median": 25.32, + "min": 25.11, + "max": 25.33, + "mean": 25.253333333333334 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.090000152587891, + "min": 4.034999847412109, + "max": 4.9649999141693115, + "mean": 4.3633333047231035 + }, + "performance_clock_loop_ns": { + "median": 71.10000133514404, + "min": 69.84999895095825, + "max": 71.74999952316284, + "mean": 70.89999993642171 + }, + "cpp_clock_loop_ns": { + "median": 124.50000047683716, + "min": 123.65000009536743, + "max": 125, + "mean": 124.38333352406819 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.5, + "max": 28.400001525878906, + "mean": 28.016667366027832 + }, + "paired_slowdown": { + "median": 7.758727695888276, + "min": 7.600152905198786, + "max": 7.800623052959499 + }, + "paired_net_us_per_yield": { + "median": 4.355999999999999, + "min": 4.3165000000000004, + "max": 4.366 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 0.16000000000000797, + "min": 0.13650000000002507, + "max": 0.16050000000000467, + "mean": 0.1523333333333459 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 125.0, + "min": 5.000000000009663, + "max": 155.00000000000114, + "mean": 95.0000000000036 + }, + "elapsed_ms": { + "median": 6.445000000000007, + "min": 6.420000000000002, + "max": 6.539999999999992, + "mean": 6.468333333333334 + }, + "million_ops_per_second": { + "median": 15.516058960434428, + "min": 15.290672782874637, + "max": 15.576479750778812, + "mean": 15.461070498029292 + }, + "zero_percent": { + "median": 97.11, + "min": 97.05, + "max": 97.27, + "mean": 97.14333333333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.074999809265137, + "min": 4.049999952316284, + "max": 4.884999990463257, + "mean": 4.336666584014893 + }, + "performance_clock_loop_ns": { + "median": 71.94999933242798, + "min": 68.70000123977661, + "max": 72.69999980926514, + "mean": 71.11666679382324 + }, + "cpp_clock_loop_ns": { + "median": 123.90000104904175, + "min": 123.59999895095825, + "max": 124.75000143051147, + "mean": 124.08333381017049 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.749998569488525, + "max": 28.299999237060547, + "mean": 28.083332379659016 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.829101562500132, + "min": 4.794921874999789, + "max": 4.863281250000018, + "mean": 4.82910156249998 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 174.99999999999716, + "min": 149.99999999999147, + "max": 180.00000000000682, + "mean": 168.3333333333318 + }, + "elapsed_ms": { + "median": 8.310000000000002, + "min": 8.280000000000001, + "max": 8.33999999999999, + "mean": 8.309999999999997 + }, + "million_ops_per_second": { + "median": 12.322623345367024, + "min": 12.278297362110328, + "max": 12.367270531400964, + "mean": 12.322730412959439 + }, + "zero_percent": { + "median": 24.609375, + "min": 21.97265625, + "max": 25.5859375, + "mean": 24.055989583333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.9100000858306885, + "min": 4.039999961853027, + "max": 4.945000171661377, + "mean": 4.631666739781697 + }, + "performance_clock_loop_ns": { + "median": 71.09999895095825, + "min": 68.65000009536743, + "max": 72.40000009536743, + "mean": 70.71666638056438 + }, + "cpp_clock_loop_ns": { + "median": 124.24999952316284, + "min": 123.39999914169312, + "max": 124.74999904632568, + "mean": 124.13333257039388 + }, + "wall_clock_loop_ns": { + "median": 28.20000171661377, + "min": 27.59999990463257, + "max": 28.550000190734863, + "mean": 28.1166672706604 + }, + "paired_slowdown": { + "median": 1.8512763596004433, + "min": 1.8026030368763564, + "max": 1.9255813953488388 + }, + "paired_net_us_per_yield": { + "median": 3.745117187499994, + "min": 3.6132812500000027, + "max": 3.886718750000004 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.14160156249998224, + "min": 0.10742187499997169, + "max": 0.19042968749999334, + "mean": 0.14648437499998243 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 4.5049999999999955, + "min": 4.299999999999997, + "max": 4.609999999999999, + "mean": 4.471666666666664 + }, + "million_ops_per_second": { + "median": 22.730521642619337, + "min": 22.212798264642085, + "max": 23.814186046511644, + "mean": 22.91916865125769 + }, + "zero_percent": { + "median": 97.16796875, + "min": 96.19140625, + "max": 97.8515625, + "mean": 97.0703125 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.945000171661377, + "min": 4.819999933242798, + "max": 5.069999933242798, + "mean": 4.945000012715657 + }, + "performance_clock_loop_ns": { + "median": 69.7000002861023, + "min": 69.45000171661377, + "max": 71.60000085830688, + "mean": 70.25000095367432 + }, + "cpp_clock_loop_ns": { + "median": 124.90000009536743, + "min": 123.99999856948853, + "max": 125.20000219345093, + "mean": 124.7000002861023 + }, + "wall_clock_loop_ns": { + "median": 28.1499981880188, + "min": 27.59999990463257, + "max": 28.499999046325684, + "mean": 28.083332379659016 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.941406249999572, + "min": 4.892578125000102, + "max": 5.029296874999853, + "mean": 4.954427083333176 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 13.333333333335418 + }, + "max_us": { + "median": 174.99999999999716, + "min": 160.0000000000108, + "max": 179.9999999999926, + "mean": 171.66666666666686 + }, + "elapsed_ms": { + "median": 32.685, + "min": 32.455, + "max": 33.035, + "mean": 32.725 + }, + "million_ops_per_second": { + "median": 31.329386568762427, + "min": 30.997457242318756, + "max": 31.551409644122632, + "mean": 31.292751151734606 + }, + "zero_percent": { + "median": 21.6796875, + "min": 21.38671875, + "max": 21.77734375, + "mean": 21.614583333333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.055000066757202, + "min": 4.0350000858306885, + "max": 4.955000162124634, + "mean": 4.348333438237508 + }, + "performance_clock_loop_ns": { + "median": 70.05000114440918, + "min": 69.6500015258789, + "max": 70.9500002861023, + "mean": 70.21666765213013 + }, + "cpp_clock_loop_ns": { + "median": 121.49999856948853, + "min": 120.65000057220459, + "max": 123.65000009536743, + "mean": 121.93333307902019 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.850000858306885, + "max": 28.450000286102295, + "mean": 28.166666825612385 + }, + "paired_slowdown": { + "median": 0.8616053776196125, + "min": 0.8481641186462825, + "max": 0.8739417989417989 + }, + "paired_net_us_per_yield": { + "median": -5.126953125, + "min": -5.673828125000002, + "max": -4.653320312500001 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.12207031249995837, + "min": 0.11230468749989786, + "max": 0.1269531249999678, + "mean": 0.12044270833327468 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000004927 + }, + "elapsed_ms": { + "median": 37.935, + "min": 37.8, + "max": 38.265, + "mean": 38.0 + }, + "million_ops_per_second": { + "median": 26.993567945169367, + "min": 26.76077355285509, + "max": 27.089973544973546, + "mean": 26.94810501433267 + }, + "zero_percent": { + "median": 97.55859375, + "min": 97.4609375, + "max": 97.75390625, + "mean": 97.59114583333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.015000104904175, + "min": 3.9800000190734863, + "max": 5.059999942779541, + "mean": 4.351666688919067 + }, + "performance_clock_loop_ns": { + "median": 71.79999828338623, + "min": 69.34999942779541, + "max": 72.14999914169312, + "mean": 71.09999895095825 + }, + "cpp_clock_loop_ns": { + "median": 123.89999866485596, + "min": 122.35000133514404, + "max": 126.25, + "mean": 124.16666666666667 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.750000953674316, + "max": 28.19999933242798, + "mean": 27.966667016347248 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.98535156249981, + "min": 4.907226562500034, + "max": 5.083007812500082, + "mean": 4.991861979166642 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 15.000000000000568, + "max": 15.000000000000568, + "mean": 15.000000000000568 + }, + "max_us": { + "median": 165.00000000000625, + "min": 165.00000000000625, + "max": 165.00000000000625, + "mean": 165.00000000000625 + }, + "elapsed_ms": { + "median": 139.115, + "min": 134.38, + "max": 140.955, + "mean": 138.15 + }, + "million_ops_per_second": { + "median": 36.80409014125004, + "min": 36.32365648611259, + "max": 38.10091531477899, + "mean": 37.07622064738054 + }, + "zero_percent": { + "median": 22.94921875, + "min": 22.0703125, + "max": 24.21875, + "mean": 23.079427083333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.875, + "min": 3.9800000190734863, + "max": 4.894999980926514, + "mean": 4.583333333333333 + }, + "performance_clock_loop_ns": { + "median": 68.30000162124634, + "min": 67.7999997138977, + "max": 71.5499997138977, + "mean": 69.21666701634724 + }, + "cpp_clock_loop_ns": { + "median": 122.85000085830688, + "min": 120.89999914169312, + "max": 126.80000066757202, + "mean": 123.51666688919067 + }, + "wall_clock_loop_ns": { + "median": 28.250000476837158, + "min": 27.950000762939453, + "max": 28.550000190734863, + "mean": 28.250000476837158 + }, + "paired_slowdown": { + "median": 0.7358246059452026, + "min": 0.7229395308801377, + "max": 0.7491429938082964 + }, + "paired_net_us_per_yield": { + "median": -48.77441406249999, + "min": -50.29296875, + "max": -46.093749999999986 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.1220703125, + "min": 0.12207031249991673, + "max": 0.17578125000003442, + "mean": 0.13997395833331705 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000009663, + "max": 5.000000000023874, + "mean": 5.000000000019138 + }, + "elapsed_ms": { + "median": 188.155, + "min": 185.88, + "max": 189.06, + "mean": 187.69833333333332 + }, + "million_ops_per_second": { + "median": 27.211612766070527, + "min": 27.081355125357028, + "max": 27.544657843770175, + "mean": 27.279208578399242 + }, + "zero_percent": { + "median": 97.55859375, + "min": 96.484375, + "max": 97.55859375, + "mean": 97.20052083333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.09499979019165, + "min": 3.9649999141693115, + "max": 5.055000066757202, + "mean": 4.371666590372722 + }, + "performance_clock_loop_ns": { + "median": 70.70000171661377, + "min": 67.99999952316284, + "max": 72.65000104904175, + "mean": 70.45000076293945 + }, + "cpp_clock_loop_ns": { + "median": 123.65000009536743, + "min": 123.15000057220459, + "max": 125.04999876022339, + "mean": 123.94999980926514 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.850000858306885, + "max": 28.350000381469727, + "mean": 28.1166672706604 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.473632812500323, + "min": 5.380859374999964, + "max": 5.63476562500001, + "mean": 5.4964192708334325 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000019327, + "min": 10.000000000019327, + "max": 10.000000000019327, + "mean": 10.000000000019327 + }, + "p99_us": { + "median": 19.99999999998181, + "min": 15.000000000043201, + "max": 19.99999999999602, + "mean": 18.333333333340345 + }, + "max_us": { + "median": 180.00000000000682, + "min": 180.00000000000682, + "max": 210.00000000000796, + "mean": 190.0000000000072 + }, + "elapsed_ms": { + "median": 271.815, + "min": 269.55, + "max": 274.21, + "mean": 271.85833333333335 + }, + "million_ops_per_second": { + "median": 37.67268546621783, + "min": 37.34364538127713, + "max": 37.98924503802634, + "mean": 37.668525295173765 + }, + "zero_percent": { + "median": 19.3359375, + "min": 18.75, + "max": 20.5078125, + "mean": 19.53125 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.059999942779541, + "min": 4.015000104904175, + "max": 4.950000047683716, + "mean": 4.3416666984558105 + }, + "performance_clock_loop_ns": { + "median": 72.44999885559082, + "min": 69.7000002861023, + "max": 72.70000219345093, + "mean": 71.61666711171468 + }, + "cpp_clock_loop_ns": { + "median": 123.65000009536743, + "min": 123.15000057220459, + "max": 125.24999856948853, + "mean": 124.01666641235352 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 28.15000057220459, + "max": 28.70000123977661, + "mean": 28.350000381469727 + }, + "paired_slowdown": { + "median": 0.749645409795033, + "min": 0.7404789146779994, + "max": 0.7656182379137523 + }, + "paired_net_us_per_yield": { + "median": -87.91015624999999, + "min": -93.03222656249999, + "max": -81.97753906250004 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.16113281249993672, + "min": 0.14648437500004718, + "max": 0.16601562500008493, + "mean": 0.1578776041666896 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000052296, + "min": 5.000000000052296, + "max": 5.000000000052296, + "mean": 5.000000000052296 + }, + "elapsed_ms": { + "median": 359.57, + "min": 358.15500000000003, + "max": 367.08, + "mean": 361.6016666666667 + }, + "million_ops_per_second": { + "median": 28.478463164335178, + "min": 27.895829247030623, + "max": 28.590975974089428, + "mean": 28.321756128485077 + }, + "zero_percent": { + "median": 96.77734375, + "min": 96.6796875, + "max": 97.0703125, + "mean": 96.84244791666667 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.0899999141693115, + "min": 4.019999980926514, + "max": 4.954999923706055, + "mean": 4.354999939600627 + }, + "performance_clock_loop_ns": { + "median": 69.0499997138977, + "min": 68.55000019073486, + "max": 69.85000133514404, + "mean": 69.15000041325887 + }, + "cpp_clock_loop_ns": { + "median": 121.80000066757202, + "min": 121.60000085830688, + "max": 126.5500020980835, + "mean": 123.31666787465413 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.750000953674316, + "max": 28.84999990463257, + "mean": 28.21666717529297 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.4290000000000065, + "min": 4.380999999999981, + "max": 4.576500000000005, + "mean": 4.462166666666664 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 280.00000000000114, + "min": 265.00000000000057, + "max": 284.9999999999966, + "mean": 276.6666666666661 + }, + "elapsed_ms": { + "median": 45.5, + "min": 45.19499999999999, + "max": 47.290000000000006, + "mean": 45.995 + }, + "million_ops_per_second": { + "median": 0.21978021978021978, + "min": 0.21146119687037426, + "max": 0.22126341409447953, + "mean": 0.21750161024835785 + }, + "zero_percent": { + "median": 26.99, + "min": 25.48, + "max": 27.22, + "mean": 26.563333333333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 3.9850001335144043, + "min": 3.929999828338623, + "max": 3.990000009536743, + "mean": 3.9683333237965903 + }, + "performance_clock_loop_ns": { + "median": 69.34999942779541, + "min": 67.69999980926514, + "max": 71.25, + "mean": 69.43333307902019 + }, + "cpp_clock_loop_ns": { + "median": 122.99999952316284, + "min": 122.5, + "max": 123.69999885559082, + "mean": 123.06666612625122 + }, + "wall_clock_loop_ns": { + "median": 28.09999942779541, + "min": 27.900002002716064, + "max": 28.299999237060547, + "mean": 28.100000222524006 + } + }, + { + "group": "no-exceptions", + "variant": "asyncify", + "mode": "direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 5.308000000000014, + "min": 5.308000000000011, + "max": 5.3144999999999865, + "mean": 5.310166666666671 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 384.9999999999909, + "min": 364.9999999999949, + "max": 385.0000000000051, + "mean": 378.3333333333303 + }, + "elapsed_ms": { + "median": 54.33, + "min": 54.245000000000005, + "max": 54.375, + "mean": 54.31666666666667 + }, + "million_ops_per_second": { + "median": 0.18406037180195106, + "min": 0.1839080459770115, + "max": 0.18434878790671952, + "mean": 0.1841057352285607 + }, + "zero_percent": { + "median": 18.03, + "min": 17.71, + "max": 18.29, + "mean": 18.01 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.0350000858306885, + "min": 3.9700000286102295, + "max": 4.9100000858306885, + "mean": 4.305000066757202 + }, + "performance_clock_loop_ns": { + "median": 69.50000047683716, + "min": 68.70000123977661, + "max": 71.29999876022339, + "mean": 69.83333349227905 + }, + "cpp_clock_loop_ns": { + "median": 124.24999952316284, + "min": 123.04999828338623, + "max": 125.45000076293945, + "mean": 124.24999952316284 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.5, + "max": 28.399999141693115, + "mean": 28.016666571299236 + }, + "component_means_us": { + "entry": 0.23500955804190796, + "channel_create": 1.0708333571751913, + "handler_setup": 0.6878330866495769, + "post_message": 0.4943335294723511, + "post_to_delivery": 1.409332799911499, + "message_handler": 1.0190003633499145, + "resume": 0.39382397206623004 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 4.171700000000003, + "min": 4.167849999999996, + "max": 4.232099999999989, + "mean": 4.1905499999999964 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 9.999999999990905, + "min": 9.999999999990905, + "max": 9.999999999990905, + "mean": 9.999999999990905 + }, + "p99_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "max_us": { + "median": 4269.999999999982, + "min": 4245.000000000005, + "max": 4329.999999999984, + "mean": 4281.666666666657 + }, + "elapsed_ms": { + "median": 430.76, + "min": 430.62, + "max": 436.64, + "mean": 432.67333333333335 + }, + "million_ops_per_second": { + "median": 0.23215015321756893, + "min": 0.22902390985709054, + "max": 0.23222562816404255, + "mean": 0.23113323041290068 + }, + "zero_percent": { + "median": 30.963, + "min": 30.323, + "max": 31.096, + "mean": 30.794 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.174999952316284, + "min": 2.1550002098083496, + "max": 2.2149999141693115, + "mean": 2.181666692097982 + }, + "performance_clock_loop_ns": { + "median": 70.59999942779541, + "min": 69.90000009536743, + "max": 71.49999856948853, + "mean": 70.66666603088379 + }, + "cpp_clock_loop_ns": { + "median": 118.1000018119812, + "min": 116.39999866485596, + "max": 118.35000038146973, + "mean": 117.61666695276897 + }, + "wall_clock_loop_ns": { + "median": 27.850000858306885, + "min": 27.699999809265137, + "max": 27.999999523162842, + "mean": 27.85000006357829 + }, + "paired_slowdown": { + "median": 17.36935483870968, + "min": 17.20415501398322, + "max": 17.95394736842105 + }, + "paired_net_us_per_yield": { + "median": 4.0596, + "min": 4.0559, + "max": 4.1232 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 0.1348500000000024, + "min": 0.13474999999999626, + "max": 0.1350499999999984, + "mean": 0.13488333333333236 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 15.000000000000568, + "min": 15.000000000000568, + "max": 134.9999999999909, + "mean": 54.99999999999735 + }, + "elapsed_ms": { + "median": 24.799999999999997, + "min": 24.32, + "max": 25.03, + "mean": 24.716666666666665 + }, + "million_ops_per_second": { + "median": 4.032298387096775, + "min": 3.9952457051538155, + "max": 4.11188322368421, + "mean": 4.046475771978267 + }, + "zero_percent": { + "median": 97.309, + "min": 97.303, + "max": 97.346, + "mean": 97.31933333333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.375, + "min": 2.194999933242798, + "max": 2.4200000762939453, + "mean": 2.3300000031789145 + }, + "performance_clock_loop_ns": { + "median": 71.19999885559082, + "min": 70.44999837875366, + "max": 71.84999942779541, + "mean": 71.16666555404663 + }, + "cpp_clock_loop_ns": { + "median": 116.94999933242798, + "min": 116.20000123977661, + "max": 119.94999885559082, + "mean": 117.69999980926514 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 28.05000066757202, + "max": 28.350000381469727, + "mean": 28.18333387374878 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.167500000000021, + "min": 4.113000000000007, + "max": 4.2264999999999855, + "mean": 4.169000000000004 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 269.999999999996, + "min": 269.999999999996, + "max": 280.00000000000114, + "mean": 273.33333333333104 + }, + "elapsed_ms": { + "median": 45.78, + "min": 45.620000000000005, + "max": 46.599999999999994, + "mean": 46.0 + }, + "million_ops_per_second": { + "median": 2.1843818261249455, + "min": 2.145944206008584, + "max": 2.1920429636124505, + "mean": 2.174122998581993 + }, + "zero_percent": { + "median": 30.49, + "min": 29.48, + "max": 30.68, + "mean": 30.216666666666665 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4549999237060547, + "min": 2.1649999618530273, + "max": 2.5400002002716064, + "mean": 2.386666695276896 + }, + "performance_clock_loop_ns": { + "median": 70.09999990463257, + "min": 69.6500015258789, + "max": 70.79999923706055, + "mean": 70.18333355585735 + }, + "cpp_clock_loop_ns": { + "median": 117.10000038146973, + "min": 116.25, + "max": 118.55000019073486, + "mean": 117.30000019073486 + }, + "wall_clock_loop_ns": { + "median": 27.899999618530273, + "min": 27.899999618530273, + "max": 28.499999046325684, + "mean": 28.09999942779541 + }, + "paired_slowdown": { + "median": 8.62164662349677, + "min": 8.34639927073838, + "max": 8.789980732177268 + }, + "paired_net_us_per_yield": { + "median": 4.043000000000001, + "min": 4.0295, + "max": 4.1195 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 0.13949999999998824, + "min": 0.1365000000000066, + "max": 0.1410000000000018, + "mean": 0.13899999999999887 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000002558, + "mean": 4.999999999997821 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 5.404999999999994, + "min": 5.189999999999998, + "max": 5.484999999999999, + "mean": 5.359999999999997 + }, + "million_ops_per_second": { + "median": 18.501572617946366, + "min": 18.231722880583412, + "max": 19.268015414258198, + "mean": 18.667103637595993 + }, + "zero_percent": { + "median": 97.21, + "min": 97.18, + "max": 97.27, + "mean": 97.22 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3350000381469727, + "min": 2.2049999237060547, + "max": 2.434999942779541, + "mean": 2.324999968210856 + }, + "performance_clock_loop_ns": { + "median": 70.59999942779541, + "min": 67.74999856948853, + "max": 70.85000038146973, + "mean": 69.73333279291789 + }, + "cpp_clock_loop_ns": { + "median": 116.15000009536743, + "min": 114.34999942779541, + "max": 117.94999837875366, + "mean": 116.14999930063884 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 28.05000066757202, + "max": 28.249998092651367, + "mean": 28.16666603088379 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.340820312500076, + "min": 4.077148437499817, + "max": 4.501953124999972, + "mean": 4.306640624999955 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 170.0000000000017, + "min": 45.000000000001705, + "max": 194.99999999999318, + "mean": 136.66666666666552 + }, + "elapsed_ms": { + "median": 7.7250000000000085, + "min": 7.594999999999999, + "max": 8.170000000000002, + "mean": 7.830000000000003 + }, + "million_ops_per_second": { + "median": 13.255792880258884, + "min": 12.53378212974296, + "max": 13.482685977616855, + "mean": 13.090753662539566 + }, + "zero_percent": { + "median": 28.3203125, + "min": 27.44140625, + "max": 29.8828125, + "mean": 28.548177083333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4200000762939453, + "min": 2.319999933242798, + "max": 2.565000057220459, + "mean": 2.435000022252401 + }, + "performance_clock_loop_ns": { + "median": 69.29999828338623, + "min": 68.50000143051147, + "max": 71.25, + "mean": 69.6833332379659 + }, + "cpp_clock_loop_ns": { + "median": 118.39999914169312, + "min": 115.89999914169312, + "max": 118.4499979019165, + "mean": 117.58333206176758 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.899999618530273, + "max": 28.15000057220459, + "mean": 28.033333619435627 + }, + "paired_slowdown": { + "median": 2.220760233918132, + "min": 2.157821229050283, + "max": 2.330955777460774 + }, + "paired_net_us_per_yield": { + "median": 4.077148437500004, + "min": 4.04785156250001, + "max": 4.555664062500006 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.14648437499996392, + "min": 0.14160156249995448, + "max": 0.16601562499996003, + "mean": 0.15136718749995948 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 3.5049999999999955, + "min": 3.4199999999999946, + "max": 3.5799999999999983, + "mean": 3.501666666666663 + }, + "million_ops_per_second": { + "median": 29.215691868758952, + "min": 28.60363128491621, + "max": 29.941812865497123, + "mean": 29.253712006390764 + }, + "zero_percent": { + "median": 97.0703125, + "min": 96.6796875, + "max": 97.16796875, + "mean": 96.97265625 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2249999046325684, + "min": 2.2149999141693115, + "max": 2.384999990463257, + "mean": 2.2749999364217124 + }, + "performance_clock_loop_ns": { + "median": 69.85000133514404, + "min": 69.54999923706055, + "max": 72.10000038146973, + "mean": 70.50000031789143 + }, + "cpp_clock_loop_ns": { + "median": 116.90000057220459, + "min": 116.8500018119812, + "max": 119.14999961853027, + "mean": 117.63333400090535 + }, + "wall_clock_loop_ns": { + "median": 28.600001335144043, + "min": 28.19999933242798, + "max": 28.65000009536743, + "mean": 28.483333587646484 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.438476562499627, + "min": 4.277343750000079, + "max": 4.482421875000531, + "mean": 4.399414062500079 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 11.666666666670267 + }, + "max_us": { + "median": 195.0000000000074, + "min": 190.00000000001194, + "max": 225.00000000000853, + "mean": 203.3333333333426 + }, + "elapsed_ms": { + "median": 31.97500000000001, + "min": 31.654999999999994, + "max": 32.870000000000005, + "mean": 32.16666666666667 + }, + "million_ops_per_second": { + "median": 32.02505082095386, + "min": 31.153057499239424, + "max": 32.348791660085304, + "mean": 31.842299993426195 + }, + "zero_percent": { + "median": 27.9296875, + "min": 27.83203125, + "max": 30.17578125, + "mean": 28.645833333333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.305000066757202, + "min": 2.1700000762939453, + "max": 2.365000009536743, + "mean": 2.2800000508626304 + }, + "performance_clock_loop_ns": { + "median": 69.75000143051147, + "min": 69.0999984741211, + "max": 71.69999837875366, + "mean": 70.18333276112874 + }, + "cpp_clock_loop_ns": { + "median": 118.84999990463257, + "min": 117.00000047683716, + "max": 120.35000085830688, + "mean": 118.73333374659221 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.55000114440918, + "max": 28.499999046325684, + "mean": 28.066666920979817 + }, + "paired_slowdown": { + "median": 1.1836017027577272, + "min": 1.1159880133967919, + "max": 1.2133628645256553 + }, + "paired_net_us_per_yield": { + "median": 4.843750000000001, + "min": 3.212890624999999, + "max": 5.644531250000001 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.11230468750005052, + "min": 0.09277343749998501, + "max": 0.13183593750003275, + "mean": 0.11230468750002276 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000004927 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 27.090000000000003, + "min": 27.015000000000008, + "max": 28.364999999999995, + "mean": 27.490000000000002 + }, + "million_ops_per_second": { + "median": 37.79996308600959, + "min": 36.100863740525305, + "max": 37.904904682583734, + "mean": 37.26857716970621 + }, + "zero_percent": { + "median": 97.75390625, + "min": 97.36328125, + "max": 98.14453125, + "mean": 97.75390625 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.25, + "min": 2.1649999618530273, + "max": 2.3550000190734863, + "mean": 2.256666660308838 + }, + "performance_clock_loop_ns": { + "median": 70.79999923706055, + "min": 70.49999952316284, + "max": 71.45000219345093, + "mean": 70.9166669845581 + }, + "cpp_clock_loop_ns": { + "median": 116.00000143051147, + "min": 115.39999961853027, + "max": 116.64999961853027, + "mean": 116.01666688919067 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.950000762939453, + "max": 28.550000190734863, + "mean": 28.18333387374878 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.643554687500148, + "min": 4.624023437500069, + "max": 4.750976562499912, + "mean": 4.6728515625000435 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 15.000000000000568, + "max": 15.00000000001478, + "mean": 15.000000000005306 + }, + "max_us": { + "median": 200.00000000001705, + "min": 190.00000000002615, + "max": 210.00000000000796, + "mean": 200.00000000001705 + }, + "elapsed_ms": { + "median": 140.44, + "min": 137.66, + "max": 140.715, + "mean": 139.605 + }, + "million_ops_per_second": { + "median": 36.456857020791794, + "min": 36.385609210105535, + "max": 37.19309167514165, + "mean": 36.678519302012994 + }, + "zero_percent": { + "median": 26.66015625, + "min": 25.390625, + "max": 27.5390625, + "mean": 26.529947916666668 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.180000066757202, + "min": 2.1499998569488525, + "max": 2.375, + "mean": 2.234999974568685 + }, + "performance_clock_loop_ns": { + "median": 69.80000019073486, + "min": 67.14999914169312, + "max": 73.05000066757202, + "mean": 70.0 + }, + "cpp_clock_loop_ns": { + "median": 117.59999990463257, + "min": 116.50000095367432, + "max": 117.74999856948853, + "mean": 117.28333314259847 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.749998569488525, + "max": 28.550000190734863, + "mean": 28.083333174387615 + }, + "paired_slowdown": { + "median": 1.0419474268789337, + "min": 1.0288490284005978, + "max": 1.0677006120044097 + }, + "paired_net_us_per_yield": { + "median": 5.532226562499992, + "min": 3.769531249999986, + "max": 8.696289062500028 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.12207031249997224, + "min": 0.11230468750000888, + "max": 0.19042968750006273, + "mean": 0.14160156250001463 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000023874, + "max": 5.000000000023874, + "mean": 5.000000000023874 + }, + "elapsed_ms": { + "median": 133.8, + "min": 131.53499999999997, + "max": 135.05, + "mean": 133.46166666666667 + }, + "million_ops_per_second": { + "median": 38.26607623318385, + "min": 37.911891891891884, + "max": 38.92500855285666, + "mean": 38.36765889264413 + }, + "zero_percent": { + "median": 97.55859375, + "min": 96.19140625, + "max": 97.75390625, + "mean": 97.16796875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.6449999809265137, + "min": 2.2799999713897705, + "max": 2.7099997997283936, + "mean": 2.544999917348226 + }, + "performance_clock_loop_ns": { + "median": 70.59999942779541, + "min": 69.10000085830688, + "max": 71.25, + "mean": 70.3166667620341 + }, + "cpp_clock_loop_ns": { + "median": 117.75000095367432, + "min": 115.05000114440918, + "max": 118.80000114440918, + "mean": 117.20000108083089 + }, + "wall_clock_loop_ns": { + "median": 27.899999618530273, + "min": 27.649998664855957, + "max": 28.64999771118164, + "mean": 28.066665331522625 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.239257812499412, + "min": 4.892578124999644, + "max": 5.312499999999804, + "mean": 5.148111979166287 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000019327, + "mean": 10.000000000009853 + }, + "p99_us": { + "median": 15.00000000001478, + "min": 15.000000000000568, + "max": 19.99999999998181, + "mean": 16.66666666666572 + }, + "max_us": { + "median": 235.00000000001364, + "min": 204.99999999998408, + "max": 305.0000000000068, + "mean": 248.33333333333485 + }, + "elapsed_ms": { + "median": 277.995, + "min": 273.09499999999997, + "max": 282.79499999999996, + "mean": 277.96166666666664 + }, + "million_ops_per_second": { + "median": 36.83519847479271, + "min": 36.209978960024046, + "max": 37.49611307420495, + "mean": 36.84709683634057 + }, + "zero_percent": { + "median": 24.0234375, + "min": 20.41015625, + "max": 25.5859375, + "mean": 23.33984375 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3550000190734863, + "min": 2.174999952316284, + "max": 2.5950000286102295, + "mean": 2.375 + }, + "performance_clock_loop_ns": { + "median": 68.70000123977661, + "min": 68.15000057220459, + "max": 69.25000190734863, + "mean": 68.70000123977661 + }, + "cpp_clock_loop_ns": { + "median": 118.05000066757202, + "min": 117.05000162124634, + "max": 119.64999914169312, + "mean": 118.25000047683716 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.59999990463257, + "max": 28.349997997283936, + "mean": 28.03333282470703 + }, + "paired_slowdown": { + "median": 1.024601003605007, + "min": 1.0095373639169731, + "max": 1.0278029392735002 + }, + "paired_net_us_per_yield": { + "median": 6.6308593749999645, + "min": 2.5195312499999845, + "max": 7.343749999999982 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 1, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.13671874999994504, + "min": 0.10742187499994393, + "max": 0.14648437499999167, + "mean": 0.13020833333329354 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000023874, + "max": 5.000000000052296, + "mean": 5.000000000033348 + }, + "elapsed_ms": { + "median": 270.515, + "min": 270.475, + "max": 276.005, + "mean": 272.33166666666665 + }, + "million_ops_per_second": { + "median": 37.85372715006562, + "min": 37.10078078295683, + "max": 37.859325261114705, + "mean": 37.60461106471239 + }, + "zero_percent": { + "median": 97.265625, + "min": 97.0703125, + "max": 97.8515625, + "mean": 97.39583333333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.450000047683716, + "min": 2.43999981880188, + "max": 2.565000057220459, + "mean": 2.484999974568685 + }, + "performance_clock_loop_ns": { + "median": 68.65000009536743, + "min": 68.05000066757202, + "max": 70.9499979019165, + "mean": 69.21666622161865 + }, + "cpp_clock_loop_ns": { + "median": 117.85000085830688, + "min": 116.70000076293945, + "max": 118.99999856948853, + "mean": 117.85000006357829 + }, + "wall_clock_loop_ns": { + "median": 28.449997901916504, + "min": 28.250000476837158, + "max": 28.550000190734863, + "mean": 28.41666618982951 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.028000000000001, + "min": 3.990500000000007, + "max": 4.0749999999999975, + "mean": 4.031166666666668 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 260.0000000000051, + "min": 260.0000000000051, + "max": 275.0000000000057, + "mean": 265.0000000000053 + }, + "elapsed_ms": { + "median": 41.37, + "min": 41.105000000000004, + "max": 42.2, + "mean": 41.55833333333334 + }, + "million_ops_per_second": { + "median": 0.24172105390379503, + "min": 0.23696682464454974, + "max": 0.24327940639824838, + "mean": 0.24065576164886437 + }, + "zero_percent": { + "median": 31.64, + "min": 31.46, + "max": 32.77, + "mean": 31.956666666666667 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.494999885559082, + "min": 2.4549999237060547, + "max": 2.5299999713897705, + "mean": 2.4933332602183023 + }, + "performance_clock_loop_ns": { + "median": 68.94999980926514, + "min": 68.84999990463257, + "max": 68.99999856948853, + "mean": 68.93333276112874 + }, + "cpp_clock_loop_ns": { + "median": 118.05000066757202, + "min": 117.89999961853027, + "max": 119.0499997138977, + "mean": 118.33333333333333 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.749998569488525, + "max": 28.299999237060547, + "mean": 28.016665776570637 + } + }, + { + "group": "no-exceptions", + "variant": "jspi", + "mode": "direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "off", + "isolate": 1, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.920500000000006, + "min": 4.796500000000012, + "max": 4.95350000000001, + "mean": 4.890166666666676 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 379.99999999999545, + "min": 370.00000000000455, + "max": 400.0000000000057, + "mean": 383.33333333333525 + }, + "elapsed_ms": { + "median": 50.54, + "min": 49.15500000000001, + "max": 50.79, + "mean": 50.16166666666667 + }, + "million_ops_per_second": { + "median": 0.19786307874950534, + "min": 0.19688915140775742, + "max": 0.2034381039568711, + "mean": 0.19939677803804462 + }, + "zero_percent": { + "median": 21.42, + "min": 21.04, + "max": 22.52, + "mean": 21.66 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3399999141693115, + "min": 2.1700000762939453, + "max": 2.359999895095825, + "mean": 2.2899999618530273 + }, + "performance_clock_loop_ns": { + "median": 68.94999980926514, + "min": 67.14999914169312, + "max": 71.49999856948853, + "mean": 69.19999917348225 + }, + "cpp_clock_loop_ns": { + "median": 118.35000038146973, + "min": 115.75000047683716, + "max": 118.99999856948853, + "mean": 117.69999980926514 + }, + "wall_clock_loop_ns": { + "median": 27.850000858306885, + "min": 27.799999713897705, + "max": 27.999999523162842, + "mean": 27.88333336512248 + }, + "component_means_us": { + "entry": 0.20944915771482944, + "channel_create": 1.0919998645782472, + "handler_setup": 0.6698334058125813, + "post_message": 0.494500199953715, + "post_to_delivery": 1.2021662791570027, + "message_handler": 1.011333378156026, + "resume": 0.2108843812942742 + } + }, + { + "group": "ordinary-page", + "variant": "asyncify", + "mode": "direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 0, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.73, + "min": 4.669999999999999, + "max": 4.759999999999997, + "mean": 4.719999999999999 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 100.00000000000853, + "min": 100.00000000000853, + "max": 100.00000000000853, + "mean": 100.00000000000853 + }, + "max_us": { + "median": 299.99999999999716, + "min": 299.99999999999716, + "max": 299.99999999999716, + "mean": 299.99999999999716 + }, + "elapsed_ms": { + "median": 48.599999999999994, + "min": 48.199999999999996, + "max": 48.900000000000006, + "mean": 48.56666666666666 + }, + "million_ops_per_second": { + "median": 0.20576131687242802, + "min": 0.20449897750511245, + "max": 0.20746887966804983, + "mean": 0.20590972468186344 + }, + "zero_percent": { + "median": 95.34, + "min": 95.32, + "max": 95.4, + "mean": 95.35333333333334 + }, + "clock_step_us": { + "median": 99.99990463256836, + "min": 99.99990463256836, + "max": 99.99990463256836, + "mean": 99.99990463256836 + }, + "js_to_cpp_sync_ns": { + "median": 4.099999904632568, + "min": 4.099999904632568, + "max": 4.099999904632568, + "mean": 4.099999904632568 + }, + "performance_clock_loop_ns": { + "median": 70.99999904632568, + "min": 68.00000190734863, + "max": 70.99999904632568, + "mean": 70.0 + }, + "cpp_clock_loop_ns": { + "median": 140.99999904632568, + "min": 138.99999856948853, + "max": 141.00000143051147, + "mean": 140.3333330154419 + }, + "wall_clock_loop_ns": { + "median": 28.000001907348633, + "min": 26.999998092651367, + "max": 29.000000953674316, + "mean": 28.000000317891438 + } + }, + { + "group": "ordinary-page", + "variant": "asyncify", + "mode": "direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 0, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 5.559999999999997, + "min": 5.49, + "max": 5.62, + "mean": 5.556666666666666 + }, + "p50_us": { + "median": 0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 99.99999999999432, + "min": 99.99999999999432, + "max": 99.99999999999432, + "mean": 99.99999999999432 + }, + "p99_us": { + "median": 100.00000000000853, + "min": 100.00000000000853, + "max": 100.00000000000853, + "mean": 100.00000000000853 + }, + "max_us": { + "median": 400.0000000000057, + "min": 399.9999999999915, + "max": 400.0000000000057, + "mean": 400.00000000000097 + }, + "elapsed_ms": { + "median": 56.7, + "min": 56.300000000000004, + "max": 57.099999999999994, + "mean": 56.7 + }, + "million_ops_per_second": { + "median": 0.1763668430335097, + "min": 0.17513134851138354, + "max": 0.17761989342806392, + "mean": 0.1763726949909857 + }, + "zero_percent": { + "median": 94.6, + "min": 94.52, + "max": 94.64, + "mean": 94.58666666666666 + }, + "clock_step_us": { + "median": 99.99990463256836, + "min": 99.99990463256836, + "max": 99.99990463256836, + "mean": 99.99990463256836 + }, + "js_to_cpp_sync_ns": { + "median": 5, + "min": 4.1000001430511475, + "max": 5.099999904632568, + "mean": 4.733333349227905 + }, + "performance_clock_loop_ns": { + "median": 69.00000095367432, + "min": 68.99999856948853, + "max": 70.99999904632568, + "mean": 69.66666618982951 + }, + "cpp_clock_loop_ns": { + "median": 135, + "min": 134.00000095367432, + "max": 136.00000143051147, + "mean": 135.0000007947286 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.999999523162842, + "max": 27.999999523162842, + "mean": 27.999999523162842 + }, + "component_means_us": { + "entry": 0.20330028851831017, + "channel_create": 1.1666666587193808, + "handler_setup": 0.6833333412806193, + "post_message": 0.48000006675720214, + "post_to_delivery": 1.5666666746139526, + "message_handler": 1.023333239555359, + "resume": 0.43336639722184195 + } + }, + { + "group": "ordinary-page", + "variant": "jspi", + "mode": "direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 0, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.030000000000003, + "min": 4.029999999999999, + "max": 4.049999999999995, + "mean": 4.036666666666666 + }, + "p50_us": { + "median": 0.0, + "min": 0, + "max": 0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 100.00000000000142, + "min": 100.00000000000142, + "max": 100.00000000000142, + "mean": 100.00000000000142 + }, + "max_us": { + "median": 299.99999999999716, + "min": 299.99999999999716, + "max": 300.00000000001137, + "mean": 300.0000000000019 + }, + "elapsed_ms": { + "median": 41.7, + "min": 41.50000000000001, + "max": 42.300000000000004, + "mean": 41.833333333333336 + }, + "million_ops_per_second": { + "median": 0.2398081534772182, + "min": 0.23640661938534277, + "max": 0.2409638554216867, + "mean": 0.2390595427614159 + }, + "zero_percent": { + "median": 96.04, + "min": 96.04, + "max": 96.05, + "mean": 96.04333333333334 + }, + "clock_step_us": { + "median": 99.99990463256836, + "min": 99.99990463256836, + "max": 99.99990463256836, + "mean": 99.99990463256836 + }, + "js_to_cpp_sync_ns": { + "median": 2.299999952316284, + "min": 2.200000047683716, + "max": 2.5, + "mean": 2.3333333333333335 + }, + "performance_clock_loop_ns": { + "median": 70.99999904632568, + "min": 70, + "max": 72.99999952316284, + "mean": 71.33333285649617 + }, + "cpp_clock_loop_ns": { + "median": 112.00000047683716, + "min": 111.00000143051147, + "max": 113.00000190734863, + "mean": 112.00000127156575 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.000000476837158, + "max": 29.000000953674316, + "mean": 28.000000317891438 + } + }, + { + "group": "ordinary-page", + "variant": "jspi", + "mode": "direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 0, + "work": 0, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.830000000000002, + "min": 4.790000000000001, + "max": 4.890000000000001, + "mean": 4.836666666666668 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0, + "max": 0, + "mean": 0.0 + }, + "p99_us": { + "median": 100.00000000000142, + "min": 100.00000000000142, + "max": 100.00000000000142, + "mean": 100.00000000000142 + }, + "max_us": { + "median": 400.0000000000057, + "min": 399.9999999999915, + "max": 400.0000000000057, + "mean": 400.00000000000097 + }, + "elapsed_ms": { + "median": 49.6, + "min": 49.599999999999994, + "max": 49.7, + "mean": 49.63333333333333 + }, + "million_ops_per_second": { + "median": 0.20161290322580644, + "min": 0.20120724346076457, + "max": 0.20161290322580647, + "mean": 0.20147768330412583 + }, + "zero_percent": { + "median": 95.3, + "min": 95.22, + "max": 95.32, + "mean": 95.28 + }, + "clock_step_us": { + "median": 99.99990463256836, + "min": 99.99990463256836, + "max": 99.99990463256836, + "mean": 99.99990463256836 + }, + "js_to_cpp_sync_ns": { + "median": 2.6000001430511475, + "min": 2.299999952316284, + "max": 2.700000047683716, + "mean": 2.5333333810170493 + }, + "performance_clock_loop_ns": { + "median": 70, + "min": 67.00000047683716, + "max": 70.99999904632568, + "mean": 69.33333317438762 + }, + "cpp_clock_loop_ns": { + "median": 111.99999809265137, + "min": 110.99999904632568, + "max": 112.00000047683716, + "mean": 111.66666587193806 + }, + "wall_clock_loop_ns": { + "median": 29.000000953674316, + "min": 26.999998092651367, + "max": 30, + "mean": 28.666666348775227 + }, + "component_means_us": { + "entry": 0.20334917545317618, + "channel_create": 1.0199999968210856, + "handler_setup": 0.6333333412806192, + "post_message": 0.4133333444595337, + "post_to_delivery": 1.3300000588099163, + "message_handler": 1.0399999698003133, + "resume": 0.19665078004202363 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 4.849999999999997, + "min": 4.831200000000004, + "max": 5.320599999999979, + "mean": 4.927699999999996 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 9.999999999990905, + "min": 9.999999999990905, + "max": 9.999999999990905, + "mean": 9.999999999990905 + }, + "p99_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "max_us": { + "median": 4425.000000000011, + "min": 3939.9999999999977, + "max": 39720.00000000003, + "mean": 9399.285714285721 + }, + "elapsed_ms": { + "median": 499.33000000000004, + "min": 497.385, + "max": 546.24, + "mean": 506.89714285714285 + }, + "million_ops_per_second": { + "median": 0.20027036228546252, + "min": 0.18307154364381956, + "max": 0.20105350985654977, + "mean": 0.1974742532152993 + }, + "zero_percent": { + "median": 22.624, + "min": 21.601, + "max": 22.721, + "mean": 22.387285714285714 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.930000066757202, + "min": 4.115000009536743, + "max": 4.980000019073486, + "mean": 4.705000025885446 + }, + "performance_clock_loop_ns": { + "median": 70.09999990463257, + "min": 67.55000114440918, + "max": 72.45000123977661, + "mean": 70.1142862864903 + }, + "cpp_clock_loop_ns": { + "median": 141.39999866485596, + "min": 140.79999923706055, + "max": 145.75000047683716, + "mean": 142.21428564616613 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.650001049041748, + "max": 28.350000381469727, + "mean": 28.02142892565046 + }, + "paired_slowdown": { + "median": 14.49433962264151, + "min": 14.290091638029782, + "max": 16.19688658265382 + }, + "paired_net_us_per_yield": { + "median": 4.6488000000000005, + "min": 4.62825, + "max": 5.12515 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 0.21849999999999808, + "min": 0.20955000000000126, + "max": 0.22399999999999964, + "mean": 0.21865000000000023 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "max_us": { + "median": 140.00000000000057, + "min": 19.99999999999602, + "max": 150.00000000000568, + "mean": 105.71428571428295 + }, + "elapsed_ms": { + "median": 34.45, + "min": 33.36500000000001, + "max": 34.92, + "mean": 34.20857142857143 + }, + "million_ops_per_second": { + "median": 2.9027866473149486, + "min": 2.8637170675830466, + "max": 2.997182676457365, + "mean": 2.923921579938907 + }, + "zero_percent": { + "median": 95.655, + "min": 95.567, + "max": 95.816, + "mean": 95.67071428571428 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.119999885559082, + "min": 4.039999961853027, + "max": 5.019999980926514, + "mean": 4.339999948229108 + }, + "performance_clock_loop_ns": { + "median": 69.3999981880188, + "min": 67.40000009536743, + "max": 72.75000095367432, + "mean": 69.585713999612 + }, + "cpp_clock_loop_ns": { + "median": 143.59999895095825, + "min": 137.69999980926514, + "max": 150.55000066757202, + "mean": 143.192857333592 + }, + "wall_clock_loop_ns": { + "median": 28.1000018119812, + "min": 27.849998474121094, + "max": 28.599998950958252, + "mean": 28.23571409497942 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 4.980500000000045, + "min": 4.835500000000006, + "max": 5.025500000000006, + "mean": 4.944642857142863 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000019327, + "min": 10.000000000019327, + "max": 10.000000000019327, + "mean": 10.000000000019327 + }, + "max_us": { + "median": 245.00000000000455, + "min": 240.0000000000091, + "max": 275.0000000000057, + "mean": 252.14285714285924 + }, + "elapsed_ms": { + "median": 61.30000000000001, + "min": 59.250000000000014, + "max": 61.44500000000001, + "mean": 60.80428571428572 + }, + "million_ops_per_second": { + "median": 1.6313376835236537, + "min": 1.627487997396045, + "max": 1.6877805907172991, + "mean": 1.6448877050463937 + }, + "zero_percent": { + "median": 21.01, + "min": 20.57, + "max": 22.2, + "mean": 21.124285714285715 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.045000076293945, + "min": 3.995000123977661, + "max": 5.055000066757202, + "mean": 4.188571487154279 + }, + "performance_clock_loop_ns": { + "median": 71.8500018119812, + "min": 69.19999837875366, + "max": 73.25000047683716, + "mean": 71.52142831257412 + }, + "cpp_clock_loop_ns": { + "median": 141.09999895095825, + "min": 136.8999981880188, + "max": 145.0499987602234, + "mean": 141.00714240755354 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.799999713897705, + "max": 28.69999885559082, + "mean": 28.114285469055176 + }, + "paired_slowdown": { + "median": 4.674400912894634, + "min": 4.57705677867903, + "max": 4.923952826352176 + }, + "paired_net_us_per_yield": { + "median": 4.82, + "min": 4.630500000000002, + "max": 4.848000000000001 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 0.24699999999998568, + "min": 0.22399999999998385, + "max": 0.25099999999999767, + "mean": 0.24257142857142455 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "max_us": { + "median": 20.000000000010232, + "min": 9.999999999990905, + "max": 140.00000000000057, + "mean": 68.57142857143117 + }, + "elapsed_ms": { + "median": 13.049999999999997, + "min": 12.295000000000002, + "max": 13.225000000000009, + "mean": 12.945714285714288 + }, + "million_ops_per_second": { + "median": 7.662911877394637, + "min": 7.561512287334589, + "max": 8.133468889792598, + "mean": 7.728611954042006 + }, + "zero_percent": { + "median": 95.32, + "min": 95.01, + "max": 95.53, + "mean": 95.28857142857143 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.169999837875366, + "min": 4.055000066757202, + "max": 5.015000104904175, + "mean": 4.484285729272025 + }, + "performance_clock_loop_ns": { + "median": 70.9500002861023, + "min": 67.85000085830688, + "max": 72.2000002861023, + "mean": 70.54999998637608 + }, + "cpp_clock_loop_ns": { + "median": 141.64999961853027, + "min": 140.19999980926514, + "max": 145.39999961853027, + "mean": 141.85714278902327 + }, + "wall_clock_loop_ns": { + "median": 28.250000476837158, + "min": 27.750000953674316, + "max": 28.350000381469727, + "mean": 28.10000044958932 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 5.4541015625001465, + "min": 5.336914062500378, + "max": 5.517578125000047, + "mean": 5.433872767857227 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 14.285714285715503 + }, + "max_us": { + "median": 155.00000000000114, + "min": 150.00000000000568, + "max": 180.00000000000682, + "mean": 159.2857142857176 + }, + "elapsed_ms": { + "median": 15.86, + "min": 15.594999999999999, + "max": 16.28, + "mean": 15.868571428571427 + }, + "million_ops_per_second": { + "median": 6.456557377049181, + "min": 6.289987714987714, + "max": 6.566271240782303, + "mean": 6.454282377731332 + }, + "zero_percent": { + "median": 18.75, + "min": 16.9921875, + "max": 20.01953125, + "mean": 18.498883928571427 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.109999895095825, + "min": 4.075000047683716, + "max": 5.039999961853027, + "mean": 4.483571427209037 + }, + "performance_clock_loop_ns": { + "median": 71.25, + "min": 67.69999980926514, + "max": 72.44999885559082, + "mean": 70.8071425982884 + }, + "cpp_clock_loop_ns": { + "median": 140.54999828338623, + "min": 137.89999961853027, + "max": 142.8499984741211, + "mean": 140.03571374075753 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.649998664855957, + "max": 29.650001525878906, + "mean": 28.321428639548166 + }, + "paired_slowdown": { + "median": 1.4281135531135527, + "min": 1.3943724877177301, + "max": 1.5030732860520086 + }, + "paired_net_us_per_yield": { + "median": 4.721679687499994, + "min": 4.311523437499992, + "max": 5.195312499999993 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.214843749999985, + "min": 0.18554687500001166, + "max": 0.23925781250000444, + "mean": 0.21693638392856643 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000007633 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 19.99999999999602, + "mean": 7.142857142864857 + }, + "elapsed_ms": { + "median": 10.989999999999995, + "min": 10.575000000000003, + "max": 11.445000000000007, + "mean": 11.029285714285717 + }, + "million_ops_per_second": { + "median": 9.317652411282989, + "min": 8.947225862822188, + "max": 9.683309692671392, + "mean": 9.289289544057237 + }, + "zero_percent": { + "median": 95.703125, + "min": 95.21484375, + "max": 96.2890625, + "mean": 95.703125 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.8999998569488525, + "min": 4.015000104904175, + "max": 4.990000009536743, + "mean": 4.680714300700596 + }, + "performance_clock_loop_ns": { + "median": 69.34999942779541, + "min": 68.30000162124634, + "max": 70.89999914169312, + "mean": 69.34285742895943 + }, + "cpp_clock_loop_ns": { + "median": 142.2000002861023, + "min": 136.94999933242798, + "max": 145.9500002861023, + "mean": 141.7214288030352 + }, + "wall_clock_loop_ns": { + "median": 27.899999618530273, + "min": 27.649998664855957, + "max": 28.65000009536743, + "mean": 27.957142761775426 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 5.732421874999824, + "min": 5.605468749999856, + "max": 5.903320312499918, + "mean": 5.743582589285528 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000019327, + "mean": 10.000000000007146 + }, + "p99_us": { + "median": 15.00000000001478, + "min": 15.000000000000568, + "max": 19.99999999999602, + "mean": 17.142857142857792 + }, + "max_us": { + "median": 159.9999999999966, + "min": 144.99999999999602, + "max": 195.0000000000074, + "mean": 164.2857142857151 + }, + "elapsed_ms": { + "median": 93.58000000000001, + "min": 91.3, + "max": 95.61000000000001, + "mean": 93.54642857142858 + }, + "million_ops_per_second": { + "median": 10.942519769181448, + "min": 10.710187218910153, + "max": 11.215783132530122, + "mean": 10.949250047472058 + }, + "zero_percent": { + "median": 16.50390625, + "min": 14.35546875, + "max": 18.26171875, + "mean": 16.015625 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.105000019073486, + "min": 3.984999895095825, + "max": 5.025000095367432, + "mean": 4.425000020435879 + }, + "performance_clock_loop_ns": { + "median": 70.04999876022339, + "min": 67.05000162124634, + "max": 72.95000076293945, + "mean": 70.24285725184849 + }, + "cpp_clock_loop_ns": { + "median": 139.9500012397766, + "min": 135.6500005722046, + "max": 143.7999987602234, + "mean": 139.81428623199463 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.799999713897705, + "max": 28.09999942779541, + "mean": 27.964285441807338 + }, + "paired_slowdown": { + "median": 1.0528748590755355, + "min": 1.0188026558053895, + "max": 1.0895726495726497 + }, + "paired_net_us_per_yield": { + "median": 4.580078124999998, + "min": 1.6455078124999885, + "max": 7.675781250000013 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.24414062499998612, + "min": 0.20019531249997058, + "max": 0.2685546875001027, + "mean": 0.23716517857144284 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 4.9999999999954525, + "mean": 1.4285714285701292 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000007633 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000023874, + "max": 5.000000000023874, + "mean": 5.000000000023874 + }, + "elapsed_ms": { + "median": 88.70000000000002, + "min": 86.11, + "max": 90.255, + "mean": 88.62 + }, + "million_ops_per_second": { + "median": 11.544543404735059, + "min": 11.345642900670324, + "max": 11.89177795842527, + "mean": 11.557469931774694 + }, + "zero_percent": { + "median": 95.1171875, + "min": 94.62890625, + "max": 95.99609375, + "mean": 95.25669642857143 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.115000009536743, + "min": 4.0350000858306885, + "max": 4.995000123977661, + "mean": 4.230000087193081 + }, + "performance_clock_loop_ns": { + "median": 69.50000047683716, + "min": 68.49999904632568, + "max": 71.64999961853027, + "mean": 69.5928566796439 + }, + "cpp_clock_loop_ns": { + "median": 142.59999990463257, + "min": 138.25000047683716, + "max": 149.60000038146973, + "mean": 142.7214285305568 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.650001049041748, + "max": 28.70000123977661, + "mean": 28.10000044958932 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 6.401367187499493, + "min": 5.986328125000134, + "max": 6.777343749999873, + "mean": 6.38602120535687 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000047748, + "min": 10.000000000019327, + "max": 14.999999999986358, + "mean": 10.714285714320633 + }, + "p99_us": { + "median": 20.000000000010232, + "min": 19.99999999999602, + "max": 24.999999999991473, + "mean": 21.42857142857224 + }, + "max_us": { + "median": 185.00000000000227, + "min": 160.000000000025, + "max": 194.99999999999318, + "mean": 184.2857142857172 + }, + "elapsed_ms": { + "median": 446.52500000000003, + "min": 436.28499999999997, + "max": 451.11499999999995, + "mean": 445.335 + }, + "million_ops_per_second": { + "median": 11.466325513689043, + "min": 11.349658069450141, + "max": 11.735450450966686, + "mean": 11.498815720644803 + }, + "zero_percent": { + "median": 12.79296875, + "min": 11.328125, + "max": 15.8203125, + "mean": 13.462611607142858 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.889999866485596, + "min": 4.079999923706055, + "max": 4.990000009536743, + "mean": 4.597142832619803 + }, + "performance_clock_loop_ns": { + "median": 68.94999980926514, + "min": 67.7999997138977, + "max": 72.04999923706055, + "mean": 69.37142848968506 + }, + "cpp_clock_loop_ns": { + "median": 141.94999933242798, + "min": 138.25000047683716, + "max": 148.94999980926514, + "mean": 142.74999959128243 + }, + "wall_clock_loop_ns": { + "median": 28.20000171661377, + "min": 27.699999809265137, + "max": 30.400002002716064, + "mean": 28.41428620474679 + }, + "paired_slowdown": { + "median": 0.9948505899217112, + "min": 0.9578567128236002, + "max": 1.0479784936138243 + }, + "paired_net_us_per_yield": { + "median": -2.280273437500091, + "min": -18.798828125, + "max": 19.956054687500057 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.25390624999996336, + "min": 0.16601562500007105, + "max": 0.292968750000025, + "mean": 0.23507254464287727 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 4.9999999999954525, + "min": 0.0, + "max": 4.9999999999954525, + "mean": 2.8571428571402584 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000052296, + "min": 5.000000000052296, + "max": 10.000000000047748, + "mean": 6.428571428614305 + }, + "elapsed_ms": { + "median": 449.94999999999993, + "min": 425.91999999999996, + "max": 456.775, + "mean": 446.58714285714285 + }, + "million_ops_per_second": { + "median": 11.379044338259808, + "min": 11.209021947348258, + "max": 12.021039162283998, + "mean": 11.47096058855468 + }, + "zero_percent": { + "median": 94.921875, + "min": 94.140625, + "max": 96.6796875, + "mean": 95.32645089285714 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.099999904632568, + "min": 3.990000009536743, + "max": 4.115000009536743, + "mean": 4.079285757882254 + }, + "performance_clock_loop_ns": { + "median": 72.30000019073486, + "min": 67.59999990463257, + "max": 72.75000095367432, + "mean": 71.51428529194423 + }, + "cpp_clock_loop_ns": { + "median": 141.5499997138977, + "min": 136.99999809265137, + "max": 142.64999866485596, + "mean": 140.66428559167045 + }, + "wall_clock_loop_ns": { + "median": 28.04999828338623, + "min": 27.849998474121094, + "max": 28.450000286102295, + "mean": 28.135713509150914 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 6.928710937499291, + "min": 6.538085937499841, + "max": 7.1386718749984475, + "mean": 6.8952287946425255 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 14.999999999986358, + "mean": 11.428571428609757 + }, + "p99_us": { + "median": 20.000000000095497, + "min": 19.99999999999602, + "max": 25.000000000005684, + "mean": 22.142857142867456 + }, + "max_us": { + "median": 230.0000000000182, + "min": 204.99999999998408, + "max": 299.9999999999545, + "mean": 251.42857142855388 + }, + "elapsed_ms": { + "median": 887.9849999999999, + "min": 849.33, + "max": 1112.595, + "mean": 914.0814285714285 + }, + "million_ops_per_second": { + "median": 11.531727450351076, + "min": 9.203709346168193, + "max": 12.056563408804585, + "mean": 11.287259332977705 + }, + "zero_percent": { + "median": 11.328125, + "min": 10.25390625, + "max": 13.28125, + "mean": 11.495535714285714 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.170000076293945, + "min": 4.055000066757202, + "max": 5.020000219345093, + "mean": 4.378571476255145 + }, + "performance_clock_loop_ns": { + "median": 71.19999885559082, + "min": 68.49999904632568, + "max": 73.15000057220459, + "mean": 70.91428518295288 + }, + "cpp_clock_loop_ns": { + "median": 139.90000009536743, + "min": 137.05000162124634, + "max": 141.94999933242798, + "mean": 140.1142862864903 + }, + "wall_clock_loop_ns": { + "median": 28.350000381469727, + "min": 27.55000114440918, + "max": 29.100000858306885, + "mean": 28.350000040871755 + }, + "paired_slowdown": { + "median": 1.016751492806476, + "min": 0.9087193533373634, + "max": 1.225817646961609 + }, + "paired_net_us_per_yield": { + "median": 14.287109374999885, + "min": -83.31542968749994, + "max": 200.15625000000003 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.21972656249993894, + "min": 0.18066406250004385, + "max": 0.2441406249999306, + "mean": 0.21763392857139321 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000109139, + "min": 5.000000000052296, + "max": 14.999999999986358, + "mean": 7.857142857200675 + }, + "elapsed_ms": { + "median": 896.74, + "min": 873.355, + "max": 934.645, + "mean": 899.0264285714286 + }, + "million_ops_per_second": { + "median": 11.419141557196067, + "min": 10.956032504319822, + "max": 11.724901099781874, + "mean": 11.398163302406527 + }, + "zero_percent": { + "median": 95.60546875, + "min": 95.1171875, + "max": 96.38671875, + "mean": 95.703125 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.954999923706055, + "min": 4.120000123977661, + "max": 5.090000152587891, + "mean": 4.770714317049299 + }, + "performance_clock_loop_ns": { + "median": 70.45000076293945, + "min": 68.15000057220459, + "max": 72.54999876022339, + "mean": 70.37857157843453 + }, + "cpp_clock_loop_ns": { + "median": 140.79999923706055, + "min": 139.50000047683716, + "max": 142.7999997138977, + "mean": 141.0285714694432 + }, + "wall_clock_loop_ns": { + "median": 28.000001907348633, + "min": 27.950000762939453, + "max": 28.299999237060547, + "mean": 28.05000032697405 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "clock", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 0.11395000000000025, + "min": 0.10944999999999752, + "max": 0.11575000000000472, + "mean": 0.11278571428571407 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 34.99999999999659, + "min": 10.000000000005116, + "max": 45.000000000001705, + "mean": 31.428571428571267 + }, + "elapsed_ms": { + "median": 23.015, + "min": 22.325000000000003, + "max": 23.385000000000005, + "mean": 22.944285714285716 + }, + "million_ops_per_second": { + "median": 4.344992396263306, + "min": 4.276245456489201, + "max": 4.479283314669652, + "mean": 4.359676662868472 + }, + "zero_percent": { + "median": 97.738, + "min": 97.7, + "max": 97.819, + "mean": 97.75500000000001 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.125, + "min": 4.0249998569488525, + "max": 4.889999866485596, + "mean": 4.225714240755353 + }, + "performance_clock_loop_ns": { + "median": 69.60000038146973, + "min": 67.89999961853027, + "max": 72.40000009536743, + "mean": 69.80714321136475 + }, + "cpp_clock_loop_ns": { + "median": 142.5499987602234, + "min": 140.09999990463257, + "max": 146.9000005722046, + "mean": 143.50714308874947 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.850000858306885, + "max": 28.899998664855957, + "mean": 28.235714435577393 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 4.7364999999999835, + "min": 4.585499999999996, + "max": 4.937499999999988, + "mean": 4.748999999999999 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 14.999999999986358, + "mean": 10.71428571428815 + }, + "max_us": { + "median": 255.00000000000966, + "min": 230.00000000000398, + "max": 805.0000000000068, + "mean": 330.00000000000233 + }, + "elapsed_ms": { + "median": 48.735000000000014, + "min": 47.215, + "max": 51.06999999999999, + "mean": 48.95857142857143 + }, + "million_ops_per_second": { + "median": 0.2051913409254129, + "min": 0.19580967299784613, + "max": 0.2117970983797522, + "mean": 0.20436768687883689 + }, + "zero_percent": { + "median": 23.13, + "min": 22.09, + "max": 24.97, + "mean": 23.228571428571428 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.120000123977661, + "min": 4.0299999713897705, + "max": 4.549999952316284, + "mean": 4.177142824445452 + }, + "performance_clock_loop_ns": { + "median": 71.50000095367432, + "min": 66.50000095367432, + "max": 73.35000038146973, + "mean": 70.75000047683716 + }, + "cpp_clock_loop_ns": { + "median": 141.74999952316284, + "min": 138.89999866485596, + "max": 147.99999952316284, + "mean": 142.1428564616612 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.849998474121094, + "max": 28.450000286102295, + "mean": 28.12142848968506 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 5.567500000000001, + "min": 5.5270000000000055, + "max": 5.708500000000012, + "mean": 5.591357142857148 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 12.857142857145375 + }, + "max_us": { + "median": 390.00000000000057, + "min": 375.0, + "max": 420.0000000000017, + "mean": 391.4285714285707 + }, + "elapsed_ms": { + "median": 57.11, + "min": 56.39, + "max": 58.52499999999999, + "mean": 57.302142857142854 + }, + "million_ops_per_second": { + "median": 0.17510068289266328, + "min": 0.1708671507902606, + "max": 0.17733640716439084, + "mean": 0.17453352744715847 + }, + "zero_percent": { + "median": 15.43, + "min": 14.8, + "max": 16.29, + "mean": 15.505714285714285 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.125, + "min": 4.0899999141693115, + "max": 4.169999837875366, + "mean": 4.130714212145124 + }, + "performance_clock_loop_ns": { + "median": 70.75000047683716, + "min": 69.80000019073486, + "max": 72.74999856948853, + "mean": 71.07857125146049 + }, + "cpp_clock_loop_ns": { + "median": 143.05000066757202, + "min": 139.0499997138977, + "max": 145.80000162124634, + "mean": 142.34999997275216 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 28.09999942779541, + "max": 29.149999618530273, + "mean": 28.421428544180735 + }, + "component_means_us": { + "entry": 0.26381318092346523, + "channel_create": 1.1185713461467197, + "handler_setup": 0.6977143594196864, + "post_message": 0.5007857050214495, + "post_to_delivery": 1.5185715300696236, + "message_handler": 1.0248572179249356, + "resume": 0.4670438033512677 + } + }, + { + "group": "primary", + "variant": "asyncify", + "mode": "sync", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 0.13539999999999877, + "min": 0.13099999999999923, + "max": 0.1365000000000019, + "mean": 0.1343642857142851 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 159.9999999999966, + "min": 149.99999999999147, + "max": 174.99999999999716, + "mean": 161.4285714285708 + }, + "elapsed_ms": { + "median": 24.88499999999999, + "min": 24.52000000000001, + "max": 25.394999999999996, + "mean": 24.892142857142858 + }, + "million_ops_per_second": { + "median": 4.0184850311432605, + "min": 3.9377830281551494, + "max": 4.078303425774876, + "mean": 4.01789584866913 + }, + "zero_percent": { + "median": 97.358, + "min": 97.323, + "max": 97.422, + "mean": 97.36471428571429 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.2099997997283936, + "min": 4.034999847412109, + "max": 5.205000162124634, + "mean": 4.497857093811035 + }, + "performance_clock_loop_ns": { + "median": 70.54999828338623, + "min": 67.59999990463257, + "max": 71.74999952316284, + "mean": 69.64999914169312 + }, + "cpp_clock_loop_ns": { + "median": 140.5999994277954, + "min": 137.24999904632568, + "max": 142.8000020980835, + "mean": 140.06428582327706 + }, + "wall_clock_loop_ns": { + "median": 28.09999942779541, + "min": 27.750000953674316, + "max": 28.450000286102295, + "mean": 28.12142883028303 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 4.183950000000005, + "min": 4.171800000000004, + "max": 4.216200000000001, + "mean": 4.186850000000001 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 9.999999999990905, + "min": 9.999999999990905, + "max": 9.999999999990905, + "mean": 9.999999999990905 + }, + "p99_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "max_us": { + "median": 4324.999999999989, + "min": 4169.999999999987, + "max": 5009.999999999991, + "mean": 4383.571428571421 + }, + "elapsed_ms": { + "median": 431.485, + "min": 430.69500000000005, + "max": 434.955, + "mean": 432.15357142857147 + }, + "million_ops_per_second": { + "median": 0.2317600843598271, + "min": 0.22991114023289766, + "max": 0.2321851890548996, + "mean": 0.23140401780774894 + }, + "zero_percent": { + "median": 30.982, + "min": 30.378, + "max": 31.117, + "mean": 30.841857142857144 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4549999237060547, + "min": 2.234999895095825, + "max": 2.680000066757202, + "mean": 2.445714235305786 + }, + "performance_clock_loop_ns": { + "median": 68.39999914169312, + "min": 67.5, + "max": 73.94999980926514, + "mean": 69.99285697937012 + }, + "cpp_clock_loop_ns": { + "median": 116.15000009536743, + "min": 115.39999961853027, + "max": 120.55000066757202, + "mean": 116.61428553717477 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.55000114440918, + "max": 28.399999141693115, + "mean": 28.028571605682373 + }, + "paired_slowdown": { + "median": 17.28999400838825, + "min": 16.666859903381642, + "max": 17.7092140365278 + }, + "paired_net_us_per_yield": { + "median": 4.0712, + "min": 4.049550000000001, + "max": 4.0985 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 0.14185000000000159, + "min": 0.134049999999999, + "max": 0.14330000000000012, + "mean": 0.14018571428571444 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 90.00000000000341, + "min": 19.99999999999602, + "max": 144.99999999999602, + "mean": 93.57142857142671 + }, + "elapsed_ms": { + "median": 25.10499999999999, + "min": 24.36500000000001, + "max": 25.875, + "mean": 25.250714285714285 + }, + "million_ops_per_second": { + "median": 3.983310097590123, + "min": 3.8647729468599032, + "max": 4.1042889390519175, + "mean": 3.9619376380818303 + }, + "zero_percent": { + "median": 97.195, + "min": 97.162, + "max": 97.343, + "mean": 97.22271428571429 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2750000953674316, + "min": 2.1599998474121094, + "max": 2.4600000381469727, + "mean": 2.307142870766776 + }, + "performance_clock_loop_ns": { + "median": 69.24999952316284, + "min": 67.30000019073486, + "max": 69.84999895095825, + "mean": 68.97142853055682 + }, + "cpp_clock_loop_ns": { + "median": 116.80000066757202, + "min": 114.75000143051147, + "max": 120.80000162124634, + "mean": 117.8285721370152 + }, + "wall_clock_loop_ns": { + "median": 27.899999618530273, + "min": 27.59999990463257, + "max": 28.75, + "mean": 27.97142846243722 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 4.149500000000027, + "min": 4.079499999999964, + "max": 4.230000000000037, + "mean": 4.151642857142854 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 274.9999999999915, + "min": 254.99999999999545, + "max": 304.9999999999926, + "mean": 274.2857142857125 + }, + "elapsed_ms": { + "median": 46.69, + "min": 45.545, + "max": 47.349999999999994, + "mean": 46.5 + }, + "million_ops_per_second": { + "median": 2.141807667594774, + "min": 2.1119535374868006, + "max": 2.195652651224064, + "mean": 2.150932555367389 + }, + "zero_percent": { + "median": 30.49, + "min": 29.38, + "max": 31.29, + "mean": 30.38285714285714 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2149999141693115, + "min": 2.109999895095825, + "max": 2.5249998569488525, + "mean": 2.257857084274292 + }, + "performance_clock_loop_ns": { + "median": 70.09999990463257, + "min": 67.40000009536743, + "max": 72.59999990463257, + "mean": 69.79285717010498 + }, + "cpp_clock_loop_ns": { + "median": 116.40000104904175, + "min": 115.2999997138977, + "max": 120.59999942779541, + "mean": 117.18571424484253 + }, + "wall_clock_loop_ns": { + "median": 28.1000018119812, + "min": 27.799999713897705, + "max": 28.65000009536743, + "mean": 28.12857219151088 + }, + "paired_slowdown": { + "median": 7.676935886761037, + "min": 7.585950413223145, + "max": 8.039383561643831 + }, + "paired_net_us_per_yield": { + "median": 4.0555, + "min": 3.970999999999999, + "max": 4.125499999999999 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 0.14350000000000165, + "min": 0.12699999999999106, + "max": 0.15099999999999766, + "mean": 0.14285714285714407 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 4.999999999997483 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 15.000000000000568, + "mean": 7.857142857149922 + }, + "elapsed_ms": { + "median": 6.049999999999997, + "min": 5.835000000000008, + "max": 6.134999999999991, + "mean": 6.011428571428569 + }, + "million_ops_per_second": { + "median": 16.529090909090915, + "min": 16.300081499592526, + "max": 17.138131962296463, + "mean": 16.64154382686012 + }, + "zero_percent": { + "median": 97.13, + "min": 96.99, + "max": 97.46, + "mean": 97.15 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2649998664855957, + "min": 2.200000047683716, + "max": 2.455000162124634, + "mean": 2.291428600038801 + }, + "performance_clock_loop_ns": { + "median": 70.19999980926514, + "min": 68.65000009536743, + "max": 71.05000019073486, + "mean": 70.05000012261527 + }, + "cpp_clock_loop_ns": { + "median": 117.64999866485596, + "min": 116.39999866485596, + "max": 117.99999952316284, + "mean": 117.39999941417149 + }, + "wall_clock_loop_ns": { + "median": 28.249998092651367, + "min": 28.05000066757202, + "max": 28.300001621246338, + "mean": 28.20000035422189 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 4.404296875000033, + "min": 4.37988281250011, + "max": 4.497070312500198, + "mean": 4.421037946428587 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 190.00000000001194, + "min": 170.0000000000017, + "max": 209.99999999999375, + "mean": 190.0000000000018 + }, + "elapsed_ms": { + "median": 8.239999999999995, + "min": 7.905000000000001, + "max": 8.36, + "mean": 8.19142857142857 + }, + "million_ops_per_second": { + "median": 12.427305825242726, + "min": 12.248923444976077, + "max": 12.953953194180896, + "mean": 12.505464347829854 + }, + "zero_percent": { + "median": 28.02734375, + "min": 25.390625, + "max": 28.61328125, + "mean": 27.608816964285715 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4049999713897705, + "min": 2.1649999618530273, + "max": 2.619999885559082, + "mean": 2.4107142857142856 + }, + "performance_clock_loop_ns": { + "median": 70.49999952316284, + "min": 67.7999997138977, + "max": 72.7999997138977, + "mean": 70.65714257104057 + }, + "cpp_clock_loop_ns": { + "median": 116.84999942779541, + "min": 115.24999856948853, + "max": 119.24999952316284, + "mean": 117.24285704748971 + }, + "wall_clock_loop_ns": { + "median": 27.949998378753662, + "min": 27.699999809265137, + "max": 28.19999933242798, + "mean": 27.97142812183925 + }, + "paired_slowdown": { + "median": 2.093994778067885, + "min": 1.8557158712541637, + "max": 2.2168674698795185 + }, + "paired_net_us_per_yield": { + "median": 4.125976562499995, + "min": 3.764648437500004, + "max": 4.438476562500002 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.14160156250002387, + "min": 0.11718750000000444, + "max": 0.1660156249999878, + "mean": 0.14369419642856365 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 4.999999999999512 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 3.885000000000005, + "min": 3.7349999999999994, + "max": 4.5049999999999955, + "mean": 3.9585714285714286 + }, + "million_ops_per_second": { + "median": 26.358043758043724, + "min": 22.730521642619337, + "max": 27.416599732262387, + "mean": 25.954524705012254 + }, + "zero_percent": { + "median": 97.16796875, + "min": 96.6796875, + "max": 97.65625, + "mean": 97.12611607142857 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3350000381469727, + "min": 2.200000047683716, + "max": 2.6649999618530273, + "mean": 2.385714360645839 + }, + "performance_clock_loop_ns": { + "median": 71.5499997138977, + "min": 67.95000076293945, + "max": 72.75000095367432, + "mean": 70.4428574017116 + }, + "cpp_clock_loop_ns": { + "median": 116.60000085830688, + "min": 114.90000009536743, + "max": 119.85000133514404, + "mean": 116.85714312962124 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.799999713897705, + "max": 28.550000190734863, + "mean": 28.221428394317627 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 4.638671874999903, + "min": 4.3066406249999964, + "max": 4.731445312500194, + "mean": 4.607282366071368 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 14.285714285715503 + }, + "max_us": { + "median": 189.99999999999773, + "min": 35.0000000000108, + "max": 210.00000000000796, + "mean": 172.14285714285893 + }, + "elapsed_ms": { + "median": 36.69, + "min": 35.89000000000001, + "max": 37.32000000000001, + "mean": 36.61 + }, + "million_ops_per_second": { + "median": 27.909539384028346, + "min": 27.438397642014998, + "max": 28.53165227082752, + "mean": 27.9753098537306 + }, + "zero_percent": { + "median": 26.07421875, + "min": 24.4140625, + "max": 28.515625, + "mean": 26.395089285714285 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4749999046325684, + "min": 2.1599998474121094, + "max": 2.684999942779541, + "mean": 2.399285691125052 + }, + "performance_clock_loop_ns": { + "median": 71.64999961853027, + "min": 67.1500015258789, + "max": 72.95000076293945, + "mean": 71.00000074931553 + }, + "cpp_clock_loop_ns": { + "median": 116.40000104904175, + "min": 115.39999961853027, + "max": 119.14999961853027, + "mean": 117.03571455819267 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.749998569488525, + "max": 28.250000476837158, + "mean": 28.014285564422607 + }, + "paired_slowdown": { + "median": 1.1459288537549406, + "min": 1.0975172001196531, + "max": 1.1944986979166663 + }, + "paired_net_us_per_yield": { + "median": 4.506835937499995, + "min": 3.183593750000005, + "max": 5.834960937499995 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.1464843749999778, + "min": 0.11230468750002276, + "max": 0.19531249999997502, + "mean": 0.1492745535714415 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000001543 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 32.03, + "min": 30.720000000000013, + "max": 33.42999999999999, + "mean": 31.937142857142856 + }, + "million_ops_per_second": { + "median": 31.970059319388074, + "min": 30.63119952138798, + "max": 33.33336588541665, + "mean": 32.08095830292321 + }, + "zero_percent": { + "median": 97.0703125, + "min": 96.09375, + "max": 97.75390625, + "mean": 97.01450892857143 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.1649999618530273, + "min": 2.0850000381469727, + "max": 2.615000009536743, + "mean": 2.224285738808768 + }, + "performance_clock_loop_ns": { + "median": 69.0499997138977, + "min": 67.14999914169312, + "max": 72.69999980926514, + "mean": 69.36428546905518 + }, + "cpp_clock_loop_ns": { + "median": 116.79999828338623, + "min": 114.90000009536743, + "max": 118.4500002861023, + "mean": 116.71428578240531 + }, + "wall_clock_loop_ns": { + "median": 27.750000953674316, + "min": 27.650001049041748, + "max": 28.15000057220459, + "mean": 27.828571455819265 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 4.819335937499655, + "min": 4.667968750000265, + "max": 5.249023437499667, + "mean": 4.876534598214089 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000019327, + "mean": 10.000000000007146 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 14.999999999986358, + "max": 20.000000000010232, + "mean": 16.4285714285707 + }, + "max_us": { + "median": 204.99999999998408, + "min": 50.00000000001137, + "max": 259.9999999999909, + "mean": 200.00000000000082 + }, + "elapsed_ms": { + "median": 162.07, + "min": 158.06, + "max": 164.86, + "mean": 161.42785714285714 + }, + "million_ops_per_second": { + "median": 31.59129388535818, + "min": 31.056660196530384, + "max": 32.392768568897885, + "mean": 31.723151678050662 + }, + "zero_percent": { + "median": 24.21875, + "min": 22.16796875, + "max": 26.07421875, + "mean": 24.260602678571427 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4850001335144043, + "min": 2.2200000286102295, + "max": 2.6050000190734863, + "mean": 2.461428608213152 + }, + "performance_clock_loop_ns": { + "median": 69.80000019073486, + "min": 67.65000104904175, + "max": 72.04999923706055, + "mean": 70.2285715511867 + }, + "cpp_clock_loop_ns": { + "median": 118.25000047683716, + "min": 116.90000057220459, + "max": 120.35000085830688, + "mean": 118.52857146944318 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.699999809265137, + "max": 28.949999809265137, + "mean": 28.214285714285715 + }, + "paired_slowdown": { + "median": 1.0330496226112094, + "min": 1.0076822543113066, + "max": 1.050565556794647 + }, + "paired_net_us_per_yield": { + "median": 5.02441406250001, + "min": 1.1767578125000122, + "max": 7.749023437500002 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.15625000000005218, + "min": 0.14160156249992673, + "max": 0.19042968750003497, + "mean": 0.16183035714288047 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 4.999999999999512 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000009663, + "max": 5.000000000023874, + "mean": 5.000000000021844 + }, + "elapsed_ms": { + "median": 156.855, + "min": 154.42499999999998, + "max": 159.75, + "mean": 156.58642857142857 + }, + "million_ops_per_second": { + "median": 32.64161805489147, + "min": 32.05008450704226, + "max": 33.1552598348713, + "mean": 32.70078720128848 + }, + "zero_percent": { + "median": 96.875, + "min": 96.19140625, + "max": 97.16796875, + "mean": 96.76339285714286 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2300000190734863, + "min": 2.1549999713897705, + "max": 2.615000009536743, + "mean": 2.3378571442195346 + }, + "performance_clock_loop_ns": { + "median": 69.80000019073486, + "min": 68.29999923706055, + "max": 73.25000047683716, + "mean": 70.13571398598808 + }, + "cpp_clock_loop_ns": { + "median": 117.40000009536743, + "min": 115.19999980926514, + "max": 118.49999904632568, + "mean": 117.07142761775425 + }, + "wall_clock_loop_ns": { + "median": 28.350000381469727, + "min": 27.699999809265137, + "max": 28.70000123977661, + "mean": 28.264285836900985 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 4.858398437500814, + "min": 4.7607421874999165, + "max": 5.170898437499558, + "mean": 4.959542410714363 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 9.999999999990905, + "max": 10.000000000019327, + "mean": 10.000000000007146 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 14.999999999986358, + "max": 15.00000000001478, + "mean": 14.999999999998538 + }, + "max_us": { + "median": 235.00000000001364, + "min": 85.00000000000796, + "max": 245.00000000000455, + "mean": 210.71428571430116 + }, + "elapsed_ms": { + "median": 314.505, + "min": 307.935, + "max": 318.725, + "mean": 313.41714285714284 + }, + "million_ops_per_second": { + "median": 32.559103988807806, + "min": 32.128013177504116, + "max": 33.253774335492885, + "mean": 32.676439228276664 + }, + "zero_percent": { + "median": 23.14453125, + "min": 21.2890625, + "max": 25.29296875, + "mean": 23.200334821428573 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2750000953674316, + "min": 2.1500000953674316, + "max": 2.5899999141693115, + "mean": 2.320000035422189 + }, + "performance_clock_loop_ns": { + "median": 71.40000104904175, + "min": 67.34999895095825, + "max": 72.05000162124634, + "mean": 70.40714366095406 + }, + "cpp_clock_loop_ns": { + "median": 116.94999933242798, + "min": 115.9500002861023, + "max": 117.69999980926514, + "mean": 116.74999952316284 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.750000953674316, + "max": 28.450000286102295, + "mean": 28.035714626312256 + }, + "paired_slowdown": { + "median": 1.0100534654114868, + "min": 0.8485081057790705, + "max": 1.034232723326592 + }, + "paired_net_us_per_yield": { + "median": 2.993164062499998, + "min": -54.93652343749994, + "max": 10.166015624999968 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 7168, + "mean_us": { + "median": 0.15136718750002887, + "min": 0.1269531250000927, + "max": 0.23437499999995337, + "mean": 0.1660156249999977 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 4.999999999997483 + }, + "max_us": { + "median": 5.000000000052296, + "min": 5.000000000009663, + "max": 5.000000000052296, + "mean": 5.0000000000401155 + }, + "elapsed_ms": { + "median": 310.035, + "min": 304.095, + "max": 371.34, + "mean": 319.96785714285716 + }, + "million_ops_per_second": { + "median": 33.02853226248649, + "min": 27.57580923143211, + "max": 33.6736907874184, + "mean": 32.139484740920864 + }, + "zero_percent": { + "median": 96.97265625, + "min": 95.3125, + "max": 97.4609375, + "mean": 96.6796875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.315000057220459, + "min": 2.125, + "max": 2.5250000953674316, + "mean": 2.330000025885446 + }, + "performance_clock_loop_ns": { + "median": 69.84999895095825, + "min": 67.14999914169312, + "max": 72.10000038146973, + "mean": 69.87142835344586 + }, + "cpp_clock_loop_ns": { + "median": 116.25, + "min": 115.75000047683716, + "max": 119.60000038146973, + "mean": 116.87857151031494 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.899999618530273, + "max": 28.450000286102295, + "mean": 28.164285591670446 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "clock", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 0.10910000000000317, + "min": 0.10340000000000145, + "max": 0.10979999999999883, + "mean": 0.10747142857142945 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 40.00000000000625, + "min": 15.000000000000568, + "max": 54.99999999999261, + "mean": 37.85714285714294 + }, + "elapsed_ms": { + "median": 21.53, + "min": 21.019999999999996, + "max": 21.68, + "mean": 21.457857142857144 + }, + "million_ops_per_second": { + "median": 4.644681839294009, + "min": 4.612546125461255, + "max": 4.757373929590867, + "mean": 4.660784811846449 + }, + "zero_percent": { + "median": 97.843, + "min": 97.815, + "max": 97.948, + "mean": 97.863 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.325000047683716, + "min": 2.200000047683716, + "max": 2.444999933242798, + "mean": 2.3107143470219205 + }, + "performance_clock_loop_ns": { + "median": 70.45000076293945, + "min": 67.99999952316284, + "max": 72.35000133514404, + "mean": 70.77857153756278 + }, + "cpp_clock_loop_ns": { + "median": 118.09999942779541, + "min": 116.44999980926514, + "max": 120.39999961853027, + "mean": 118.10000010899135 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.750000953674316, + "max": 28.350000381469727, + "mean": 28.028571265084402 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "direct", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 4.062000000000011, + "min": 3.984500000000002, + "max": 4.145500000000002, + "mean": 4.074357142857144 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 259.9999999999909, + "min": 250.0, + "max": 310.0000000000023, + "mean": 263.5714285714284 + }, + "elapsed_ms": { + "median": 41.97, + "min": 41.065, + "max": 42.73499999999999, + "mean": 42.02428571428571 + }, + "million_ops_per_second": { + "median": 0.2382654276864427, + "min": 0.23400023400023404, + "max": 0.24351637647631805, + "mean": 0.238003336717656 + }, + "zero_percent": { + "median": 31.36, + "min": 29.75, + "max": 32.63, + "mean": 31.21857142857143 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.330000162124634, + "min": 2.174999952316284, + "max": 2.4749999046325684, + "mean": 2.323571409497942 + }, + "performance_clock_loop_ns": { + "median": 69.64999914169312, + "min": 68.04999828338623, + "max": 71.60000085830688, + "mean": 69.80714218957084 + }, + "cpp_clock_loop_ns": { + "median": 118.59999895095825, + "min": 117.05000162124634, + "max": 119.80000019073486, + "mean": 118.46428564616612 + }, + "wall_clock_loop_ns": { + "median": 27.999999523162842, + "min": 27.749998569488525, + "max": 28.500001430511475, + "mean": 28.049999986376083 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "direct", + "limit": 1, + "trace": 1, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 70000, + "mean_us": { + "median": 4.851000000000019, + "min": 4.763999999999995, + "max": 4.900499999999997, + "mean": 4.832428571428576 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 379.99999999999545, + "min": 370.00000000000455, + "max": 459.99999999999375, + "mean": 392.14285714285575 + }, + "elapsed_ms": { + "median": 49.81999999999999, + "min": 48.985, + "max": 50.17999999999999, + "mean": 49.59785714285714 + }, + "million_ops_per_second": { + "median": 0.2007226013649137, + "min": 0.19928258270227184, + "max": 0.20414412575278146, + "mean": 0.2016398235116768 + }, + "zero_percent": { + "median": 22.23, + "min": 21.29, + "max": 23.33, + "mean": 22.257142857142856 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.509999990463257, + "min": 2.1550002098083496, + "max": 2.690000057220459, + "mean": 2.455000025885446 + }, + "performance_clock_loop_ns": { + "median": 69.94999885559082, + "min": 68.79999876022339, + "max": 71.05000019073486, + "mean": 70.05714246204921 + }, + "cpp_clock_loop_ns": { + "median": 118.1000018119812, + "min": 116.84999942779541, + "max": 118.4000015258789, + "mean": 117.778571333204 + }, + "wall_clock_loop_ns": { + "median": 28.19999933242798, + "min": 27.999999523162842, + "max": 28.350000381469727, + "mean": 28.17857129233224 + }, + "component_means_us": { + "entry": 0.2117062109538448, + "channel_create": 1.058357262611389, + "handler_setup": 0.666214268548148, + "post_message": 0.4739284481321062, + "post_to_delivery": 1.1993572235107421, + "message_handler": 1.0110713992800031, + "resume": 0.2117937583923421 + } + }, + { + "group": "primary", + "variant": "jspi", + "mode": "sync", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 0, + "repetitions": 7, + "total_samples": 700000, + "mean_us": { + "median": 0.11114999999999597, + "min": 0.11009999999999934, + "max": 0.11434999999999995, + "mean": 0.11171428571428499 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 79.9999999999983, + "min": 74.99999999999574, + "max": 85.00000000000085, + "mean": 79.9999999999993 + }, + "elapsed_ms": { + "median": 21.654999999999994, + "min": 21.495000000000005, + "max": 22.525, + "mean": 21.79142857142857 + }, + "million_ops_per_second": { + "median": 4.617871161394598, + "min": 4.439511653718091, + "max": 4.652244708071644, + "mean": 4.590079889112346 + }, + "zero_percent": { + "median": 97.806, + "min": 97.758, + "max": 97.83, + "mean": 97.79785714285714 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3450000286102295, + "min": 2.115000009536743, + "max": 2.615000009536743, + "mean": 2.3478571006229947 + }, + "performance_clock_loop_ns": { + "median": 70.14999866485596, + "min": 67.5, + "max": 71.09999895095825, + "mean": 69.82857159205845 + }, + "cpp_clock_loop_ns": { + "median": 117.8499984741211, + "min": 115.09999990463257, + "max": 120.05000114440918, + "mean": 117.64999968664986 + }, + "wall_clock_loop_ns": { + "median": 28.09999942779541, + "min": 27.749998569488525, + "max": 31.700000762939453, + "mean": 28.492857388087682 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 4.862849999999996, + "min": 4.8150999999999895, + "max": 4.917199999999983, + "mean": 4.865049999999989 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 9.999999999990905, + "min": 9.999999999990905, + "max": 9.999999999990905, + "mean": 9.999999999990905 + }, + "p99_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "max_us": { + "median": 4204.999999999984, + "min": 4074.9999999999886, + "max": 4425.000000000011, + "mean": 4234.9999999999945 + }, + "elapsed_ms": { + "median": 500.78999999999996, + "min": 496.08000000000004, + "max": 505.60999999999996, + "mean": 500.82666666666665 + }, + "million_ops_per_second": { + "median": 0.199686495337367, + "min": 0.1977828761298234, + "max": 0.2015824060635381, + "mean": 0.19968392584357617 + }, + "zero_percent": { + "median": 22.247, + "min": 21.957, + "max": 22.897, + "mean": 22.367 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.109999895095825, + "min": 4.0899999141693115, + "max": 5.0350000858306885, + "mean": 4.411666631698608 + }, + "performance_clock_loop_ns": { + "median": 68.4500002861023, + "min": 66.94999933242798, + "max": 71.5499997138977, + "mean": 68.98333311080933 + }, + "cpp_clock_loop_ns": { + "median": 140.69999933242798, + "min": 140.2999997138977, + "max": 141.09999895095825, + "mean": 140.69999933242798 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.799999713897705, + "max": 28.999998569488525, + "mean": 28.249999682108562 + }, + "paired_slowdown": { + "median": 14.89781347612673, + "min": 14.63147028461879, + "max": 14.938986556359875 + }, + "paired_net_us_per_yield": { + "median": 4.671749999999999, + "min": 4.6217500000000005, + "max": 4.71765 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 0.21315000000000112, + "min": 0.211099999999999, + "max": 0.21470000000000142, + "mean": 0.21298333333333386 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "max_us": { + "median": 34.99999999999659, + "min": 30.000000000001137, + "max": 115.0000000000091, + "mean": 60.000000000002274 + }, + "elapsed_ms": { + "median": 33.845, + "min": 33.614999999999995, + "max": 33.905, + "mean": 33.788333333333334 + }, + "million_ops_per_second": { + "median": 2.954675727581622, + "min": 2.949446984220616, + "max": 2.9748921612375434, + "mean": 2.9596716243465937 + }, + "zero_percent": { + "median": 95.758, + "min": 95.741, + "max": 95.797, + "mean": 95.76533333333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 5.109999895095825, + "min": 5.059999942779541, + "max": 5.229999780654907, + "mean": 5.133333206176758 + }, + "performance_clock_loop_ns": { + "median": 72.54999876022339, + "min": 68.80000114440918, + "max": 72.7999997138977, + "mean": 71.38333320617676 + }, + "cpp_clock_loop_ns": { + "median": 145, + "min": 141.2000012397766, + "max": 145.15000104904175, + "mean": 143.7833340962728 + }, + "wall_clock_loop_ns": { + "median": 28.450000286102295, + "min": 27.55000114440918, + "max": 28.450000286102295, + "mean": 28.15000057220459 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 5.010499999999946, + "min": 4.9474999999999785, + "max": 5.025499999999984, + "mean": 4.994499999999969 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000019327, + "min": 10.000000000019327, + "max": 10.000000000019327, + "mean": 10.000000000019327 + }, + "max_us": { + "median": 235.00000000001364, + "min": 234.99999999999943, + "max": 240.0000000000091, + "mean": 236.66666666667405 + }, + "elapsed_ms": { + "median": 61.730000000000004, + "min": 61.46499999999999, + "max": 62.02000000000001, + "mean": 61.73833333333334 + }, + "million_ops_per_second": { + "median": 1.6199740806739023, + "min": 1.6123992260561106, + "max": 1.626958431627756, + "mean": 1.6197772461192563 + }, + "zero_percent": { + "median": 20.32, + "min": 19.99, + "max": 21.19, + "mean": 20.5 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.849999904632568, + "min": 4.105000019073486, + "max": 4.9700000286102295, + "mean": 4.641666650772095 + }, + "performance_clock_loop_ns": { + "median": 72.2000002861023, + "min": 68.15000057220459, + "max": 73.04999828338623, + "mean": 71.13333304723103 + }, + "cpp_clock_loop_ns": { + "median": 144.7000002861023, + "min": 144.14999961853027, + "max": 145.35000085830688, + "mean": 144.73333358764648 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.899999618530273, + "max": 28.350000381469727, + "mean": 28.066666920979817 + }, + "paired_slowdown": { + "median": 4.822706065318819, + "min": 4.7702755141637585, + "max": 4.830203442879499 + }, + "paired_net_us_per_yield": { + "median": 4.895, + "min": 4.858, + "max": 4.916 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 0.22000000000001307, + "min": 0.21249999999999858, + "max": 0.24450000000000216, + "mean": 0.22566666666667126 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "max_us": { + "median": 10.000000000005116, + "min": 5.000000000009663, + "max": 125.0, + "mean": 46.666666666671595 + }, + "elapsed_ms": { + "median": 12.86, + "min": 12.780000000000001, + "max": 12.884999999999991, + "mean": 12.841666666666663 + }, + "million_ops_per_second": { + "median": 7.7761275272161745, + "min": 7.761039968956156, + "max": 7.824804381846635, + "mean": 7.7873239593396555 + }, + "zero_percent": { + "median": 95.6, + "min": 95.35, + "max": 95.77, + "mean": 95.57333333333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.120000123977661, + "min": 4.099999904632568, + "max": 4.909999847412109, + "mean": 4.376666625340779 + }, + "performance_clock_loop_ns": { + "median": 69.10000085830688, + "min": 67.59999990463257, + "max": 72.24999904632568, + "mean": 69.64999993642171 + }, + "cpp_clock_loop_ns": { + "median": 141.94999933242798, + "min": 141.15000009536743, + "max": 147.99999952316284, + "mean": 143.69999965031943 + }, + "wall_clock_loop_ns": { + "median": 28.20000171661377, + "min": 27.649998664855957, + "max": 28.450000286102295, + "mean": 28.100000222524006 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.556640625000192, + "min": 5.527343750000205, + "max": 5.561523437499813, + "mean": 5.548502604166736 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 19.99999999999602, + "min": 15.000000000000568, + "max": 19.99999999999602, + "mean": 18.33333333333087 + }, + "max_us": { + "median": 180.00000000000682, + "min": 150.00000000000568, + "max": 195.0000000000074, + "mean": 175.00000000000662 + }, + "elapsed_ms": { + "median": 16.180000000000007, + "min": 15.974999999999994, + "max": 16.185000000000002, + "mean": 16.113333333333333 + }, + "million_ops_per_second": { + "median": 6.328862793572309, + "min": 6.326907630522088, + "max": 6.410078247261348, + "mean": 6.355282890451915 + }, + "zero_percent": { + "median": 17.578125, + "min": 16.2109375, + "max": 17.67578125, + "mean": 17.154947916666668 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.039999961853027, + "min": 4.0299999713897705, + "max": 4.115000009536743, + "mean": 4.061666647593181 + }, + "performance_clock_loop_ns": { + "median": 69.50000047683716, + "min": 69.3500018119812, + "max": 72.7999997138977, + "mean": 70.55000066757202 + }, + "cpp_clock_loop_ns": { + "median": 142.2000002861023, + "min": 141.95000171661377, + "max": 144.7000002861023, + "mean": 142.95000076293945 + }, + "wall_clock_loop_ns": { + "median": 28.1000018119812, + "min": 27.950000762939453, + "max": 28.19999933242798, + "mean": 28.08333396911621 + }, + "paired_slowdown": { + "median": 1.495841035120149, + "min": 1.4784821841739921, + "max": 1.4981481481481491 + }, + "paired_net_us_per_yield": { + "median": 5.239257812500009, + "min": 5.048828124999988, + "max": 5.25390625000001 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.234374999999995, + "min": 0.21972656249992506, + "max": 0.24902343749992617, + "mean": 0.23437499999994874 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000004927 + }, + "max_us": { + "median": 10.000000000005116, + "min": 5.000000000009663, + "max": 15.000000000000568, + "mean": 10.000000000005116 + }, + "elapsed_ms": { + "median": 10.805000000000007, + "min": 10.799999999999997, + "max": 10.819999999999993, + "mean": 10.808333333333332 + }, + "million_ops_per_second": { + "median": 9.477186487737153, + "min": 9.464048059149729, + "max": 9.481574074074077, + "mean": 9.47426954032032 + }, + "zero_percent": { + "median": 95.5078125, + "min": 95.1171875, + "max": 95.60546875, + "mean": 95.41015625 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.085000038146973, + "min": 4.085000038146973, + "max": 4.144999980926514, + "mean": 4.105000019073486 + }, + "performance_clock_loop_ns": { + "median": 71.90000057220459, + "min": 69.90000009536743, + "max": 72.39999771118164, + "mean": 71.39999945958455 + }, + "cpp_clock_loop_ns": { + "median": 140.85000038146973, + "min": 139.24999952316284, + "max": 141.70000076293945, + "mean": 140.60000022252402 + }, + "wall_clock_loop_ns": { + "median": 27.850000858306885, + "min": 27.44999885559082, + "max": 28.350000381469727, + "mean": 27.88333336512248 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.85937499999957, + "min": 5.7128906249999805, + "max": 5.913085937499895, + "mean": 5.828450520833148 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000019327, + "min": 10.000000000005116, + "max": 10.000000000019327, + "mean": 10.00000000001459 + }, + "p99_us": { + "median": 19.99999999998181, + "min": 15.00000000001478, + "max": 19.99999999999602, + "mean": 18.33333333333087 + }, + "max_us": { + "median": 179.9999999999926, + "min": 165.00000000000625, + "max": 189.99999999999773, + "mean": 178.3333333333322 + }, + "elapsed_ms": { + "median": 96.015, + "min": 94.86999999999999, + "max": 97.41000000000001, + "mean": 96.09833333333333 + }, + "million_ops_per_second": { + "median": 10.665010675415301, + "min": 10.512278000205317, + "max": 10.793728259723833, + "mean": 10.657005645114817 + }, + "zero_percent": { + "median": 14.84375, + "min": 14.35546875, + "max": 17.1875, + "mean": 15.462239583333334 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.1000001430511475, + "min": 4.070000171661377, + "max": 4.130000114440918, + "mean": 4.1000001430511475 + }, + "performance_clock_loop_ns": { + "median": 72.89999961853027, + "min": 70.65000057220459, + "max": 73.79999876022339, + "mean": 72.44999965031941 + }, + "cpp_clock_loop_ns": { + "median": 141.94999933242798, + "min": 141.44999980926514, + "max": 143.90000104904175, + "mean": 142.43333339691162 + }, + "wall_clock_loop_ns": { + "median": 27.949998378753662, + "min": 27.55000114440918, + "max": 27.950000762939453, + "mean": 27.8166667620341 + }, + "paired_slowdown": { + "median": 1.0469569055895822, + "min": 1.0377117289868967, + "max": 1.0749552171965964 + }, + "paired_net_us_per_yield": { + "median": 4.155273437499996, + "min": 3.457031249999992, + "max": 6.538085937499993 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.26855468750001943, + "min": 0.19531249999996114, + "max": 0.28320312499997835, + "mean": 0.24902343749998632 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 4.9999999999954525, + "min": 0.0, + "max": 4.9999999999954525, + "mean": 3.3333333333303017 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000004927 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000023874, + "max": 5.000000000023874, + "mean": 5.000000000023874 + }, + "elapsed_ms": { + "median": 90.615, + "min": 89.32000000000001, + "max": 93.87000000000002, + "mean": 91.26833333333335 + }, + "million_ops_per_second": { + "median": 11.30056833857529, + "min": 10.908714179183974, + "max": 11.464408866995072, + "mean": 11.224563794918112 + }, + "zero_percent": { + "median": 94.62890625, + "min": 94.3359375, + "max": 96.09375, + "mean": 95.01953125 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.215000152587891, + "min": 4.110000133514404, + "max": 5.009999990463257, + "mean": 4.4450000921885175 + }, + "performance_clock_loop_ns": { + "median": 70.85000038146973, + "min": 69.54999923706055, + "max": 72.89999961853027, + "mean": 71.09999974568684 + }, + "cpp_clock_loop_ns": { + "median": 142.40000009536743, + "min": 138.29999923706055, + "max": 143.54999780654907, + "mean": 141.41666571299234 + }, + "wall_clock_loop_ns": { + "median": 28.05000066757202, + "min": 27.699999809265137, + "max": 28.19999933242798, + "mean": 27.983333269755047 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.396484374999095, + "min": 6.3916015624997105, + "max": 6.5234374999995905, + "mean": 6.437174479166132 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "p99_us": { + "median": 19.99999999999602, + "min": 19.99999999999602, + "max": 24.999999999977263, + "mean": 21.666666666656436 + }, + "max_us": { + "median": 180.00000000000682, + "min": 174.99999999998295, + "max": 195.0000000000216, + "mean": 183.33333333333712 + }, + "elapsed_ms": { + "median": 443.08000000000004, + "min": 443.08000000000004, + "max": 458.5, + "mean": 448.22 + }, + "million_ops_per_second": { + "median": 11.555477566128014, + "min": 11.166850599781897, + "max": 11.555477566128014, + "mean": 11.425935244012642 + }, + "zero_percent": { + "median": 13.28125, + "min": 12.98828125, + "max": 13.4765625, + "mean": 13.248697916666666 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.079999923706055, + "min": 4.069999933242798, + "max": 4.085000038146973, + "mean": 4.078333298365275 + }, + "performance_clock_loop_ns": { + "median": 71.70000076293945, + "min": 67.89999961853027, + "max": 72.04999923706055, + "mean": 70.54999987284343 + }, + "cpp_clock_loop_ns": { + "median": 140.69999933242798, + "min": 139.74999904632568, + "max": 143.7999987602234, + "mean": 141.41666571299234 + }, + "wall_clock_loop_ns": { + "median": 28.499999046325684, + "min": 28.250000476837158, + "max": 28.69999885559082, + "mean": 28.48333279291789 + }, + "paired_slowdown": { + "median": 1.0156910839341182, + "min": 0.998377647589004, + "max": 1.1077153521858352 + }, + "paired_net_us_per_yield": { + "median": 6.684570312500027, + "min": -0.7031250000000266, + "max": 43.54003906249998 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.2832031249998812, + "min": 0.24414062500002776, + "max": 0.2880859375000294, + "mean": 0.2718098958333128 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 4.9999999999954525, + "min": 0.0, + "max": 4.9999999999954525, + "mean": 3.3333333333303017 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 5.000000000052296, + "min": 5.000000000052296, + "max": 9.999999999990905, + "mean": 6.666666666698499 + }, + "elapsed_ms": { + "median": 436.235, + "min": 413.915, + "max": 443.80000000000007, + "mean": 431.3166666666667 + }, + "million_ops_per_second": { + "median": 11.736795534516947, + "min": 11.536730509238394, + "max": 12.36969184494401, + "mean": 11.88107262956645 + }, + "zero_percent": { + "median": 94.3359375, + "min": 94.3359375, + "max": 95.1171875, + "mean": 94.59635416666667 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.174999952316284, + "min": 4.0350000858306885, + "max": 5, + "mean": 4.403333346048991 + }, + "performance_clock_loop_ns": { + "median": 68.05000066757202, + "min": 67.65000104904175, + "max": 69.3500018119812, + "mean": 68.35000117619832 + }, + "cpp_clock_loop_ns": { + "median": 140.85000038146973, + "min": 138.80000114440918, + "max": 143.29999923706055, + "mean": 140.98333358764648 + }, + "wall_clock_loop_ns": { + "median": 28.000001907348633, + "min": 27.950000762939453, + "max": 28.19999933242798, + "mean": 28.05000066757202 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 6.879882812500348, + "min": 6.708984374999879, + "max": 6.914062500000387, + "mean": 6.834309895833538 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000104592, + "min": 10.000000000104592, + "max": 10.000000000104592, + "mean": 10.000000000104592 + }, + "p99_us": { + "median": 25.000000000005684, + "min": 20.000000000010232, + "max": 25.000000000005684, + "mean": 23.333333333340533 + }, + "max_us": { + "median": 284.99999999996817, + "min": 269.9999999999818, + "max": 295.00000000007276, + "mean": 283.33333333334093 + }, + "elapsed_ms": { + "median": 882.175, + "min": 867.585, + "max": 888.9000000000001, + "mean": 879.5533333333334 + }, + "million_ops_per_second": { + "median": 11.60767534786182, + "min": 11.519857126785913, + "max": 11.802879256787518, + "mean": 11.643470577145084 + }, + "zero_percent": { + "median": 12.40234375, + "min": 12.3046875, + "max": 12.890625, + "mean": 12.532552083333334 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.894999980926514, + "min": 4.159999847412109, + "max": 4.925000190734863, + "mean": 4.660000006357829 + }, + "performance_clock_loop_ns": { + "median": 72.75000095367432, + "min": 68.94999980926514, + "max": 73.19999933242798, + "mean": 71.63333336512248 + }, + "cpp_clock_loop_ns": { + "median": 142.1500015258789, + "min": 138.29999923706055, + "max": 143.0999994277954, + "mean": 141.18333339691162 + }, + "wall_clock_loop_ns": { + "median": 28.399999141693115, + "min": 28.19999933242798, + "max": 28.399999141693115, + "mean": 28.333332538604736 + }, + "paired_slowdown": { + "median": 0.984145612364651, + "min": 0.9790001071998826, + "max": 1.0068824224300772 + }, + "paired_net_us_per_yield": { + "median": -13.984374999999938, + "min": -18.173828125000014, + "max": 5.888671874999973 + } + }, + { + "group": "work-64", + "variant": "asyncify", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.23925781249992117, + "min": 0.23437499999998113, + "max": 0.2587890625000838, + "mean": 0.24414062499999536 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 4.9999999999954525, + "mean": 1.6666666666651508 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000109139, + "min": 5.000000000052296, + "max": 9.999999999990905, + "mean": 6.666666666717447 + }, + "elapsed_ms": { + "median": 886.195, + "min": 876.145, + "max": 903.22, + "mean": 888.52 + }, + "million_ops_per_second": { + "median": 11.555020057662253, + "min": 11.337216846394012, + "max": 11.687564273036998, + "mean": 11.52660039236442 + }, + "zero_percent": { + "median": 95.21484375, + "min": 94.921875, + "max": 95.3125, + "mean": 95.14973958333333 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 4.924999952316284, + "min": 4.125, + "max": 4.980000019073486, + "mean": 4.676666657129924 + }, + "performance_clock_loop_ns": { + "median": 71.19999885559082, + "min": 67.64999866485596, + "max": 72.00000047683716, + "mean": 70.28333266576131 + }, + "cpp_clock_loop_ns": { + "median": 140.79999923706055, + "min": 140.45000076293945, + "max": 143.84999990463257, + "mean": 141.69999996821085 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.849998474121094, + "max": 28.299999237060547, + "mean": 28.09999942779541 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 4.21314999999999, + "min": 4.193799999999999, + "max": 4.284250000000003, + "mean": 4.230399999999997 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 9.999999999990905, + "min": 9.999999999990905, + "max": 9.999999999990905, + "mean": 9.999999999990905 + }, + "p99_us": { + "median": 10.000000000047748, + "min": 10.000000000047748, + "max": 10.000000000047748, + "mean": 10.000000000047748 + }, + "max_us": { + "median": 4189.999999999998, + "min": 4015.0000000000146, + "max": 4280.000000000001, + "mean": 4161.6666666666715 + }, + "elapsed_ms": { + "median": 435.44000000000005, + "min": 432.905, + "max": 442.315, + "mean": 436.88666666666666 + }, + "million_ops_per_second": { + "median": 0.229655061546941, + "min": 0.22608548206594847, + "max": 0.23099987295134036, + "mean": 0.22891347218807662 + }, + "zero_percent": { + "median": 30.434, + "min": 29.386, + "max": 30.632, + "mean": 30.150666666666666 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3449997901916504, + "min": 2.2250001430511475, + "max": 2.440000057220459, + "mean": 2.3366666634877524 + }, + "performance_clock_loop_ns": { + "median": 70.25000095367432, + "min": 68.59999895095825, + "max": 72.40000009536743, + "mean": 70.41666666666667 + }, + "cpp_clock_loop_ns": { + "median": 117.14999914169312, + "min": 115.65000057220459, + "max": 118.55000019073486, + "mean": 117.11666663487752 + }, + "wall_clock_loop_ns": { + "median": 28.15000057220459, + "min": 27.900002002716064, + "max": 29.650001525878906, + "mean": 28.566668033599854 + }, + "paired_slowdown": { + "median": 16.950078308535627, + "min": 16.288528816055972, + "max": 17.255399247077474 + }, + "paired_net_us_per_yield": { + "median": 4.10205, + "min": 4.07365, + "max": 4.151599999999999 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 1, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 300000, + "mean_us": { + "median": 0.14169999999999974, + "min": 0.1388000000000001, + "max": 0.15935000000000044, + "mean": 0.14661666666666676 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 129.99999999999545, + "min": 75.00000000000284, + "max": 135.00000000000512, + "mean": 113.33333333333447 + }, + "elapsed_ms": { + "median": 25.540000000000006, + "min": 25.235, + "max": 27.155, + "mean": 25.97666666666667 + }, + "million_ops_per_second": { + "median": 3.915465935787, + "min": 3.682599889523108, + "max": 3.9627897761046165, + "mean": 3.8536185338049083 + }, + "zero_percent": { + "median": 97.188, + "min": 96.855, + "max": 97.259, + "mean": 97.10066666666667 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2250001430511475, + "min": 2.2049999237060547, + "max": 2.2750000953674316, + "mean": 2.2350000540415444 + }, + "performance_clock_loop_ns": { + "median": 70.15000104904175, + "min": 68.35000038146973, + "max": 70.20000219345093, + "mean": 69.56666787465413 + }, + "cpp_clock_loop_ns": { + "median": 118.80000114440918, + "min": 114.3999981880188, + "max": 119.54999923706055, + "mean": 117.58333285649617 + }, + "wall_clock_loop_ns": { + "median": 28.349997997283936, + "min": 28.300001621246338, + "max": 28.65000009536743, + "mean": 28.4333332379659 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 4.119000000000009, + "min": 4.105500000000011, + "max": 4.15600000000001, + "mean": 4.126833333333344 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 285.0000000000108, + "min": 270.00000000001023, + "max": 285.0000000000108, + "mean": 280.00000000001063 + }, + "elapsed_ms": { + "median": 46.25, + "min": 46.06, + "max": 46.605000000000004, + "mean": 46.305 + }, + "million_ops_per_second": { + "median": 2.162183783783784, + "min": 2.145713979186782, + "max": 2.1711029092488054, + "mean": 2.1596668907397905 + }, + "zero_percent": { + "median": 30.81, + "min": 30.54, + "max": 30.96, + "mean": 30.77 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.365000009536743, + "min": 2.1549999713897705, + "max": 2.4100000858306885, + "mean": 2.310000022252401 + }, + "performance_clock_loop_ns": { + "median": 70.6000018119812, + "min": 69.50000047683716, + "max": 72.5, + "mean": 70.86666742960612 + }, + "cpp_clock_loop_ns": { + "median": 118.09999942779541, + "min": 117.30000019073486, + "max": 118.80000114440918, + "mean": 118.06666692097981 + }, + "wall_clock_loop_ns": { + "median": 27.899999618530273, + "min": 27.750000953674316, + "max": 28.599998950958252, + "mean": 28.083333174387615 + }, + "paired_slowdown": { + "median": 7.658997534921948, + "min": 7.581967213114761, + "max": 7.715242881072029 + }, + "paired_net_us_per_yield": { + "median": 4.015000000000001, + "min": 4.009, + "max": 4.0520000000000005 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 10, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 30000, + "mean_us": { + "median": 0.1349999999999966, + "min": 0.13250000000000667, + "max": 0.13500000000000084, + "mean": 0.13416666666666804 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 6.084999999999994, + "min": 5.969999999999999, + "max": 6.099999999999994, + "mean": 6.051666666666662 + }, + "million_ops_per_second": { + "median": 16.434018077239127, + "min": 16.393606557377066, + "max": 16.75058626465662, + "mean": 16.526070299757603 + }, + "zero_percent": { + "median": 97.3, + "min": 97.3, + "max": 97.35, + "mean": 97.31666666666666 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.4600000381469727, + "min": 2.245000123977661, + "max": 2.504999876022339, + "mean": 2.4033333460489907 + }, + "performance_clock_loop_ns": { + "median": 68.94999980926514, + "min": 66.90000057220459, + "max": 69.75000143051147, + "mean": 68.53333393732707 + }, + "cpp_clock_loop_ns": { + "median": 115.04999876022339, + "min": 114.40000057220459, + "max": 116.84999942779541, + "mean": 115.43333292007446 + }, + "wall_clock_loop_ns": { + "median": 27.59999990463257, + "min": 27.40000009536743, + "max": 28.1499981880188, + "mean": 27.71666606267293 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.428710937500038, + "min": 4.394531249999723, + "max": 4.648437500000186, + "mean": 4.490559895833315 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "max_us": { + "median": 209.99999999999375, + "min": 200.00000000000284, + "max": 215.0000000000034, + "mean": 208.33333333333334 + }, + "elapsed_ms": { + "median": 8.375, + "min": 8.370000000000005, + "max": 8.53500000000001, + "mean": 8.426666666666671 + }, + "million_ops_per_second": { + "median": 12.226985074626866, + "min": 11.997773872290553, + "max": 12.234289127837508, + "mean": 12.153016024918308 + }, + "zero_percent": { + "median": 28.125, + "min": 25.87890625, + "max": 29.00390625, + "mean": 27.669270833333332 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.2200000286102295, + "min": 2.2049999237060547, + "max": 2.3549997806549072, + "mean": 2.259999910990397 + }, + "performance_clock_loop_ns": { + "median": 70.14999866485596, + "min": 69.44999933242798, + "max": 70.75000047683716, + "mean": 70.11666615804036 + }, + "cpp_clock_loop_ns": { + "median": 117.64999866485596, + "min": 116.34999990463257, + "max": 118.00000190734863, + "mean": 117.33333349227905 + }, + "wall_clock_loop_ns": { + "median": 28.1000018119812, + "min": 27.899999618530273, + "max": 28.350000381469727, + "mean": 28.1166672706604 + }, + "paired_slowdown": { + "median": 2.09375, + "min": 2.0492196878751496, + "max": 2.1243654822335047 + }, + "paired_net_us_per_yield": { + "median": 4.2724609375, + "min": 4.267578125000004, + "max": 4.326171875000007 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 100, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.15136718749998723, + "min": 0.1464843749999778, + "max": 0.17578125000002054, + "mean": 0.15787760416666186 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000000189 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 4, + "min": 3.9399999999999977, + "max": 4.165000000000006, + "mean": 4.035000000000001 + }, + "million_ops_per_second": { + "median": 25.60025, + "min": 24.58607442977187, + "max": 25.990101522842654, + "mean": 25.39214198420484 + }, + "zero_percent": { + "median": 96.97265625, + "min": 96.484375, + "max": 97.0703125, + "mean": 96.84244791666667 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.434999942779541, + "min": 2.375, + "max": 2.6449999809265137, + "mean": 2.484999974568685 + }, + "performance_clock_loop_ns": { + "median": 68.49999904632568, + "min": 67.90000200271606, + "max": 71.45000219345093, + "mean": 69.28333441416423 + }, + "cpp_clock_loop_ns": { + "median": 116.39999866485596, + "min": 113.69999885559082, + "max": 117.99999952316284, + "mean": 116.03333234786987 + }, + "wall_clock_loop_ns": { + "median": 28.450000286102295, + "min": 27.899999618530273, + "max": 28.599998950958252, + "mean": 28.31666628519694 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.511718749999817, + "min": 4.423828124999862, + "max": 4.760742187499889, + "mean": 4.565429687499856 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000005116, + "max": 15.000000000000568, + "mean": 13.333333333335418 + }, + "max_us": { + "median": 209.99999999999375, + "min": 45.000000000001705, + "max": 225.00000000000853, + "mean": 160.00000000000134 + }, + "elapsed_ms": { + "median": 38.379999999999995, + "min": 37.089999999999996, + "max": 38.38000000000001, + "mean": 37.95 + }, + "million_ops_per_second": { + "median": 26.68058884835852, + "min": 26.680588848358514, + "max": 27.60854677810731, + "mean": 26.989908158274783 + }, + "zero_percent": { + "median": 26.171875, + "min": 24.90234375, + "max": 27.1484375, + "mean": 26.07421875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.190000057220459, + "min": 2.129999876022339, + "max": 2.504999876022339, + "mean": 2.2749999364217124 + }, + "performance_clock_loop_ns": { + "median": 70.9499979019165, + "min": 67.59999990463257, + "max": 72.2000002861023, + "mean": 70.24999936421712 + }, + "cpp_clock_loop_ns": { + "median": 115.55000066757202, + "min": 115.19999980926514, + "max": 116.80000066757202, + "mean": 115.85000038146973 + }, + "wall_clock_loop_ns": { + "median": 28.299999237060547, + "min": 27.950000762939453, + "max": 28.350000381469727, + "mean": 28.200000127156574 + }, + "paired_slowdown": { + "median": 1.1353350096139625, + "min": 1.1005934718100887, + "max": 1.1574185765983112 + }, + "paired_net_us_per_yield": { + "median": 4.467773437500003, + "min": 3.310546874999994, + "max": 5.097656249999999 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 1000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.15625000000001055, + "min": 0.1562499999999689, + "max": 0.17089843749999722, + "mean": 0.16113281249999223 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000004927 + }, + "max_us": { + "median": 5.000000000009663, + "min": 5.000000000009663, + "max": 5.000000000009663, + "mean": 5.000000000009663 + }, + "elapsed_ms": { + "median": 33.7, + "min": 33.16, + "max": 33.80500000000001, + "mean": 33.555 + }, + "million_ops_per_second": { + "median": 30.385786350148365, + "min": 30.291406596657293, + "max": 30.880609167671896, + "mean": 30.519267371492518 + }, + "zero_percent": { + "median": 96.875, + "min": 96.58203125, + "max": 96.875, + "mean": 96.77734375 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.434999942779541, + "min": 2.2800002098083496, + "max": 2.6499998569488525, + "mean": 2.4550000031789145 + }, + "performance_clock_loop_ns": { + "median": 71.84999942779541, + "min": 69.54999923706055, + "max": 72.59999990463257, + "mean": 71.33333285649617 + }, + "cpp_clock_loop_ns": { + "median": 117.00000047683716, + "min": 116.94999933242798, + "max": 119.85000133514404, + "mean": 117.93333371480306 + }, + "wall_clock_loop_ns": { + "median": 28.09999942779541, + "min": 27.899999618530273, + "max": 28.15000057220459, + "mean": 28.049999872843426 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 4.838867187500026, + "min": 4.453124999999766, + "max": 5.063476562500169, + "mean": 4.785156249999987 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000005116, + "min": 10.000000000005116, + "max": 10.000000000005116, + "mean": 10.000000000005116 + }, + "p99_us": { + "median": 15.000000000000568, + "min": 10.000000000019327, + "max": 15.00000000001478, + "mean": 13.333333333344891 + }, + "max_us": { + "median": 199.99999999998863, + "min": 199.99999999998863, + "max": 250.0, + "mean": 216.6666666666591 + }, + "elapsed_ms": { + "median": 171.72, + "min": 167.28000000000003, + "max": 172.09499999999997, + "mean": 170.365 + }, + "million_ops_per_second": { + "median": 29.81598532494759, + "min": 29.751015427525502, + "max": 30.607370875179335, + "mean": 30.058123875884142 + }, + "zero_percent": { + "median": 23.046875, + "min": 22.4609375, + "max": 28.80859375, + "mean": 24.772135416666668 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.255000114440918, + "min": 2.190000057220459, + "max": 2.259999990463257, + "mean": 2.2350000540415444 + }, + "performance_clock_loop_ns": { + "median": 68.94999980926514, + "min": 67.7999997138977, + "max": 71.05000019073486, + "mean": 69.26666657129924 + }, + "cpp_clock_loop_ns": { + "median": 117.34999895095825, + "min": 117.04999923706055, + "max": 117.95000076293945, + "mean": 117.44999965031941 + }, + "wall_clock_loop_ns": { + "median": 28.350000381469727, + "min": 28.250000476837158, + "max": 28.600001335144043, + "mean": 28.40000073115031 + }, + "paired_slowdown": { + "median": 1.0235525024533856, + "min": 1.000747808919865, + "max": 1.031506232166992 + }, + "paired_net_us_per_yield": { + "median": 3.86718749999998, + "min": 0.12207031250002776, + "max": 5.122070312500004 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 5000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.14648437499996392, + "min": 0.1367187500000977, + "max": 0.21484375000001277, + "mean": 0.16601562500002479 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 5.000000000009663, + "min": 4.9999999999954525, + "max": 5.000000000009663, + "mean": 5.000000000004927 + }, + "max_us": { + "median": 5.000000000023874, + "min": 5.000000000023874, + "max": 5.000000000023874, + "mean": 5.000000000023874 + }, + "elapsed_ms": { + "median": 167.155, + "min": 166.475, + "max": 168.135, + "mean": 167.255 + }, + "million_ops_per_second": { + "median": 30.63025934013341, + "min": 30.451726291373003, + "max": 30.75537468088302, + "mean": 30.612453437463145 + }, + "zero_percent": { + "median": 97.0703125, + "min": 95.703125, + "max": 97.265625, + "mean": 96.6796875 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.179999828338623, + "min": 2.1600000858306885, + "max": 2.455000162124634, + "mean": 2.265000025431315 + }, + "performance_clock_loop_ns": { + "median": 68.84999990463257, + "min": 66.34999990463257, + "max": 68.84999990463257, + "mean": 68.01666657129924 + }, + "cpp_clock_loop_ns": { + "median": 115.35000085830688, + "min": 115.3000020980835, + "max": 117.35000133514404, + "mean": 116.00000143051147 + }, + "wall_clock_loop_ns": { + "median": 27.950000762939453, + "min": 27.850000858306885, + "max": 28.450000286102295, + "mean": 28.08333396911621 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 0, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 5.307617187499808, + "min": 4.902343750000246, + "max": 5.351562500000767, + "mean": 5.1871744791669405 + }, + "p50_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "p95_us": { + "median": 10.000000000019327, + "min": 10.000000000005116, + "max": 10.000000000019327, + "mean": 10.00000000001459 + }, + "p99_us": { + "median": 15.000000000043201, + "min": 15.00000000001478, + "max": 19.99999999998181, + "mean": 16.66666666667993 + }, + "max_us": { + "median": 295.0000000000159, + "min": 234.9999999999568, + "max": 324.99999999998863, + "mean": 284.9999999999871 + }, + "elapsed_ms": { + "median": 339.855, + "min": 334.875, + "max": 340.14, + "mean": 338.29 + }, + "million_ops_per_second": { + "median": 30.13049977196157, + "min": 30.10525371905686, + "max": 30.578577081000375, + "mean": 30.27144352400627 + }, + "zero_percent": { + "median": 23.828125, + "min": 22.16796875, + "max": 24.8046875, + "mean": 23.600260416666668 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.6050000190734863, + "min": 2.134999990463257, + "max": 2.690000057220459, + "mean": 2.4766666889190674 + }, + "performance_clock_loop_ns": { + "median": 69.10000085830688, + "min": 67.94999837875366, + "max": 71.29999876022339, + "mean": 69.44999933242798 + }, + "cpp_clock_loop_ns": { + "median": 117.05000162124634, + "min": 117.00000047683716, + "max": 118.49999904632568, + "mean": 117.5166670481364 + }, + "wall_clock_loop_ns": { + "median": 27.900002002716064, + "min": 27.750000953674316, + "max": 28.70000123977661, + "mean": 28.116668065388996 + }, + "paired_slowdown": { + "median": 1.0227313729027603, + "min": 1.0014653767363968, + "max": 1.0247090393776759 + }, + "paired_net_us_per_yield": { + "median": 7.382812500000002, + "min": 0.4785156250000089, + "max": 8.002929687499993 + } + }, + { + "group": "work-64", + "variant": "jspi", + "mode": "chain", + "limit": 10000, + "trace": 0, + "control": 1, + "exceptions": "on", + "isolate": 1, + "work": 64, + "repetitions": 3, + "total_samples": 3072, + "mean_us": { + "median": 0.14648437500001943, + "min": 0.1416015625000655, + "max": 0.1562499999999689, + "mean": 0.14811197916668462 + }, + "p50_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p95_us": { + "median": 0.0, + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "p99_us": { + "median": 4.9999999999954525, + "min": 4.9999999999954525, + "max": 4.9999999999954525, + "mean": 4.9999999999954525 + }, + "max_us": { + "median": 5.000000000052296, + "min": 5.000000000023874, + "max": 5.000000000052296, + "mean": 5.000000000042822 + }, + "elapsed_ms": { + "median": 332.58, + "min": 331.66, + "max": 334.385, + "mean": 332.875 + }, + "million_ops_per_second": { + "median": 30.789587467676952, + "min": 30.623386216486985, + "max": 30.87499547729602, + "mean": 30.76265638715332 + }, + "zero_percent": { + "median": 97.0703125, + "min": 96.875, + "max": 97.16796875, + "mean": 97.03776041666667 + }, + "clock_step_us": { + "median": 4.999876022338867, + "min": 4.999876022338867, + "max": 4.999876022338867, + "mean": 4.999876022338867 + }, + "js_to_cpp_sync_ns": { + "median": 2.3350000381469727, + "min": 2.184999942779541, + "max": 2.4749999046325684, + "mean": 2.331666628519694 + }, + "performance_clock_loop_ns": { + "median": 72.30000019073486, + "min": 71.69999837875366, + "max": 72.75000095367432, + "mean": 72.24999984105428 + }, + "cpp_clock_loop_ns": { + "median": 118.05000066757202, + "min": 117.00000047683716, + "max": 120.55000066757202, + "mean": 118.53333393732707 + }, + "wall_clock_loop_ns": { + "median": 28.1499981880188, + "min": 27.750000953674316, + "max": 28.399999141693115, + "mean": 28.09999942779541 + } + } + ] +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/run.mjs b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/run.mjs new file mode 100644 index 0000000..b41213c --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/run.mjs @@ -0,0 +1,219 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Measure yield latency in a real browser, one fresh page per case. +// node run.mjs +// CHROME names the browser; on macOS the newest cached Playwright headless shell is used. +// Each invocation owns its loopback server, Chrome process and temporary profile. +import assert from 'node:assert/strict' +import {spawn} from 'node:child_process' +import {once} from 'node:events' +import {existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, mkdirSync, writeFileSync} from 'node:fs' +import {createServer} from 'node:http' +import {homedir, tmpdir} from 'node:os' +import {dirname, extname, join, resolve, sep} from 'node:path' +import {setTimeout as delay} from 'node:timers/promises' +import {fileURLToPath} from 'node:url' + +const fetchLocal = (url, options = {}) => fetch(url, { + ...options, signal: AbortSignal.timeout(10000) +}) +const args = process.argv.slice(2) +assert.equal(args.length, 2, 'usage: node run.mjs ') +const config = JSON.parse(readFileSync(resolve(args[0]), 'utf8')) +const cases = config.cases +const output = resolve(args[1]) +mkdirSync(output, {recursive: true}) +const here = dirname(fileURLToPath(import.meta.url)) +const build = resolve(config.build_root) +const mode = 'yield benchmark' +const findChrome = () => { + if (process.env.CHROME) return process.env.CHROME + assert.equal(process.platform, 'darwin', 'set CHROME to the Chrome executable') + const cache = join(homedir(), 'Library/Caches/ms-playwright') + const shells = existsSync(cache) ? readdirSync(cache) + .filter(name => /^chromium_headless_shell-\d+$/.test(name)) + .sort((a, b) => Number(b.split('-').at(-1)) - Number(a.split('-').at(-1))) : [] + for (const shell of shells) { + for (const arch of ['arm64', 'x64']) { + const path = join(cache, shell, `chrome-headless-shell-mac-${arch}`, 'chrome-headless-shell') + if (existsSync(path)) return path + } + } + throw new Error('no cached headless Chrome found; set CHROME') +} + +const left = {chrome: null, profile: null, server: null, sockets: new Set()} +const exited = child => child.exitCode !== null || child.signalCode !== null +let cleaning +const cleanUp = () => (cleaning ??= (async () => { + for (const socket of left.sockets) socket.close() + if (left.chrome && !exited(left.chrome) && left.chrome.pid) { + const ended = once(left.chrome, 'exit') + const stubborn = setTimeout(() => left.chrome.kill('SIGKILL'), 5000) + left.chrome.kill() + try { await ended } finally { clearTimeout(stubborn) } + } + if (left.server) { + left.server.closeAllConnections() + await new Promise(resolve => left.server.close(resolve)) + } + if (left.profile) rmSync(left.profile, {recursive: true, force: true, maxRetries: 3}) +})()) +for (const [signal, code] of [['SIGHUP', 129], ['SIGINT', 130], ['SIGTERM', 143]]) { + process.on(signal, () => cleanUp().finally(() => process.exit(code))) +} + +const types = {'.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', + '.wasm': 'application/wasm', '.json': 'application/json'} +const roots = {'/build/': build, '/': here} +const startServer = async () => { + const server = createServer((request, response) => { + try { + const path = decodeURIComponent(new URL(request.url, 'http://127.0.0.1').pathname) + const [prefix, root] = Object.entries(roots).find(([prefix]) => path.startsWith(prefix)) + const file = resolve(root, path.slice(prefix.length)) + if (!file.startsWith(root + sep)) { + response.writeHead(404).end() + return + } + const content = readFileSync(file) + const headers = {'Content-Type': types[extname(file)] ?? 'application/octet-stream', 'Cache-Control': 'no-store'} + if (new URL(request.url, 'http://127.0.0.1').searchParams.get('isolate') === '1') { + headers['Cross-Origin-Opener-Policy'] = 'same-origin' + headers['Cross-Origin-Embedder-Policy'] = 'require-corp' + } + response.writeHead(200, headers) + .end(content) + } catch { + response.writeHead(404).end() + } + }) + left.server = server + server.listen(0, '127.0.0.1') + await once(server, 'listening') + return `http://127.0.0.1:${server.address().port}` +} + +const startChrome = async () => { + left.profile = mkdtempSync(join(tmpdir(), `asio-browser-${process.pid}-`)) + const executable = findChrome() + const chrome = spawn(executable, [ + '--headless=new', '--remote-debugging-address=127.0.0.1', '--remote-debugging-port=0', + `--user-data-dir=${left.profile}`, '--no-first-run', '--no-default-browser-check', + '--disable-component-update', '--disable-background-networking', '--disable-sync', + '--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1', 'about:blank' + ], {stdio: ['ignore', 'ignore', 'pipe']}) + left.chrome = chrome + let error + let said = '' + chrome.on('error', value => { error = value }) + chrome.stderr.on('data', data => { said = (said + data).slice(-2000) }) + const deadline = Date.now() + 10000 + while (Date.now() < deadline) { + if (error) throw error + if (exited(chrome)) throw new Error(`Chrome exited during startup: ${said}`) + const active = join(left.profile, 'DevToolsActivePort') + const port = existsSync(active) ? readFileSync(active, 'utf8').split('\n')[0] : '' + if (/^\d+$/.test(port)) { + const devtools = `http://127.0.0.1:${port}` + try { + const version = await (await fetchLocal(`${devtools}/json/version`)).json() + console.log(`browser ${mode}: ${version.Browser}`) + return devtools + } catch {} + } + await delay(50) + } + throw new Error(`Chrome startup timed out: ${said}`) +} + + +let version +async function runCase(devtools, base, item) { + const target = await (await fetchLocal(`${devtools}/json/new?about:blank`, {method: 'PUT'})).json() + const ws = new WebSocket(target.webSocketDebuggerUrl) + left.sockets.add(ws) + const pending = new Map() + const errors = [] + let id = 0 + await new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error('WebSocket open timed out')), 10000) + ws.addEventListener('open', () => { clearTimeout(timer); resolve() }, {once: true}) + ws.addEventListener('error', error => { clearTimeout(timer); reject(error) }, {once: true}) + }) + const send = (method, params = {}) => new Promise((resolve, reject) => { + const current = ++id + const timer = setTimeout(() => { pending.delete(current); reject(new Error(`${method} timed out`)) }, 60000) + pending.set(current, {resolve, reject, timer}) + ws.send(JSON.stringify({id: current, method, params})) + }) + ws.addEventListener('message', event => { + const message = JSON.parse(event.data) + const entry = pending.get(message.id) + if (entry) { + clearTimeout(entry.timer) + pending.delete(message.id) + if (message.error) entry.reject(new Error(JSON.stringify(message.error))) + else entry.resolve(message.result) + } + if (message.method === 'Runtime.exceptionThrown') errors.push(message.params.exceptionDetails) + if (message.method === 'Runtime.consoleAPICalled' && message.params.type === 'error') errors.push(message.params) + }) + try { + await send('Runtime.enable') + await send('Page.enable') + await send('Page.bringToFront') + await send('Page.addScriptToEvaluateOnNewDocument', {source: ` + let resolve; let value; + window.benchmarkPromise = new Promise(done => { resolve = done }); + Object.defineProperty(window, 'benchmark', {get: () => value, set: next => { value = next; if (next?.done) resolve(next) }}); + `}) + const query = new URLSearchParams(Object.fromEntries(Object.entries(item).map(([k,v]) => [k,String(v)]))) + const loaded = new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error("page load timed out")), 60000) + const onLoad = event => { if (JSON.parse(event.data).method === 'Page.loadEventFired') { ws.removeEventListener('message', onLoad); clearTimeout(timer); resolve() } }; + ws.addEventListener('message', onLoad); + }); + await send('Page.navigate', {url: `${base}/page.html?${query}`}); + await loaded + const observed = await send('Runtime.evaluate', {expression: 'window.benchmarkPromise', awaitPromise: true, returnByValue: true}) + assert.ok(!observed.exceptionDetails, JSON.stringify(observed.exceptionDetails)) + const data = observed.result.value + assert.ok(data && !data.error, data?.error) + assert.deepEqual(errors, [], JSON.stringify(errors)) + assert.equal(data.result.environment.isolated, item.isolate === 1) + assert.equal(data.result.environment.visibility, 'visible') + assert.equal(data.result.status, 0) + data.result.case_id = item.id + data.result.host_duration_ms = performance.now() - item.host_started + writeFileSync(join(output, `${item.id}.json`), JSON.stringify(data.result)) + console.log(`${item.id}: ${data.result.operations} operations, ${data.result.elapsed_ms.toFixed(3)} ms, ${data.result.pairs.length / 2} samples`) + } finally { + ws.close() + left.sockets.delete(ws) + for (const entry of pending.values()) { clearTimeout(entry.timer); entry.reject(new Error('page closed')) } + pending.clear() + await fetchLocal(`${devtools}/json/close/${target.id}`) + } +} + +try { + const base = await startServer() + const devtools = await startChrome() + version = await (await fetchLocal(`${devtools}/json/version`)).json() + writeFileSync(join(output, 'environment.json'), JSON.stringify({version, started: new Date().toISOString(), config}, null, 2)) + for (const item of cases) { + console.log(`START ${item.id}`) + await runCase(devtools, base, {...item, host_started: performance.now()}) + } + console.log(`Completed ${cases.length} cases.`) +} catch (error) { + console.error(error) + process.exitCode = 1 +} finally { + await cleanUp() +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/yield_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/yield_program.cpp new file mode 100644 index 0000000..9312667 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/bench/yield/yield_program.cpp @@ -0,0 +1,163 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Measure the actual library yield; production headers remain unchanged. +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +double now_ms() { + return std::chrono::duration( + std::chrono::steady_clock::now().time_since_epoch()) + .count(); +} + +// clang-format off +EM_JS(void, bench_phase, (int active), { + if (Module['benchPhase']) Module['benchPhase'](Boolean(active)); +}); +EM_JS(void, bench_publish, (const double* data, std::size_t count, double elapsed, + std::size_t operations, std::uint32_t checksum), { + Module['benchData']({pairs: Array.from(HEAPF64.subarray(data / 8, data / 8 + count * 2)), + elapsed_ms: elapsed, operations, checksum}); +}); +EM_JS(void, bench_sync_call, (), { globalThis.benchSyncCalls++; }); +// clang-format on + +struct chain_state { + webcpp::asio::io_context* context; + std::vector* pairs; + std::size_t limit; + std::size_t total; + std::size_t completed = 0; + std::size_t recorded = 0; + std::uint32_t work; + std::uint32_t checksum = 1; +}; + +// Function-pointer posting avoids a recursive functor instantiation. +void next_handler(chain_state* state) { + if (state->completed != 0 && state->completed % state->limit == 0) { + (*state->pairs)[2 * state->recorded + 1] = now_ms(); + ++state->recorded; + } + for (std::uint32_t i = 0; i < state->work; ++i) { + state->checksum = state->checksum * 1664525U + 1013904223U; + } + ++state->completed; + if (state->completed < state->total) { + boost::asio::post(*state->context, std::bind_front(&next_handler, state)); + if (state->completed % state->limit == 0) { + (*state->pairs)[2 * state->recorded] = now_ms(); + } + } +} + +} // namespace + +extern "C" { +EMSCRIPTEN_KEEPALIVE double bench_cpp_now() { + return now_ms(); +} + +EMSCRIPTEN_KEEPALIVE double bench_cpp_wall() { + return std::chrono::duration( + std::chrono::system_clock::now().time_since_epoch()) + .count(); +} + +EMSCRIPTEN_KEEPALIVE std::uint32_t bench_cpp_touch(std::uint32_t value) { + return value + 1; +} +} + +int main(int argc, char** argv) { + if (argc != 6) { + std::puts("expected: mode limit samples work control"); + return webcpp::test::exit_status(2); + } + const std::string_view mode{argv[1]}; + const auto limit = static_cast(std::strtoul(argv[2], nullptr, 10)); + const auto samples = static_cast(std::strtoul(argv[3], nullptr, 10)); + const auto work = static_cast(std::strtoul(argv[4], nullptr, 10)); + const bool control = std::string_view{argv[5]} == "1"; + if (limit == 0 || samples == 0 || samples > 100000 || limit > 10000 || work > 4096) { + return webcpp::test::exit_status(3); + } + std::vector pairs(samples * 2); + if (mode != "clock" && mode != "sync") { + // Warm the actual suspension path outside the recorded interval. + for (int i = 0; i < 512; ++i) + webcpp_asio_yield(); + } + if (mode == "chain") { + // Warm dispatch and allocation before measuring either chain variant. + std::vector warm_pairs(20); + webcpp::asio::io_context warm_context{ + webcpp::asio::io_context_options{.max_handlers_per_turn = 1000}}; + chain_state warm{.context = &warm_context, + .pairs = &warm_pairs, + .limit = 1000, + .total = 10001, + .work = work}; + boost::asio::post(warm_context, std::bind_front(&next_handler, &warm)); + warm_context.run(); // lint-run: bounded benchmark warmup + if (warm.completed != 10001 || warm.recorded != 10) + return webcpp::test::exit_status(6); + } + bench_phase(1); + const double started = now_ms(); + std::size_t operations = samples; + std::uint32_t checksum = 0; + if (mode == "direct" || mode == "clock" || mode == "sync") { + for (std::size_t i = 0; i < samples; ++i) { + pairs[2 * i] = now_ms(); + if (mode == "direct") + webcpp_asio_yield(); + if (mode == "sync") + bench_sync_call(); + pairs[2 * i + 1] = now_ms(); + } + } else if (mode == "chain") { + webcpp::asio::io_context context{webcpp::asio::io_context_options{ + .max_handlers_per_turn = control ? std::numeric_limits::max() : limit}}; + operations = samples * limit + 1; + chain_state state{.context = &context, + .pairs = &pairs, + .limit = limit, + .total = operations, + .work = work}; + boost::asio::post(context, std::bind_front(&next_handler, &state)); + context.run(); // lint-run: the benchmark's bounded event loop + if (state.completed != operations || state.recorded != samples) { + return webcpp::test::exit_status(4); + } + checksum = state.checksum; + } else { + return webcpp::test::exit_status(5); + } + const double elapsed = now_ms() - started; + bench_phase(0); + bench_publish(pairs.data(), samples, elapsed, operations, checksum); + return webcpp::test::exit_status(0); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/build.jam b/libraries/asio/openspec/changes/genesis/reference/source/build.jam index f19debc..e965ea7 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/build.jam +++ b/libraries/asio/openspec/changes/genesis/reference/source/build.jam @@ -12,6 +12,12 @@ project /webcpp/asio ; import feature ; import numbers ; +import webcpp ; +import webcpp-target ; + +use-project /webcpp/asio-wasip3 : ../../tools/boost/asio-wasip3 ; +use-project /webcpp/asio-wasip2 : ../../tools/boost/asio-wasip2 ; +use-project /webcpp/asio-windows : ../../tools/boost/asio-windows ; # The stack Asyncify saves a suspension in, in bytes: 8192 unless a program # asks for more with , propagated so that asio's usage @@ -56,14 +62,14 @@ rule asyncify-stack ( properties * ) # (include/webcpp/asio/browser/src.hpp), linked into every program on # emscripten by asio's usage requirements below. obj browser-src : src/browser_src.cpp : include /boost//headers - emscripten:BOOST_ASIO_DISABLE_THREADS ; + /webcpp/config//config + emscripten,single:BOOST_ASIO_DISABLE_THREADS ; explicit browser-src ; -# On emscripten Asio needs BOOST_ASIO_DISABLE_THREADS: without it, -# stops at "Only Windows and POSIX are -# supported!" (, line 27 in Boost -# 1.92). Its inline namespace differs with and without threads, so a -# translation unit that missed the define fails at link. The browser's +# Single-thread Emscripten needs BOOST_ASIO_DISABLE_THREADS. A pthread build +# supplies the POSIX thread implementation instead. Boost's inline namespace +# differs with and without threads, so every translation unit must agree. +# The browser's # values reach C++ through embind: -lembind, a free feature, which a usage # requirement keeps. # @@ -74,13 +80,70 @@ explicit browser-src ; # scheduler_task::run. ASYNCIFY_STACK_SIZE is asyncify-stack-size's, above. # The tag names every program on asio Boost's way, with its variant: # reactor-60-d-jspi.js. +# EM_JS_DEPS is read after the native link in Emscripten 6.0.11. Keep the +# bridge's stack helpers exported even when an optimized JSPI runtime does +# not otherwise need them; JavaScript calls both through stackSave/Restore. # tag::asio[] alias asio : : : : include /boost//headers - emscripten:BOOST_ASIO_DISABLE_THREADS + /webcpp/config//config + windows:/webcpp/asio-windows//headers + clang-wasip2:/webcpp/asio-wasip2//headers + clang-wasip2:/webcpp/asio-wasip2//pollable + clang-wasip3:/webcpp/asio-wasip3//headers + emscripten,single:BOOST_ASIO_DISABLE_THREADS emscripten:-lembind + emscripten:-Wl,--export=emscripten_stack_get_current + emscripten:-Wl,--export=_emscripten_stack_restore + emscripten,multi:-Wl,--wrap=__syscall_poll emscripten:browser-src emscripten,jspi:-sJSPI emscripten,asyncify:-sASYNCIFY @asyncify-stack emscripten:@webcpp%suspend-tag ; # end::asio[] + +# WASIp2 and WASIp3 use the same checked Cobalt capability overlays. +# Cobalt's entry point, with webcpp's bounded application event loop. +# tag::cobalt[] +lib cobalt-main : src/cobalt_main.cpp + : static asio /webcpp//boost_cobalt ; +explicit cobalt-main ; +# The checked common Cobalt patch supplies the promise member required even +# when a compiler builds the coroutine without exception handling. +alias cobalt : : : : asio cobalt-main /webcpp//boost_cobalt ; +# end::cobalt[] + +# tag::openssl[] +rule openssl-linked ( properties * ) +{ + if [ webcpp-target.target-of $(properties) ] in native wasip2 wasip3 + { + return /webcpp/third_party//openssl + WEBCPP_ASIO_HAS_OPENSSL=1 ; + } +} + +# Refused on Emscripten: every source of a program built for emscripten +# that names it stops at the forced include, whose message says what to +# write. Quoted, as the Jamroot quotes Boost's directory, for a path that +# holds a space. +path-constant WEBCPP_ASIO_ROOT : . ; +alias openssl : : : : @openssl-linked + emscripten:"-include \"$(WEBCPP_ASIO_ROOT)/src/openssl_on_webassembly.hpp\"" + emscripten:"-include \"$(WEBCPP_ASIO_ROOT)/src/openssl_on_webassembly.hpp\"" ; +# end::openssl[] + +# Browser tests exercise the settings adapter without linking OpenSSL. +alias openssl-tests : : : : @openssl-linked ; +explicit openssl-tests ; + +# An explicit portable trust policy, separate from the raw OpenSSL context. +# tag::tls[] +alias tls : : : : asio openssl + /webcpp/third_party//ca_certificates ; +# end::tls[] + +# tag::cobalt-ssl[] +alias cobalt_ssl : : : : cobalt tls + /webcpp//boost_cobalt_io_ssl ; +# end::cobalt-ssl[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/doc/Jamfile index 7012e68..b930f51 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/Jamfile +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/Jamfile @@ -14,4 +14,4 @@ webcpp.doc asio : asio.adoc ; # (/webcpp//emscripten-reference), with the define of build.jam that a # requirement conditioned on the emscripten toolset does not give it. webcpp.reference asio : /webcpp//emscripten-reference - BOOST_ASIO_DISABLE_THREADS ; + BOOST_ASIO_DISABLE_THREADS WEBCPP_ASIO_REFERENCE ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/allocation.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/allocation.adoc new file mode 100644 index 0000000..33aaf24 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/allocation.adoc @@ -0,0 +1,121 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-allocation] +== Allocation + +The application supplies an allocator to the `io_context` through its +`std::allocator_arg` constructor. Boost.Asio uses it for the context's +services and their I/O state. On Emscripten the bridge's registration map +uses the context's allocator too. On Windows, a checked Boost 1.92 overlay +forwards that allocator into IOCP's internal worker and timer thread state. +This includes the first timer operation, without warming up its thread or +allowing an extra global allocation. + +An asynchronous operation uses its completion handler's associated +allocator. Giving an allocator to the context does not associate it with +all handlers: bind it to each operation with `boost::asio::bind_allocator`. +The following compiled test binds a timer wait and ten posts, and on +Emscripten the handlers posted by two bridge deliveries: + +[source] +---- +include::{library-root}/test/allocation_test.cpp[tag=supplied-allocator,indent=0] +---- + +These are runtime objects, with executors, callbacks and pointers into the +current process. None of asio's runtime objects is a relocatable object +that can be shared between processes merely by placing it in shared memory. + +[#asio-allocation-runtime] +=== Runtime allocations + +The allocator contract does not cover these known allocations outside an +operation's associated allocator: + +* Emscripten's `select` allocates its poll array with `calloc` on each call. +* Asyncify allocates its unwind data when a call suspends. +* Boost.Asio's `basic_resolver_results` allocates its result entries with + `new`. The measured operation scenario above does not resolve a name. + Forward asynchronous resolution owns copies of its input names through the + initiating token's associated allocator, preserving temporary input lifetimes. + Bind the allocator when creating a deferred operation; binding one only when + later launching it cannot retroactively change its already-owned input storage. +* WASI libc allocates pipe descriptors and message storage for Asio's wakeup pipe. + The test attributes only calls creating that pipe and writes to its tracked + writer descriptors, removes descriptors on close, and exercises a real pipe + as a positive control. Ordinary user writes and allocations remain counted. +* OpenSSL owns context, trust-store and cryptographic allocations. Its memory + hooks are process-global and must be set before any OpenSSL allocation; an + Asio context cannot install a per-operation allocator for other OpenSSL users. + +The allocation test replaces Emscripten's `select` in the test executable +with a version whose poll array is on the stack. It marks only the call to +Asyncify's `allocateData` while it runs, restoring the flag even if it +throws, and counts those runtime allocations separately. These are test +instrumentation choices, not changes to allocations in a user's program. +JavaScript heap allocations are outside these WebAssembly-memory counters. + +On macOS, dyld allocates the native thread-local storage of Asio's +thread-call-stack on its first access. Before measurement the test queries +`running_in_this_thread` on a temporary context to initialize that thread +runtime. The measured context and all its operations are then constructed +anew inside the window. This measures allocation routing after thread +runtime initialization, not the process's cold-start memory usage. + +[#asio-allocation-testing] +=== What the test proves + +`allocation_native` runs natively, with `allocation_native_release` also +checking an optimized build; `allocation` joins the Node-based +WebAssembly tests with JSPI and Asyncify, each with and without exceptions. +`allocation_wasip3` checks the single-thread profile with exceptions on/off; +`allocation_wasip3_threads` checks the supported cooperative profile without +exceptions through the `threads` lane. +A counting allocator services context construction, a timer, ten posts and +on Emscripten the bridge's two event deliveries. The measurement includes +object destruction. It requires allocations through the supplied allocator +and zero calls through the other counted paths, excluding only the named +runtime operations above. This checks allocation routing, not a total +memory limit or a proof of freedom from leaks. A separate explicit +suspension verifies Asyncify's runtime attribution: the timer may already +be ready when `run` starts and therefore need no suspension. + +The counters observe all eight global `operator new` forms: scalar and +array, ordinary and aligned, throwing and nothrow. They also observe the C +library's `malloc`, `calloc`, `realloc`, `aligned_alloc`, `posix_memalign` +and `memalign` where the platform permits it. On glibc and Emscripten the +replacements forward to the underlying allocator; on macOS `malloc_logger` +observes allocations, including aligned ones, in the C counter. Only the +test's thread and measurement windows are counted on POSIX platforms. +MSVC counts global `operator new` calls from all threads in each window. +The native allocation tests use `-fno-builtin` with Clang and GCC so calls +to allocation functions remain observable by the hooks and are not moved +across their measurement flags. This setting is confined to the test; +application builds and the release size measurements keep their normal +optimizations. + +MSVC and AddressSanitizer builds do not count C-library allocations; they +print that limitation and omit the C-specific controls. Global allocations +through `operator new` are still counted. Local validation on one platform +does not establish the behaviour of the hooks on another. + +Controls deliberately call the allocation functions and post an unbound +handler. Asio's default handler storage goes through an aligned allocation, +which counting only `operator new` would miss. A separate negative run +constructs the context without its allocator and must fail. There is no +allowance for an arbitrary number of extra allocations. + +Promise operations allocate their state through the handler's allocator. +The allocation test covers resolution and rejection with a concrete context +executor and a bound allocator, including the completion post. Explicitly +erasing an executor into `any_io_executor` can introduce Boost-owned dispatch +allocations that its handler allocator does not control; see <>. + +The default browser socket transport preserves an ordinary context executor's +associated allocation policy even when stored as `any_io_executor`. The same +measurement includes an unsupported asynchronous connection with a bound +allocator. Custom executors, including strands, keep their own dispatch policy. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/asio.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/asio.adoc index 91c7319..0f713b9 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/asio.adoc +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/asio.adoc @@ -4,7 +4,7 @@ // accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) -= asio: Boost.Asio in the browser's event loop for {cpp} += asio: Boost.Asio and Cobalt for {cpp} and WebAssembly :toc: left :toclevels: 1 :idprefix: @@ -21,19 +21,68 @@ lacks there, the configuration Asio needs to build, what wakes `run` from a browser event, and a limit on the handlers one turn runs, so that the page keeps rendering. +WASIp2 provides single-threaded timers, TCP/UDP, pollable-driven forward DNS, +supplied CLI streams, Cobalt and optional source-built TLS. +See <> for its explicit limitations. +WASIp3 provides timers, TCP/UDP, waitable-driven forward DNS, Cobalt and the same +optional TLS provider, with single-thread and experimental cooperative-thread profiles. See <> for their +limits and the features available in each target variant. + +[#asio-reading] +== Find your way through the guide + +The guide follows https://diataxis.fr/[Diataxis]: choose a path for what +you need now. All paths share the compiled examples and generated API +reference on this page. + +* *Learn by doing:* start with <>. +* *Complete a task:* <>, + <>, + <>, + <>, <>, or + <>. +* *Understand the design:* read <>, <>, + <> and <>. +* *Look up a contract:* use <>, <>, <> and + the generated <>. + +include::quick-start.adoc[] + include::overview.adoc[] include::names.adoc[] +include::capabilities.adoc[] + include::building.adoc[] +include::wasip2.adoc[] + +include::wasip3.adoc[] + include::run.adoc[] +include::yield-cost.adoc[] + include::browser.adoc[] +include::promises.adoc[] + +include::timers.adoc[] + +include::cobalt.adoc[] + +include::sockets.adoc[] + +include::allocation.adoc[] + +include::guarantees.adoc[] + include::testing.adoc[] [#reference] == Reference include::{reference}[leveloffset=+1] + +include::changelog.adoc[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/browser.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/browser.adoc index 436c06b..29daf7e 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/browser.adoc +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/browser.adoc @@ -31,7 +31,7 @@ keeps a pointer to each, by key, in a map allocated with the context's allocator. Natively there is no bridge: `browser/` builds on emscripten alone. -[[asio-invariant-4]]*A browser event delivered through the bridge only +*A browser event delivered through the bridge only posts; a listener is no outstanding work.* A registration's `deliver` posts what the event completes or notifies to the io_context, and does nothing else: it never polls, runs or dispatches. The post wakes a suspended `run` @@ -61,7 +61,7 @@ nor change it, `delivering()` taking no value; the export those functions call is the JavaScript boundary's, declared in a `detail` header, and calling it from {cpp} is outside the contract. -[[asio-invariant-5]]*A registration's key is never reused; an event of a +*A registration's key is never reused; an event of a removed key, or of a destroyed io_context, finds nothing.* Keys are `std::uint64_t` values counted from 1, which JavaScript holds as a `BigInt`, so that no count of registrations a program reaches wraps around. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/building.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/building.adoc index ce6e07e..3f28791 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/building.adoc +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/building.adoc @@ -7,16 +7,21 @@ [#asio-building] == Building -asio is header-only, and is developed inside the webcpp superproject, as a -Boost library is developed inside Boost. A b2 program uses it through one -target, `/webcpp/asio//asio`, on every target: +asio is developed inside the webcpp superproject, as a Boost library is +developed inside Boost. Its headers share Boost's executor model; the browser +bridge and optional Cobalt entry point have compiled support units. A b2 +program uses `/webcpp/asio//asio` on native, Emscripten and WASIp2/P3: [listing] ---- exe app : app.cpp /webcpp/asio//asio ; ---- -The target adds asio's headers and Boost's, and on emscripten everything +The target adds asio's headers, Boost's and the webcpp configuration dependency. +`` includes `` first; +`WEBCPP_NO_EXCEPTIONS` disables asio's throwing APIs even when the compiler +supports exceptions. An explicit `WEBCPP_ASIO_NO_EXCEPTIONS` remains supported. +On emscripten the target also supplies everything else a program needs there: the define Asio needs to build, embind, the JavaScript functions asio calls, compiled once in `src/browser_src.cpp`, the link flags of the program's suspension variant, and the variant in the @@ -27,13 +32,97 @@ program's name: include::{library-root}/build.jam[tag=asio] ---- -Asio needs `BOOST_ASIO_DISABLE_THREADS` on emscripten: without it, Asio -decides it has threads under any compiler that defines `+__GNUC__+` outside -Linux, Emscripten's among them, and `` stops at -"Only Windows and POSIX are supported!". The page has no threads, and the -target defines it for every program that uses it on emscripten. Asio's -inline namespace differs with and without threads, so a translation unit -that missed the define fails at link, never silently. +The Emscripten S profile sets `BOOST_ASIO_DISABLE_THREADS`. Explicit +`threading=multi` enables pthreads consistently in the application, browser +support unit and optional Cobalt archive. Asio's inline namespace differs with +and without threads, so all translation units and compiled dependencies must +use matching settings. + +The bridge's JavaScript uses `stackSave` and `stackRestore`. On Emscripten +6.0.11, their native dependencies must survive the native link before +`EM_JS_DEPS` is processed. The target therefore exports +`emscripten_stack_get_current` and `_emscripten_stack_restore` explicitly, +including in optimized JSPI builds. A build outside b2 must keep the same +link flags shown above. + +[#asio-building-workers] +=== Browser workers and main-thread callbacks + +Select `threading=multi` together with either suspension variant and exception +setting. The public target supplies `-pthread` through the toolset and the +threaded main-poll adapter. It does not move `main` to a worker automatically. +The M-only `-Wl,--wrap=__syscall_poll` adapter uses the pinned SDK's async poll +on the actual browser main thread; worker waits retain the SDK proxy route. +This private SDK boundary must be rechecked when Emscripten is upgraded. + +A browser `io_context` must run on the thread that constructed it. Other +threads may `post` ordinary {cpp} work to its executor. One context does not +support simultaneous runners; keep separate contexts per worker. Running it +from a different thread triggers a checked-build assertion and returns zero +when assertions are disabled, before accessing thread-local JavaScript values. + +`browser::main_thread_context` supplies an Asio executor for DOM callbacks. +Construct and destroy that context on the actual browser main thread; copy its +executor to workers and use `boost::asio::post` or `bind_executor`. Obtain +JavaScript objects inside the main callback and send ordinary {cpp} data back to +the worker. Do not move `emscripten::val` handles between threads. The context +must outlive calls using its executors, and destruction must not overlap such +calls. If a callback destroys its context, an external allocator resource must +outlive the callback because queue control survives until it returns. Queued +handlers are discarded during shutdown. Handler storage follows +its associated allocator; the SDK owns its separate queue/notification storage. + +A main-executor callback runs on an ordinary browser callback stack. It must +not call a JSPI/Asyncify suspending import or drive the context's run family. +Normal {cpp} coroutine suspension that returns to its caller is a different +mechanism. If moving or invoking a handler throws, queued handlers are discarded +and further queued submissions are discarded. Inline main-thread `dispatch` +retains its ordinary direct-call behavior. The exception propagates to the +browser callback boundary; recovery after that failure is not promised. Cancellation still belongs to the originating operation; posting +a callable does not add a new cancellation protocol. + +The host needs a secure context, workers and shared memory. Serve the page with +`Cross-Origin-Opener-Policy: same-origin` and +`Cross-Origin-Embedder-Policy: require-corp`, and check `crossOriginIsolated`. +These deployment requirements cannot be diagnosed in `config.hpp`. +Applications choose their worker-pool size and must retain the runtime while +work is pending. Never block the browser main thread waiting for a live worker. + +The local lane covers JSPI/Asyncify with EH on/off in an isolated Chrome page: + +[source,bash] +---- +b2 libs/asio/test/browser//browser-workers toolset=emscripten \ + threading=multi webcpp-suspend=jspi exception-handling=on +---- + +Repeat with `webcpp-suspend=asyncify` and `exception-handling=off` for the +other profiles. The driver tests actual main/worker wakeup, DOM handoff, +cancellation, allocator routing, queued shutdown and Cobalt thread completion. +The exact coverage appears in <>. + +==== Pinned Asyncify pthread return-value limit + +A dependency-only witness is versioned in +`test/browser/probes/pthread_return.cpp`. It suspends a pthread entry, returns +pointer value 42, and joins without blocking the browser main thread. With +Emscripten 6.0.11, JSPI preserves 42; Asyncify returns zero and the witness +fails. This does not involve Asio. Void-return worker paths with explicit {cpp} +result storage are tested successfully in both variants. This runtime path is +not identifiable from a target define, so no broad compile-time ban is imposed. + +To reproduce from the superproject root using the configured SDK: + +[source,bash] +---- +em++ libs/asio/test/browser/probes/pthread_return.cpp \ + -pthread -sPTHREAD_POOL_SIZE=1 -sJSPI -o worker_return-jspi.js +node libs/asio/test/browser/run.mjs --mode workers worker_return-jspi.js +---- + +Replace `-sJSPI` with `-sASYNCIFY -sASYNCIFY_STACK_SIZE=8192` and change the +output name for the failing control. The failure is retained as evidence of an +SDK limitation, not counted as a passing application test. [#asio-building-variants] === The two suspension variants @@ -82,8 +171,12 @@ include::{webcpp-root}/tools/webcpp.jam[tag=suspend] Emscripten finds the suspending imports itself, so no list of them is given. `ASYNCIFY_IGNORE_INDIRECT` is not set, since the path from `main` to the reactor's `select` passes a virtual call, Asio's -`scheduler_task::run`. Asyncify's cost is size: about three times the JSPI -program's, in a release build. +`scheduler_task::run`. Asyncify adds instrumentation and increases the +program size. With `-O3` and exceptions enabled, the release examples +measured 1.88 to 1.91 times the JSPI WebAssembly size. The ratio depends on +the optimization profile and exception setting; see <> +for the six-profile matrix with exceptions on and off, separate JavaScript +byte counts, build and execution timings, and reproduction commands. [#asio-building-asyncify-stack] ==== Asyncify's stack @@ -98,8 +191,8 @@ enough". The trap is certain, at every suspension that deep, but only there. So asio does not keep Emscripten's default: it sets the size to at least twice the deepest suspension its tests reach, measured exactly, as the bytes each unwind wrote, read from Asyncify's own data when the unwind -stops. The deepest build is one compiled with optimization and linked -without it, which is how b2's `release` variant links on emscripten today: +stops. In the measurements of 2026-10-11, the deepest build was one compiled +with optimization and linked without it, as b2's `release` variant links on emscripten: its deepest suspension in the tests wrote 3,540 bytes, against 1,272 in a `debug` build. Linked with optimization, a suspension writes a sixth or less of what it writes linked without: 416 bytes at most in the tests, and 384 @@ -128,7 +221,8 @@ in release and in release linked with `-O3`, which measures every suspension of the run family, the reactor's wait and the yield under each member that makes one, inside a `try` and a `catch` block too, and fails when one of them leaves less than half of the stack, or when the reading -finds no unwind or no byte written; by every test of the asyncify lane, +finds no unwind, no byte written, or no blocking poll in a reactor-wait +case; by every test of the asyncify lane, which links the same size and traps if a suspension of its own does not fit; by `asyncify_stack_size_default` and `asyncify_stack_size_raised`, which read the size the program was linked with, and @@ -137,6 +231,29 @@ which read the size the program was linked with, and variant, where an event called from JavaScript after the runtime aborted reaches no registration. +The reactor-wait cases keep outstanding work until a JavaScript macrotask +posts the handler that releases it. Each delays entry by 25 ms, past the +expiry of the former 1 ms {cpp} timer, and requires a poll with a nonzero +timeout. A timer that already expired can finish in the initial +nonblocking poll: that poll suspends too, but its shorter stack is not +evidence for the waiting path. The yield cases cover `run`, `run_for` and +`run_until` separately. + +On 2026-10-14, with Emscripten 6.0.11 and Node 26.7.0, the corrected +`asyncify_stack` test measured these maxima from scratch, in bytes: + +[cols="2,1,1",options="header"] +|=== +| Build | Exceptions on | Exceptions off +| Debug | 1164 | 844 +| Release, unoptimized link | 2896 | 1940 +| Release, link with `-O3` | 384 | 288 +|=== + +Each of the eleven paths with exceptions and nine without stayed below +4096 bytes, half of the configured 8192. These are measurements of the +run-family test, not a bound on a user's own call frames. + The artifacts are named and placed as Boost's own build names and places them: one directory level per toolset, variant and property that is not the default, and a file name that carries the program's tags joined by `-`, @@ -159,6 +276,60 @@ and the suspension variant. The default variant adds no directory level: each beside its `.wasm`. +[#asio-building-loader] +=== Loading the variant a browser runs + +Build a page program and its two variants with `webcpp.variants`: + +[listing] +---- +include::{library-root}/test/browser/Jamfile[tag=page-variants] +---- + +The build writes `page_program.variants.json` beside the JSPI artifact. +Its `jspi` and `asyncify` objects each contain a `script` path relative to +the manifest and the WebAssembly size in bytes. Serve the manifest, both +scripts and their WebAssembly files with their relative layout intact. + +The loader is `include/webcpp/asio/webcpp-asio-loader.mjs`, shipped with +the headers. A page imports its `load` function and calls +`load('page_program.variants.json')`. It detects JSPI by checking whether +`WebAssembly.Suspending` is a function, chooses `jspi` when it is and +`asyncify` otherwise, and reads the artifact path from the manifest. +It resolves that path relative to the final manifest URL after any HTTP +redirects, imports the script and awaits its default factory. A custom +`fetch` that supplies no response URL uses the requested manifest URL. +The result is `{variant, module}`. + +`supportsJspi(scope)` permits detection in a supplied scope. `pick(manifest, +jspi)` returns `{variant, script}` and rejects a missing script for the +selected variant. `load(manifestUrl, options)` accepts an explicit `jspi` +choice, `module` options passed to the factory, and replacements for +`fetch` and `importModule`. Failed manifest requests report their URL and +HTTP status; fetch, JSON, import and initialization failures propagate to +the caller. A failed JSPI load does not silently retry Asyncify. + +A relative manifest URL is resolved against the page URL, or against the +loader module URL where no page location exists. Factory completion is +variant-dependent: the current JSPI factory awaits `main`, while Asyncify +can resolve before a suspended `main` finishes. An indefinitely running +JSPI program therefore reports readiness through its module callbacks; +an application observes its own completion signal. The loader test waits for the program's output, +within the driver's timeout, rather than sleeping for an assumed duration. + +The `browser` lane loads both variants under Node using a file reader for +the manifest, and in headless Chrome over loopback HTTP. It exercises this +actual page program: + +[source] +---- +include::{library-root}/test/browser/page_program.cpp[tag=page-program] +---- + +The same lane checks idle waits and animation callbacks under continuous +ready work in Chrome. See <> for its measurements +and failure criteria. + [#asio-building-exit-status] === The exit status @@ -170,3 +341,219 @@ fails chapter 9). asio's tests pin both cases where node would read a failure as a pass, in each variant: a `main` that never finishes, and a `main` that suspended and then returns 1 without the helper. + +[#asio-tls] +=== TLS: build OpenSSL from source on native and WASI + +For a program including ``, add +`/webcpp/asio//openssl` beside `/webcpp/asio//asio` in its target sources: +`exe app : app.cpp /webcpp/asio//asio /webcpp/asio//openssl ;`. +This forwards `/webcpp/third_party//openssl`, which builds OpenSSL 3.5.9 +(commit `45e844fa2a14ec92d146bd8f5778ac130b6625fb`) from the unmodified +upstream submodule. No installed OpenSSL or `OPENSSL_ROOT` is used by this target. + +In a Git checkout, initialize the source with +`git submodule update --init third_party/libs/openssl`. +A WebCPP source distribution already contains the required OpenSSL files and +does not need Git. The build needs Python 3, Perl, Make, and the selected +compiler toolchain; Git is also used to verify a source checkout. +B2 invokes upstream Configure/Make and exports static `libssl.a`, `libcrypto.a` +and their matching generated headers. Before Configure, it stages the +distributable source files in a temporary directory and verifies their paths, +file modes and content hashes against the pin. Missing, additional or altered +files fail the build. Dot paths and pinned optional upstream repositories are +omitted, just as in the source distribution. The temporary source directory +also avoids upstream Makefiles' restriction on source paths containing spaces. +Different toolsets, optimization flags, +exception settings and thread profiles use separate build directories. Effective +C flags and compiler commands also identify separate archive/header directories. +Flags retain normal B2 scope: dependency-specific `cflags` belong on the OpenSSL +target, not only on its consumer. Independent concurrent B2 processes should use +separate `--build-dir` directories. +`threading=single` builds OpenSSL with `no-threads`; `threading=multi` enables +its platform threading implementation. Native recipes support Clang/GCC on +macOS/Linux and MSVC on Windows. MSVC uses upstream Configure and nmake, +static archives and the B2 runtime/debug settings; the initial Windows recipe +uses portable C without requiring NASM. + +For a program built both natively and for the browser, use the condition below. +It also selects OpenSSL for WASIp2/P3; browser builds retain the settings adapter: + +[listing] +---- +include::{library-root}/example/tls/Jamfile[tag=project,indent=0] +---- + +Do not use `!emscripten:/webcpp/asio//openssl`: that spelling +silently fails to link OpenSSL in the tested B2 configuration. + +Correct configuration errors as follows: + +* If `ssl.hpp` reports that OpenSSL is not linked, name the `openssl` target. + Outside B2, define `WEBCPP_ASIO_HAS_OPENSSL=1` and supply matching headers, + libssl, libcrypto and platform dependencies yourself. +* If the source checkout is missing, initialize the submodule with the command + above. Tests requiring OpenSSL fail rather than silently skipping TLS. +* If the target is named for the browser, select native or WASIp2/P3. + The browser settings record does not implement TLS inside the Wasm module. +* With WASIp3 `threading=multi`, use `exception-handling=off` with wasi-sdk 34.0: + its cooperative sysroot does not contain the {cpp} exception runtime. + +The built-in default and base providers are linked statically. Loading provider +modules is disabled; this configuration is not a FIPS build. Both WASI profiles disable +assembly, dynamic loading, QUIC, Unix-domain sockets and the OpenSSL thread pool. +Native Clang/GCC builds retain upstream assembly optimizations; the initial +MSVC recipe uses portable C. The recipe uses function and data sections plus +platform dead stripping. A program has one OpenSSL provider. Native Trystero's +`/webcpp/trystero//native` target builds pinned static libdatachannel and its +required nested sources against this same provider, so it can coexist with +Asio and Beast. Such a program selects `threading=multi` and exceptions for +Trystero's worker-thread backend. Libsecp256k1 remains externally provisioned; +`OPENSSL_ROOT` and `LIBDATACHANNEL_ROOT` do not select alternate providers. + +The configured certificate directory is `/etc/ssl`. A source-built library does +not install a system trust store or import the macOS keychain. Use the embedded +factory in <> for portable defaults, or explicitly load +the intended CA file, set `verify_peer`, and verify the peer's hostname on a raw +context. WASI applications using a file must preopen its directory. Embedded +authorities need no certificate filesystem access. Both require the needed TCP +network capability; linking the library grants no runtime permission. + +WASI seeding explicitly selects OpenSSL's `getrandom` configuration, whose +WASI implementation calls `getentropy`, then wasi-libc's secure +`wasi:random/random.get-random-bytes` host import. With Wasmtime's default host +configuration, the generator is seeded from the operating system. The host +remains trusted: an embedder can replace its randomness provider. The tests +verify that host entropy is requested and a reported entropy failure prevents +random output and key generation; they do not prove cryptographic entropy +quality or snapshot/restore safety. Reseed policy after restoring a seeded +instance requires separate validation. + +The reproducible native/WASIp3 test driver is +`python3 tools/openssl/test/run.py --fresh` from the superproject. +It needs Python with TLS 1.3 and an OpenSSL 3 command-line +program only to create short-lived server fixtures. The client links the +source-built library. `WASMTIME` selects the runtime executable; the recorded +WASIp2/P3 checks use wasi-sdk 34.0 and Wasmtime 50.0.1. See +<> for the target/variant matrix. + +The recurring own lane `b2 libs/asio/test/tls//tls-integration` drives those +TLS, embedded-CA, state, cancellation and entropy fixtures on native and WASIp3 +profiles. The separate `libs/asio/test/wasip2_tls_cobalt//wasip2-tls` own lane +drives the WASIp2 fixtures with both exception modes; see <> for +the complete command, including the ordinary Cobalt consumers. +`b2 libs/asio/test/tls//openssl-upstream` is native only: it requests +`webcpp-openssl-tests=on`, builds and runs upstream's full `alltests` suite, +then links a TLS consumer against those exact archives. The +`openssl-upstream-msvc-14.3` and `openssl-upstream-msvc-14.5` aliases exercise +that suite with the corresponding Windows CI toolsets. Ordinary consumers do +not run that suite. The upstream harness is unavailable on WASI; the separate +integration tests give narrower evidence and do not claim upstream-suite parity. +A lane declaration is not evidence that the current candidate passed CI. + +The library's targets implement that distinction: + +[listing] +---- +include::{library-root}/build.jam[tag=openssl,indent=0] +---- + +[#asio-ca-certificates] +=== How-to: configure trusted certificate authorities + +For a native or WASI client with portable trust defaults, include +`` and link `/webcpp/asio//tls`. +The target includes Asio, source-built OpenSSL and +`/webcpp/third_party//ca_certificates`. No certificate file, environment setting, +system trust store or network download is read by the factory. WASI needs no +certificate directory preopen; a network connection still needs host permission. + +This program prepares the context and checks errors without exceptions. With no +arguments it uses the embedded roots. An optional argument supplies replacement +PEM bytes, not a file path: + +[source,cpp] +---- +include::{examples}/asio_tls_client.cpp[tag=program,indent=0] +---- + +The default invocation prints: + +[listing] +---- +include::{examples}/asio_tls_client.expected[] +---- + +Use the resulting context when constructing TLS streams and keep it alive while +they exist. The factory enables `verify_peer` and requires TLS 1.2 or newer. +Configure `ssl::host_name_verification` for the expected hostname and set SNI on +each connection. A trusted issuer alone does not establish the intended hostname. + +The overload taking `std::string_view` replaces the complete trust set. It does +not append private authorities to public roots. Supply one or more PEM CA +certificates separated by whitespace. Empty input, malformed certificates, +non-CA certificates, and trailing non-whitespace data return an error without +a usable context. The certificates are copied into the context; the input may +then be released. Initialization failures are errors as values too, with or +without exceptions. OpenSSL owns its allocations and does not use an Asio +allocator. On Emscripten the helper returns `unsupported_target`: browser TLS +and its trust policy remain under the browser's control. + +==== Updating the embedded snapshot + +The source is the https://curl.se/docs/caextract.html[Mozilla CA export from curl], +preserved in `third_party/ca_certificates/cacert.pem` with its MPL-2.0 license. +The adjacent manifest records the source URL, date, SHA-256 and each certificate's +DER fingerprint. The initial snapshot is dated 2026-09-25 and contains 121 CAs. +Keep its license and corresponding PEM source available when redistributing it. + +Choose a published date from the curl CA Extract page. From the superproject root: + +[source,bash] +---- +python3 tools/ca_certificates/update.py --date 2026-09-25 +python3 tools/test/ca_certificates_test.py +python3 tools/test/ca_certificates_b2_test.py +python3 tools/ca_certificates/run.py --fresh +---- + +The updater downloads through verified HTTPS, checks the published SHA-256, +validates every certificate and reports added/removed fingerprints. Review the +trust changes and version the PEM and manifest together. An older date is +rejected. Use `--output DIRECTORY` to stage a candidate separately, or +`--source-file PATH --sha256 DIGEST` for an independently authenticated offline +copy. A checksum detects a changed artifact; it is not an independent publisher +signature. Normal builds use the pinned artifact without downloading anything. + +Rebuild and redeploy applications after changing the snapshot. Existing binaries +retain their embedded roots. The updater does not schedule downloads or alter +running programs. The build rejects a missing or hash-mismatched snapshot. If an +update was interrupted between replacing its two files, restore both from Git +and repeat it. Run only one updater per output directory. + +==== Using installed headers + +`b2 install --prefix=DIR` includes the generated +`webcpp/asio/detail/ca_certificates.hpp` under `DIR/include/`. Its private +namespace is `webcpp::asio::detail::ca_certificates`. The matching PEM +source, manifest and MPL notices are under `DIR/include/webcpp/ca_certificates/`. +The CA package is generated locally without compiling OpenSSL. A consumer of +the installed TLS header must still configure Boost, define +`WEBCPP_ASIO_HAS_OPENSSL=1` and link compatible OpenSSL headers and archives. +Installation does not package the Cobalt runner or dependency archives. + +==== What portable trust does and does not mean + +The PEM export omits some additional constraints enforced by Firefox. It does +not reproduce the complete browser policy, consult the host's private roots or +automatically fetch revocation information. Explicit replacement lets an +application choose a narrower or organizational trust set. Native system trust +integration and automatic runtime updates are separate features. + +Local tests cover real TLS 1.2/1.3 connections, wrong hostnames, an unrelated CA, +and rejection of a private test CA by the default public bundle. They also check +complete replacement and invalid input. The matrix covers native macOS +single/multi with exceptions on/off, WASIp2/P3 single with exceptions on/off, and +WASIp3 cooperative threads with exceptions off under SDK 34. The WASIp3 client +runs without certificate filesystem grants. Tests use a fresh local test CA; +they do not depend on a public website's availability. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/capabilities.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/capabilities.adoc new file mode 100644 index 0000000..a6963e6 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/capabilities.adoc @@ -0,0 +1,280 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-capabilities] +== Target and variant capabilities + +This reference covers the public feature families of `webcpp::asio` and its +Cobalt build target. It does not promise every feature of the complete Boost +installation. *Supported* means the implementation provides the feature; +*limited* requires the qualification below; *unverified* is not a portability +promise. Native behavior also depends on the operating system. + +For the explicit feature-by-feature intersection of threads and exception +handling, use <>. It separates Asio from Cobalt and +distinguishes public support, isolated probes and unverified combinations. + +[#asio-capabilities-config] +=== Build configurations + +[cols="2,2,2,3",options="header"] +|=== +| Target and variant | Threads | Exceptions | Status +| Native | OS threads, subject to Boost configuration | On or off +| Existing integration; native controls run on macOS arm64. +| Emscripten / JSPI | Single or pthread workers | On or off +| Wasm exceptions when enabled; M requires isolation and creator-thread affinity. +| Emscripten / Asyncify | Single or pthread workers | On or off +| JavaScript exceptions when enabled; M has the raw pthread return-value limit below. +| WASIp3 / `threading=single` | Disabled | On or off +| Minimal port; both configurations tested with wasi-sdk 34.0 and Wasmtime 50.0.1. +| WASIp3 / `threading=multi` | Experimental cooperative threads | Off +| Minimal port; tested with wasi-sdk 34.0's cooperative sysroot and Wasmtime 50.0.1. +| WASIp3 / `threading=multi` | Experimental cooperative threads | On +| Unavailable with the tested SDK: its cooperative sysroot has no {cpp} exception runtime. +| WASIp2 / `threading=single` | Disabled | On or off +| Core, timers, TCP/UDP, forward DNS, CLI streams, Cobalt and TLS; see <>. +| WASIp2 / `threading=multi` | Unavailable | On or off +| Rejected: the pinned SDK has no supported P2 pthread runtime/profile. +|=== + +`variant=debug` and `variant=release` select build optimization, not different +APIs. The new WASIp3 runtime verification uses Release builds. JSPI and Asyncify +are browser suspension variants; they are not WASIp3 variants. The WASIp3 +thread setting and exception setting are independent choices, subject to the +SDK runtime availability above. Cooperative threads suspend at blocking WASI +operations; this does not provide simultaneous CPU execution on multiple cores. + +include::feature-matrix.adoc[] + +[#asio-capability-guards] +=== Require a capability at compile time + +`` defines the following read-only macros as `0` or `1`. +Use `#if`, not `#ifdef`, to inspect them. Do not define these capabilities on +the command line: the header rejects attempts to override them. + +[cols="3,5",options="header"] +|=== +| Macro suffix after `WEBCPP_ASIO_` | Meaning of `1` +| `HAS_SOCKET_BACKEND` | Native/WASI TCP and UDP backend, subject to runtime grants and options. +| `HAS_OPENSSL_BACKEND` | This target supports the optional source-built OpenSSL provider. +| `HAS_HOST_DNS` | Forward lookup through the native/WASI host, subject to host DNS policy. +| `HAS_REVERSE_DNS` | Native reverse lookup; the WASI interface is forward-only. +| `HAS_THREADS` | Boost.Asio thread support is enabled in this build, including cooperative threads. +| `HAS_BROWSER_BRIDGE` | Emscripten JavaScript events and Promises can reach the executor. +| `HAS_BROWSER_WORKERS` | Emscripten pthread build with Asio thread support. +| `HAS_WASI_STDIO` | The WASIp2 pollable CLI stream adapter is available. +| `HAS_LOCAL_SOCKETS`, `HAS_SIGNALS`, `HAS_SERIAL_PORT` +| Native target with the corresponding Boost.Asio facility enabled. +|=== + +`WEBCPP_ASIO_HAS_OPENSSL=1` is different: it declares that the optional compiled +dependency was selected. `/webcpp/asio//openssl` and `//tls` supply it together +with the matching provider. Outside B2, the application must also supply the +matching OpenSSL headers and libraries. Merely defining it cannot satisfy the +linker. `ssl.hpp` rejects native/WASI use without that dependency; Emscripten +keeps its portable TLS settings record. + +Define a `WEBCPP_ASIO_REQUIRE_*` switch to a nonzero integer before the first +WebCPP include, or on the compiler command line, to require `SOCKET_BACKEND`, +`OPENSSL`, `THREADS`, `LOCAL_SOCKETS`, `SIGNALS`, `SERIAL_PORT` or `REVERSE_DNS`. +An absent switch or a value of zero imposes no requirement. The default permits +portable applications to select runtime alternatives, including browser transports. +Apply configuration consistently to every translation unit. + +This compiled example requires a real socket backend and still handles a +runtime refusal from the host: + +[source,cpp] +---- +include::{examples}/asio_capabilities.cpp[tag=program,indent=0] +---- + +[listing] +---- +include::{examples}/asio_capabilities.expected[] +---- + +The browser-specific headers diagnose a non-Emscripten target before including +Emscripten headers. `wasi/stdio_stream.hpp` diagnoses targets without the P2 CLI +adapter. B2 rejects unsupported SDK/thread/EH combinations and checks the private +WASI descriptor ABI. A compiler cannot determine network grants, available peers, +trust roots, a page's isolation headers or whether a host import will block. +Those conditions retain runtime errors or the documented host behavior. + +[#asio-capabilities-core] +=== Execution and integration features + +In the following tables, *browser* covers both JSPI and Asyncify. Their API +capabilities are the same; their suspension and exception implementations differ. +The separate <> table records the P2 profile. + +[cols="3,2,2,2,2",options="header"] +|=== +| Feature | Native | Browser | WASIp3 single | WASIp3 cooperative +| `io_context`, executors, `post`, `dispatch`, run/poll family +| Supported | Supported | Supported | Supported +| Steady/system timers, expiry changes and cancellation +| Supported | Supported | Supported | Supported +| Context and associated-handler allocators +| Boost contract | Supported | Context/timer/post counters tested +| Context/timer/post counters tested; named libc pipe allocations separate +| Multiple threads posting or running a context +| Boost contract | Cross-thread post in M; one creator-thread runner per context +| Unavailable | Tested: wakeup and two runners +| {cpp}20 Boost.Asio `awaitable` / `co_spawn` +| Timer coroutine tested | Timer coroutine tested under Node and Chrome +| Timer coroutine tested | Timer coroutine tested +| Boost.Cobalt and the `co_main` runner +| Supported with qualifications in <> +| Supported with the same qualifications +| Supported with qualifications in <> +| Supported without exceptions; cooperative thread coroutine tested +| Promise operations and DOM/event bridge +| Not applicable | Supported | Not applicable | Not applicable +| Browser turn limit, explicit browser yield +| Not applied | Supported; default limit 100 | Not applied | Not applied +| Browser loader and suspension-variant manifest +| Not applicable | Supported | Not applicable | Not applicable +|=== + +WASIp3 keeps Boost.Asio's scheduler and select reactor. It does not use the +JavaScript event bridge or the browser's handler-count limit. Its syscalls +suspend through wasi-libc and the host's Component Model implementation. + +The public Cobalt target builds its static archive with checked compatibility +headers and sources on WASIp3. Timers, TCP/UDP and cancellation are exercised +through both Asio completion tokens and Cobalt's own wrappers. The optional +`/webcpp/asio//cobalt_ssl` target adds Cobalt's SSL wrapper with verified TLS +and handshake/transfer cancellation, including partial composed operations. +Truncated and cancelled shutdown are also tested; see <>. See +<> for integration details and +<> for open tests. +It has no automatic SIGINT/SIGTERM shutdown bridge on WASIp3; internal +coroutine cancellation is a separate mechanism. See <>. + +[#asio-capabilities-network] +=== Networking features + +[cols="3,2,2,2,2",options="header"] +|=== +| Feature | Native | Browser | WASIp3 single | WASIp3 cooperative +| TCP connect, accept, read/write, endpoint queries +| Supported | Requires custom transport | Supported | Supported +| TCP composed read/write with buffer sequences +| Supported | Requires custom transport | Supported; partial transfers | Supported; partial transfers +| UDP send/receive, including empty datagrams +| Supported | Requires custom transport | Supported | Supported +| UDP `send_to` / `async_send_to` with multiple nonempty buffers +| Boost contract | Transport dependent | Supported; concatenated copy | Supported; concatenated copy +| UDP receive or connected `send` / `async_send` with multiple nonempty buffers +| Boost contract | Transport dependent | Supported; gather/scatter copy | Supported; gather/scatter copy +| Asynchronous cancellation and TCP EOF +| Supported | Transport dependent | Tested | Tested +| IPv4 loopback TCP/UDP +| Tested | Requires custom transport | Tested | Tested +| IPv6 socket connections +| OS dependent | Requires custom transport | Unverified | Unverified +| IPv6 numeric scope parsing/formatting +| Supported | Browser endpoint representation | Tested | Tested +| IPv6 interface-name scopes +| OS dependent | Not a host interface lookup | Unavailable | Unavailable +| Synchronous resolver +| Supported | Retains names; no DNS lookup | wasi-libc resolver | wasi-libc resolver +| Asynchronous resolver +| Boost thread pool | Retains names; no DNS lookup | Native async host lookup +| Native async host lookup +| `available()` / `FIONREAD`, peek, out-of-band marks +| OS dependent | Transport dependent | Unavailable in tested libc | Unavailable in tested libc +| Socket options +| OS dependent | Transport dependent | Limited to libc's options | Limited to libc's options +| TLS through `/webcpp/asio//openssl` +| Source-built OpenSSL; native Clang/GCC recipe +| Settings record only +| Source-built OpenSSL; TLS 1.2/1.3 +| Source-built OpenSSL; TLS 1.2/1.3, exceptions off with SDK 34 +| Embedded CA defaults and complete replacement through `/webcpp/asio//tls` +| Supported; no certificate files required +| Helper returns `unsupported_target`; browser owns trust +| Supported; no certificate directory preopen +| Supported; no certificate directory preopen, exceptions off with SDK 34 +| WebSocket/HTTP browser streams +| Separate Beast library | Separate adapter, not supplied here | Not supplied here | Not supplied here +| Process signals, local sockets, serial ports from Boost +| OS dependent | Not supplied here | Disabled | Disabled +|=== + +OpenSSL local coverage includes native macOS arm64 single/multi with exceptions +on/off using Clang, WASIp2 and WASIp3 single with exceptions on/off, and WASIp3 cooperative +with exceptions off. A GCC 15 native multi-threaded build with exceptions also +passed the TLS tests. Linux Clang/GCC mappings are implemented but not runtime-tested +on this macOS host. The native MSVC recipe is implemented; this local macOS matrix does not establish Windows runtime coverage. The source library +uses OS threads natively and cooperative threads on WASIp3; it does not make +cooperative execution CPU-parallel. TLS tests cover verified handshakes, +asynchronous application data, clean shutdown and rejected peer identities. +The embedded CA factory's trust policy, update procedure and local checks are +documented in <>. + +The browser's default socket transport reports `operation_not_supported` for +network operations. The browser resolver does not perform DNS; see +<>. A TLS settings record is not a TLS implementation. + +[#asio-wasip3-contract] +=== WASIp3 limits and error behavior + +* TCP buffer sequences advance one nonempty buffer per syscall when necessary. + Partial reads and writes are valid Asio behavior; composed `async_read` and + `async_write` continue until their completion condition is met. No temporary + heap buffer is introduced to concatenate a sequence. +* UDP `send_to` and `async_send_to` concatenate multiple nonempty buffers into + one datagram because the tested wasi-libc does not provide `sendmsg`. + Concatenation visits the entire sequence before Asio's native iovec limit. + It copies the payload once into temporary storage: the context allocator + supplies synchronous storage, and the handler's associated allocator supplies + asynchronous storage. The operation owns asynchronous storage until completion + or destruction and releases it before invoking the handler. Scalar, empty and + single-nonempty-buffer sends need no temporary allocation or payload copy. + The gather path rejects payloads above 65,535 bytes with `message_size` before + allocating or reading their data; the host may enforce a smaller IP limit. + Allocation failure follows the supplied allocator's failure behavior. +* Connected `send` / `async_send` use the same single-datagram gather path. + Multi-buffer receives read one datagram into temporary storage and scatter the + received bytes across the destination sequence. A short destination truncates + the datagram; its remainder is not delivered as another packet. Empty buffers + do not split a datagram. Empty datagrams are delivered. Scratch allocation + follows the synchronous context or asynchronous handler allocator, as for sends. +* Synchronous resolution uses wasi-libc. Actual hostname lookup requires host + permission; numeric resolution does not need DNS. Both thread profiles use + the native asynchronous forward-lookup import and a waitable-backed descriptor + for `async_resolve`. Initiation is deferred through the executor and other timers + progress while the lookup is pending. Resolver-wide and per-operation + cancellation preserve the normal completion channel. No hidden thread or + periodic DNS polling is introduced. Canonical names, mapped-address policies + and asynchronous reverse lookup are explicitly unsupported. +* Interface-name scopes such as `%eth0` are rejected. Decimal IPv6 scopes in + the range 0 through 4294967295 are accepted. +* Missing socket options, including linger, broadcast, debug, don't-route, + out-of-band-inline and low-water marks, report `operation_not_supported`. + Other options remain subject to wasi-libc and host support. Multicast and + detailed socket-option interoperability have not been validated. +* WASI has no `ESHUTDOWN`. The port maps Asio's `shut_down` to `EPIPE`, which + wasi-libc uses; it therefore shares the numeric value of `broken_pipe`. +* Error-code overloads and asynchronous completion retain their error channels. + With exceptions disabled, invoking a throwing overload on an error can still + reach Boost's fatal exception handler. Prefer explicit error-code/result paths. +* Cobalt uses the same platform restrictions through its public B2 target. + Its async resolver uses the same native lookup in both thread profiles. + TLS through Asio/OpenSSL + with Cobalt tokens uses application-selected trust roots and host network + capabilities; embedded roots require no certificate filesystem preopen. + See <> and <>. + +These are current port boundaries, not claims that WASIp3 itself can never +support the missing operations. The compatibility patch belongs to Boost.Asio's +platform layer; implementing the missing POSIX entry points such as +`sendmsg`/`recvmsg` belongs in wasi-libc. The current port avoids pretending those +entry points or process signals exist. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/changelog.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/changelog.adoc new file mode 100644 index 0000000..6ffdb1c --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/changelog.adoc @@ -0,0 +1,33 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[appendix] +[#asio-changelog] +== Changelog + +Changes prepared for the first WebCPP release. + +[#asio-changelog-unreleased] +=== Unreleased + +// tag::unreleased[] +// end::unreleased[] + +[#asio-changelog-0-1-0] +=== webcpp 0.1.0 + +// tag::0.1.0[] +* Added Boost.Asio contexts and timers with browser event-loop suspension. +* Added browser workers, main-thread handoff and turns defaulting to 100 handlers. +* Added Promise and DOM-event operations with cancellation and allocator support. +* Added browser socket adapters, retained resolver names and TLS settings. +* Added WASIp2/P3 networking, UDP gather/scatter and asynchronous forward DNS. +* Added Cobalt, CLI streams, WASI TLS and P3 cooperative-thread integration. +* Added optional source-built OpenSSL and replaceable embedded CA certificates. +* Fixed Cobalt TLS state/cancellation and TLS error equality across shared libraries. +* Added capability guards and fixed configuration propagation and resolver allocation. +* Added Diataxis guides, compiled examples and MrDocs API reference. +// end::0.1.0[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/cobalt.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/cobalt.adoc new file mode 100644 index 0000000..0fadf26 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/cobalt.adoc @@ -0,0 +1,348 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-cobalt] +== Run a Cobalt program + +Boost.Cobalt's `co_main` remains the application's entry coroutine. Link +`/webcpp/asio//cobalt` to run it with asio's context: natively this keeps +Boost.Asio's behavior; on Emscripten it yields between bounded turns. +The default turn contains at most 100 handlers, configurable with +`WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN` as described in <>. A long handler is never +interrupted, and a yield offers the browser an opportunity to run rather +than promising a timer deadline or a rendered frame. + +The Cobalt target supports WASIp2 single-thread and WASIp3 single-thread/cooperative +profiles in <>. Its checked private Boost overlay removes +unavailable local-socket, serial-port and process-signal dependencies from IP +networking. The same thread and exception settings reach the application and +compiled archive. See <> for commands. + +[#asio-cobalt-example] +=== Tutorial: wait for a timer in co_main + +Start with the native build setup in <>. Open +`libs/asio/example/asio_cobalt.cpp`; this is the complete example: + +[source,cpp] +---- +include::{examples}/asio_cobalt.cpp[tag=program,indent=0] +---- + +`this_coro::executor` obtains the executor installed by the runner. The timer +belongs to that executor, and `co_await` suspends the coroutine until its wait +completes. `as_tuple` exposes an error as a value, so this example also builds +without exception handling. It does not move a pending Cobalt task. +The final `exit_status` call reports completion to webcpp's example harness; +an application outside that harness can simply `co_return 0`. + +Run these commands from the superproject root: + +[source,bash] +---- +b2 libs/asio/example//asio_cobalt.output +b2 toolset=emscripten libs/asio/example//asio_cobalt.output +b2 toolset=emscripten webcpp-suspend=asyncify libs/asio/example//asio_cobalt.output +---- + +Each run must produce the same standard output: + +[listing] +---- +include::{examples}/asio_cobalt.expected[] +---- + +The build compares this output against the checked-in expected file. The +50 ms is a requested timer delay, not a precise wall-clock duration. +To try the result-based path, append `exception-handling=off`; read the +upstream limitation and configuration warning below first. + +[#asio-cobalt-build] +=== How to link the integration + +Add `/webcpp/asio//cobalt` to the program's requirements. Keep the +Cobalt headers and `co_main` signature. The target supplies both the compiled +Cobalt sources and webcpp's replacement runner; do not also link a system +Cobalt library or compile Boost's `src/main.cpp`. + +Exception handling follows the application. A build without exceptions +prints the warning linked to https://github.com/boostorg/cobalt/issues/287[Cobalt issue 287]. +The checked Boost 1.92 header overlay supplies the coroutine promise's +required `unhandled_exception` member when exceptions are disabled. It calls +`std::terminate` if reached; it does not enable exception propagation. +Compiler warnings and their warnings-as-errors policy are unchanged. +Result adapters do not repair upstream operations that construct exception +objects internally. This integration does not establish universal support +for Cobalt without exceptions. + +[#asio-cobalt-ssl] +=== How to use Cobalt's SSL stream + +Include `` and add +`/webcpp/asio//cobalt_ssl` to the program's requirements. This optional +target combines the Cobalt runner, the compiled SSL wrapper, source-built +OpenSSL and embedded CAs. It supports native Clang/GCC on macOS/Linux and the +WASIp2 single-thread profile with EH on/off, and the three available WASIp3 +profiles in <>. The local native validation uses +macOS; it does not establish Linux runtime coverage. Browser OpenSSL and the +unavailable WASIp3 cooperative/EH-on runtime are refused. + +[listing] +---- +include::{library-root}/build.jam[tag=cobalt-ssl,indent=0] +---- + +Prepare the context with `webcpp::asio::make_tls_client_context`, as in +<>, and check its result. Cobalt's SSL context is an alias for +Asio's, so the factory's context can be passed directly to +`boost::cobalt::io::ssl::stream`. A supplied PEM bundle replaces the embedded +roots. Configure `set_verify_callback` with Asio's `host_name_verification` for +the intended hostname, and set SNI with `SSL_set_tlsext_host_name` on +`stream.native_ssl_handle()`. Check both results before connecting. + +`native_ssl_handle()` is an extension supplied by WebCPP's checked Boost 1.92 +patch. It returns a borrowed `SSL*` owned by the stream; do not free it or retain +it after stream destruction. The inherited `native_handle()` still denotes +the TCP socket. This extension is available only when using the patched target. +Ordinary `main` consumers can link `/webcpp//boost_cobalt_io_ssl` without adding +a `co_main` runner; the low-level target does not add WebCPP's CA factory headers. + +[#asio-cobalt-ssl-state] +==== Reference: handshake and stream state + +The wrapper supports STARTTLS: before the first handshake begins, reads and +writes use plain TCP. Complete a successful handshake before sending confidential +application data. `secure()` reports whether TLS is established, not whether +the application enabled peer/hostname verification. + +[cols="2,4",options="header"] +|=== +| State or operation | Behavior +| Before the first handshake | `secure()` is false; plain TCP I/O is allowed. +| Handshake succeeds | `secure()` becomes true before the awaiting coroutine +resumes; application I/O uses TLS. +| Handshake fails or is cancelled | `secure()` remains false; subsequent reads +and writes return `not_connected` with zero bytes, without falling back to plaintext. +| Another handshake after an attempt has started | Returns `already_started`; +use a new stream for a new TLS attempt. +| Shutdown before TLS is established | Returns `no_protocol_option`. +| TLS shutdown completes, including with an error | `secure()` becomes false; +further application I/O is blocked. A second shutdown returns `no_protocol_option`. +|=== + +Both handshake overloads update the same state. The buffered overload consumes +already-read handshake bytes and reports their consumed size. Keep the context, +stream and buffers alive while operations are pending. Serialize state-changing +operations; the wrapper does not add synchronization for overlapping handshakes, +shutdown or concurrent manipulation of the underlying SSL object. + +The private patch also corrects the verification callback constraint to use +`boost::asio::ssl::verify_context`. The installed Boost tree is not modified. +Rebase and verify this patch when updating Boost. The no-exceptions warning in +<> still applies. + +[#asio-cobalt-ssl-tests] +==== Run the local wrapper checks + +From the configured superproject root, build the client and state tests: + +[source,bash] +---- +b2 variant=release tools/openssl/test//cobalt_ssl_client tools/openssl/test//cobalt_ssl_state +b2 toolset=clang-wasip3 variant=release threading=single exception-handling=on \ + tools/openssl/test//cobalt_ssl_client tools/openssl/test//cobalt_ssl_state +b2 variant=release tools/openssl/test//cobalt_ssl_cancel +b2 toolset=clang-wasip3 variant=release tools/openssl/test//cobalt_ssl_cancel +---- + +Use each executable path printed by B2's link action. For WASI, put Wasmtime +50.0.1 on `PATH` or set `WASMTIME` to it. The harness needs Python with TLS 1.3 +and an OpenSSL CLI to generate temporary local certificates; the tested {cpp} +program still links WebCPP's source-built OpenSSL. + +[source,bash] +---- +python3 tools/openssl/test/tls.py --embedded --require-sni +python3 tools/openssl/test/tls.py --embedded --require-sni --client-arg=buffered +python3 tools/openssl/test/tls.py --state-test +python3 tools/openssl/test/tls.py --state-test +---- + +The client checks TLS 1.2/1.3, encrypted ping/pong, hostname, SNI, trust rejection, +malformed CA data and clean shutdown. The state test checks a STARTTLS exchange, +a server handshake with actual buffered ClientHello bytes, operation state read +at await time, and coroutine cancellation while a handshake is pending. It uses +loopback sockets and temporary certificate material, without a WASI CA preopen. +The cancellation test covers pending `read_some` and `write_some`, composed +`io::read` after receiving part of its buffer, and composed `io::write` under TCP +backpressure. It requires `operation_aborted` and checks the partial byte count. +The peer stops reading, socket buffers are bounded, and a zero-timeout poll +confirms the TCP socket is not writable before cancellation. An SSL completion +may nevertheless already be queued. If cancellation loses to successful +completion, the test closes that connection and retries with a fresh one, +up to eight attempts; only an actual `operation_aborted` satisfies the case. +A watchdog catches lost cancellation; elapsed time is not the witness that an +operation is pending. + +For shutdown, the peer first observes `close_notify` but does not send its own. +Closing its TCP socket produces `stream_truncated`; cancelling the pending +shutdown produces `operation_aborted`. Both paths clear `secure()`, block further +application I/O, and make a second shutdown return `no_protocol_option`. +These checks run with TLS 1.2 and 1.3 in the supported native/WASIp2/WASIp3 profiles. +Select one case with `--client-arg=read_some`, `write_some`, `read`, `write`, +`shutdown_error` or `shutdown_cancel` when diagnosing a failure. + +These transfer tests request terminal cancellation through the Cobalt promise. +Close the socket afterward: cancellation cannot retract bytes already sent and +the test does not promise safe connection reuse. Cancelling a transfer does not +undo the TLS negotiation, so `secure()` can remain true; it is not a connection +health or retry-safety indicator. Shutdown completion, including failure or +cancellation, does clear that flag. + +The common checked Boost 1.92 patch in `tools/boost/cobalt-common` connects a +composition promise's cancellation source to its completion handler. Without +this connection, a cancelled composed `io::read` or `io::write` can remain +pending indefinitely. The B2 target applies the fix to both compiled Cobalt +operations and application-defined compositions, including consumers without SSL. +The separately compiled WASIp3 acceptor object receives this patch too. +`cobalt_accept_cancel` initiates the composed `accept()` overload without a +client connection, cancels its Cobalt promise and requires `operation_aborted` +with an unopened returned socket. A watchdog fails if cancellation is lost; +no timer is used to guess when the accept is pending. + +[#asio-cobalt-runner] +=== Why the runner changes + +Cobalt's header supplies `main`, which calls +`boost::cobalt::detail::main_promise::run_main` to execute the application's +`co_main`. Its compiled runner owns a Boost.Asio context. webcpp replaces +that definition with one using `webcpp::asio::io_context`, preserving the +executor setup, initial post, signal cancellation and final suspension. +A differently named entry coroutine would require application changes; +a second `co_main` would conflict with the application's definition. + +The replacement reads Boost 1.92's internal promise members: `result`, +`exec`, `exec_`, `signal_set` and `signal`. Compiling and running the +integration against the pinned Boost is its compatibility check. A future +Boost change may require updating this adapter. Linking Cobalt's original +runner instead is a fallback with its original behavior, without webcpp's +turn limit; the two runners must not be linked together. + +On WASIp2/P3, the runner omits the POSIX signal headers, registration and cleanup, +and initializes the promise's `signal_set` pointer to null. This removes its +dependency on `SIGINT` and `SIGTERM`; it does not remove Asio's internal +`cancellation_signal` or Cobalt's coroutine cancellation machinery. Native and +Emscripten builds keep the existing process-signal integration. + +A WASI host cannot request graceful shutdown through this automatic signal +bridge. An application needs an explicit host/component shutdown protocol that +requests cancellation on its executor and lets pending operations finish their +cleanup. Calling `io_context::stop()` alone does not do that, and forcibly +terminating the component does not guarantee {cpp} cleanup. No host shutdown API +is supplied by this runner change. + +The `cobalt_main_wasip3` compile test checks the actual runner without requiring +signal emulation. Public-target tests additionally execute timers, Asio socket +operations through `use_op`, Cobalt's own IP socket wrappers and cancellation. + +[#asio-cobalt-status] +=== Completion and limitations + +The runner preserves `co_return` as the process exit status. Under Asyncify, +a suspended `main` cannot simply return that status: the replacement exits +explicitly after the context and signal set have been destroyed. Tests check +that a timer followed by `co_return 7` exits with exactly 7. With Emscripten's +default `EXIT_RUNTIME=0`, a debug Asyncify build may print its runtime-retained +notice after `std::exit`; the integration does not force runtime shutdown. + +The WASI runner returns the coroutine's result to wasi-libc. In wasi-sdk 34.0, +the command startup code reduces that integer to success or failure before +returning through `wasi:cli/run`. In the local runner probe, `co_return 7` +therefore produces host exit status 1, while `co_return 0` produces 0. This +runtime mapping is separate from process-signal cancellation; do not assume +that every target exposes an arbitrary nonzero exit code unchanged. + +The plain Cobalt target keeps OpenSSL optional. For Cobalt's own SSL stream, +use <>. Asio SSL streams with `boost::cobalt::use_op` remain +available by combining `/webcpp/asio//cobalt` and `/webcpp/asio//tls`. + +[#asio-cobalt-verify] +=== Reference: checks and suspension storage + +`cobalt_test.cpp` runs 5,000 posts, checks the yield counter against the +configured default (100 handlers), observes a separate page timer, and awaits both timer +APIs. It does not assume that a JavaScript timer runs at a fixed callback index. +The exact-exit drivers check both 7 and 0, with no completion helper in the +program being checked. Run them locally with: + +[source,bash] +---- +b2 libs/asio/test//cobalt +b2 toolset=emscripten libs/asio/test//cobalt +b2 toolset=emscripten libs/asio/test//cobalt_asyncify +---- + +The Asyncify stack probe covers the yield and forced blocking waits through +both timer APIs. Its largest Cobalt observation was 1,088 bytes in a release +build with the toolset's default link, with exceptions; release linked with +`-O3` used at most 384 bytes. Debug used at most 1,032 bytes. The configured +8,192 bytes therefore remains unchanged. These are suspension-stack readings, +not binary sizes or a guarantee about arbitrary application call depth. + +[#asio-cobalt-sizes] +=== Reference: release binary sizes + +The timer example above was measured with Emscripten 6.0.11, Boost 1.92, +{cpp}20 and Node 26.7.0 on macOS arm64, on 2026-10-15. Each of the twelve +configurations used its own build directory, with `variant=release`, +`NDEBUG`, matching compile and link optimization flags, and an 8192-byte +Asyncify suspension stack. Compile commands were checked for the requested +optimization and exception mode; LTO objects were checked for LLVM bitcode. + +All 24 page modules completed once under Node, reporting status zero and +exactly `cobalt slept`. The `-O2` modules also passed in local HeadlessChrome +153.0.8010.12 under both suspension variants and both exception modes. +The other optimization profiles were not individually tested in Chrome. +These are complete modules, including the Cobalt runner and the selected +library code, without the Node test harness. Sizes are uncompressed bytes; +JavaScript excludes the shared loader and HTML. Add the matching Wasm and +JavaScript columns for the two-file payload. These measurements do not +isolate the size added by Cobalt and are not runtime-memory measurements. + +.asio_cobalt: uncompressed release bytes +[cols="2,1,2,2,2,2",options="header"] +|=== +| Flags | Exceptions | JSPI Wasm | Asyncify Wasm | JSPI JavaScript | Asyncify JavaScript +| `-O2` | on | 106,576 | 217,448 | 79,879 | 91,502 +| `-O2` | off | 89,343 | 144,979 | 79,917 | 84,340 +| `-O3` | on | 107,528 | 212,837 | 79,480 | 90,057 +| `-O3` | off | 88,619 | 141,357 | 79,074 | 83,007 +| `-Os` | on | 95,141 | 199,988 | 79,480 | 89,676 +| `-Os` | off | 78,139 | 133,278 | 79,074 | 83,007 +| `-Oz` | on | 87,956 | 196,771 | 78,909 | 89,103 +| `-Oz` | off | 73,602 | 134,390 | 78,503 | 82,436 +| `-O3 -flto` | on | 113,033 | 193,297 | 80,690 | 90,115 +| `-O3 -flto` | off | 88,243 | 132,345 | 80,684 | 83,628 +| `-Oz -flto` | on | 82,107 | 163,883 | 80,119 | 89,544 +| `-Oz -flto` | off | 70,016 | 123,353 | 80,113 | 83,057 +|=== + +To reproduce one pair, run from the superproject root: + +[source,bash] +---- +b2 -a -j4 --build-dir=bin/cobalt-size-oz-lto-on \ + toolset=emscripten variant=release exception-handling=on \ + "cxxflags=-Oz -flto" "linkflags=-Oz -flto" \ + libs/asio/example//page-asio_cobalt.variants.json +---- + +Use the profiles in <> and a separate build directory for +each profile and exception mode. The `asio.sizes.md` table generated by the +example's `asyncify` lane now includes this example. These single builds +establish file sizes and successful execution; they do not supply repeated +build-time or execution-time benchmarks. Task 14's timing tables remain +measurements of its original three examples, without Cobalt. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/feature-matrix.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/feature-matrix.adoc new file mode 100644 index 0000000..91e521d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/feature-matrix.adoc @@ -0,0 +1,637 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-feature-matrix] +=== Feature matrix by library and build profile + +This records the WebCPP integration and capability-completion work verified +on 2026-11-03, using +Boost 1.92.0, Emscripten 6.0.11 and wasi-sdk 34.0. The project now selects +Wasmtime 50.0.1 for its regression suites; the original isolated probes used +Wasmtime 49.0.3. It is not a +list of everything those upstream projects might support in other builds. +The Asio target is `/webcpp/asio//asio`; the Cobalt integration is +`/webcpp/asio//cobalt`, using Boost.Cobalt's names. Do not infer that an Asio +feature has also been tested through a Cobalt wrapper or completion token. + +Each cell describes the named feature, not every overload or possible input. +Read the profile availability table first: an unavailable profile makes all +of its public features unavailable, even if an isolated source file compiles. + +.Status legend +[cols="1,5",options="header"] +|=== +| Mark | Meaning +| T | Tested: the named behavior has local runtime evidence in this profile. +| A | Provided by the backend or Boost contract; dedicated runtime validation +is pending. Treat this as a validation task, not as a tested support guarantee. +| L | Limited: usable only within the restriction explained beside the table. +| U | Unverified: there is insufficient evidence to promise this combination. +| X | Unavailable through this integration or the tested toolchain. +| B | Build integration blocked: WebCPP rejects the library target before +compilation. Read the named blocker; this does not establish a platform limit. +| P | Probe only: isolated runtime evidence, outside the public library target. +This is progress toward a port, not an available application configuration. +| C | Compile only: an isolated source compiles; linking and execution are unverified. +| N/A | The feature is specific to another environment. +|=== + +[#asio-feature-profiles] +==== Profile availability + +`EH on/off` means `exception-handling=on/off`. `S/M` means +`threading=single/multi`. Every on/off pair below refers to both choices; +it does not conceal a requirement for exceptions. + +[cols="2,2,1,1,1,4",options="header"] +|=== +| Environment | Thread profile | EH | Asio | Cobalt | Qualification +| Native | S | on | T | T | Existing backend; native evidence is macOS arm64. +| Native | S | off | T | L | Cobalt issue 287 applies to pending-task moves. +| Native | M | on | T | T | Cobalt runner, IP wrappers and thread completion/join tested. +| Native | M | off | T | L | Same tested paths, with Cobalt issue 287. +| Native | Asio threads disabled with `BOOST_ASIO_DISABLE_THREADS` | on/off | U | U +| A separate profile with Asio's thread support disabled has not been validated. +| Browser / JSPI | S | on | T | T | Requires a JSPI-capable engine. +| Browser / JSPI | S | off | T | L | Cobalt issue 287; use result-based paths. +| Browser / JSPI | M | on | T | T | Isolated page and creator-thread affinity. +| Browser / JSPI | M | off | T | L | Same profile; Cobalt issue 287 applies. +| Browser / Asyncify | S | on | T | T | Uses the configured Asyncify stack. +| Browser / Asyncify | S | off | T | L | Cobalt issue 287; use result-based paths. +| Browser / Asyncify | M | on | T | T | Isolated page and creator-thread affinity. +| Browser / Asyncify | M | off | T | L | Same profile; Cobalt issue 287 applies. +| WASIp3 | S | on | T | T | Public Cobalt target; Asio threads disabled. +| WASIp3 | S | off | T | L | Same tested target; pending-task moves retain issue 287. +| WASIp3 | M, cooperative | on | X | X | SDK 34.0 lacks the cooperative {cpp} EH runtime. +| WASIp3 | M, cooperative | off | T | L | Public Cobalt target, including its +thread coroutine; SDK cooperative runtime and Cobalt issue 287 apply. +| WASIp2 | S | on | T | T | Core, DNS, CLI streams, Cobalt and TLS consumers. +| WASIp2 | S | off | T | L | Same consumers; Cobalt issue 287 applies. +| WASIp2 | M | on/off | X | X | Pinned SDK has no supported P2 pthread runtime/profile. +|=== + +*Native S is not a promise of no threads.* The native build does not set +`BOOST_ASIO_DISABLE_THREADS`. Boost may use internal threads, for example for +asynchronous name resolution. Explicitly disabling Asio threads is a different +configuration and must be applied consistently to the application and compiled +dependencies. It does not disable unrelated libraries' threads. + +Browser S sets `BOOST_ASIO_DISABLE_THREADS`; explicit M enables pthreads in +the application and compiled dependencies. WASIp3 S also disables Asio threads. WASIp3 M +uses cooperative threads, not simultaneous CPU execution on multiple cores. +The missing cooperative EH runtime is a limitation of the SDK distribution +tested here, not proof that threads and exceptions are fundamentally incompatible. + +`variant=release/debug` changes optimization, not these feature declarations. +The WASIp3 evidence here uses Release. Native operating-system features remain +subject to Boost and the host OS; macOS results are not Windows or Linux tests. + +[#asio-feature-native] +==== Asio: native + +The S/M columns use the build profiles above, not a count of active application +threads. The strict thread-disabled profile remains U for all features here. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | S / EH on | S / EH off | M / EH on | M / EH off +| Context, executors and posting | T | T | T | T +| Complete run/poll family | T | T | T | T +| Timers, expiry and cancellation | T | T | T | T +| Cross-thread post and multiple context runners | A | A | T | T +| Strands and thread pools | A | A | A | A +| Asio `awaitable`, `co_spawn`, result-based timer wait | T | T | T | T +| Context and associated-handler allocation routing | T | T | T | T +| IPv4 TCP connect/accept, read/write, EOF and cancellation | T | T | T | T +| IPv4 UDP single-buffer datagrams | T | T | T | T +| UDP multi-buffer `send_to` / `async_send_to` | T | T | T | T +| UDP multi-buffer receive and connected send | T | T | A | A +| Synchronous and asynchronous DNS | A | A | A | A +| IPv6 traffic, multicast and socket options | A | A | A | A +| TLS through Asio/OpenSSL | T | T | T | T +| Process signals, local sockets and serial ports | A | A | A | A +| Files, descriptors, pipes and platform-specific Asio backends | A | A | A | A +| Browser Promise/DOM bridge and turn limit | N/A | N/A | N/A | N/A +|=== + +Asio availability follows the native backend, including platform feature +macros. A does not mean every operating system supplies every row's APIs. +TLS T refers to the tested Clang/macOS recipe, not an MSVC recipe. Exceptions +off retain error-code and callback paths; throwing error paths require the +qualification in <>. + +[#asio-feature-browser] +==== Asio: browser / Emscripten + +The first table covers S. The M table below records narrower real-browser +worker coverage; S results are not automatically evidence for M. +T includes the project's local Emscripten tests under Node; it does not mean +every case was independently exercised in every browser engine. +The coroutine timer row also passed in HeadlessChrome 153.0.8010.12 in all +four columns, linked for the browser without Node's raw-filesystem option. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | JSPI / EH on | JSPI / EH off | Asyncify / EH on | Asyncify / EH off +| Context, run/poll family, posting and timers | T | T | T | T +| Bounded turns and explicit browser yield | T | T | T | T +| Context and associated-handler allocation routing | T | T | T | T +| JavaScript Promise operations and event bridge | T | T | T | T +| Promise/event cancellation | T | T | T | T +| Socket API with a supplied custom transport | L | L | L | L +| Direct native TCP/UDP through the default transport | X | X | X | X +| Browser resolver retaining a name for a transport | T | T | T | T +| OS DNS lookup through that resolver | X | X | X | X +| Asio `awaitable`, `co_spawn`, result-based timer wait | T | T | T | T +| Strands on the single executor | A | A | A | A +| Worker-thread execution | X | X | X | X +| TLS settings for a transport | T | T | T | T +| Linked OpenSSL through the native/WASI TLS target | X | X | X | X +| Supplied WebSocket, HTTP or Fetch stream adapter | X | X | X | X +| Host POSIX signals, local sockets and serial ports | X | X | X | X +| Native-style files/descriptors through this integration | U | U | U | U +|=== + +L for sockets means that the default transport reports +`operation_not_supported`; the application supplies a transport with the +required semantics. This is not raw browser TCP/UDP access. Browser HTTPS or +WSS capabilities do not by themselves supply an Asio/OpenSSL stream adapter. +The SSL settings record does not encrypt data. See <>. + +The run family must execute on a stack configured for suspension. A browser +yield gives the host an opportunity to run; it does not guarantee a timer +deadline or a rendered frame. EH on uses Wasm exceptions with JSPI and the +configured JavaScript exception mechanism with Asyncify. + +[#asio-feature-browser-workers] +===== Browser pthread profiles + +These columns use `threading=multi` and real HeadlessChrome 156.0.8078.4 with +isolation headers. Run each context on its constructing thread; post between +threads. See <> for lifetime and hosting requirements. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | JSPI / EH on | JSPI / EH off | Asyncify / EH on | Asyncify / EH off +| Main-context wait woken by a browser event | T | T | T | T +| Worker timer, cross-thread wakeup and main DOM handoff | T | T | T | T +| Timer cancellation delivered through the main executor | T | T | T | T +| Context/handler allocators and queued-handler shutdown | T | T | T | T +| Reentrant context destruction with queued work | T | T | T | T +| Cleanup when moving a handler throws | T | N/A | T | N/A +| Reject running a context from a different thread | T | T | T | T +| Multiple simultaneous runners of one browser context | X | X | X | X +| Complete S scheduling, transport and Promise suite under M | U | U | U | U +| Raw pthread return value after an async suspension | T | T | X | X +|=== + +The last row is a dependency-only witness. A suspended pthread returning pointer +value 42 joins with zero under the pinned Asyncify SDK. The versioned probe fails +that assertion; void-return workers with explicit result storage pass in both +variants. This runtime path cannot be identified by a target macro. It is not a +blanket prohibition of pthreads with Asyncify. + +[#asio-feature-wasip2] +==== Asio on WASIp2 + +Both columns use `threading=single`, SDK 34.0 and Wasmtime 50.0.1. +Multiple threads are rejected before compilation. T is limited to the stated +consumer contracts, not every Boost.Asio overload. + +[cols="4,1,1",options="header"] +|=== +| Feature | EH on | EH off +| Run/poll family, timers and timer cancellation | T | T +| TCP connect/accept, partial transfer and shutdown | T | T +| UDP scalar, empty datagrams and gathered send_to | T | T +| Pending socket cancellation | T | T +| Async forward DNS, deferred initiation and associated executor | T | T +| Resolver-wide and per-operation cancellation | T | T +| Numeric synchronous resolution | T | T +| Canonical name, mapped-address policy and async reverse DNS | X | X +| Asio timer coroutine | T | T +| CLI stream pending read cancellation, allocator and executor | T | T +| CLI stream WebSocket client/server, text/binary and close | T | T +| UDP multiple-buffer receive and connected multiple-buffer send | T | T +| POSIX signals, local sockets and serial ports | X | X +| Asio/OpenSSL TLS, roots and peer verification | T | T +| Cobalt runner/wrappers and SSL integration | T | L +| Parallel threads, thread pools and cross-thread post | X | X +|=== + +See <> for resolver flag/allocation limits and +<> for the host-import blocking boundary. Pollable-based +waiting does not make an independently blocking host import preemptible. + +[#asio-feature-wasip3] +==== Asio: WASIp3 + +M is the SDK's cooperative profile. X in its EH-on column reflects the missing +runtime, including rows that do not otherwise need exceptions. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | S / EH on | S / EH off | M / EH on | M / EH off +| Context, run/poll family, posting and timers | T | T | X | T +| Cross-thread post and multiple context runners | X | X | X | T +| Strands | A | A | X | A +| Thread pools | X | X | X | U +| Asio `awaitable`, `co_spawn`, result-based timer wait | T | T | X | T +| Context/timer/post allocators with dedicated allocation counters | T | T | X | T +| Allocation routing in UDP gather operations | T | T | X | T +| IPv4 TCP connect/accept, read/write, EOF and cancellation | T | T | X | T +| TCP composed read/write with multiple buffers | T | T | X | T +| IPv4 UDP, including empty datagrams | T | T | X | T +| UDP multi-buffer `send_to` / `async_send_to` | T | T | X | T +| UDP multi-buffer receive or connected send | T | T | X | T +| Synchronous resolver: numeric addresses and localhost | T | T | X | T +| Asynchronous forward resolver | T | T | X | T +| Arbitrary external DNS and network reachability | U | U | X | U +| IPv6 numeric scope parsing and formatting | T | T | X | T +| IPv6 connections and multicast interoperability | U | U | X | U +| Interface-name IPv6 scopes | X | X | X | X +| Socket options | L | L | X | L +| `available` / `FIONREAD`, peek and out-of-band marks | X | X | X | X +| TLS through Asio/OpenSSL | T | T | X | T +| Process signals, local sockets and serial ports | X | X | X | X +| Asio file/pipe/descriptor runtime integration | U | U | X | U +| Browser Promise/DOM bridge and browser turn limit | N/A | N/A | X | N/A +|=== + +Both profiles use native asynchronous forward lookup with a waitable-backed +reactor descriptor. Deferred initiation, real localhost lookup, timer progress, +cancellation and allocator routing are tested. The cooperative lane also checks +two-runner cancellation after the host waitable joins the active wait set. +External DNS and network access still depend on host capabilities. + +UDP gather/scatter preserves one datagram and uses the caller-associated +allocator, including connected sends, truncation, empty buffers and cancellation. +The separate context/timer/post counters now cover all three supported WASIp3 +profiles; narrowly attributed libc wakeup-pipe allocations remain outside the +Asio allocator contract. These scenarios are not a complete audit of every +operation. Socket-option limits are in +<>. TLS support does not automatically validate a Cobalt +TLS completion token or `boost::cobalt::io::ssl::stream`. + +[#asio-feature-cobalt-native] +==== Cobalt: native + +These cells apply to the existing Cobalt build target. S does not disable +`boost::cobalt::thread` or guarantee that Cobalt cannot create threads. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | S / EH on | S / EH off | M / EH on | M / EH off +| `co_main`, posting, timer suspension and exact exit status | T | T | T | T +| Await Asio timers with Cobalt's `use_op` | T | T | T | T +| Cobalt `io::steady_timer` | T | T | T | T +| Await Asio IPv4 TCP/UDP, cancellation and EOF with `use_op` | T | T | T | T +| Cobalt `io` TCP/UDP wrappers and numeric resolver | T | T | T | T +| Tasks, promises, generators and composition algorithms | A | U | A | U +| Moving a pending task safely without exception support | N/A | X | N/A | X +| Channels and wait groups | A | A | A | A +| PMR coroutine allocation | A | A | A | A +| Internal coroutine cancellation | A | A | A | A +| Automatic SIGINT/SIGTERM cancellation in the runner | A | A | A | A +| Cobalt thread coroutine completion and join | U | U | T | T +| Cobalt file/pipe/serial/local-socket wrappers | A | A | A | A +| Await Asio/OpenSSL TLS through a Cobalt token | T | T | T | T +| Cobalt `io::ssl::stream` via `cobalt_ssl` | T | T | T | T +|=== + +The task limitation is <>; A for other +EH-off APIs does not establish universal exception-free safety. The thread +coroutine also has internal exception-handling paths that require a dedicated +failure-path audit without EH. Native I/O rows are subject to the OS and Boost +feature macros. Cobalt's SSL wrapper is supplied by the optional +`/webcpp/asio//cobalt_ssl` target; plain Cobalt remains independent of OpenSSL. + +The M thread test creates a Cobalt thread coroutine and awaits its completion. +It does not establish correctness of arbitrary concurrent coroutine composition. +The network test uses Asio socket types with Cobalt's completion token; it does +not validate Cobalt's separate `io` socket wrappers. The independent `cobalt_io` +test supplies that wrapper evidence, including refused TCP connections, +TCP/UDP cancellation and numeric resolution. + +[#asio-feature-cobalt-browser] +==== Cobalt: browser / Emscripten + +The following columns cover S. M has separate evidence below. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | JSPI / EH on | JSPI / EH off | Asyncify / EH on | Asyncify / EH off +| `co_main`, posting, timer suspension and exact exit status | T | T | T | T +| Runner's bounded turns | T | T | T | T +| Await Asio timers with `use_op` | T | T | T | T +| Cobalt `io::steady_timer` | T | T | T | T +| Await JavaScript Promise operations through Cobalt | T | T | T | T +| Await the custom socket transport through Cobalt | U | U | U | U +| Direct TCP/UDP using Cobalt's `io` socket wrappers | X | X | X | X +| Tasks, promises, generators and composition algorithms | U | U | U | U +| Moving a pending task safely without exception support | N/A | X | N/A | X +| Channels and wait groups | U | U | U | U +| PMR allocation and cancellation across all coroutine families | U | U | U | U +| Cobalt thread coroutine | X | X | X | X +| Host SIGINT/SIGTERM notifications | X | X | X | X +| Cobalt file/pipe runtime behavior | U | U | U | U +| Native local sockets and serial ports | X | X | X | X +| Cobalt `io::ssl::stream` compiled implementation | X | X | X | X +|=== + +The runner retains Emscripten's existing signal registration, but that does +not supply POSIX process notifications from a browser host. The successful +timer and Promise tests do not establish every Cobalt composition or I/O API. +Asyncify tests also measure suspension-stack usage; application call depth +still needs an appropriate configured stack, as explained in <>. + +M passes the public Cobalt thread posting/completion/join test in all four +suspension/EH combinations. Broader composition, cancellation and Promise paths +under M remain unverified. The completed-thread join still emits the SDK's main +thread blocking warning; Asyncify also emits its documented successful exit notice. +The driver matches only these exact notices. This does not authorize waiting +synchronously on a live worker from the browser main thread. + +[#asio-feature-cobalt-wasip2] +==== Cobalt: WASIp2 + +Both columns use `threading=single`, the public `//cobalt` or optional +`//cobalt_ssl` target, SDK 34.0 and Wasmtime 50.0.1. + +[cols="4,1,1",options="header"] +|=== +| Feature | EH on | EH off +| Runner, bounded posting, timers and exact exit status | T | T +| Asio TCP/UDP with `use_op` and Cobalt IP wrappers | T | T +| Pending accept/read/resolver cancellation | T | T +| Asio/OpenSSL and Cobalt SSL verified TLS | T | T +| Cobalt SSL transfer/shutdown errors and cancellation | T | T +| Entropy-backed key generation and failure handling | T | T +| Moving a pending task safely without exception support | N/A | X +| Thread coroutine, local sockets, serial ports and POSIX signals | X | X +| Broader coroutine families and filesystem I/O | U | U +|=== + +The focused suite has 13 checks per EH profile. Entropy tests observe calls to +host `getentropy`, distinct generated keys and failure handling; they do not +measure the host RNG's entropy strength. TLS uses the shared source-built +OpenSSL and embedded/replacement CA provider. Host networking grants and trust +policy remain application/runtime requirements. + +[#asio-feature-cobalt-wasip3] +==== Cobalt: WASIp3 + +The public dependency `/webcpp/asio//cobalt` builds and runs in all three +available profiles. M/EH on remains X because SDK 34.0 lacks that runtime. +EH-off tests do not remove the pending-task move restriction in issue 287. + +[cols="4,1,1,1,1",options="header"] +|=== +| Feature | S / EH on | S / EH off | M / EH on | M / EH off +| Runner without POSIX signal registration | T | T | X | T +| Await Asio and Cobalt timers in `co_main` | T | T | X | T +| Return success/failure through the WASI command entry point | T | T | X | T +| Await Asio IPv4 TCP/UDP, cancellation and EOF with `use_op` | T | T | X | T +| Cobalt `io` IPv4 TCP/UDP wrappers, cancellation and EOF | T | T | X | T +| Cobalt async resolver: numeric address | T | T | X | T +| Task result and eager promise completion | T | T | X | T +| Generators, channels and composition | U | U | X | U +| Cobalt thread coroutine completion and join | X | X | X | T +| Automatic SIGINT/SIGTERM cancellation | X | X | X | X +| Cobalt file/pipe/descriptor runtime integration | U | U | X | U +| Cobalt local sockets and serial ports | X | X | X | X +| Await Asio/OpenSSL TLS with a Cobalt token | T | T | X | T +| Cobalt `io::ssl::stream` via `cobalt_ssl` | T | T | X | T +|=== + +Numeric asynchronous resolution is tested through Cobalt's compiled resolver +in the supported profiles above. WASIp3's single-thread and cooperative profiles +use the native asynchronous forward resolver; the Asio consumers test localhost +lookup, deferred initiation, progress and cancellation. Arbitrary external DNS +access depends on host policy and is not established by localhost or numeric +consumers. + +[#asio-feature-cobalt-build-block] +===== How the Cobalt source integration works + +The target builds the normal compiled archive, replacing its endpoint and +acceptor source files with checked private copies. The private header overlay +uses Asio capability macros to omit unsupported local-socket, signal and serial +APIs. Seqpacket declarations are omitted when that socket type is unavailable. +Single-thread builds omit the thread source and declaration; cooperative builds +include it. Native and browser builds retain their original sources and headers. + +The application, archive and replacement runner use the same patched Asio +headers, thread profile and exception setting. No system Cobalt archive is +linked, and installed Boost files are never modified. Input/output hashes pin +the compatibility patch to Boost 1.92. A changed upstream input is rejected. + +The public-target tests cover both Cobalt completion tokens applied to Asio +sockets and Cobalt's own compiled TCP/UDP wrappers, with IPv4 loopback traffic, +refused TCP connections, TCP EOF and TCP/UDP cancellation. +TLS tests add the ordinary Asio/OpenSSL stream and +Cobalt token, with custom or embedded CAs and peer identity verification. + +SDK 34.0 maps nonzero command returns to failure: the host statuses are 0 for +`co_return 0` and 1 for `co_return 7`. The status driver checks both output and +status, so a trap cannot satisfy the failure case. No host shutdown protocol +has been added. See <> and <>. + +[#asio-feature-errors] +==== Exceptions and error handling + +[cols="3,3,3",options="header"] +|=== +| Behavior | EH on | EH off +| Error-code overloads and callback error parameters +| Available where the underlying operation is available +| Same error channels; no exception is needed to report an ordinary I/O error +| Result/tuple adapters around an asynchronous wait +| Available | Available for the tested paths; underlying operation support still applies +| Throwing overload invoked on an error +| Can report an exception according to the API contract +| May be excluded by the wrapper or reach the fatal Boost exception handler; +do not treat it as an error-code overload +| Exceptions escaping a coroutine +| Follows the coroutine's documented propagation policy +| No guarantee of recoverable propagation; use supported result-based paths +| Cobalt pending-task move with `libc++` +| No exception-disabled limitation claimed here +| Known abort risk linked to https://github.com/boostorg/cobalt/issues/287[Cobalt issue 287] +| WASIp3 cooperative profile in SDK 34.0 +| Missing runtime in this distribution | Available for the tested Asio feature set +|=== + +Result adapters do not repair a library operation that constructs an exception +object internally. The Cobalt EH-off build warning is a configuration warning, +so the compiler's warnings-as-errors setting does not turn that warning into +a build failure. It remains a restriction the application must account for. + +[#asio-feature-restrictions] +==== Restrictions, causes and application consequences + +[cols="2,3,4",options="header"] +|=== +| Restriction | Cause | Consequence or required work +| WASIp3 cooperative threads with EH +| SDK 34.0's cooperative sysroot is built without the {cpp} exception runtime +| Use S/EH on or M/EH off. Supporting M/EH on needs a matching runtime build +and runtime validation, not just adding `-fexceptions` to an application. +| Native S versus disabled thread support +| `threading=single` does not define `BOOST_ASIO_DISABLE_THREADS` natively +| Native S can still use internal threads. Explicit thread disabling needs +consistent library/application settings and its own validation. +| Browser M hosting and affinity +| Pthreads need isolated shared memory; JavaScript values have thread affinity +| Use the creator thread to run each context and the main executor for DOM work. +Configure COOP/COEP when hosting; compiler macros cannot verify deployment. +| Browser sockets and TLS +| The default transport returns `operation_not_supported`; only a transport +interface and TLS settings are supplied +| Supply and validate an adapter. These APIs do not expose raw browser TCP/UDP +or provide an OpenSSL stream. See <>. +| WASI reverse DNS and canonical/mapped-name policies +| The host lookup interface supplies forward address results +| Unsupported async policies report `operation_not_supported`. Host DNS permission +remains a runtime fact; numeric and forward lookup paths are available. +| WASIp3 UDP buffer sequences +| The tested wasi-libc lacks the vectored socket calls used by stock Asio +| The port supplies gather sends and scatter receives, including connected sends, +with temporary allocator-aware storage. See <>. +| WASIp3 socket options and IPv6 scopes +| The port exposes only the tested libc interfaces +| Missing options return `operation_not_supported`; interface-name scopes are +rejected. Numeric IPv6 scope parsing is tested, IPv6 traffic is not. +| WASIp3 process signals and OS-specific devices +| This port has no POSIX signal service, local-socket family or serial backend +| There is no automatic SIGINT/SIGTERM cancellation. Explicit operation +cancellation works; a host shutdown protocol would be separate integration work. +| Cobalt pending-task move without EH +| Boost 1.92's move path can construct an exception with `std::make_exception_ptr`; +the reported `libc++` no-EH configuration aborts +| See https://github.com/boostorg/cobalt/issues/287[issue 287]. This concerns +the pending task's move implementation, not every `std::move` or every coroutine. +Result adapters do not repair this internal path. Other coroutine families +still need their own success, error and cancellation tests. +| Cobalt `io::ssl::stream` +| Available through an optional target with a checked Boost 1.92 patch +| `/webcpp/asio//cobalt_ssl` adds the wrapper, state/callback corrections and +`native_ssl_handle()` extension. Native, P2 S and supported P3 profiles are +available; browser TLS remains host-owned. See +<> for trust configuration and the STARTTLS contract. +|=== + +[#asio-feature-validation-pending] +==== Validation still required + +A and U are open validation work, not reasons to skip testing. C needs linking +and runtime checks. P needs the same behavior tested through the public target. +This inventory groups the remaining gaps; each test must record its target, +thread/EH profile, tool versions and observed success or supported failure. + +[cols="3,5",options="header"] +|=== +| Pending area | Required evidence before claiming tested support +| Native profile coverage +| Test a consistently Asio-thread-disabled build separately. macOS results +do not validate Windows or Linux platform-specific APIs. +| Strands, pools and concurrent Cobalt +| Check strand serialization and pool shutdown/cancellation in each supplied +profile. The Cobalt thread completion/join test does not cover cancellation, +exception propagation or concurrent coroutine composition. +| Network coverage beyond current loopback cases +| Extend resolver variants, IPv6 traffic, multicast and supported socket options. +Native scatter/connected UDP now has focused S controls. For WASIp3, record host +network/DNS grants and test both permitted and denied operations. +| Cobalt coroutine families +| Add lifecycle, result/error, cancellation and cleanup cases for tasks, +promises, generators, channels, wait groups and composition; measure PMR +allocation/release. Retain issue 287's negative/control evidence separately. +| Cobalt network wrappers and TLS +| Extend IP wrappers to broader resolver/IPv6 cases. Cobalt SSL handshake and +terminal transfer cancellation, buffered ClientHello, STARTTLS, peer verification, +clean/truncated/cancelled shutdown and partial composed transfers are covered. +Connection recovery after terminal cancellation is not established. +| Browser custom transport and I/O +| Await the custom transport through Cobalt with success/error/cancellation; +establish what filesystem/pipe APIs are exposed before testing their runtime +behavior. Node filesystem access is not browser filesystem evidence. +| OS-specific I/O and signals +| Validate each native file/descriptor/pipe/serial/local-socket backend where +available, and runner cancellation on an actual process signal. WASIp3 +file/pipe probes need linking, granted host resources and runtime checks. +| Browser engines and unavailable profiles +| Record real-browser runs for each supported engine; Node evidence alone +does not cover them. Browser M has the focused Chrome coverage above, not the +complete S suite. WASIp3 M/EH on needs a matching SDK runtime before validation. +|=== + +[#asio-feature-evidence] +==== Evidence and maintenance + +The matrix records existing local results; updating this page does not run CI +or establish new feature coverage. T is limited to the behavior exercised by +these tests, not a blanket certification of an upstream library. + +[cols="3,5",options="header"] +|=== +| Feature family | Evidence to maintain +| Native/WASIp3 context, TCP/UDP, timers and threads +| `wasi_core`, explicit `wasi_core_threads`, `wasi_contract`, +`wasi_coroutine`, `run_family_native/wasip3`, `timers_native/wasip3` +| UDP multi-buffer sends and their allocators +| `wasi_udp_gather`; keep receive and connected-send limits distinct +| Native M run/poll and allocation coverage +| `run_family_native`, `allocation_native` and `wasi_udp_gather`, Release +with `threading=multi` and both EH settings +| WASI datagram sequences and DNS +| `capability_wasi` plus `wasi-dns-threads`: retries, canonical cleanup, +timer progress, cancellation and two-runner ownership +| Browser M contexts and main-thread handoff +| `test/browser//browser-workers`, both suspensions and EH settings; +`test/browser/probes/pthread_return.cpp` is the separate SDK counterexample +| P2 Cobalt/TLS +| `test/wasip2_tls_cobalt` and its `wasip2-tls` lane in both EH profiles +| Browser scheduling, timers, Promise/event bridge and transports +| `reactor`, `run_family`, `turn_limit`, `timers`, `allocation`, `promise`, +`event`, `sockets`, `transport`, `resolver`, and their declared suspension/EH variants +| Asio coroutine timer in browser configurations +| `asio_coroutine_exceptions_on/off` and Asyncify counterparts under Node; +the same coroutine timer also passed in HeadlessChrome 153.0.8010.12 for all +four variants. The browser links replace `-sNODERAWFS=1` with `-sENVIRONMENT=web`. +The test uses `awaitable`, `co_spawn` and result-based timer completion. +| Cobalt native/browser runner and timers +| `cobalt_exceptions_on/off_native`, Emscripten counterparts and Asyncify +counterparts; the `cobalt` and `cobalt_asyncify` exact-exit driver lanes +| Cobalt token with native Asio sockets +| `cobalt_network_exceptions_on/off`, in S and M: IPv4 TCP/UDP data, +pending-receive cancellation and TCP EOF +| Browser Promise/Cobalt interoperability +| `promise_cobalt_exceptions_on/off` and Asyncify counterparts +| WASIp3 runner compile regression +| `cobalt_main_wasip3`, with S EH on/off and M EH off +| WASIp3 Cobalt runtime tests +| `cobalt_wasi`, `cobalt_network_wasi`, `cobalt_io`, explicit `cobalt_thread` +and the `cobalt_wasip3` status lane, all through the public target +| Cobalt TLS over Asio/OpenSSL +| `tools/openssl/test//cobalt_tls_client` and `tools/openssl/test/tls.py --embedded` +| Cobalt SSL wrapper +| `tools/openssl/test//cobalt_ssl_client` with `tls.py --embedded --require-sni`, +including `--client-arg=buffered`; `cobalt_ssl_state` and `cobalt_ssl_cancel` +with `--state-test`, for TLS 1.2/1.3 in the recorded native/WASIp3 profiles. +WASIp2 has separate peer, state and cancellation evidence from +`test/wasip2_tls_cobalt//wasip2-tls` in S with EH on/off +| Native/WASIp3 TLS +| Superproject `tools/openssl/test/run.py`: verified TLS 1.2/1.3 handshakes, +application data, shutdown and rejected peer identities in the recorded profiles +|=== + +The commands in <> and <> reproduce the +registered lanes. To promote U, C or P to T, record a successful runtime test +through the intended public target, including the relevant thread and EH +profile. Keep unsupported-operation tests as evidence of a limit, not evidence +that the rejected operation is supported. Update this matrix when a backend, +toolchain, capability guard or test result changes. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/guarantees.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/guarantees.adoc new file mode 100644 index 0000000..5a9c0eb --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/guarantees.adoc @@ -0,0 +1,75 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-guarantees] +== Guarantees + +These contracts apply to the supported calls described in <>. +The numbered anchors are stable: code and tests link to the same guarantee +when its explanation moves. The reference describes individual API members; +these guarantees describe their behaviour together. + +. [[asio-invariant-1]]Natively, `io_context` derives from Boost.Asio's context, + shares its executor type and uses Boost's run family. Browser scheduling + options are accepted without changing native execution. The timer aliases + name Boost's types. See <>; checked by `names`. +. [[asio-invariant-2]]On Emscripten, supported handler execution happens on + the stack of a run family call from `main` or another export configured + for suspension. Posted work and events delivered through the bridge wait + for such a call. See <>; checked by `reactor` and `bridge`. +. [[asio-invariant-3]]A polling turn runs at most `max_handlers_per_turn` + handlers. A full turn yields through a macrotask unless the context is + stopped or its timed call has expired. A wait may run one additional + handler between turns; the bound between yields is therefore at most + twice the limit, not always the limit itself. Timed calls check deadlines + before handlers; they cannot interrupt a running handler or guarantee + when the host resumes them. See <>; checked by `turn_limit`, + `run_family` and `browser_render`. +. [[asio-invariant-4]]A conforming bridge registration only posts completed + work; it does not run or dispatch it inline. A listener alone is not + outstanding work. See <>; checked by `bridge`. +. [[asio-invariant-5]]A bridge registration's key is never reused. An event + for a removed key or a destroyed context delivers nothing. The + registration must outlive its key. See <>; checked by `bridge`. +. [[asio-invariant-6]]On Emscripten, a run family call on a context already + running or delivering a bridge event reports an assertion violation and, + if assertion handling permits execution to continue, returns zero without + running work. It is also refused with assertions disabled. The detection + scope and bypasses are listed in <>; checked by `detection`. +. [[asio-invariant-7]]With exceptions enabled, a handler's {cpp} exception + propagates out of the run family as it does in Boost.Asio, natively and + under both suspension variants. JavaScript errors have different rules. + See <> and <>; + checked by `exceptions`. +. [[asio-invariant-8]]Boost's timers and Beast's timeouts complete through + the reactor on both targets. Timer cancellation retains Boost's semantics, + including cancellation of an individual wait through its associated slot. + See <>; checked by `timers`. +. [[asio-invariant-9]]Context services use the context's allocator; operation + storage uses the handler's associated allocator. Supplying one does not + implicitly supply the other. The named runtime allocations and measurement + limits in <> remain outside that routing claim. + See <>; checked by `allocation`. +. [[asio-invariant-10]]A Promise completes its operation through the bridge + with its value, or with `promise_rejected` and its reason. Cancellation + posts `operation_aborted`; a later settlement cannot complete it again. + See <>; checked by `promise` and `promise_cobalt`. +. [[asio-invariant-11]]A pending Promise or event operation owns outstanding work. + Destroying the context destroys its pending handler without invoking it. + An event wait also removes its listener. See <>; + checked by `promise` and `event`. +. [[asio-invariant-12]]On Emscripten, network operations on a socket or acceptor + fail with `operation_not_supported` unless a transport supplies them. Open + and close manage local state; synchronous failures never block and asynchronous + failures are posted. See <>; checked by `sockets` and `transport`. + +[[asio-invariant-13]] +=== 13. Resolver entries preserve host and service + +On Emscripten, forward resolution returns one entry containing the original +host and service, an unspecified address and the service port. A plain socket +cannot connect to it. `resolver_test.cpp` checks service parsing and posted +completion, including failures. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/names.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/names.adoc index 6a2197e..ff94166 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/names.adoc +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/names.adoc @@ -7,7 +7,9 @@ [#asio-names] == The names -asio's targets are native and emscripten. On each, a name of asio is +asio's targets are native, emscripten, wasip2 and wasip3. The table below compares +native and browser interfaces; <> specifies the WASIp2 and WASIp3 +subsets, which keep Boost's socket and timer types. A name of asio is Boost.Asio's own, or a type with Boost.Asio's interface where the browser needs one of its own: @@ -67,10 +69,10 @@ of each of Boost's constructors: with none, with an allocator, which it allocates its services and its objects' state with, and with Boost's hint of the concurrency it will see, with or without an allocator, so that Boost's idiom `+io_context io{1}+` compiles unchanged. Its one option, -`max_handlers_per_turn`, 1000 by default, bounds the handlers one turn of +`max_handlers_per_turn`, 100 by default, bounds the handlers one turn of its run family runs on emscripten before it yields to the browser; 0 is -taken as 1. Natively the options are accepted and change nothing, since no -page waits on a native loop. +taken as 1. Natively and on WASIp2/P3 the options are accepted and change nothing, since +no browser page waits on these loops. On emscripten, `/webcpp/asio//asio` also gives every program the configuration Asio needs to build there, and the link flags of its diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/promises.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/promises.adoc new file mode 100644 index 0000000..9ba4a72 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/promises.adoc @@ -0,0 +1,110 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + + +[#asio-promises] +== Promises and events + +=== Tutorial: receive a value and a rejection + +On Emscripten, `browser::async_await` connects a JavaScript Promise to an +Asio executor. Build this example with `b2 toolset=emscripten +libs/asio/example//asio_promise.output`. + +[source] +---- +include::{examples}/asio_promise.cpp[tag=program] +---- + +Expected output: + +[listing] +---- +include::{examples}/asio_promise.expected[] +---- + +A callback receives an error code and an `emscripten::val`: +success supplies the resolved value, and `promise_rejected` supplies the +rejection reason. Embind is linked by the library's build requirements. + +=== How-to: choose a completion token or cancel a wait + +Callbacks, `boost::asio::deferred`, `boost::asio::use_awaitable` and +`boost::cobalt::use_op` use the same initiation. Coroutine tokens that turn +errors into exceptions require exception support for that error path. +Use an error-preserving completion token adapter for errors as values. + +Bind a cancellation slot to the handler and emit `terminal`, `partial` or +`total` to complete the wait with `operation_aborted` and `undefined`. +`none` does nothing. Completion is posted, never invoked inside initiation +or the cancellation signal. The Promise itself continues running; any late +settlement finds no registration and cannot complete the operation again. + +=== Reference: values, ownership and allocation + +The completion signature is `+void(boost::system::error_code, emscripten::val)+`. +The rejection category is `webcpp.asio`, with value 1 and message +`the promise was rejected`. JavaScript `Promise.resolve` normalizes inputs: +an ordinary value is accepted, and already-settled Promises still complete +asynchronously. An `undefined` rejection reason is preserved. + +A pending operation owns outstanding work. A Promise that never settles +keeps `run` waiting until cancellation. Destroying the context destroys its +pending handler without invoking it; later settlements are ignored. +Operation storage uses the handler's associated allocator, while the +bridge service and its map use the context's allocator. The operation preserves +the executor's concrete type when passed directly, including its scheduling +properties. An explicitly type-erased `any_io_executor` remains accepted, but +Boost's erased executor can allocate its dispatch wrappers independently of +the handler allocator. Custom executors likewise control their own storage. +For the measured allocation guarantee, pass `io.get_executor()` directly. +See <>. + +=== Explanation: why the bridge posts the result + +JavaScript delivers the settlement through <>. The bridge +posts completion so application code runs on the event-loop stack, where +suspension is supported. It never calls the handler inline from a Promise +reaction. See guarantees <> and <>. + +[#asio-events] +=== Await one browser event + +`browser::async_wait_event(executor, target, type, token)` completes with the +next event of the requested type. It uses a one-shot listener and posts the +event to the executor. The event type is copied into a JavaScript string, +including when initiation is deferred; the view needs no terminating null. +A pending wait owns work. Terminal, partial or total cancellation removes +the listener and posts `operation_aborted` with `undefined`; `none` does nothing. +Context destruction removes the listener and destroys the handler silently. +Storage follows the same allocator and executor rules as Promise waits. + +==== Tutorial: receive a message + +This example creates an EventTarget, waits for its next message, and schedules +a JavaScript timer to send it. Build with `b2 toolset=emscripten +libs/asio/example//asio_event.output`. + +[source] +---- +include::{examples}/asio_event.cpp[tag=program,indent=0] +---- + +Expected output: + +[listing] +---- +include::{examples}/asio_event.expected[] +---- + +The operation removes its listener before posting completion. To receive another +event, initiate another wait. Cancelling the wait does not cancel a JavaScript +timer that might later dispatch an event. + +Pending promise and event waits keep both the owning executor and the handler's +associated executor active. Binding a completion to another context does not +require restarting that context after settlement. Cancellation transfers the +completion to it; destroying the owning context releases both work guards. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/quick-start.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/quick-start.adoc new file mode 100644 index 0000000..6d6efea --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/quick-start.adoc @@ -0,0 +1,92 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-quick-start] +== Tutorial: your first asynchronous program + +We will run a program that prints a message, waits for a timer and returns +from its event loop. You will see when a scheduled handler actually runs +and why the context stays alive while a timer wait is pending. + +You need basic {cpp} knowledge, a webcpp checkout, b2 and a configured native +{cpp}20 compiler. For the second run, you also need the Emscripten and Node +setup described in <>. Run the commands below from the +superproject root. No web server is needed for this first exercise. + +[#asio-quick-start-program] +=== 1. Open the program + +Open `libs/asio/example/asio_quick_start.cpp`. This is the complete program +we will compile, including its headers: + +[source] +---- +include::{examples}/asio_quick_start.cpp[tag=program,indent=0] +---- + +The context owns the event loop. The timer belongs to that context and +stays alive until `main` ends. `post` schedules the first handler; it does +not call it immediately. That handler prints `posted`, arms the timer and +registers its completion handler. This sequence keeps the output order +the same even if the machine pauses before entering `run`. + +[#asio-quick-start-native] +=== 2. Run it natively + +[source,bash] +---- +b2 libs/asio/example//asio_quick_start.output +---- + +The build compiles and executes the program, then compares its output +with the file beside it, `asio_quick_start.expected`. On success, b2 saves +the captured output in `asio_quick_start.output` at the build path printed +by its `run-and-compare` action. Open that file; its contents should be: + +[listing] +---- +include::{examples}/asio_quick_start.expected[] +---- + +The last line uses webcpp's example-test helper to report completion, +including after an Asyncify suspension. It leaves page modules without +the Node harness unchanged. + +Notice that `run` returns after both handlers have run. The timer's 50 ms +is a requested delay, not a promise about exact wall-clock execution time. +The output deliberately shows no measured duration. + +[#asio-quick-start-wasm] +=== 3. Run the same source as WebAssembly + +[source,bash] +---- +b2 toolset=emscripten libs/asio/example//asio_quick_start.output +---- + +Node executes the generated WebAssembly using JSPI. Its `.output` file +contains exactly the same three lines. Next, run it with Asyncify: + +[source,bash] +---- +b2 toolset=emscripten webcpp-suspend=asyncify libs/asio/example//asio_quick_start.output +---- + +Again the output is unchanged. These runs exercise the source and its +suspension under Node; loading a page in a browser is a separate step in +<>. If b2 cannot find a compiler or Node, check +<> before changing the program. If the output differs, +the example runner prints the difference and fails the build. + +[#asio-quick-start-next] +=== 4. Follow the next piece of work + +You have now run the same event loop natively and with both WebAssembly +suspension variants. Follow <> to schedule several +deadlines and cancel a wait, or <> to configure a +finite chain of posted work. For the reason the browser needs a turn +limit, read <>. Exact contracts are in <> +and the generated <>. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/run.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/run.adoc index d5754b4..8ba0960 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/run.adoc +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/run.adoc @@ -10,7 +10,7 @@ The io_context's `run`, `run_one`, `run_for`, `run_until`, `run_one_for` and `run_one_until` keep Boost.Asio's meaning on every target: `run` returns when the io_context is out of work or stopped, `run_one` after one -handler, `run_for` and `run_until` at their deadline at most, and each +handler, `run_for` and `run_until` after their deadline is observed, and each returns the number of handlers it ran. `poll` and `poll_one` are Boost's everywhere. Natively the six are Boost's own, and the options change nothing. @@ -30,7 +30,9 @@ go to step 1. `run_for` and `run_until` are the same composition with Boost's `run_one_until` in step 4. Like Boost's, they check their deadline before each handler, so that a deadline already passed runs nothing, and they -return once it has passed, even when every turn reaches the limit. +return once it has passed, even when every turn reaches the limit. A +running handler cannot be interrupted, and host scheduling can delay +resumption beyond the deadline. `run_one` is step 4 alone, and `run_one_for` and `run_one_until` are Boost's, each running one handler at most. Code that calls `run` through a `boost::asio::io_context&` gets @@ -47,18 +49,18 @@ before a JavaScript `setTimeout(0)` ran, in either suspension variant. Boost's `run` is not virtual and cannot be told to yield, hence the composition. The yield is a suspension, an `EM_ASYNC_JS` import whose promise a -`MessageChannel` message resolves: a macrotask, never a microtask, so that -the browser renders, runs its timers and delivers its events before the -next turn. `MessageChannel` exists in every browser and in node. +`MessageChannel` message resolves: a macrotask rather than only a microtask, giving +the browser an opportunity to render, run timers and deliver events. It does +not guarantee that any particular work happens before the next turn. `MessageChannel` exists in every browser and in node. -[[asio-invariant-3]]*A turn runs at most `max_handlers_per_turn` handlers, +*A turn runs at most `max_handlers_per_turn` handlers, and the run family yields to the browser after each turn that reaches it.* Step 4's one handler belongs to no turn: when it follows a short turn of `k` handlers and its wait ends at once, a timer having fallen due meanwhile, no macrotask comes between them, so that up to -`k + 1 + max_handlers_per_turn` handlers, fewer than twice the limit and -one, can run between two yields. The option is 1000 by default: -measured with Emscripten 6.0.11, the `setTimeout(0)` above then ran after +`k + 1 + max_handlers_per_turn` handlers, at most twice the limit, +can run between two yields. The option is 100 by default. +Historically, with a limit of 1000 and Emscripten 6.0.11, the `setTimeout(0)` above ran after 1,000 handlers under JSPI and 999 under Asyncify, against 300,000 without the limit, and `run` still ran every handler. It is given at construction, `+io_context io(io_context_options{.max_handlers_per_turn = 250})+`, or @@ -70,6 +72,46 @@ itself: one after every `max_handlers_per_turn` handlers under `run` and `run`; and a JavaScript `setTimeout(0)` runs at a yield, seen by the first handler of a turn. And by `run_family`, in each variant. +[#asio-run-default] +=== Configure the build's default turn limit + +`WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN` in `config.hpp` supplies the +initial value of `io_context_options::max_handlers_per_turn`. It defaults +to 100 and can be replaced by a compiler definition, for example to use 1000: + +[source,bash] +---- +-DWEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN=1000 +---- + +For b2, pass the definition on the command line for the complete build: + +[source,bash] +---- +b2 -a --build-dir=bin/asio-limit-1000 toolset=emscripten \ + define=WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN=1000 \ + libs/asio/example//asio_cobalt.output +---- + +Use the same value in every translation unit that uses asio and rebuild all +of them when changing it. In particular, Cobalt's runner is compiled separately: +a definition in an application source file alone cannot configure an existing +runner archive. A separate build directory avoids reusing outputs built with +another definition. Do not mix differently configured objects in one program. + +An explicit option at construction or a later `max_handlers_per_turn(n)` call +overrides this build default for that context. Zero is normalized to one; +negative build defaults are rejected. Native scheduling is unchanged. + +The value 100 is a configurable scheduling policy, not a measured optimum or +a time budget. Smaller values offer more frequent yields under continuous +ready work, with more suspension and scheduling overhead. A single expensive +handler can still block the thread. The original browser measurements used +small self-posting handlers and checked turn duration, not isolated yield cost. +The later <> measures yield latency separately. +See <> for the default's origin and validation, +and <> for the cost model and its limits. + [#asio-run-callers] === Who may call it @@ -86,7 +128,7 @@ event, on the wrong stack. asio's bridge only posts. Nor does a program block the page's thread without suspending, in a busy loop or a blocking system call. -[[asio-invariant-6]]*On emscripten, a run family call made while another +*On emscripten, a run family call made while another runs, or while the bridge delivers a browser event, asserts and returns 0 having run nothing.* The io_context keeps a flag while one of its six members runs, and the bridge counts the deliveries in progress. A call @@ -137,7 +179,7 @@ the program's io_context is safe in either variant. [#asio-run-exceptions] === Exceptions -[[asio-invariant-7]]*A handler's exception propagates out of `run`, as +*A handler's exception propagates out of `run`, as Boost's, on both variants.* Handlers run on the stack of `main`, inside the run family call, so that a {cpp} exception a handler throws leaves `run`, clearing the run family's flag on its way, and reaches the program's @@ -164,7 +206,7 @@ default limit. [#asio-run-main] === Before run, and after main -[[asio-invariant-2]]*On emscripten, handlers run only on the stack of a +*On emscripten, handlers run only on the stack of a run family call*, as natively: work posted before `run` is called waits for it, and a browser event that arrives while no `run` is active is posted and waits for the next one. _Held by_ `reactor`, where work posted before `run` @@ -177,3 +219,36 @@ alive, and its messages queue. After `main` returns, the runtime stays alive, since Emscripten keeps it by default, events keep being posted, and nothing runs them unless an export listed for suspension calls the run family again. + +[#asio-run-configure] +=== How to configure the turn limit + +When ready work repeatedly posts more work, set the limit on the context +that runs it. This program requests turns of 250 handlers and posts a +finite chain of 5,000 pieces of work: + +[source] +---- +include::{examples}/asio_turn_limit.cpp[tag=program,indent=0] +---- + +Run it from the superproject root: + +[source,bash] +---- +b2 toolset=emscripten libs/asio/example//asio_turn_limit.output +---- + +[listing] +---- +include::{examples}/asio_turn_limit.expected[] +---- + +Keep the state alive until `run` returns. Each handler posts the next one +instead of calling it inline, so the context can yield between turns. +Natively the same program prints the same output, but the option does not +change Boost's scheduling. Change the limit to trade handler throughput +against opportunities for the browser to process other work. A handler +that itself blocks for a long time still blocks the page; the option does +not impose a time budget on individual handlers. The measured browser +checks are described in <>. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/sockets.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/sockets.adoc new file mode 100644 index 0000000..6e415a0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/sockets.adoc @@ -0,0 +1,127 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + + +[#asio-sockets] +== Sockets and transports + +=== Explanation: native sockets and browser capabilities + +Native builds use Boost.Asio's socket types directly. Emscripten builds use +webcpp protocol and socket templates with the supported Boost signatures. +They do not call SOCKFS or invent IP addresses through getaddrinfo. Browser +TCP and UDP are unavailable unless a transport supplies the operations. + +With the default transport, opening and closing an object succeeds without +acquiring a network resource. +Opening an already open object reports `already_open`. With the default +transport, network operations return `operation_not_supported`: synchronous +calls return immediately, and asynchronous calls post their completion. +The `error_code&` overloads do not throw; throwing overloads are present only +with exceptions enabled. Queries such as `is_open` describe the local object. + +=== How-to: provide a transport + +Specialize `browser::transport` for a protocol to provide its network +operations. The specialization must be visible before first use in every +translation unit using that protocol. A relay is a separate transport, not a +change to an individual socket's error policy. Its `close()` must cancel pending +operations, release connection resources and return an `error_code`; the socket +forwards closure and marks itself closed on success. Destruction must release +resources as well. Move operations must transfer resources while preserving a +usable executor in the source, so a moved-from socket can be reopened. +Boost.Beast's `tcp_stream` +contains a Boost socket; a relay reaches Beast as an explicitly named next layer. + +=== Reference: supported operations + +Stream sockets support connect, read/write_some, send/receive, shutdown, +options, endpoint queries and non-blocking settings. Datagram sockets add +bind, send_to and receive_from. Acceptors support bind, listen and accept, +including asynchronous acceptance into an existing or returned socket. +Callbacks and deferred tokens use the same asynchronous initiation. +See <> and the generated API reference for overloads. + +=== Tutorial: observe an unsupported connection + +Build and run `asio_sockets` on Emscripten. The object opens locally; connecting +reports a value without attempting a network connection. Closing succeeds. + +[source,cpp] +---- +include::{examples}/asio_sockets.cpp[tag=program,indent=0] +---- + +Expected output: + +[listing] +---- +include::{examples}/asio_sockets.expected[] +---- + +=== Explanation: the resolver preserves names + +On Emscripten, forward resolution constructs one entry with the original host +and service, an unspecified IPv4 address and the service port. This is not a +DNS lookup. A browser stream can retain the name without rewriting a client's +resolve step. A plain socket still refuses connecting to this entry. + +An empty service means port 0. Decimal services accept 0 through 65535; +`http` and `ws` select 80, and `https` and `wss` select 443. Named services +are refused with `numeric_service`. Other services report `service_not_found`. +Reverse resolution reports `operation_not_supported`. Async completion is +posted; cancel does not retract a result already computed at initiation. +See <>. + +=== Tutorial: retain a WebSocket service name + +Build and run `asio_resolver` on Emscripten. The callback receives the retained +name and service, port 443, and an unspecified address. + +[source,cpp] +---- +include::{examples}/asio_resolver.cpp[tag=program,indent=0] +---- + +Expected output: + +[listing] +---- +include::{examples}/asio_resolver.expected[] +---- + +=== Explanation: TLS settings + +Native and WASIp2/P3 `ssl` names are Boost's, with OpenSSL explicitly linked as described +in <>. In the browser, `ssl::context` records method, verification, +options, additional roots and client-credential requests. It does not read +files, parse certificates, implement TLS or execute verification callbacks. +A browser stream adapter must check this record against its capabilities +before use; recording a request successfully does not mean the browser honors it. +The webcpp::beast browser integration consumes these settings. + +A `host_name_verification` request owns its input string. The context copies +that name into its own `std::pmr::string`, using the resource given to its +constructor. The allocation test verifies that recorded copy separately from +the request object's standard string allocation. Other callbacks record the +`other` kind and clear a previously recorded host. + +=== Tutorial: configure peer verification on both targets + +Build and run the `tls` example. Natively this configures an OpenSSL context; +on Emscripten it records the same request for a browser adapter. + +[source,cpp] +---- +include::{examples}/tls/asio_tls.cpp[tag=program,indent=0] +---- + +Expected output on either target: + +[listing] +---- +include::{examples}/tls/asio_tls.expected[] +---- diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/testing.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/testing.adoc index 29da3d1..2136021 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/doc/testing.adoc +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/testing.adoc @@ -7,10 +7,32 @@ [#asio-testing] == Testing +[#asio-testing-application] +=== How to test your application + +For a small program with deterministic text output, follow the compiled +examples: keep an `.expected` file beside its source and declare the program +with `webcpp.example` in its example Jamfile. Run the native target first, +then Emscripten with JSPI and Asyncify. Compare observable completions and +error values; avoid exact elapsed-time assertions, since the host can +resume a ready operation later than its deadline. + +Keep the context and objects captured by handlers alive until their work +finishes. A cancelled operation must still complete with its cancellation +error; merely requesting cancellation does not prove that it was delivered. +Use <> and <> as executable starting +points. Native and Node runs do not establish browser rendering behaviour; +use a real browser when your contract depends on page events or animation. + +[#asio-testing-library] +=== What the library checks + asio's tests are under `test/`, each declared in `test/Jamfile` with -webcpp's rules, for two targets, native and emscripten: -{n-tests} tests in all, {n-tests-native} natively and {n-tests-emscripten} -on emscripten, run by node. Each public header is also compiled alone, as +webcpp's rules, for native, emscripten, wasip2 and wasip3: +{n-tests} tests in all, {n-tests-native} natively, {n-tests-emscripten} +on emscripten, run by node, {n-tests-wasip2} on WASIp2, and {n-tests-wasip3} on WASIp3. +The WASI profiles and local commands are in <> and <>. +Each public header is also compiled alone, as the only include of its translation unit, so that a header that leans on an include it does not make fails, naming it. @@ -18,12 +40,13 @@ include it does not make fails, naming it. first, defines `WEBCPP_ASIO_NO_EXCEPTIONS` when the build has no exceptions, and a program may define it itself to turn asio's exceptions off in a build that has them, as Boost.Asio's `BOOST_ASIO_NO_EXCEPTIONS` does. The tests -`config` and `config_developer_defined` check both ways it is defined. +`config`, `config_developer_defined` and `config_all_off` check compiler, +library-specific and global WebCPP settings. [#asio-testing-lanes] === The lanes -The continuous integration runs asio in four lanes, each built from scratch +In addition to the WASIp2/P3 targets above, asio declares these lanes for the build and test matrix, each built from scratch with `b2 -a` and a `--build-dir` of its own. From the root of a webcpp checkout: @@ -46,11 +69,14 @@ b2 toolset=emscripten libs/asio/test libs/asio/example asyncify:: A lane of asio's own, on emscripten: every browser test again under -Asyncify, the other suspension variant, and the size table of both: +Asyncify, the other suspension variant. Generate the size table separately +in optimized release mode, then execute the guide examples under Asyncify: + [source,bash] ---- -b2 toolset=emscripten libs/asio/test//asyncify libs/asio/example//asyncify +b2 toolset=emscripten libs/asio/test//asyncify +b2 -a toolset=emscripten variant=release linkflags=-O3 libs/asio/example//asyncify +b2 toolset=emscripten webcpp-suspend=asyncify libs/asio/example ---- browser:: @@ -63,9 +89,68 @@ keeps rendering, and the variant the loader picks: b2 toolset=emscripten libs/asio/test/browser//browser ---- +cobalt:: +An exact-exit driver runs the Cobalt entry point with statuses 7 and 0, with +exceptions on and off, natively and under JSPI. A trap cannot count as the +expected nonzero status: ++ +[source,bash] +---- +b2 libs/asio/test//cobalt +b2 toolset=emscripten libs/asio/test//cobalt +---- + +cobalt_asyncify:: +The same exact-exit driver under Asyncify. It is also included in the +`asyncify` test lane: ++ +[source,bash] +---- +b2 toolset=emscripten libs/asio/test//cobalt_asyncify +---- + `b2 libs/asio/test//config` builds and runs one test alone, while working on it. +[#asio-testing-browser] +=== Browser observations + +`browser_idle`, `browser_render` and `browser_loader` run real page programs +in headless Chrome, on both JSPI and Asyncify. The driver serves only its +page, loader and build artifacts on loopback HTTP. Set `CHROME` to the +browser executable; on macOS it otherwise finds the newest installed +Playwright headless shell. Each driver has a 120-second outer bound and +removes its Chrome process and temporary profile on success, failure or a +termination signal. + +An idle context with outstanding work must schedule exactly one positive +`setTimeout`, at most 300 seconds, during a three-second observation. +Calls to `setInterval` and `MessagePort.postMessage` are recorded too, so +repeated polling cannot pass as a wait. + +A self-posting handler runs for one second. The bounded run must allow at +least ten animation callbacks; Boost's unbounded control must allow none +between the program's start and completion. Callback entry times use +`performance.now()`, not the frame timestamp supplied by +`requestAnimationFrame`. This observes animation opportunities, not +individual painted pixels or a universal frame-rate guarantee. + +The yield's `MessageChannel` records each complete turn at the configured limit, +from resumption to the next post. The first starts at the program's +`spinning` line; the final partial turn is not a full-lot sample. Three +historical runs at limit 1000 record callback and handler counts, turn counts, +p95 and maximum turn duration in the library's `AGENTS.md`. A p95 above 8 ms in either +variant stops the task for the owner to decide the default. A run with +no animation callbacks also stops for a decision about the witness. +The maximum is reported separately. Heavy individual handlers can still +block the page regardless of the handler-count limit. + +The loader check runs the three-handler page normally and again after +removing `WebAssembly.Suspending` before navigation. The page identifies +the actual imported URL against the manifest before awaiting its factory, +so a JSPI program whose `main` never returns can still report its variant. +Any page exception, `console.error` or recorded loader error fails the run. + [#asio-testing-report] === The test matrix @@ -76,3 +161,274 @@ examples by lanes, where each cell says whether that program passed in that lane, or how it failed, at compile time, at link time or when it ran. The matrix is published with the documentation, at https://webcpporg.github.io/webcpp/report/. + +[#asio-testing-sizes] +=== How to compare release sizes and timings + +Published binary sizes always use release builds. Compare the same page +programs under six optimization profiles, with exceptions both enabled and +disabled. Each command builds JSPI and Asyncify. Run from the superproject +root, keeping the suspension-stack size and toolchain fixed: + +[source,bash] +---- +for profile in o2 o3 os oz o3-lto oz-lto; do + case "$profile" in + o2) flags="-O2" ;; + o3) flags="-O3" ;; + os) flags="-Os" ;; + oz) flags="-Oz" ;; + o3-lto) flags="-O3 -flto" ;; + oz-lto) flags="-Oz -flto" ;; + esac + for exceptions in on off; do + b2 -a -j4 "--build-dir=bin/asio-size-$profile-$exceptions" \ + toolset=emscripten variant=release \ + "exception-handling=$exceptions" \ + "cxxflags=$flags" "linkflags=$flags" \ + libs/asio/example//asyncify + done +done +---- + +`variant=release` supplies `NDEBUG` and disables debug symbols. The explicit +`cxxflags` selects the optimization level instead of the release default +`-O3`; the same level must be passed through `linkflags` for Emscripten's +final WebAssembly and JavaScript optimization. The current b2 toolset does +not forward it automatically. Keep separate build directories: free-form +flags do not select separate output paths in b2. + +`-O2` and `-O3` favor execution performance; `-Os` and `-Oz` favor smaller +code. `-flto` enables link-time optimization across translation units and +must be used when compiling their object files as well as when linking. +Neither a size-oriented level nor LTO guarantees a smaller result in every +program. + +With `exception-handling=on`, JSPI uses WebAssembly exceptions +(`-fwasm-exceptions`) and Asyncify uses JavaScript-based exceptions +(`-fexceptions`). With `off`, objects use `-fno-exceptions`, neither +exception mechanism is enabled at link, and Boost's no-exception handler +is linked. The programs do not throw: this compares the cost of enabling +exception support on their normal path, not throw/catch latency. Disabling +exceptions changes error behavior; select it only when that contract fits +the application. + +==== Binary sizes + +Each build prints its Wasm table and writes `asio.sizes.md` beside the +variant manifests. The manifests record the Wasm byte counts; the JavaScript +columns below measure the corresponding scripts themselves. These are +complete page modules without the Node test harness, not asio's isolated +contribution. Add the matching Wasm and JavaScript columns for the two-file +uncompressed payload. Compression, loader/HTML assets, HTTP overhead and +runtime memory are outside these measurements. + +The following task 14 tables cover the three examples listed below. The +current command also builds the later Cobalt example; its separate measurements +are in <>. + +Measured on 2026-10-14 with Emscripten 6.0.11, Boost 1.92 and {cpp}20, +Node 26.7.0, macOS 27 arm64, Apple M5 Max, 128 GiB RAM. Asyncify uses an +8192-byte suspension stack. All values below are bytes. Every configuration +was rebuilt in four fresh directories: one preparation build and three +measured builds. File sizes were identical across the four builds. Compile +and link commands were checked for optimization and exception settings; +LTO object files were checked to contain LLVM bitcode. All 72 page modules +matched their expected output and signalled successful completion in each +runtime round. This validates these examples under Node, not the full +library suite or real browsers under every profile. + +.asio_quick_start: uncompressed bytes +[cols="2,1,2,2,2,2",options="header"] +|=== +| Flags | Exceptions | JSPI Wasm | Asyncify Wasm | JSPI JavaScript | Asyncify JavaScript +| `-O2` | on | 81,162 | 157,410 | 79,404 | 90,706 +| `-O2` | off | 64,051 | 101,265 | 79,442 | 83,865 +| `-O3` | on | 80,979 | 153,459 | 78,899 | 89,248 +| `-O3` | off | 62,446 | 97,040 | 78,493 | 82,499 +| `-Os` | on | 74,490 | 147,893 | 78,899 | 88,867 +| `-Os` | off | 57,213 | 94,893 | 78,493 | 82,499 +| `-Oz` | on | 70,771 | 148,813 | 78,328 | 88,296 +| `-Oz` | off | 55,822 | 97,682 | 77,922 | 81,928 +| `-O3 -flto` | on | 86,096 | 143,667 | 79,747 | 89,240 +| `-O3 -flto` | off | 62,925 | 92,583 | 79,341 | 83,036 +| `-Oz -flto` | on | 65,712 | 127,067 | 79,176 | 88,871 +| `-Oz -flto` | off | 52,861 | 90,073 | 78,770 | 82,465 +|=== + +.asio_timers: uncompressed bytes +[cols="2,1,2,2,2,2",options="header"] +|=== +| Flags | Exceptions | JSPI Wasm | Asyncify Wasm | JSPI JavaScript | Asyncify JavaScript +| `-O2` | on | 82,969 | 162,160 | 79,394 | 90,696 +| `-O2` | off | 66,110 | 106,196 | 79,432 | 83,855 +| `-O3` | on | 82,724 | 157,831 | 78,889 | 89,238 +| `-O3` | off | 64,738 | 102,226 | 78,483 | 82,489 +| `-Os` | on | 74,987 | 150,501 | 78,889 | 88,857 +| `-Os` | off | 57,592 | 97,281 | 78,483 | 82,489 +| `-Oz` | on | 72,022 | 153,293 | 78,318 | 88,286 +| `-Oz` | off | 57,047 | 101,572 | 77,912 | 81,918 +| `-O3 -flto` | on | 87,840 | 148,668 | 79,737 | 89,496 +| `-O3 -flto` | off | 65,222 | 97,809 | 79,331 | 83,026 +| `-Oz -flto` | on | 67,968 | 132,768 | 79,166 | 89,386 +| `-Oz -flto` | off | 54,966 | 94,870 | 78,760 | 82,455 +|=== + +.asio_turn_limit: uncompressed bytes +[cols="2,1,2,2,2,2",options="header"] +|=== +| Flags | Exceptions | JSPI Wasm | Asyncify Wasm | JSPI JavaScript | Asyncify JavaScript +| `-O2` | on | 78,205 | 149,904 | 79,402 | 90,704 +| `-O2` | off | 61,386 | 95,829 | 79,440 | 83,863 +| `-O3` | on | 78,085 | 146,529 | 78,897 | 89,246 +| `-O3` | off | 59,860 | 91,775 | 78,491 | 82,497 +| `-Os` | on | 71,052 | 139,673 | 78,897 | 88,661 +| `-Os` | off | 54,219 | 88,489 | 78,491 | 82,497 +| `-Oz` | on | 67,838 | 141,185 | 78,326 | 88,090 +| `-Oz` | off | 53,031 | 91,253 | 77,920 | 81,926 +| `-O3 -flto` | on | 83,189 | 136,877 | 79,745 | 89,238 +| `-O3 -flto` | off | 60,291 | 87,248 | 79,339 | 83,034 +| `-Oz -flto` | on | 62,824 | 120,140 | 79,174 | 89,104 +| `-Oz -flto` | off | 50,151 | 83,722 | 78,768 | 82,463 +|=== + +In this matrix, `-Oz -flto` produced the smallest Wasm modules and combined +Wasm-plus-JavaScript payloads, with exceptions on or off. Removing exception +support reduced Wasm and the combined payload in every matched configuration. +For JSPI at `-O2`, JavaScript alone grew by 38 bytes without exceptions; +it shrank in the other matched configurations. Without LTO, +Asyncify's `-Os` Wasm modules with exceptions were smaller than its `-Oz` +modules. LTO with `-O3` increased the JSPI Wasm size with exceptions. +Rebuild and test an application's own candidates before selecting a profile. + +==== Build duration + +Each sample is elapsed wall time for the task 14 b2 invocation with +`-a -j4`: compilation, linking the six page modules of the three examples +above, and writing their manifests and size table. Cobalt was not registered +then and is excluded from these timings; the current command builds it too. +It is not a time per example or per suspension variant. One complete preparation pass populated Emscripten's system-library +cache for all profiles and exception settings. The next three passes used +new output directories, alternated configuration order, and ran one b2 +process at a time. The table gives the median and observed minimum to +maximum, in seconds. Downloads and the preparation pass are excluded. +No runtime measurements ran concurrently with compilation. These are local +observations; the host was not reserved against other system activity. + +[cols="2,2,2",options="header"] +|=== +| Flags | Exceptions on: median (min to max), s | Exceptions off: median (min to max), s +| `-O2` | 3.33 (3.29 to 3.37) | 3.16 (3.13 to 3.18) +| `-O3` | 4.08 (4.04 to 4.09) | 3.60 (3.57 to 3.69) +| `-Os` | 3.93 (3.92 to 3.99) | 3.58 (3.52 to 3.58) +| `-Oz` | 3.93 (3.92 to 3.94) | 3.51 (3.48 to 3.59) +| `-O3 -flto` | 4.71 (4.71 to 4.75) | 4.17 (4.14 to 4.18) +| `-Oz -flto` | 4.46 (4.45 to 4.46) | 4.01 (4.00 to 4.04) +|=== + +==== Module initialization and example execution + +Each sample used a fresh Node process and the exact page artifacts measured +above. The runner imported the generated JavaScript and read the Wasm file +before starting its clock. Initialization is measured from calling the module +factory to `onRuntimeInitialized`; it excludes Node startup, JavaScript +import/parsing, disk reads and network transfer. Execution is measured from +that callback to the example's explicit `webcppTestFinished(0)` signal. That +signal occurs just before returning from `main`, before local-object cleanup. +The runner waits for both the factory and the completion signal, so an +Asyncify suspension cannot end a sample prematurely. It checks status zero, +a single completion, exact `.expected` output and no stderr. + +One runtime round was discarded, followed by eleven measured rounds per +module, reversing configuration order between rounds. Each sample still +starts a fresh process: this is not a warmed-JIT or steady-state benchmark. +The tables report the median in milliseconds. Parentheses contain the +25th to 75th percentiles, calculated by linear interpolation of sorted +samples. This spread describes observed variability, not a confidence +interval. + +The quick-start example deliberately waits 50 ms. The timers example waits +until its 60 ms deadline, then tests cancellation. The turn-limit example +runs 5,000 handlers with a budget of 250 per turn and yields to the event +loop. Execution includes these waits, scheduling and compilation performed +lazily by the runtime. None of these values is CPU-only throughput, and +small differences are not evidence that a flag makes application code faster. + +.asio_quick_start: median (25th to 75th percentiles), ms +[cols="2,1,3,3,3,3",options="header"] +|=== +| Flags | Exceptions | JSPI init | JSPI execution | Asyncify init | Asyncify execution +| `-O2` | on | 3.48 (3.42 to 3.52) | 53.33 (52.83 to 53.80) | 3.16 (3.13 to 3.20) | 54.66 (54.63 to 54.76) +| `-O2` | off | 3.39 (3.33 to 3.44) | 53.53 (53.32 to 53.64) | 2.91 (2.77 to 3.05) | 53.97 (53.53 to 54.08) +| `-O3` | on | 3.40 (3.33 to 3.49) | 53.68 (53.11 to 53.83) | 3.07 (2.93 to 3.18) | 54.59 (54.47 to 54.66) +| `-O3` | off | 3.40 (3.31 to 3.47) | 52.79 (52.64 to 53.47) | 2.90 (2.86 to 2.91) | 54.01 (53.45 to 54.16) +| `-Os` | on | 3.38 (3.29 to 3.43) | 53.47 (52.79 to 53.81) | 3.10 (2.95 to 3.17) | 54.64 (54.40 to 54.73) +| `-Os` | off | 3.37 (3.27 to 3.44) | 53.48 (53.12 to 53.64) | 2.86 (2.77 to 2.89) | 53.82 (53.12 to 54.10) +| `-Oz` | on | 3.44 (3.31 to 3.47) | 53.64 (52.80 to 53.73) | 3.09 (3.02 to 3.17) | 54.53 (54.45 to 54.82) +| `-Oz` | off | 3.36 (3.33 to 3.43) | 53.61 (53.47 to 53.67) | 2.89 (2.76 to 2.97) | 54.07 (53.79 to 54.26) +| `-O3 -flto` | on | 3.51 (3.41 to 3.56) | 53.75 (53.60 to 53.87) | 3.06 (2.94 to 3.14) | 53.64 (53.46 to 54.46) +| `-O3 -flto` | off | 3.37 (3.33 to 3.40) | 53.48 (52.78 to 53.58) | 2.85 (2.76 to 2.99) | 53.90 (52.95 to 53.99) +| `-Oz -flto` | on | 3.43 (3.31 to 3.46) | 53.61 (53.13 to 53.69) | 3.04 (2.90 to 3.11) | 54.39 (54.33 to 54.47) +| `-Oz -flto` | off | 3.35 (3.24 to 3.40) | 53.39 (52.95 to 53.50) | 2.87 (2.75 to 2.92) | 54.07 (53.87 to 54.13) +|=== + +.asio_timers: median (25th to 75th percentiles), ms +[cols="2,1,3,3,3,3",options="header"] +|=== +| Flags | Exceptions | JSPI init | JSPI execution | Asyncify init | Asyncify execution +| `-O2` | on | 3.35 (3.18 to 3.43) | 63.09 (62.99 to 63.13) | 3.13 (3.11 to 3.18) | 64.20 (64.15 to 64.27) +| `-O2` | off | 3.22 (3.19 to 3.47) | 62.93 (62.86 to 62.98) | 2.96 (2.94 to 3.07) | 63.61 (63.41 to 63.66) +| `-O3` | on | 3.28 (3.22 to 3.40) | 63.09 (63.02 to 63.21) | 3.15 (3.11 to 3.16) | 64.10 (64.05 to 64.16) +| `-O3` | off | 3.27 (3.21 to 3.39) | 62.94 (62.86 to 63.05) | 2.98 (2.97 to 3.02) | 63.65 (63.35 to 63.74) +| `-Os` | on | 3.39 (3.17 to 3.45) | 62.95 (62.78 to 63.13) | 3.14 (3.09 to 3.17) | 64.12 (64.01 to 64.19) +| `-Os` | off | 3.19 (3.17 to 3.38) | 62.85 (62.78 to 63.08) | 2.93 (2.91 to 2.97) | 63.53 (63.43 to 63.67) +| `-Oz` | on | 3.34 (3.26 to 3.40) | 63.11 (63.05 to 63.13) | 3.16 (3.08 to 3.18) | 64.18 (63.99 to 64.30) +| `-Oz` | off | 3.21 (3.19 to 3.46) | 62.84 (62.40 to 63.05) | 2.98 (2.90 to 2.99) | 63.66 (63.58 to 63.68) +| `-O3 -flto` | on | 3.29 (3.28 to 3.49) | 63.02 (62.95 to 63.12) | 3.13 (3.11 to 3.19) | 63.94 (63.78 to 64.01) +| `-O3 -flto` | off | 3.29 (3.23 to 3.40) | 62.98 (62.79 to 63.22) | 2.94 (2.92 to 2.98) | 63.44 (63.36 to 63.56) +| `-Oz -flto` | on | 3.27 (3.21 to 3.41) | 63.09 (62.96 to 63.19) | 3.15 (3.08 to 3.16) | 63.90 (63.56 to 64.04) +| `-Oz -flto` | off | 3.33 (3.22 to 3.37) | 63.00 (62.89 to 63.04) | 2.92 (2.89 to 2.96) | 63.56 (63.50 to 63.61) +|=== + +.asio_turn_limit: median (25th to 75th percentiles), ms +[cols="2,1,3,3,3,3",options="header"] +|=== +| Flags | Exceptions | JSPI init | JSPI execution | Asyncify init | Asyncify execution +| `-O2` | on | 3.33 (3.28 to 3.45) | 10.15 (10.06 to 10.48) | 3.04 (2.94 to 3.18) | 13.19 (12.78 to 13.67) +| `-O2` | off | 3.36 (3.20 to 3.41) | 10.00 (9.77 to 10.25) | 2.88 (2.80 to 3.00) | 10.61 (10.33 to 11.04) +| `-O3` | on | 3.34 (3.17 to 3.43) | 10.48 (9.95 to 10.55) | 2.98 (2.95 to 3.21) | 12.93 (12.83 to 13.56) +| `-O3` | off | 3.38 (3.16 to 3.42) | 10.14 (9.75 to 10.33) | 2.83 (2.76 to 3.04) | 10.52 (10.21 to 11.06) +| `-Os` | on | 3.35 (3.20 to 3.44) | 10.44 (10.00 to 10.51) | 3.06 (2.96 to 3.09) | 13.92 (13.14 to 14.07) +| `-Os` | off | 3.33 (3.16 to 3.41) | 10.21 (9.86 to 10.41) | 2.83 (2.78 to 2.98) | 10.50 (10.32 to 11.05) +| `-Oz` | on | 3.39 (3.24 to 3.43) | 10.94 (10.57 to 11.23) | 2.97 (2.92 to 3.12) | 14.33 (14.15 to 14.78) +| `-Oz` | off | 3.32 (3.18 to 3.41) | 10.85 (10.51 to 11.05) | 2.84 (2.77 to 2.98) | 11.63 (11.52 to 12.40) +| `-O3 -flto` | on | 3.39 (3.21 to 3.45) | 10.25 (9.85 to 10.43) | 3.02 (2.94 to 3.13) | 12.49 (12.23 to 13.04) +| `-O3 -flto` | off | 3.33 (3.19 to 3.37) | 9.99 (9.73 to 10.22) | 2.81 (2.73 to 2.94) | 10.44 (10.19 to 11.00) +| `-Oz -flto` | on | 3.34 (3.21 to 3.39) | 10.93 (10.46 to 11.06) | 2.94 (2.90 to 3.11) | 14.75 (14.21 to 14.96) +| `-Oz -flto` | off | 3.17 (3.09 to 3.19) | 10.27 (10.10 to 10.34) | 2.80 (2.74 to 2.99) | 11.25 (11.07 to 11.86) +|=== + +threads:: +The `threads` lane runs Cobalt worker/post/join, multiple Asio context runners +and the WASIp3 allocator witness. The cooperative SDK profile uses exceptions +off and remains distinct from simultaneous native CPU execution. ++ +[source,bash] +---- +b2 -a libs/asio/test//threads +b2 -a toolset=clang-wasip3 libs/asio/test//threads +---- + +tls-integration:: +Real peers exercise trusted/rejected certificates, SNI, embedded/replacement +roots, Cobalt TLS state, encrypted transfer cancellation, and shutdown errors +and cancellation. Native single/multi profiles run with exceptions on/off; +WASIp3 runs single with exceptions on/off and cooperative with exceptions off. +The WASIp3 entropy control verifies that host randomness failure prevents +random output and key generation. It does not measure entropy quality. ++ +[source,bash] +---- +b2 -a libs/asio/test/tls//tls-integration +b2 -a toolset=clang-wasip3 libs/asio/test/tls//tls-integration +---- diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/timers.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/timers.adoc new file mode 100644 index 0000000..e6d5ba0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/timers.adoc @@ -0,0 +1,104 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-timers] +== Timers + +`steady_timer`, `system_timer` and `basic_waitable_timer` are aliases of +Boost.Asio's timers on native, Emscripten and WASIp2/P3. Their executors, completion tokens, +associated allocators and per-operation cancellation slots keep Boost's +interfaces and behaviour. + +Use `steady_timer` for an interval measured by a monotonic clock, and +`system_timer` for a deadline on the system clock. Adjusting the system +clock can affect a system timer; it does not change a steady timer's clock. +A deadline makes a handler eligible to run, not a promise that the host +will execute it at that exact instant. + +[#asio-timers-waiting] +=== Waiting and cancellation + +On Emscripten the timers sit in Boost.Asio's reactor queue. The run family +waits through the selected suspension variant, JSPI or Asyncify +(<>), allowing JavaScript to run while it waits. The reactor +caps each wait at five minutes; an idle wait therefore holds one +JavaScript `setTimeout` of at most 300 seconds. This bounds one reactor +wait, not the duration a program may give a timer. + +Cancelling a timer completes its pending waits with +`boost::asio::error::operation_aborted`. An operation already ready for +completion cannot be cancelled retroactively. To cancel a particular wait, +bind a cancellation slot to its completion handler. A terminal signal on +that slot cancels that wait without cancelling another wait on the same +timer. This test cancels the other wait explicitly only after checking +that it remains pending: + +[source] +---- +include::{library-root}/test/timers_test.cpp[tag=slot-cancellation,indent=0] +---- + +[#asio-timers-beast] +=== Beast's timeouts + +Boost.Beast's `basic_stream` and WebSocket stream use Boost.Asio timers +internally. Their timeout handling therefore uses the same reactor queue +and works with both suspension variants. The test below starts a WebSocket +handshake over Beast's in-memory test stream. Its peer sends no handshake, +so the completion reports `boost::beast::error::timeout`: + +[source] +---- +include::{library-root}/test/timers_test.cpp[tag=beast-timeout,indent=0] +---- + +This checks Beast's timeout integration. It does not open a network +connection or provide a browser WebSocket transport. + +[#asio-timers-guarantees] +=== What the timer tests establish + +<> records the timer contract. + +The `timers_native` test runs natively. The `timers` browser tests run +WebAssembly under Node with JSPI and Asyncify, each with and without +exceptions. They check steady timers registered with deadlines of 60, 20 +and 40 milliseconds against completion order 20, 40, 60; a system timer; +whole-timer and per-operation cancellation; and Beast's handshake timeout. +The three steady deadlines share one starting instant. The tests check +completion order and error values, without requiring exact elapsed times. + +[#asio-timers-example] +=== How to schedule deadlines and cancel a wait + +Use a common clock origin when several waits belong to the same schedule. +This program registers 60, 20 and 40 ms deadlines, then runs their handlers. +After that run finishes, it restarts the context and cancels a separate +pending wait: + +[source] +---- +include::{examples}/asio_timers.cpp[tag=program,indent=0] +---- + +[source,bash] +---- +b2 toolset=emscripten libs/asio/example//asio_timers.output +---- + +[listing] +---- +include::{examples}/asio_timers.expected[] +---- + +The labels identify the requested deadlines, not measured completion times. +`restart` allows another run after the first exhausted its work. The final +timer uses the clock's maximum deadline so it remains pending until +`cancel`. Cancelling schedules the aborted completion; the second `run` +delivers it. Keeping these two phases separate makes the displayed order +independent of when the host schedules cancellation against ready timers. +For cancellation of one wait while another remains pending, use the slot +example in <>. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/wasip2.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/wasip2.adoc new file mode 100644 index 0000000..edb78f0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/wasip2.adoc @@ -0,0 +1,135 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-wasip2] +== Build for WASIp2 + +Use `/webcpp/asio//asio` with `toolset=clang-wasip2` and `threading=single`. +This profile uses Boost 1.92, wasi-sdk 34.0 and Wasmtime 50.0.1. Both exception +modes are supported for the core, timers, TCP/UDP, asynchronous forward DNS, +Cobalt and source-built OpenSSL. Multiple application threads remain unavailable +with the pinned SDK profile. + +Configure the compiler using the project's wasi-sdk user-configuration example. +Then run the local consumers from the superproject root: + +[source,bash] +---- +b2 -a toolset=clang-wasip2 variant=release threading=single \ + exception-handling=on,off testing.launcher=tools/boost/asio-wasip2/run.sh \ + libs/asio/test/wasip2 libs/asio/test/capability_wasi +b2 -a toolset=clang-wasip2 variant=release exception-handling=on,off \ + libs/asio/test/wasip2//supplied-stream libs/asio/test/wasip2//scheduler-idle +---- + +Add `/webcpp/asio//cobalt` for Cobalt, `//tls` for OpenSSL with embedded or +replacement trust roots, or `//cobalt_ssl` for Cobalt's SSL wrapper. These targets +share the same source-built provider as native and WASIp3 programs. Run their +real peer, trust, transfer/shutdown and cancellation consumers with: + +[source,bash] +---- +b2 -a toolset=clang-wasip2 variant=release exception-handling=on,off \ + testing.launcher=tools/boost/asio-wasip2/run.sh \ + libs/asio/test/wasip2_tls_cobalt libs/asio/test/wasip2_tls_cobalt//wasip2-tls +---- + +The first command exercises timers, the run/poll family, TCP and UDP exchanges, +coroutines, forward name resolution and pollable readiness. The supplied-stream +lane keeps standard input open without sending data; its timer must still cancel +a pending read. Each consumer reports a passing result. The network launcher +explicitly grants socket access and IP name lookup; production hosts should grant +only the application's required capabilities. + +The idle driver uses an external watchdog and a Wasmtime fuel budget. A context +with a live work guard must remain asleep, including before a reactor is created. +The write-permit consumers exercise a real output with a controlled 64-bit quota +and cancellation against a deliberately non-ready native pollable. Those fixtures +test the adapter's boundary handling; they do not measure every host implementation. + +[#asio-wasip2-readiness] +=== How readiness reaches the executor + +WASIp2 provides TCP, UDP, name-resolution streams, monotonic clocks and resources +that expose readiness through `wasi:io/poll`. The port retains Boost.Asio's select +reactor. wasi-libc gathers socket pollables and timer deadlines into one host wait. +No worker thread, fixed-interval DNS scan or browser turn budget is introduced. +The P2 single-thread profile omits Asio's pipe-based cross-thread interrupter: +this libc has no P2 pipe implementation, and the profile cannot receive work from +another application thread. +An idle scheduler without a reactor waits on a maximum-instant monotonic-clock +pollable. It does not submit an empty poll list, which WASIp2 rejects, or spin. + +A DNS address stream is not a POSIX descriptor. A small compiled bridge registers +its borrowed pollable with wasi-libc's descriptor table so the same reactor can +wait for sockets, DNS and timers together. That registration API is private to +wasi-libc. The build verifies SDK 34.0, libc revision `2e6fb9d8ee0c` and the exact +copied declaration hashes. Changing the SDK requires revalidating this bridge; +the build must not silently use an unknown ABI. The upstream installation is +never modified. + +[#asio-wasip2-dns] +=== Resolver contract + +`async_resolve` starts the native lookup through the executor. A deferred token +does not start DNS until initiated. The handler never runs inside initiation, +uses its associated executor, and receives an error value on failure. Resolver +cancellation and per-operation cancellation work before and after registration. +Destroying a resolver cancels pending lookups; destroying its context abandons +handlers and releases the owned resources. + +Numeric host parsing and the libc service-name table require no host DNS wait. +The host supplies forward lookup addresses; host capabilities govern access. +`canonical_name`, `v4_mapped` and `all_matching` are explicitly unsupported by this +adapter and complete with `operation_not_supported`. Asynchronous reverse lookup +also remains unsupported. `address_configured` uses libc's numeric family checks. +Loopback tests establish local resolution, not access to every external DNS server. + +Operation storage and copied input/endpoint scratch storage use the associated +handler allocator. Resolver ownership uses the context allocator. The public +Boost result container, libc address parsing and descriptor-table storage retain +their upstream allocation behavior; this is not a zero-global-allocation promise. + +[#asio-wasip2-streams] +=== Use a supplied CLI byte stream + +`webcpp::asio::wasi::stdio_stream` implements partial synchronous and asynchronous +reads/writes over WASIp2 CLI resources. Its asynchronous waits use the same reactor, +preserve completion-token associations and support cancellation. Only one read +and one write may be pending per stream. Keep buffer storage alive until completion. +The stream owns resource handles but does not close libc's descriptors 0 and 1. +Cancellation aborts pending operations; subsequent operations remain usable. +Closing or destroying the stream cancels pending operations and prevents new I/O. + +The Beast supplied-channel client and server run real WebSocket upgrade, text, +fragmented binary transfer, ping/pong and close over this adapter, in both exception +modes. They need no TCP socket grant. These channels do not provide Unix socket +names, descriptor passing, peer credentials or `wasi:http` WebSocket upgrades. + +Writes request a WASI flush before the protocol switches to reading. Readiness +cannot preempt an import that the host itself implements with blocking I/O. In +particular, Wasmtime CLI stdout can block when its OS pipe fills. A paused consumer +must resume draining before the component can observe cancellation. A strict +cancellation deadline requires a host/channel whose write imports remain nonblocking. + +[#asio-wasip2-errors] +=== Unsupported operations and build profiles + +`threading=multi` is rejected: SDK 34.0 has no supported P2 pthread runtime +profile. POSIX signals, Unix-domain sockets and serial ports are absent from the +host interfaces used here. Use the capability guards in <> +for compiler-visible requirements. Cobalt's known no-EH pending-task move issue +remains an upstream limitation, as on native and P3; see <>. + +Unsupported socket operations retain error-code overloads. Tested examples include +`linger` and `at_mark`, which return `operation_not_supported`. +UDP `send_to` and connected `send` gather multiple buffers into one datagram; +receive scatters one datagram across the destination buffers. Asynchronous forms +retain handler allocation and cancellation. TCP retains partial I/O semantics. +Numeric IPv6 scope identifiers work; named interfaces are rejected with +`invalid_argument`. Host permission denial is a runtime error, distinct from an +unsupported build profile. Prefer error-code/completion-handler paths for recovery, +especially when exception handling is disabled. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/wasip3.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/wasip3.adoc new file mode 100644 index 0000000..dbefa87 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/wasip3.adoc @@ -0,0 +1,186 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-wasip3] +== Build and test a WASIp3 program + +This how-to uses the same timer example as the native tutorial. The port also +provides TCP/UDP through Boost's socket types. Read <> before +choosing a profile; it records the restrictions that still differ from native. + +=== Prerequisites + +Use Boost 1.92.0, wasi-sdk 34.0 and Wasmtime 50.0.1 for the configuration verified +here. The port pins the exact input headers: a newer or modified Boost requires +rebasing the patch and rerunning the tests. It is not accepted silently. +WASIp3 and cooperative threads require runtime support; the previously installed +Wasmtime 47.0.3 could not load the SDK's cooperative-thread component. + +Register `clang-wasip3` in `user-config.jam` as shown by the superproject's WASI +setup. Put the SDK in `.local/wasi-sdk`, or supply `-sWASI_SDK=/path/to/wasi-sdk` +when choosing the cooperative profile. It must be the same SDK as the compiler +registered for this toolset. Put the tested Wasmtime binary on `PATH`. + +`/webcpp/asio//asio` prepares a private copy of the patched Boost headers under +`bin/boost-asio-wasip3/include`. It verifies the input and output hashes and +searches those headers before the stock headers, only for `clang-wasip3`. +It does not rewrite the Boost installation. Native and browser builds retain +their existing headers and settings. + +=== Run without threads + +From the superproject root, build and check the existing timer example: + +[source,bash] +---- +b2 -a toolset=clang-wasip3 variant=release threading=single \ + exception-handling=on \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/asio/example//asio_quick_start.output +---- + +The example's source is in <>. Expected output: + +[listing] +---- +include::{examples}/asio_quick_start.expected[] +---- + +Repeat with `exception-handling=off` to use the single-thread runtime without +{cpp} exceptions. The library keeps Boost's callback and error-code interfaces. +No JSPI or Asyncify flags are needed. + +=== Run with cooperative threads + +[source,bash] +---- +b2 -a toolset=clang-wasip3 variant=release threading=multi \ + exception-handling=off \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/asio/test//wasi_core_threads +---- + +The build selects `experimental-coop-threads` as its sysroot and adds `-pthread` +consistently to compilation and linking. It uses that sysroot's {cpp} configuration +and the matching SDK's common libc{plus}{plus} headers. This is an experimental SDK profile, +not a promise of CPU parallelism. In the tested SDK, requesting exceptions in +this profile fails at configuration with a message naming the missing runtime. + +The test launcher is for local and CI verification: it enables WASIp3 asynchronous +components and cooperative-thread support, grants host network and name-lookup +access for the loopback tests, and bounds each guest's execution to 600 seconds. +The global lane also runs large finite document and Unicode workloads. Set +`WEBCPP_WASIP3_TEST_TIMEOUT` to a positive integer number of seconds to choose +another bound, for example `WEBCPP_WASIP3_TEST_TIMEOUT=15` for focused loopback +tests. Invalid or zero bounds fail before launch. Enabling a runtime feature +does not create threads in a single-thread binary. Production applications +should choose their own timeout and network capabilities. + +=== Reproduce the local verification + +Run the declared WASIp3 tests and examples with `-a`, then repeat for each +supported profile from <>: + +[source,bash] +---- +b2 -a toolset=clang-wasip3 variant=release threading=single \ + exception-handling=on \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/asio/test libs/asio/example + +b2 -a toolset=clang-wasip3 variant=release threading=single \ + exception-handling=off \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/asio/test libs/asio/example + +b2 -a toolset=clang-wasip3 variant=release threading=multi \ + exception-handling=off \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/asio/test libs/asio/test//wasi_core_threads libs/asio/example + +python3 tools/boost/asio-wasip3/prepare_test.py +python3 tools/test/asio_wasip3_test.py +python3 tools/boost/cobalt-wasip3/prepare_test.py +python3 tools/test/cobalt_wasip3_test.py +---- + +`wasi_core` exchanges real TCP and UDP traffic over ephemeral IPv4 loopback +ports, tests timer and socket cancellation, scatter/gather TCP, and TCP EOF. +`wasi_core_threads` adds a cross-thread post into a reactor with a pending timer +and two runners sharing a context. `wasi_contract` checks empty datagrams, +vectored UDP receive with datagram truncation, IPv6 numeric scopes, socket +option errors and resolver behavior. `wasi_coroutine` waits for a timer using +Boost.Asio's `co_spawn` and `awaitable` with result-based error handling. +The existing run-family and timer tests also run on WASIp3. +`wasi_udp_gather` and `capability_wasi/datagrams` check synchronous and asynchronous +multi-buffer sends and receives, +including complete sequences beyond 64 buffers, allocation routing, empty +datagrams, oversized input and release of storage before completion. + +The preparation tests check exact hashes, idempotence and protection of the +installed headers. The build tests use a checkout with spaces, check that the +private headers are selected only for WASIp3, and reject unavailable SDK +profiles. Native controls use the same runtime test sources. These are local +commands; none starts a CI job. + +[#asio-wasip3-cobalt] +=== Build a Cobalt application + +Use `/webcpp/asio//cobalt` in the application's B2 requirements. +Its ordinary `boost::cobalt::main co_main(int, char**)` entry point is unchanged. +The target builds Boost.Cobalt from source, applies the checked Cobalt and Asio +compatibility overlays, and supplies the signal-free WASIp3 runner. Applications +do not compile a special subset of Cobalt sources themselves. + +Run the existing <>: + +[source,bash] +---- +b2 -a toolset=clang-wasip3 variant=release threading=single \ + exception-handling=on \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/asio/example//asio_cobalt.output +---- + +[listing] +---- +include::{examples}/asio_cobalt.expected[] +---- + +Repeat with `exception-handling=off`, or with `threading=multi` and +`exception-handling=off` for the cooperative runtime. The latter can also run +the explicit `libs/asio/test//cobalt_thread` test. The ordinary test target +includes `cobalt_wasi`, `cobalt_network_wasi` and `cobalt_io`; they cover the +runner, both timer APIs, Asio TCP/UDP through `use_op`, Cobalt's own IP socket +wrappers, refused TCP connections, TCP/UDP cancellation, EOF and result-based +resolver behavior. + +The `libs/asio/test//cobalt_wasip3` lane checks successful and unsuccessful +command completion with an exact-status driver. Put Wasmtime 50.0.1 on `PATH`, +or set `WASMTIME` to its executable for that driver. The SDK maps nonzero +coroutine returns to host status 1. + +For TLS, add `/webcpp/asio//tls` and await Asio SSL operations with +`boost::cobalt::use_op`. `tools/openssl/test//cobalt_tls_client` is a compiled +consumer of both public targets. Run the following command to check TLS 1.2/1.3, +trusted and rejected +identities, malformed CA data and clean shutdown; the path is printed by B2's +link action: + +[source,bash] +---- +python3 tools/openssl/test/tls.py --embedded +---- + +The WASI client needs network capabilities but no CA filesystem +preopen. To use Cobalt's own `io::ssl::stream`, link the optional +`/webcpp/asio//cobalt_ssl` target. Its checked patch, trust configuration and +local test commands are described in <>. + +The underlying platform contracts are documented by +https://github.com/WebAssembly/wasi-sdk/blob/main/CoopThreading.md[wasi-sdk's cooperative-thread guide] +and the +https://github.com/bytecodealliance/wasmtime/releases/tag/v50.0.1[Wasmtime release used here]. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/doc/yield-cost.adoc b/libraries/asio/openspec/changes/genesis/reference/source/doc/yield-cost.adoc new file mode 100644 index 0000000..1f9fd6b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/doc/yield-cost.adoc @@ -0,0 +1,339 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#asio-yield-cost] +== Measured cost of yielding to the browser + +On 2026-10-15, a direct round trip through the library's actual +`webcpp_asio_yield()` took about *4.06 microseconds with JSPI* and +*4.74 microseconds with Asyncify*. These are medians of seven per-run means, +not the duration of a batch of callbacks and not a real-time guarantee. +One microsecond is 0.001 milliseconds. + +The benchmark ran locally on an Apple M5 Max, 128 GiB RAM, macOS 27.0 +(26A428), HeadlessChrome 153.0.8010.12, Emscripten 6.0.11 and Boost 1.92. +Both compilation and linking used Release `-O3`; `NDEBUG` was enabled. +The primary matrix enabled exceptions and cross-origin isolation. Additional +cases disabled exceptions or isolation and exercised an arithmetic workload. +No CI ran. The benchmark used explicit limits; the configured default was +1,000 at measurement time. The subsequent policy decision below changes it to 100. + +[#asio-yield-default-origin] +=== From the original 1,000 default to 100 + +The value 1,000 predates the isolated yield-cost benchmark. It was specified +as the initial scheduling policy in design decision D3 and the implementation +plan. The design recorded a timer witness: with that limit, `setTimeout(0)` +ran after about 1,000 handlers instead of waiting for the entire ready chain. +That establishes that yielding happens; it does not derive an optimal limit. +No calculation selecting 1,000 over all other limits was recorded there. + +Task 13 subsequently checked whether keeping that value was acceptable for +its trivial-handler workload. Its local Chrome experiment measured full +1,000-handler turns in three debug runs on 2026-10-14. The p95 was 0.7 ms for +JSPI and 1.6 ms for Asyncify in every run. Animation callbacks occurred about +60 times per second; the unbounded controls had none during the observed work. +The measured maxima were 1.8-1.9 ms and 8.9-9.2 ms, respectively. These are +historical *batch durations*, distinct from the Release yield latencies below. +The complete historical table remains in the library's `AGENTS.md`. + +The predeclared stop criterion was a turn p95 above 8 ms in either variant. +Its motivation was to leave roughly half of a 60 Hz frame's 16.7 ms interval +for browser work. This is a screening heuristic, not a guarantee of frame +rate: p95 does not bound every turn, browser work varies, and an animation +callback does not prove that particular pixels were painted. The observations +passed that criterion, so the existing default was retained. + +The 2026-10-15 Release benchmark then measured the missing part: the actual +cost of yielding. It supports amortizing that cost across cheap callbacks; +it does not retrospectively turn 1,000 into a mathematically derived optimum. +The documented rationale is therefore: *an initial configurable policy, +retained after a workload-specific responsiveness check, with its scheduling +cost now measured independently*. Choosing an optimal default would require +an explicit responsiveness/overhead objective and representative workloads +across the supported browsers and hardware. + +On 2026-10-15, after reviewing these results, the owner selected *100* as the +new default to favor browser responsiveness. In a continuously ready chain, +it offers roughly ten times as many yields as 1,000. The measured boundary +gaps imply about 44.0/54.5 ms of accumulated scheduling time per million +handlers at 100 (JSPI/Asyncify), versus 4.64/5.73 ms at 1,000. The additional +39/49 ms is an extrapolation from this machine, not one uninterrupted pause. + +For illustration, 100 callbacks that each take 50 us occupy about 5 ms, +whereas 1,000 occupy about 50 ms, excluding scheduling overhead. These are +calculated examples, not measured application response times. Browser work +gets an opportunity at a yield, not a guarantee that an input or frame runs +before Wasm resumes. A long handler is never preempted; short-drain/wait paths +can also run up to twice the configured count between yields, as described +in <>. The choice of 100 is a responsiveness-oriented policy, not +proof of an optimum. Applications can still select 1,000 or another value. + +=== What was timed + +The direct measurement surrounds the production function without changing +its implementation. The {cpp} steady-clock timestamp is read immediately before the call and +immediately after it resumes. Their difference in milliseconds is multiplied +by 1,000 to report microseconds. The compiled implementation is in +`bench/yield/yield_program.cpp`. + +That function awaits a Promise, creates a MessageChannel, posts a message, +closes port1 in its message handler and resolves the Promise. The suspended +Wasm execution then resumes. This is a cooperative browser event-loop yield, +not a measurement of an operating-system thread context switch. + +The chain measurement uses `boost::asio::post` to schedule its next handler. +It records the end of the last callback before a yield, after posting its +successor, and the entry of the first callback after the yield. This excludes +batch execution, but includes the small dispatcher return/reentry around the +yield. A matched control records the same boundaries with periodic yielding +disabled. It uses exactly the same number of handlers and clock reads. + +=== Direct round-trip latency + +Each primary row contains seven fresh-page runs of 10,000 yields each. +Percentiles are nearest-rank quantiles per run, then medians across runs. +The maximum is the largest individual observation across all repetitions. +The mean range exposes variation between independent runs. + +[cols="1,1,1,1,1,1,1",options="header"] +|=== +|Path |Mean, us |Run means, us |p50, us |p95, us |p99, us |Maximum, us + +|jspi |4.06 |3.98-4.15 |5 |10 |10 |310 +|asyncify |4.74 |4.59-4.94 |5 |10 |10 |805 +|js |3.93 |3.85-4.01 |5 |10 |10 |285 +|=== + +The JavaScript control implements the same Promise/MessageChannel sequence +without entering Wasm. Its similar cost suggests that browser scheduling and +channel/Promise management account for much of the round trip in this setup. +Subtracting its mean from the Wasm mean does not isolate an ABI transition: +these are separate runs, with different optimized code and runtime work. + +=== Actual yield gaps with different turn limits + +Each cell below is a yield gap, *not time spent running the callbacks*. +Each limit has seven repetitions per variant. Runs contain at least 100,000 +handlers and at least 1,024 yield samples. Limit 1 uses 100,000 samples; +limit 10 uses 10,000; the other limits use 1,024. + +[cols="1,1,1,1,1,1,1",options="header"] +|=== +|Handlers per turn |JSPI gap, us |Asyncify gap, us |JSPI p95, us |Asyncify p95, us |JSPI amortized, ns/handler |Asyncify amortized, ns/handler + +|1 |4.18 |4.85 |10 |10 |4183.95 |4850.00 +|10 |4.15 |4.98 |10 |10 |414.95 |498.05 +|100 |4.40 |5.45 |10 |10 |44.04 |54.54 +|1000 |4.64 |5.73 |10 |10 |4.64 |5.73 +|5000 |4.82 |6.40 |10 |10 |0.96 |1.28 +|10000 |4.86 |6.93 |10 |10 |0.49 |0.69 +|=== + +The amortized columns divide the measured gap by the turn limit. They are an +estimate of scheduling cost per handler, not the handler's execution time. +For example, one million handlers with a limit of 1 imply roughly four to +five seconds of accumulated yield gaps at these means. A limit of 100 implies +roughly 44-55 milliseconds; a limit of 1,000 roughly 5-6 milliseconds. +These extrapolations describe this workload and machine, not all applications. + +The largest chain gaps were 5.01 ms with JSPI and 39.72 ms with Asyncify, +both at limit 1. No samples were removed. The benchmark does not identify +whether these outliers came from collection, scheduling or another cause. +A browser yield gives an opportunity to service the page; it does not guarantee +that rendering or a particular queued task executes before resumption. + +=== Where the instrumented interval was spent + +A separate run observes six JavaScript timestamps inside the MessageChannel +path. The observer is warmed before collection. These observations perturb +the operation: the median mean rises from 4.06 to 4.85 us for JSPI and from +4.74 to 5.57 us for Asyncify. Consequently the following decomposition is of +the *instrumented* path, not a claim that the observer is free. + +All entries below are arithmetic means across seven runs of 10,000 samples; +they add to the arithmetic mean of the traced round trip. Sub-resolution +values are aggregate estimates, not individually resolved durations. + +[cols="1,1,1",options="header"] +|=== +|Observed segment |JSPI mean, us |Asyncify mean, us + +|{cpp} start to channel observer entry |0.21 |0.26 +|Native MessageChannel construction |1.06 |1.12 +|Handler/observer setup before post |0.67 |0.70 +|Synchronous postMessage call |0.47 |0.50 +|Post return to message-handler entry |1.20 |1.52 +|Message handler: close port and resolve |1.01 |1.02 +|Handler return to {cpp} resumption |0.21 |0.47 +|Instrumented total |4.83 |5.59 +|=== + +Post-return-to-delivery includes suspension/unwinding and browser scheduling; +it is not a pure queue-residence measurement. The last segment includes +Promise/microtask continuation, runtime resumption and the {cpp} timestamp. +The entry segment includes Promise setup before the first observed channel +operation. Handler setup includes observer allocations and timestamp reads. +These measurements cannot isolate pure engine suspension and restoration +instructions from all surrounding work. + +A validation-only 2 ms busy wait inserted into the JavaScript message handler +was detected in that segment, about 2.001 ms on both variants. It was absent +from all 442 production-mechanism measurement cases. + +=== Clock resolution and synchronous controls + +In this Emscripten build, {cpp} `steady_clock` reaches `clock_gettime`, WASI's +monotonic clock and then `emscripten_get_now`, which uses `performance.now()`. +{cpp} `system_clock` reaches the same wall-clock source as `Date.now()`. +These are not independent hardware clocks. Two thousand bracketed reads +before and after each Wasm case verified their correspondence. + +Observed positive clock steps were about 5 us in an isolated page and 100 us +in an ordinary page. `Date.now()` advanced in 1 ms steps where a positive +step was observed. Isolated-page direct yield samples therefore include many +zeros despite a nonzero aggregate mean. In an ordinary page, about 96% of +JSPI and 95% of Asyncify direct samples were zero; the median p95 was also +zero. Those individual percentiles cannot resolve a 4-5 us operation. +The ordinary-page mean still agreed: 4.03 us JSPI and 4.73 us Asyncify. + +[cols="1,1,1",options="header"] +|=== +|Control |JSPI, ns/iteration |Asyncify, ns/iteration + +|Adjacent {cpp} timestamps |109.1 |114.0 +|{cpp} -> JS counter call, including timestamps |111.1 |135.4 +|Optimized JS -> {cpp} increment loop |2.3 |4.1 +|JS performance clock study loop |69.6 |71.5 +|JS -> {cpp} monotonic clock study loop |118.6 |141.7 +|JS wall-clock study loop |28.0 |28.2 +|=== + +Clock-study values include loop and comparison overhead. The JS-to-{cpp} control +uses one million synchronous calls, with observable results; an optimizing +engine may inline this trivial export. The {cpp}-to-JS control increments an +observable counter between the same two {cpp} timestamps as the clock-only +control. Neither performs an asynchronous yield. Small differences between +these controls are not a precise standalone ABI-cost estimate. No per-sample +clock-floor subtraction was performed on the reported yield latencies. + +=== Exceptions and arithmetic controls + +[cols="1,1,1",options="header"] +|=== +|Variant |Exceptions on, us |Exceptions off, us + +|jspi |4.06 |4.03 +|asyncify |4.74 |4.43 +|=== + +Exception-free controls used three repetitions, including all six turn limits. +The additional arithmetic control used 64 source-level LCG updates per handler, +with an independently verified checksum. This is not a claim of 64 machine +instructions: optimization can combine arithmetic. All its raw run statistics, +plus the traced chain runs, are retained with the benchmark results. + +=== What the measurements justify + +For the instrumented trivial chain, limit 1 took 17.29 times the matched +no-periodic-yield control with JSPI and 14.49 times with Asyncify. At limit 100 +the ratios were 2.09 and 1.43; at limit 1,000 they were 1.15 and 1.05. +These are measured whole-program ratios, including the clocks in both cases, +not universal application overhead factors. + +Subtracting whole-run durations is unreliable for small differences. Some +large-limit pairs produced negative differences. Exception-free Asyncify's +large-limit controls were consistently slower than the yielding runs. This +experiment does not identify the cause; execution/tiering, allocation and +other runtime effects can confound such controls. The retained CSV and JSON +include these results. They must not be described as negative yield latency. +The direct interval and callback-boundary observations remain the primary +latency measurements. + +The evidence supports amortizing yields when handlers are very cheap. It does +*not* prove that 1,000 is optimal, or that 1 is always inappropriate. A heavy +handler can make a 4-5 us yield negligible. Choosing a limit balances accumulated +scheduling cost against time spent away from the browser. Counting handlers +cannot bound that time when their costs vary, and no limit interrupts a handler +in the middle. Configure the limit as described in <>; +the current default is 100. + +[#asio-yield-select-limit] +=== Relating the limit to an application's cost budget + +For a continuously ready chain with roughly uniform callbacks, let `Y` be +mean yield latency, `C` the mean cost of handling one callback without a forced +yield, and `N` the number of callbacks per turn. The scheduling cost per +callback is approximately `Y / N`. Relative to the callback work, the added +cost is approximately `Y / (N * C)`. These are workload estimates, not latency +bounds; they omit variability and other browser work. + +For an allowed additional cost ratio `r`, the estimate asks for +`N >= Y / (r * C)`, rounded up to a positive integer. This must be balanced +against time away from the browser, approximately `N * C` for this continuous +chain. The general run-family paths described in <> can have +more than one turn's handlers between yields, and no handler is preempted. + +For illustration only, assume `Y = 5 us` and allow 10% added scheduling cost: + +[cols="1,1,1",options="header"] +|=== +|Assumed callback cost C |Estimated minimum N |Callback work per full turn + +|0.05 us |1,000 |50 us +|1 us |50 |50 us +|100 us |1 |100 us +|=== + +These assumed callback costs and the 10% objective did *not* produce the +original default. They show why a count cannot be selected from yield latency +alone. A limit of 1 can be inexpensive for substantial callbacks; 1,000 can +amortize scheduling for extremely cheap callbacks. Conversely, 1,000 callbacks +that each take 100 us can occupy the thread for about 100 ms before a periodic +yield in this chain. Measure the actual application and choose its limit using +<> or the per-context option. + +[#asio-yield-charts] +=== Charts and complete tables + +These charts use the recorded observations. Marked error bars show ranges +between independent runs, not confidence intervals. Logarithmic axes are labeled. +The per-callback scheduling cost is derived by dividing a yield gap by the limit. +The complete aggregate table is `bench/yield/results/2026-10-15/figures/all-configurations.csv` +(102 configurations); `runs.csv` in its parent directory retains all 442 runs. +All summary fields, including ranges, percentiles, clocks and phase components, +are preserved in the aggregate CSV. The figures directory also contains a +four-page PDF and separate PNG/SVG images. + +.Yield latency and amortization +image::{library-root}/bench/yield/results/2026-10-15/figures/01-yield-latency.svg[Yield latency and amortization,opts=inline] + +.Direct controls and instrumented phases +image::{library-root}/bench/yield/results/2026-10-15/figures/02-direct-and-phases.svg[Direct controls and instrumented phases,opts=inline] + +.Chain controls and whole-program comparisons +image::{library-root}/bench/yield/results/2026-10-15/figures/03-chain-controls.svg[Chain controls and whole-program comparisons,opts=inline] + +.Tails and clock resolution +image::{library-root}/bench/yield/results/2026-10-15/figures/04-tails-and-clocks.svg[Tails and clock resolution,opts=inline] + +=== Reproduce and inspect + +The manual benchmark is in `bench/yield/`; its README documents exact build, +run and analysis commands. It is not connected to a CI lane. The recorded +`results/2026-10-15/runs.csv` retains statistics for every case, +`summary.json` groups repetitions, and `build.json` identifies the hardware, +toolchain and source/binary hashes. Full timestamp arrays are also preserved +in the local raw-data archive identified in the README. + +The run used 442 sequential fresh-page cases in deterministic shuffled order +(seed 20261015), totaling 970,139,132 operations and 9,429,856 timing pairs. +Primary cases had seven repetitions; secondary controls had three. Direct and chain +Wasm cases first warmed 512 actual yields, and chain cases additionally warmed +10,001 posted handlers. Builds completed before measurement started. There +was no polling timer in the measured page. The machine was not isolated from +all other OS activity, and this headless, otherwise idle-page experiment does +not represent a loaded application's rendering or input workload. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/example/Jamfile index 6e13a60..3950c92 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/example/Jamfile +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/Jamfile @@ -8,4 +8,36 @@ project : requirements /webcpp/asio//asio ; import webcpp ; -webcpp.targets native emscripten ; +webcpp.targets native emscripten wasip2 wasip3 ; + +webcpp.example asio_quick_start.cpp ; +webcpp.example asio_turn_limit.cpp : : native emscripten ; +webcpp.example asio_timers.cpp ; +webcpp.example asio_promise.cpp : : emscripten ; +webcpp.example asio_event.cpp : : emscripten ; +webcpp.example asio_sockets.cpp : : emscripten ; +webcpp.example asio_resolver.cpp : : emscripten ; +webcpp.example asio_cobalt.cpp : /webcpp/asio//cobalt : native emscripten wasip2 wasip3 ; +webcpp.example asio_tls_client.cpp : /webcpp/asio//tls : native wasip2 wasip3 ; +webcpp.example asio_capabilities.cpp : : native wasip2 wasip3 ; + +# A page needs the completion helper header, but not the Node harness. +webcpp.variants page-asio_quick_start : asio_quick_start.cpp + : ../../../tools/node-test/include ; +webcpp.variants page-asio_turn_limit : asio_turn_limit.cpp + : ../../../tools/node-test/include ; +webcpp.variants page-asio_timers : asio_timers.cpp + : ../../../tools/node-test/include ; +webcpp.variants page-asio_cobalt : asio_cobalt.cpp + : /webcpp/asio//cobalt ../../../tools/node-test/include ; +webcpp.variants page-asio_promise : asio_promise.cpp + : ../../../tools/node-test/include ; +webcpp.variants page-asio_event : asio_event.cpp + : ../../../tools/node-test/include ; +webcpp.variants page-asio_sockets : asio_sockets.cpp + : ../../../tools/node-test/include ; +webcpp.variants page-asio_resolver : asio_resolver.cpp + : ../../../tools/node-test/include ; +webcpp.size-table asio + : page-asio_quick_start page-asio_turn_limit page-asio_timers page-asio_cobalt page-asio_promise page-asio_event page-asio_sockets page-asio_resolver ; +webcpp.lane asyncify : asio.sizes.md : emscripten ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_capabilities.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_capabilities.cpp new file mode 100644 index 0000000..af88c75 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_capabilities.cpp @@ -0,0 +1,29 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +// State requirements before the first WebCPP include, or use a compiler define. +#define WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND 1 +#include +#include +#include +#include + +int main() { + webcpp::asio::io_context context; + webcpp::asio::ip::tcp::socket socket(context); + boost::system::error_code error; + if (socket.open(webcpp::asio::ip::tcp::v4(), error)) { + // A compiled backend does not imply that the host granted socket access. + const auto message = error.message(); + (void)std::fprintf(stderr, "socket open: %s\n", message.c_str()); + return webcpp::test::exit_status(1); + } + std::puts("TCP socket opened"); + return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_capabilities.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_capabilities.expected new file mode 100644 index 0000000..72a9404 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_capabilities.expected @@ -0,0 +1 @@ +TCP socket opened diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_cobalt.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_cobalt.cpp new file mode 100644 index 0000000..56b5355 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_cobalt.cpp @@ -0,0 +1,33 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include + +#include +#include +#include +#include +#include + +#include +#include + +boost::cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // Cobalt's awaiter has static members called by the compiler's co_await expansion. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await boost::cobalt::this_coro::executor; + boost::asio::steady_timer timer(exec, std::chrono::milliseconds(50)); + auto [error] = co_await boost::cobalt::as_tuple(timer.async_wait(boost::cobalt::use_op)); + if (error) { + std::printf("timer error: %d\n", error.value()); + co_return webcpp::test::exit_status(1); + } + std::puts("cobalt slept"); + co_return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_cobalt.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_cobalt.expected new file mode 100644 index 0000000..3300e21 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_cobalt.expected @@ -0,0 +1 @@ +cobalt slept diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_event.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_event.cpp new file mode 100644 index 0000000..733cfde --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_event.cpp @@ -0,0 +1,40 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include +#include +#include +#include + +// clang-format off +EM_JS(void, send_event, (emscripten::EM_VAL handle), { + const target = Emval.toValue(handle); + setTimeout(() => target.dispatchEvent( + new CustomEvent('message', {detail: 5})), 20); +}); +// clang-format on + +int main() { + webcpp::asio::io_context io; + const auto target = emscripten::val::global("EventTarget").new_(); + int failures = 0; + webcpp::asio::browser::async_wait_event( + io.get_executor(), target, "message", + [&](boost::system::error_code ec, const emscripten::val& event) { + if (ec) { + ++failures; + return; + } + std::printf("event: message %d\n", event["detail"].as()); + }); + send_event(target.as_handle()); + io.run(); // lint-run: main waits for the browser event + return webcpp::test::exit_status(failures); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_event.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_event.expected new file mode 100644 index 0000000..c23271b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_event.expected @@ -0,0 +1 @@ +event: message 5 diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_promise.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_promise.cpp new file mode 100644 index 0000000..cbc528d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_promise.cpp @@ -0,0 +1,40 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include +#include +#include + +int main() { + webcpp::asio::io_context io; + auto resolved = emscripten::val::global("Promise").call("resolve", 42); + auto rejected = emscripten::val::global("Promise").call("reject", 9); + int failures = 0; + webcpp::asio::browser::async_await( + io.get_executor(), resolved, + [&](boost::system::error_code ec, const emscripten::val& value) { + if (ec) { + ++failures; + return; + } + std::printf("resolved: %d\n", value.as()); + }); + webcpp::asio::browser::async_await( + io.get_executor(), rejected, + [&](boost::system::error_code ec, const emscripten::val& reason) { + if (ec != webcpp::asio::browser::error::promise_rejected) { + ++failures; + return; + } + std::printf("rejected: promise_rejected %d\n", reason.as()); + }); + io.run(); // lint-run: main waits for both Promise completions + return webcpp::test::exit_status(failures); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_promise.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_promise.expected new file mode 100644 index 0000000..67bacce --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_promise.expected @@ -0,0 +1,2 @@ +resolved: 42 +rejected: promise_rejected 9 diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_quick_start.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_quick_start.cpp new file mode 100644 index 0000000..688ff7e --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_quick_start.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include + +#include + +#include + +#include +#include + +namespace asio = webcpp::asio; +using namespace std::chrono_literals; + +int main() { + asio::io_context io; + asio::steady_timer timer(io); + + boost::asio::post(io, [&timer] { + std::puts("posted"); + timer.expires_after(50ms); + timer.async_wait([](boost::system::error_code ec) { + if (ec) { + std::printf("timer error: %d\n", ec.value()); + } else { + std::puts("timer fired"); + } + }); + }); + + const auto handlers = io.run(); // lint-run: main owns the program's event loop + std::printf("run returned %zu handlers\n", handlers); + return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_quick_start.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_quick_start.expected new file mode 100644 index 0000000..69c561a --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_quick_start.expected @@ -0,0 +1,3 @@ +posted +timer fired +run returned 2 handlers diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_resolver.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_resolver.cpp new file mode 100644 index 0000000..371eb8a --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_resolver.cpp @@ -0,0 +1,33 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include +#include +#include + +int main() { + webcpp::asio::io_context io; + webcpp::asio::ip::tcp::resolver resolver(io); + int failures = 0; + resolver.async_resolve( + "example.com", "wss", [&](boost::system::error_code ec, const auto& results) { + if (ec || results.size() != 1) { + ++failures; + return; + } + const auto& entry = *results.begin(); + const auto endpoint = entry.endpoint(); + std::printf("%s %s %u unspecified: %s\n", entry.host_name().c_str(), + entry.service_name().c_str(), static_cast(endpoint.port()), + endpoint.address().is_unspecified() ? "true" : "false"); + }); + io.run(); // lint-run: main waits for the posted resolver result + return webcpp::test::exit_status(failures); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_resolver.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_resolver.expected new file mode 100644 index 0000000..914320c --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_resolver.expected @@ -0,0 +1 @@ +example.com wss 443 unspecified: true diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_sockets.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_sockets.cpp new file mode 100644 index 0000000..988374c --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_sockets.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include +#include +#include + +int main() { + webcpp::asio::io_context io; + webcpp::asio::ip::tcp::socket socket(io); + boost::system::error_code ec; + int failures = 0; + const auto open_result = socket.open(webcpp::asio::ip::tcp::v4(), ec); + const bool opened = !open_result && !ec && socket.is_open(); + std::printf("open: %s\n", opened ? "true" : "false"); + failures += static_cast(!opened); + const auto connect_result = socket.connect({boost::asio::ip::address_v4::loopback(), 80}, ec); + const bool unsupported = + connect_result == ec && ec == boost::asio::error::operation_not_supported; + std::printf("connect: %s\n", unsupported ? "operation_not_supported" : "unexpected"); + failures += static_cast(!unsupported); + const auto close_result = socket.close(ec); + const bool closed = !close_result && !ec && !socket.is_open(); + std::printf("close: %s\n", closed ? "ok" : "unexpected"); + failures += static_cast(!closed); + return webcpp::test::exit_status(failures); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_sockets.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_sockets.expected new file mode 100644 index 0000000..c4ee147 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_sockets.expected @@ -0,0 +1,3 @@ +open: true +connect: operation_not_supported +close: ok diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_timers.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_timers.cpp new file mode 100644 index 0000000..a1691b0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_timers.cpp @@ -0,0 +1,55 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include + +#include + +#include + +#include +#include + +namespace asio = webcpp::asio; +using namespace std::chrono_literals; + +int main() { + asio::io_context io; + const auto start = std::chrono::steady_clock::now(); + asio::steady_timer sixty(io, start + 60ms); + asio::steady_timer twenty(io, start + 20ms); + asio::steady_timer forty(io, start + 40ms); + const auto report = [](const char* label) { + return [label](boost::system::error_code ec) { + if (ec) { + std::printf("timer error: %d\n", ec.value()); + } else { + std::puts(label); + } + }; + }; + sixty.async_wait(report("60 ms")); + twenty.async_wait(report("20 ms")); + forty.async_wait(report("40 ms")); + io.run(); // lint-run: main waits for the three deadlines + + io.restart(); + asio::steady_timer cancelled(io, std::chrono::steady_clock::time_point::max()); + cancelled.async_wait([](boost::system::error_code ec) { + if (ec == boost::asio::error::operation_aborted) { + std::puts("cancelled: operation_aborted"); + } else { + std::printf("unexpected cancellation result: %d\n", ec.value()); + } + }); + cancelled.cancel(); + io.run(); // lint-run: main delivers the cancelled wait's completion + return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_timers.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_timers.expected new file mode 100644 index 0000000..813c60a --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_timers.expected @@ -0,0 +1,4 @@ +20 ms +40 ms +60 ms +cancelled: operation_aborted diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_tls_client.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_tls_client.cpp new file mode 100644 index 0000000..53235fb --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_tls_client.cpp @@ -0,0 +1,30 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// tag::program[] +#include +#include +#include + +// main's standard signature requires char**, even though it does not modify argv. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // An optional argument contains replacement PEM bytes, not a filename. + // Keep the prepared context mutable for subsequent TLS stream construction. + // NOLINTNEXTLINE(misc-const-correctness) + auto prepared = argc == 1 ? webcpp::asio::make_tls_client_context() + : webcpp::asio::make_tls_client_context(argv[1]); + if (!prepared) { + const auto message = prepared.error().message(); + (void)std::fprintf(stderr, "%s\n", message.c_str()); + return webcpp::test::exit_status(1); + } + // Pass *prepared to TLS streams and keep it alive while those streams exist. + std::puts(argc == 1 ? "TLS client ready: embedded authorities" + : "TLS client ready: replacement authorities"); + return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_tls_client.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_tls_client.expected new file mode 100644 index 0000000..9c50bc7 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_tls_client.expected @@ -0,0 +1 @@ +TLS client ready: embedded authorities diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_turn_limit.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_turn_limit.cpp new file mode 100644 index 0000000..b0b4190 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_turn_limit.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include + +#include + +#include + +#include +#include +#include + +namespace asio = webcpp::asio; + +namespace { + +/** The context and remaining work of a finite chain of posted handlers. */ +struct work { + asio::io_context& io; + std::size_t remaining; +}; + +/** Runs one piece of work and schedules the next without calling it inline. */ +void next(work* state) { + if (--state->remaining != 0) { + boost::asio::post(state->io, std::bind_front(&next, state)); + } +} + +} // namespace + +int main() { + asio::io_context io(asio::io_context_options{.max_handlers_per_turn = 250}); + work state{.io = io, .remaining = 5000}; + boost::asio::post(io, std::bind_front(&next, &state)); + std::printf("max_handlers_per_turn: %zu\n", io.max_handlers_per_turn()); + const auto handlers = io.run(); // lint-run: main owns the program's event loop + std::printf("handlers run: %zu\n", handlers); + return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/asio_turn_limit.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_turn_limit.expected new file mode 100644 index 0000000..f1281fe --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/asio_turn_limit.expected @@ -0,0 +1,2 @@ +max_handlers_per_turn: 250 +handlers run: 5000 diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/tls/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/example/tls/Jamfile new file mode 100644 index 0000000..b556af5 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/tls/Jamfile @@ -0,0 +1,22 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# tag::project[] +project : requirements @source-openssl ; + +rule source-openssl ( properties * ) +{ + if ! emscripten in $(properties) + { + return /webcpp/asio//openssl ; + } +} +# end::project[] + +import webcpp ; +webcpp.targets native wasip3 emscripten ; +webcpp.example asio_tls.cpp ; +webcpp.lane tls : asio_tls asio_tls.output : native wasip3 emscripten ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/tls/asio_tls.cpp b/libraries/asio/openspec/changes/genesis/reference/source/example/tls/asio_tls.cpp new file mode 100644 index 0000000..9295620 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/tls/asio_tls.cpp @@ -0,0 +1,19 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// tag::program[] +#include +#include +#include + +int main() { + webcpp::asio::ssl::context context(webcpp::asio::ssl::context::tlsv12_client); + context.set_verify_mode(webcpp::asio::ssl::verify_peer); + std::puts("context: tlsv12_client, verify_peer"); + return webcpp::test::exit_status(0); +} + +// end::program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/example/tls/asio_tls.expected b/libraries/asio/openspec/changes/genesis/reference/source/example/tls/asio_tls.expected new file mode 100644 index 0000000..3fbee37 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/example/tls/asio_tls.expected @@ -0,0 +1 @@ +context: tlsv12_client, verify_peer diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio.hpp index 7f26169..97e5818 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio.hpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio.hpp @@ -5,20 +5,33 @@ // https://www.boost.org/LICENSE_1_0.txt) /** - Every public header of asio but , which natively brings OpenSSL. + Every public header except ssl.hpp and tls_client_context.hpp, which bring optional TLS + dependencies. */ #ifndef WEBCPP_ASIO_HPP #define WEBCPP_ASIO_HPP #include +#include +#include +#include #include #include +#include +#include +#include #include // lint-world: Boost's timers are asio's #include // lint-world: Boost's timers are asio's -#ifdef __EMSCRIPTEN__ +#ifdef WEBCPP_TARGET_EMSCRIPTEN +#include +#include #include +#include +#if WEBCPP_ASIO_HAS_BROWSER_WORKERS +#include +#endif #endif #endif // WEBCPP_ASIO_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_datagram_socket.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_datagram_socket.hpp new file mode 100644 index 0000000..c42c247 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_datagram_socket.hpp @@ -0,0 +1,466 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BASIC_DATAGRAM_SOCKET_HPP +#define WEBCPP_ASIO_BASIC_DATAGRAM_SOCKET_HPP +#include +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: native sockets keep Boost semantics + +namespace webcpp::asio { +/** + Boost's native datagram socket. + @tparam Protocol The network protocol. + @tparam Executor The associated executor. +*/ +template +using basic_datagram_socket = boost::asio::basic_datagram_socket; +} // namespace webcpp::asio +#else +#include + +namespace webcpp::asio { +/** + A browser datagram socket whose operations use browser::transport. + @tparam Protocol The network protocol. + @tparam Executor The associated executor. +*/ +template +class basic_datagram_socket : public detail::browser_socket { + using base = detail::browser_socket; + using base::transport_state; + +public: + /** Inherits executor, context, protocol and endpoint constructors. */ + using base::base; + /** The executor type. */ + using executor_type = Executor; + /** The protocol type. */ + using protocol_type = Protocol; + /** The endpoint type. */ + using endpoint_type = Protocol::endpoint; + + /** + Forwards connect to the transport. + @param endpoint The endpoint. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code connect(const endpoint_type& endpoint, + boost::system::error_code& ec) { + ec = transport_state.connect(endpoint); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards connect, throwing on error. + @param endpoint The endpoint. + */ + void connect(const endpoint_type& endpoint) { + boost::system::error_code ec; + connect(endpoint, ec); + detail::throw_socket_error(ec); + } +#endif + /** + Initiates connect and posts its completion. + @tparam Token The completion token type. + @param endpoint The endpoint. + @param token The completion token. + @return The completion token result. + */ + template + auto async_connect(const endpoint_type& endpoint, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const endpoint_type& endpoint) { + transport_state.async_connect(endpoint, std::move(handler)); + }, + token, endpoint); + } + + /** + Forwards shutdown to the transport. + @param what The what. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code shutdown(boost::asio::socket_base::shutdown_type what, + boost::system::error_code& ec) { + ec = transport_state.shutdown(what); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards shutdown, throwing on error. + @param what The what. + */ + void shutdown(boost::asio::socket_base::shutdown_type what) { + boost::system::error_code ec; + shutdown(what, ec); + detail::throw_socket_error(ec); + } +#endif + /** + Forwards send to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t send(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + boost::system::error_code& ec) { + return transport_state.send(buffers, flags, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards send, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @return The operation result. + */ + template + std::size_t send(const Buffers& buffers, boost::asio::socket_base::message_flags flags) { + boost::system::error_code ec; + const auto result = send(buffers, flags, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates send and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param flags The flags. + @param token The completion token. + @return The completion token result. + */ + template + auto async_send(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers, + boost::asio::socket_base::message_flags flags) { + transport_state.async_send(buffers, flags, std::move(handler)); + }, + token, buffers, flags); + } + + /** + Uses send with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param ec Receives the transport error, or success. + @return The byte count. + */ + template + std::size_t send(const Buffers& buffers, boost::system::error_code& ec) { + return send(buffers, 0, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Uses send with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @return The byte count. + */ + template + std::size_t send(const Buffers& buffers) { + return send(buffers, 0); + } +#endif + /** + Initiates send with no message flags. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param token The completion token. + @return The token result. + */ + template + auto async_send(const Buffers& buffers, Token&& token) { + return async_send(buffers, 0, std::forward(token)); + } + + /** + Forwards receive to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t receive(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + boost::system::error_code& ec) { + return transport_state.receive(buffers, flags, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards receive, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @return The operation result. + */ + template + std::size_t receive(const Buffers& buffers, boost::asio::socket_base::message_flags flags) { + boost::system::error_code ec; + const auto result = receive(buffers, flags, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates receive and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param flags The flags. + @param token The completion token. + @return The completion token result. + */ + template + auto async_receive(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers, + boost::asio::socket_base::message_flags flags) { + transport_state.async_receive(buffers, flags, std::move(handler)); + }, + token, buffers, flags); + } + + /** + Uses receive with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param ec Receives the transport error, or success. + @return The byte count. + */ + template + std::size_t receive(const Buffers& buffers, boost::system::error_code& ec) { + return receive(buffers, 0, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Uses receive with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @return The byte count. + */ + template + std::size_t receive(const Buffers& buffers) { + return receive(buffers, 0); + } +#endif + /** + Initiates receive with no message flags. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param token The completion token. + @return The token result. + */ + template + auto async_receive(const Buffers& buffers, Token&& token) { + return async_receive(buffers, 0, std::forward(token)); + } + + /** + Forwards send_to to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @param flags The flags. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t send_to(const Buffers& buffers, const endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags, + boost::system::error_code& ec) { + return transport_state.send_to(buffers, endpoint, flags, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards send_to, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @param flags The flags. + @return The operation result. + */ + template + std::size_t send_to(const Buffers& buffers, const endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags) { + boost::system::error_code ec; + const auto result = send_to(buffers, endpoint, flags, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates send_to and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param endpoint The endpoint. + @param flags The flags. + @param token The completion token. + @return The completion token result. + */ + template + auto async_send_to(const Buffers& buffers, const endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers, const endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags) { + transport_state.async_send_to(buffers, endpoint, flags, std::move(handler)); + }, + token, buffers, endpoint, flags); + } + + /** + Uses send_to with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @param ec Receives the transport error, or success. + @return The byte count. + */ + template + std::size_t send_to(const Buffers& buffers, const endpoint_type& endpoint, + boost::system::error_code& ec) { + return send_to(buffers, endpoint, 0, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Uses send_to with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @return The byte count. + */ + template + std::size_t send_to(const Buffers& buffers, const endpoint_type& endpoint) { + return send_to(buffers, endpoint, 0); + } +#endif + /** + Initiates send_to with no message flags. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param endpoint The endpoint. + @param token The completion token. + @return The token result. + */ + template + auto async_send_to(const Buffers& buffers, const endpoint_type& endpoint, Token&& token) { + return async_send_to(buffers, endpoint, 0, std::forward(token)); + } + + /** + Forwards receive_from to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @param flags The flags. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t receive_from(const Buffers& buffers, endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags, + boost::system::error_code& ec) { + return transport_state.receive_from(buffers, endpoint, flags, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards receive_from, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @param flags The flags. + @return The operation result. + */ + template + std::size_t receive_from(const Buffers& buffers, endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags) { + boost::system::error_code ec; + const auto result = receive_from(buffers, endpoint, flags, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates receive_from and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param endpoint The endpoint. + @param flags The flags. + @param token The completion token. + @return The completion token result. + */ + template + auto async_receive_from(const Buffers& buffers, endpoint_type& endpoint, + boost::asio::socket_base::message_flags flags, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers, endpoint_type* endpoint, + boost::asio::socket_base::message_flags flags) { + transport_state.async_receive_from(buffers, *endpoint, flags, std::move(handler)); + }, + token, buffers, &endpoint, flags); + } + + /** + Uses receive_from with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @param ec Receives the transport error, or success. + @return The byte count. + */ + template + std::size_t receive_from(const Buffers& buffers, endpoint_type& endpoint, + boost::system::error_code& ec) { + return receive_from(buffers, endpoint, 0, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Uses receive_from with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param endpoint The endpoint. + @return The byte count. + */ + template + std::size_t receive_from(const Buffers& buffers, endpoint_type& endpoint) { + return receive_from(buffers, endpoint, 0); + } +#endif + /** + Initiates receive_from with no message flags. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param endpoint The endpoint. + @param token The completion token. + @return The token result. + */ + template + auto async_receive_from(const Buffers& buffers, endpoint_type& endpoint, Token&& token) { + return async_receive_from(buffers, endpoint, 0, std::forward(token)); + } +}; +} // namespace webcpp::asio +#endif +#endif // WEBCPP_ASIO_BASIC_DATAGRAM_SOCKET_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_socket_acceptor.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_socket_acceptor.hpp new file mode 100644 index 0000000..1e6c4c6 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_socket_acceptor.hpp @@ -0,0 +1,167 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BASIC_SOCKET_ACCEPTOR_HPP +#define WEBCPP_ASIO_BASIC_SOCKET_ACCEPTOR_HPP +#include +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: native sockets keep Boost semantics + +namespace webcpp::asio { +/** + Boost's native socket acceptor. + @tparam Protocol The network protocol. + @tparam Executor The associated executor. +*/ +template +using basic_socket_acceptor = boost::asio::basic_socket_acceptor; +} // namespace webcpp::asio +#else +#include // lint-world: allocate a stable peer with the handler allocator +#include // lint-world: preserve associations and peer lifetime across acceptance +#include +#include +#include + +namespace webcpp::asio { +/** + A browser socket acceptor whose operations use browser::transport. + @tparam Protocol The network protocol. + @tparam Executor The associated executor. +*/ +template +class basic_socket_acceptor : public detail::browser_socket { + using base = detail::browser_socket; + using base::transport_state; + +public: + /** Inherits executor, context, protocol and endpoint constructors. */ + using base::base; + /** The executor type. */ + using executor_type = Executor; + /** The protocol type. */ + using protocol_type = Protocol; + /** The endpoint type. */ + using endpoint_type = Protocol::endpoint; + /** The accepted socket type. */ + using socket_type = basic_stream_socket; + + /** + Forwards listen to the transport. + @param backlog The backlog. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code listen(int backlog, boost::system::error_code& ec) { + ec = transport_state.listen(backlog); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards listen, throwing on error. + @param backlog The backlog. + */ + void listen(int backlog) { + boost::system::error_code ec; + listen(backlog, ec); + detail::throw_socket_error(ec); + } +#endif + /** + Listens with the default backlog. + @param ec Receives the transport error, or success. + @return The error code. + */ + boost::system::error_code listen(boost::system::error_code& ec) { + return listen(boost::asio::socket_base::max_listen_connections, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** Listens with the default backlog, throwing on error. */ + void listen() { listen(boost::asio::socket_base::max_listen_connections); } +#endif + /** + Forwards accept to the transport. + @param peer The peer socket or remote endpoint. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code accept(socket_type& peer, boost::system::error_code& ec) { + ec = transport_state.accept(peer); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards accept, throwing on error. + @param peer The peer socket or remote endpoint. + */ + void accept(socket_type& peer) { + boost::system::error_code ec; + accept(peer, ec); + detail::throw_socket_error(ec); + } +#endif + /** + Accepts into peer asynchronously. + @tparam Token The completion token type. + @param peer The peer socket or remote endpoint. + @param token The completion token. + @return The token result. + */ + template + auto async_accept(socket_type& peer, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, socket_type* destination) { + transport_state.async_accept(*destination, std::move(handler)); + }, + token, &peer); + } + + /** + Returns a socket with the acceptance result. + @param ec Receives the transport error, or success. + @return The accepted socket, or a closed socket on failure. + */ + socket_type accept(boost::system::error_code& ec) { + socket_type peer(this->get_executor()); + accept(peer, ec); + return peer; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** Returns an accepted socket, throwing on error. @return The accepted socket. */ + socket_type accept() { + boost::system::error_code ec; + auto peer = accept(ec); + detail::throw_socket_error(ec); + return peer; + } +#endif + /** + Accepts a socket whose storage stays stable until completion. + @tparam Token The completion token type. + @param token The completion token. + @return The token result. + */ + template + auto async_accept(Token&& token) { + return boost::asio::async_compose( + [this, peer = std::shared_ptr()]( + auto& self, boost::system::error_code ec = {}) mutable { + if (!peer) { + peer = std::allocate_shared( + boost::asio::get_associated_allocator(self), this->get_executor()); + transport_state.async_accept(*peer, std::move(self)); + } else { + auto result = std::move(*peer); + peer.reset(); + self.complete(ec, std::move(result)); + } + }, + token, this->get_executor()); + } +}; +} // namespace webcpp::asio +#endif +#endif // WEBCPP_ASIO_BASIC_SOCKET_ACCEPTOR_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_stream_socket.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_stream_socket.hpp new file mode 100644 index 0000000..4bdd2fd --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/basic_stream_socket.hpp @@ -0,0 +1,364 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BASIC_STREAM_SOCKET_HPP +#define WEBCPP_ASIO_BASIC_STREAM_SOCKET_HPP +#include +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: native sockets keep Boost semantics + +namespace webcpp::asio { +/** + Boost's native stream socket. + @tparam Protocol The network protocol. + @tparam Executor The associated executor. +*/ +template +using basic_stream_socket = boost::asio::basic_stream_socket; +} // namespace webcpp::asio +#else +#include + +namespace webcpp::asio { +/** + A browser stream socket whose operations use browser::transport. + @tparam Protocol The network protocol. + @tparam Executor The associated executor. +*/ +template +class basic_stream_socket : public detail::browser_socket { + using base = detail::browser_socket; + using base::transport_state; + +public: + /** Inherits executor, context, protocol and endpoint constructors. */ + using base::base; + /** The executor type. */ + using executor_type = Executor; + /** The protocol type. */ + using protocol_type = Protocol; + /** The endpoint type. */ + using endpoint_type = Protocol::endpoint; + + /** + Forwards connect to the transport. + @param endpoint The endpoint. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code connect(const endpoint_type& endpoint, + boost::system::error_code& ec) { + ec = transport_state.connect(endpoint); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards connect, throwing on error. + @param endpoint The endpoint. + */ + void connect(const endpoint_type& endpoint) { + boost::system::error_code ec; + connect(endpoint, ec); + detail::throw_socket_error(ec); + } +#endif + /** + Initiates connect and posts its completion. + @tparam Token The completion token type. + @param endpoint The endpoint. + @param token The completion token. + @return The completion token result. + */ + template + auto async_connect(const endpoint_type& endpoint, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const endpoint_type& endpoint) { + transport_state.async_connect(endpoint, std::move(handler)); + }, + token, endpoint); + } + + /** + Forwards shutdown to the transport. + @param what The what. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code shutdown(boost::asio::socket_base::shutdown_type what, + boost::system::error_code& ec) { + ec = transport_state.shutdown(what); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards shutdown, throwing on error. + @param what The what. + */ + void shutdown(boost::asio::socket_base::shutdown_type what) { + boost::system::error_code ec; + shutdown(what, ec); + detail::throw_socket_error(ec); + } +#endif + /** + Forwards read_some to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t read_some(const Buffers& buffers, boost::system::error_code& ec) { + return transport_state.read_some(buffers, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards read_some, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @return The operation result. + */ + template + std::size_t read_some(const Buffers& buffers) { + boost::system::error_code ec; + const auto result = read_some(buffers, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates read_some and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param token The completion token. + @return The completion token result. + */ + template + auto async_read_some(const Buffers& buffers, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers) { + transport_state.async_read_some(buffers, std::move(handler)); + }, + token, buffers); + } + + /** + Forwards write_some to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t write_some(const Buffers& buffers, boost::system::error_code& ec) { + return transport_state.write_some(buffers, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards write_some, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @return The operation result. + */ + template + std::size_t write_some(const Buffers& buffers) { + boost::system::error_code ec; + const auto result = write_some(buffers, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates write_some and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param token The completion token. + @return The completion token result. + */ + template + auto async_write_some(const Buffers& buffers, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers) { + transport_state.async_write_some(buffers, std::move(handler)); + }, + token, buffers); + } + + /** + Forwards send to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t send(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + boost::system::error_code& ec) { + return transport_state.send(buffers, flags, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards send, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @return The operation result. + */ + template + std::size_t send(const Buffers& buffers, boost::asio::socket_base::message_flags flags) { + boost::system::error_code ec; + const auto result = send(buffers, flags, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates send and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param flags The flags. + @param token The completion token. + @return The completion token result. + */ + template + auto async_send(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers, + boost::asio::socket_base::message_flags flags) { + transport_state.async_send(buffers, flags, std::move(handler)); + }, + token, buffers, flags); + } + + /** + Uses send with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param ec Receives the transport error, or success. + @return The byte count. + */ + template + std::size_t send(const Buffers& buffers, boost::system::error_code& ec) { + return send(buffers, 0, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Uses send with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @return The byte count. + */ + template + std::size_t send(const Buffers& buffers) { + return send(buffers, 0); + } +#endif + /** + Initiates send with no message flags. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param token The completion token. + @return The token result. + */ + template + auto async_send(const Buffers& buffers, Token&& token) { + return async_send(buffers, 0, std::forward(token)); + } + + /** + Forwards receive to the transport. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + std::size_t receive(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + boost::system::error_code& ec) { + return transport_state.receive(buffers, flags, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards receive, throwing on error. + @tparam Buffers The operation type. + @param buffers The buffers. + @param flags The flags. + @return The operation result. + */ + template + std::size_t receive(const Buffers& buffers, boost::asio::socket_base::message_flags flags) { + boost::system::error_code ec; + const auto result = receive(buffers, flags, ec); + detail::throw_socket_error(ec); + return result; + } +#endif + /** + Initiates receive and posts its completion. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param flags The flags. + @param token The completion token. + @return The completion token result. + */ + template + auto async_receive(const Buffers& buffers, boost::asio::socket_base::message_flags flags, + Token&& token) { + return boost::asio::async_initiate( + [this](auto handler, const Buffers& buffers, + boost::asio::socket_base::message_flags flags) { + transport_state.async_receive(buffers, flags, std::move(handler)); + }, + token, buffers, flags); + } + + /** + Uses receive with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @param ec Receives the transport error, or success. + @return The byte count. + */ + template + std::size_t receive(const Buffers& buffers, boost::system::error_code& ec) { + return receive(buffers, 0, ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Uses receive with no message flags. + @tparam Buffers The operation type. + @param buffers The buffers. + @return The byte count. + */ + template + std::size_t receive(const Buffers& buffers) { + return receive(buffers, 0); + } +#endif + /** + Initiates receive with no message flags. + @tparam Buffers The operation type. + @tparam Token The completion token type. + @param buffers The buffers. + @param token The completion token. + @return The token result. + */ + template + auto async_receive(const Buffers& buffers, Token&& token) { + return async_receive(buffers, 0, std::forward(token)); + } +}; +} // namespace webcpp::asio +#endif +#endif // WEBCPP_ASIO_BASIC_STREAM_SOCKET_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/async_await.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/async_await.hpp new file mode 100644 index 0000000..4f4ac8a --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/async_await.hpp @@ -0,0 +1,175 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BROWSER_ASYNC_AWAIT_HPP +#define WEBCPP_ASIO_BROWSER_ASYNC_AWAIT_HPP + +#include + +#if !WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#error \ + "webcpp::asio::browser::async_await requires the Emscripten browser bridge; use native/WASI Asio operations on this target" +#else + +#include // lint-world: the operation's executor +#include // lint-world: preserve handler associations when posting values +#include // lint-world: operation storage belongs to its handler +#include // lint-world: cancel an outstanding operation +#include // lint-world: retain the handler executor while pending +#include // lint-world: completion token initiation +#include // lint-world: Asio's cancellation error +#include // lint-world: keep both contexts alive until completion +#include // lint-world: completions only post to the event loop +#include +#include +#include +#include +#include +#include +#include + +namespace webcpp::asio::browser { +namespace detail { +/** One Promise wait, owned by its bridge until completion or shutdown. */ +template +class await_operation final : public registration { +public: + /** Allocates this operation with the handler's associated allocator. */ + using storage_allocator = std::allocator_traits< + boost::asio::associated_allocator_t>::template rebind_alloc; + + /** Constructs a pending wait that owns outstanding work on executor. */ + await_operation(bridge& owner, const Executor& executor, Handler handler) + : bridge_(owner), + work_(boost::asio::prefer(executor, boost::asio::execution::outstanding_work_t::tracked)), + completion_work_(boost::asio::get_associated_executor(handler, executor)), + handler_(std::move(handler)) {} + + /** Removes a registered wait, including when initiation throws. */ + ~await_operation() { + if (id_ != 0) { + bridge_.remove(id_); + boost::asio::get_associated_cancellation_slot(handler_).clear(); + } + } + + /** Not copyable: the bridge and cancellation callback refer to this address. */ + await_operation(const await_operation&) = delete; + /** Not copy-assignable: the registration has one owner. */ + await_operation& operator=(const await_operation&) = delete; + /** Not movable: registered callbacks refer to this address. */ + await_operation(await_operation&&) = delete; + /** Not move-assignable: registered callbacks refer to this address. */ + await_operation& operator=(await_operation&&) = delete; + + /** Registers settlement and cancellation reactions for promise. */ + void start(const emscripten::val& promise) { + id_ = bridge_.add(*this); + auto slot = boost::asio::get_associated_cancellation_slot(handler_); + if (slot.is_connected()) { + slot.assign([this](boost::asio::cancellation_type kind) { + if ((kind & boost::asio::cancellation_type::all) != + boost::asio::cancellation_type::none) { + complete(boost::asio::error::operation_aborted, emscripten::val::undefined()); + } + }); + } + webcpp_asio_await(promise.as_handle(), bridge_.function(id_).as_handle()); + } + + /** Posts the resolved value or rejection reason and releases this registration. */ + bool deliver(const emscripten::val& envelope) override { + const bool fulfilled = envelope["ok"].as(); + complete(fulfilled ? boost::system::error_code() + : error::make_error_code(error::promise_rejected), + envelope["value"]); + return true; + } + + /** Destroys the pending handler without calling it when its context shuts down. */ + void shutdown() noexcept override { + destroy(storage_allocator(boost::asio::get_associated_allocator(handler_))); + } + +private: + /** Removes registration before freeing state and posting its completion. */ + void complete(boost::system::error_code ec, emscripten::val value) { + boost::asio::get_associated_cancellation_slot(handler_).clear(); + bridge_.remove(id_); + id_ = 0; + const storage_allocator allocator(boost::asio::get_associated_allocator(handler_)); + const auto cleanup = [allocator](await_operation* operation) { + operation->destroy(allocator); + }; + std::unique_ptr owned(this, cleanup); + auto handler = std::move(handler_); + const auto executor = work_; + const auto completion_work = completion_work_; + owned.reset(); + boost::asio::post(executor, boost::asio::append(std::move(handler), ec, std::move(value))); + } + + /** Destroys and deallocates this wait through its associated allocator. */ + void destroy(storage_allocator allocator) noexcept { + std::allocator_traits::destroy(allocator, this); + std::allocator_traits::deallocate(allocator, this, 1); + } + + bridge& bridge_; + decltype(boost::asio::prefer(std::declval(), + boost::asio::execution::outstanding_work_t::tracked)) work_; + boost::asio::executor_work_guard> + completion_work_; + Handler handler_; + std::uint64_t id_ = 0; +}; + +/** Allocates and starts a wait once the completion token initiates it. */ +struct initiate_await { + /** Starts the operation with handler, executor and promise. */ + template + void operator()(Handler&& handler, const Executor& executor, + const emscripten::val& promise) const { + using operation = await_operation, Executor>; + auto& context = boost::asio::query(executor, boost::asio::execution::context); + auto& owner = boost::asio::use_service(context); + const typename operation::storage_allocator allocator( + boost::asio::get_associated_allocator(handler)); + auto pending = boost::allocate_unique(allocator, owner, executor, + std::forward(handler)); + pending->start(promise); + (void)pending.release(); + } +}; +} // namespace detail + +/** + Asynchronously receives a JavaScript Promise's value or rejection reason. + + Completion is posted through the bridge, never invoked inline. Terminal, + partial or total cancellation posts operation_aborted and undefined; it does + not cancel the JavaScript Promise. A pending wait owns outstanding work. + Destroying its context destroys its handler without calling it. Operation + storage uses the handler's associated allocator. + + @tparam Executor The concrete or type-erased executor of the owning context. + @tparam CompletionToken A token for void(boost::system::error_code, emscripten::val). + @param executor The executor whose context owns the wait. + @param promise A Promise or a value normalized by JavaScript Promise.resolve. + @param token The completion token. + @return The result determined by token. + @see "Promises and events", in the guide. +*/ +template +auto async_await(const Executor& executor, emscripten::val promise, CompletionToken&& token) { + return boost::asio::async_initiate( + detail::initiate_await{}, token, executor, std::move(promise)); +} +} // namespace webcpp::asio::browser + +#endif // WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#endif // WEBCPP_ASIO_BROWSER_ASYNC_AWAIT_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/async_wait_event.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/async_wait_event.hpp new file mode 100644 index 0000000..b6ee3ae --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/async_wait_event.hpp @@ -0,0 +1,187 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BROWSER_ASYNC_WAIT_EVENT_HPP +#define WEBCPP_ASIO_BROWSER_ASYNC_WAIT_EVENT_HPP + +#include + +#if !WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#error \ + "webcpp::asio::browser::async_wait_event requires the Emscripten browser bridge; use native/WASI Asio operations on this target" +#else + +#include // lint-world: the operation's executor +#include // lint-world: preserve handler associations when posting values +#include // lint-world: operation storage belongs to its handler +#include // lint-world: cancel an outstanding operation +#include // lint-world: retain the handler executor while pending +#include // lint-world: completion token initiation +#include // lint-world: Asio's cancellation error +#include // lint-world: keep both contexts alive until completion +#include // lint-world: completions only post to the event loop +#include +#include +#include +#include +#include +#include +#include + +namespace webcpp::asio::browser { +namespace detail { +/** One event wait, owned by its bridge until completion or shutdown. */ +template +class event_operation final : public registration { +public: + /** Allocates this operation with the handler's associated allocator. */ + using storage_allocator = std::allocator_traits< + boost::asio::associated_allocator_t>::template rebind_alloc; + + /** Constructs a pending wait that owns outstanding work on executor. */ + event_operation(bridge& owner, const Executor& executor, Handler handler) + : bridge_(owner), + work_(boost::asio::prefer(executor, boost::asio::execution::outstanding_work_t::tracked)), + completion_work_(boost::asio::get_associated_executor(handler, executor)), + handler_(std::move(handler)) {} + + /** Removes a listener and registration, including when initiation throws. */ + ~event_operation() { detach(); } + + /** Not copyable: the bridge and cancellation callback refer to this address. */ + event_operation(const event_operation&) = delete; + /** Not copy-assignable: the registration has one owner. */ + event_operation& operator=(const event_operation&) = delete; + /** Not movable: registered callbacks refer to this address. */ + event_operation(event_operation&&) = delete; + /** Not move-assignable: registered callbacks refer to this address. */ + event_operation& operator=(event_operation&&) = delete; + + /** Registers a one-shot listener and cancellation callback. */ + void start(const emscripten::val& target, const emscripten::val& type) { + target_ = target; + type_ = type; + id_ = bridge_.add(*this); + auto slot = boost::asio::get_associated_cancellation_slot(handler_); + if (slot.is_connected()) { + slot.assign([this](boost::asio::cancellation_type kind) { + if ((kind & boost::asio::cancellation_type::all) != + boost::asio::cancellation_type::none) { + complete(boost::asio::error::operation_aborted, emscripten::val::undefined()); + } + }); + } + function_ = bridge_.function(id_); + auto options = emscripten::val::object(); + options.set("once", true); + target_.call("addEventListener", type_, function_, options); + } + + /** Posts the next event and releases the one-shot listener. */ + bool deliver(const emscripten::val& event) override { + complete({}, event); + return true; + } + + /** Destroys the pending handler without calling it when its context shuts down. */ + void shutdown() noexcept override { + destroy(storage_allocator(boost::asio::get_associated_allocator(handler_))); + } + +private: + /** Removes the listener, cancellation callback and bridge key once. */ + void detach() { + if (id_ != 0) { + boost::asio::get_associated_cancellation_slot(handler_).clear(); + bridge_.remove(id_); + id_ = 0; + if (!function_.isUndefined()) { + target_.call("removeEventListener", type_, function_); + } + } + } + + /** Removes registration before freeing state and posting its completion. */ + void complete(boost::system::error_code ec, emscripten::val value) { + detach(); + const storage_allocator allocator(boost::asio::get_associated_allocator(handler_)); + const auto cleanup = [allocator](event_operation* operation) { + operation->destroy(allocator); + }; + std::unique_ptr owned(this, cleanup); + auto handler = std::move(handler_); + const auto executor = work_; + const auto completion_work = completion_work_; + owned.reset(); + boost::asio::post(executor, boost::asio::append(std::move(handler), ec, std::move(value))); + } + + /** Destroys and deallocates this wait through its associated allocator. */ + void destroy(storage_allocator allocator) noexcept { + std::allocator_traits::destroy(allocator, this); + std::allocator_traits::deallocate(allocator, this, 1); + } + + bridge& bridge_; + decltype(boost::asio::prefer(std::declval(), + boost::asio::execution::outstanding_work_t::tracked)) work_; + boost::asio::executor_work_guard> + completion_work_; + Handler handler_; + std::uint64_t id_ = 0; + emscripten::val target_ = emscripten::val::undefined(); + emscripten::val type_ = emscripten::val::undefined(); + emscripten::val function_ = emscripten::val::undefined(); +}; + +/** Allocates and starts a wait once the completion token initiates it. */ +struct initiate_event { + /** Starts the operation with handler, executor, target and event type. */ + template + void operator()(Handler&& handler, const Executor& executor, const emscripten::val& target, + const emscripten::val& type) const { + using operation = event_operation, Executor>; + auto& context = boost::asio::query(executor, boost::asio::execution::context); + auto& owner = boost::asio::use_service(context); + const typename operation::storage_allocator allocator( + boost::asio::get_associated_allocator(handler)); + auto pending = boost::allocate_unique(allocator, owner, executor, + std::forward(handler)); + pending->start(target, type); + (void)pending.release(); + } +}; +} // namespace detail + +/** + Asynchronously receives the next event of type on a JavaScript EventTarget. + + Completion is posted through the bridge. Terminal, partial or total cancellation + removes the listener and posts operation_aborted and undefined. A pending wait + owns outstanding work. Context destruction removes the listener and destroys its + handler silently. The event type is copied even when initiation is deferred. + + @tparam Executor The concrete or type-erased executor of the owning context. + @tparam CompletionToken A token for void(boost::system::error_code, emscripten::val). + @param executor The executor whose context owns the wait. + @param target The JavaScript EventTarget. + @param type The event type, which need not end in a null byte. + @param token The completion token. + @return The result determined by token. + @see "Await one browser event", in the guide. +*/ +template +auto async_wait_event(const Executor& executor, emscripten::val target, std::string_view type, + CompletionToken&& token) { + auto name = emscripten::val::take_ownership(webcpp_asio_string(type.data(), type.size())); + return boost::asio::async_initiate( + detail::initiate_event{}, token, executor, std::move(target), std::move(name)); +} +} // namespace webcpp::asio::browser + +#endif // WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#endif // WEBCPP_ASIO_BROWSER_ASYNC_WAIT_EVENT_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/bridge.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/bridge.hpp index e794d26..c150b38 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/bridge.hpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/bridge.hpp @@ -9,10 +9,16 @@ #include +#if !WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#error \ + "webcpp::asio::browser::bridge requires the Emscripten browser bridge; use native/WASI Asio completion operations on this target" +#else + #include #include #include // lint-world: a service of the io_context +#include #include #include @@ -59,6 +65,31 @@ class registration { registration& operator=(const registration&) = default; }; +/** + A registration whose lookup node lives in its owner's allocation. + + The bridge indexes it without allocating memory. Remove it before destruction, + exactly as for registration; it may not be registered in two bridges at once. +*/ +class intrusive_registration : public registration, + public boost::intrusive::avl_set_base_hook< + boost::intrusive::link_mode> { + friend class bridge; + std::uint64_t bridge_key_ = 0; + +protected: + /** Constructs an unregistered node. */ + intrusive_registration() = default; + /** Destroys an already removed node. */ + ~intrusive_registration() = default; + +public: + /** A registered node cannot be copied. */ + intrusive_registration(const intrusive_registration&) = delete; + /** A registered node cannot be assigned. */ + intrusive_registration& operator=(const intrusive_registration&) = delete; +}; + /** The io_context's bridge: the JavaScript functions through which browser events reach it, each delivering to one registration by a key that is never reused. @@ -114,11 +145,22 @@ class bridge : public boost::asio::execution_context::service { return key; } + /** + Registers an owner-allocated node without allocating lookup storage. + @param r Unregistered node that remains alive until removal or shutdown. + @return Its unique key, from the same sequence as ordinary registrations. + */ + [[nodiscard]] std::uint64_t add(intrusive_registration& r) { + r.bridge_key_ = next_++; + intrusive_.insert(r); + return r.bridge_key_; + } + /** A JavaScript function that delivers its argument to the registration key. Called once key is removed, once the io_context is destroyed, or once the runtime aborted, - a trap or abort(), it does nothing. + with Emscripten's ABORT flag set, it does nothing. @param key A key add returned. @return The function, to install as a listener or a promise's reaction. @@ -132,7 +174,13 @@ class bridge : public boost::asio::execution_context::service { @param key A key add returned; one already removed is ignored. */ - void remove(std::uint64_t key) noexcept { registrations_.erase(key); } + void remove(std::uint64_t key) noexcept { + registrations_.erase(key); + const auto found = intrusive_.find(key, node_less{}); + if (found != intrusive_.end()) { + intrusive_.erase(found); + } + } /** Whether the bridge is delivering an event, which the run family refuses to run inside. @@ -155,6 +203,10 @@ class bridge : public boost::asio::execution_context::service { void deliver(std::uint64_t key, const emscripten::val& event) { const auto found = registrations_.find(key); if (found == registrations_.end()) { + const auto node = intrusive_.find(key, node_less{}); + if (node != intrusive_.end() && node->deliver(event)) { + remove(key); + } return; } // A registration that is done may have freed itself, and one added meanwhile may have @@ -168,6 +220,24 @@ class bridge : public boost::asio::execution_context::service { std::uint64_t, registration*, boost::hash, std::equal_to<>, boost::asio::execution_context::allocator>>; + struct node_less { + bool operator()(const intrusive_registration& a, const intrusive_registration& b) const { + return a.bridge_key_ < b.bridge_key_; + } + + bool operator()(std::uint64_t a, const intrusive_registration& b) const { + return a < b.bridge_key_; + } + + bool operator()(const intrusive_registration& a, std::uint64_t b) const { + return a.bridge_key_ < b; + } + }; + + using nodes = + boost::intrusive::avl_set, + boost::intrusive::constant_time_size>; + /** Stops the functions and shuts down every registration still held, without calling it. */ void shutdown() override { token_.set("alive", false); @@ -175,9 +245,15 @@ class bridge : public boost::asio::execution_context::service { for (auto& [key, r] : pending) { r->shutdown(); } + while (!intrusive_.empty()) { + auto& r = *intrusive_.begin(); + intrusive_.erase(intrusive_.begin()); + r.shutdown(); + } } map registrations_; + nodes intrusive_; // {alive, depth}: whether the bridge exists, which every function of the bridge reads first, // and how many of its deliveries are in progress, which its functions put back however a // delivery ends and delivering() reads. @@ -187,4 +263,5 @@ class bridge : public boost::asio::execution_context::service { } // namespace webcpp::asio::browser +#endif // WEBCPP_ASIO_HAS_BROWSER_BRIDGE #endif // WEBCPP_ASIO_BROWSER_BRIDGE_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/error.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/error.hpp new file mode 100644 index 0000000..5b9356d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/error.hpp @@ -0,0 +1,67 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BROWSER_ERROR_HPP +#define WEBCPP_ASIO_BROWSER_ERROR_HPP + +#include + +#include +#include +#include + +namespace webcpp::asio::browser::error { +/** Errors reported by browser operations; values are never reused. */ +enum class errors : int { + /** The JavaScript Promise rejected; its reason is the completion value. */ + promise_rejected = 1, +}; +/** A JavaScript Promise rejection. */ +inline constexpr errors promise_rejected = errors::promise_rejected; + +namespace detail { +/** The category for browser operation errors. */ +class browser_category final : public boost::system::error_category { +public: + /** Returns the stable category name, webcpp.asio. */ + const char* name() const noexcept override { return "webcpp.asio"; } + + /** Returns a description of value, or the unknown-error description. */ + std::string message(int value) const override { + return value == static_cast(errors::promise_rejected) ? "the promise was rejected" + : "unknown webcpp.asio error"; + } +}; +} // namespace detail + +/** + Returns the category shared by all browser operation errors. + + @return The category named webcpp.asio. +*/ +inline const boost::system::error_category& category() noexcept { + static const detail::browser_category instance; + return instance; +} + +/** + Creates the error code corresponding to value. + + @param value The browser error. + @return Its code in category(). +*/ +inline boost::system::error_code make_error_code(errors value) noexcept { + return {static_cast(value), category()}; +} +} // namespace webcpp::asio::browser::error + +namespace boost::system { +/** Enables implicit conversion of browser errors to error_code. */ +template <> +struct is_error_code_enum : std::true_type {}; +} // namespace boost::system + +#endif // WEBCPP_ASIO_BROWSER_ERROR_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/main_thread_context.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/main_thread_context.hpp new file mode 100644 index 0000000..5cd4ab2 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/main_thread_context.hpp @@ -0,0 +1,360 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BROWSER_MAIN_THREAD_CONTEXT_HPP +#define WEBCPP_ASIO_BROWSER_MAIN_THREAD_CONTEXT_HPP + +#include + +#if !WEBCPP_ASIO_HAS_BROWSER_WORKERS && !defined(WEBCPP_ASIO_REFERENCE) +#error \ + "webcpp::asio::browser::main_thread_context requires Emscripten pthreads; select threading=multi" +#else + +#include +#include +#include // lint-world: Asio's exception policy +#include // lint-world: owns the main-thread executor service +#include +#include +#include + +#include +#include +#include +#include + +namespace webcpp::asio::browser { + +/** + An execution context that posts C++ handlers onto the browser's main runtime thread. + + Construct and destroy it on the main browser thread. Its executors may be copied to + workers and used with post, dispatch, defer and bind_executor. Handlers execute in + ordinary browser callbacks and must not suspend WebAssembly's stack or call an + io_context run family. + JavaScript values remain on their owning thread: obtain DOM values inside the main + handler, and exchange ordinary C++ data with worker contexts through their executors. + + Destruction discards queued handlers without invoking them. As with an Asio context, + the context must outlive every call that uses its executors. The Emscripten runtime + must remain alive until pending work finishes. The SDK owns proxy-queue notification + storage; handler storage uses the allocator supplied to the executor. + If moving or invoking a callable throws, remaining queued callables and further + queued submissions are discarded. The exception propagates to the browser's + callback boundary; this context does not promise queue recovery after such a failure. +*/ +class main_thread_context : public boost::asio::execution_context { + struct operation : boost::intrusive::list_base_hook<> { + void (*finish)(operation*, bool); + + explicit operation(void (*function)(operation*, bool)) : finish(function) {} + }; + + template + struct handler_operation final : operation { + // This is storage ownership, not a uses_allocator construction protocol. + using storage_allocator = + std::allocator_traits::template rebind_alloc; + + handler_operation(Function handler, const storage_allocator& storage) + : operation(&complete), function(std::move(handler)), allocator(storage) {} + + static void complete(operation* base, bool invoke) { + auto* self = static_cast(base); + const auto release = [](handler_operation* value) { + auto allocator = value->allocator; + std::allocator_traits::destroy(allocator, value); + std::allocator_traits::deallocate(allocator, value, 1); + }; + std::unique_ptr owned(self, release); + if (!invoke) { + return; + } + // A throwing move still destroys the pending operation. Successful moves + // release its allocation before invoking the callable, as Asio requires. + auto function = std::move(self->function); + owned.reset(); + std::move(function)(); + } + + Function function; + storage_allocator allocator; + }; + + // This state can outlive the Asio service when a handler destroys its context. + // Allocate it with a copy of the original allocator, not execution_context's + // allocator adapter, whose implementation is destroyed with that context. + class control { + public: + control() : queue_(em_proxying_queue_create()) { + if (queue_ == nullptr) { + boost::asio::detail::throw_exception(std::bad_alloc()); + } + } + + ~control() { em_proxying_queue_destroy(queue_); } + + void post(operation* pending, const std::shared_ptr& self) { + std::unique_lock lock(mutex_); + if (stopped_) { + lock.unlock(); + pending->finish(pending, false); + return; + } + pending_.push_back(*pending); + if (active_ || notification_) { + return; + } + // One notification drains our queue. It owns the control even if the + // context is destroyed before the SDK starts delivering that notification. + notification_ = self; + if (!emscripten_proxy_async(queue_, emscripten_main_runtime_thread_id(), &deliver, + this)) { + notification_.reset(); + pending_.erase(pending_.iterator_to(*pending)); + lock.unlock(); + pending->finish(pending, false); + boost::asio::detail::throw_exception(std::bad_alloc()); + } + } + + void stop() { + boost::intrusive::list discarded; + bool drain = false; + { + const std::scoped_lock lock(mutex_); + stopped_ = true; + discarded.splice(discarded.end(), pending_); + drain = !active_ && notification_ != nullptr; + } + while (!discarded.empty()) { + auto& pending = discarded.front(); + discarded.pop_front(); + pending.finish(&pending, false); + } + // The SDK rejects recursive queue execution. Active delivery already + // retains this control, and will observe the now-empty stopped queue. + if (drain) { + emscripten_proxy_execute_queue(queue_); + } + } + + private: + static void deliver(void* argument) { + auto& state = *static_cast(argument); + std::shared_ptr self; + { + const std::scoped_lock lock(state.mutex_); + self = std::move(state.notification_); + state.active_ = true; + } + bool finished = false; + const boost::scope::scope_exit cleanup([&] { + if (!finished) { + // A throwing callable must not strand queued allocations or an + // active flag. The exception still propagates to the browser. + self->stop(); + const std::scoped_lock lock(self->mutex_); + self->active_ = false; + } + }); + for (;;) { + operation* pending = nullptr; + { + const std::scoped_lock lock(self->mutex_); + if (self->pending_.empty()) { + // Atomically release the drain so a concurrent post schedules + // a fresh notification rather than missing this wakeup. + self->active_ = false; + finished = true; + return; + } + pending = &self->pending_.front(); + self->pending_.pop_front(); + } + pending->finish(pending, true); + } + } + + em_proxying_queue* queue_; + std::mutex mutex_; + boost::intrusive::list pending_; + std::shared_ptr notification_; + bool stopped_ = false; + bool active_ = false; + }; + + class service final : public boost::asio::execution_context::service { + public: + // Boost's service identity has an empty constructor and no dynamic dependencies. + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-throwing-static-initialization,cert-err58-cpp,bugprone-dynamic-static-initializers) + static inline boost::asio::execution_context::id id; + + explicit service(boost::asio::execution_context& context) + : boost::asio::execution_context::service(context) {} + + template + void start(const Allocator& allocator) { + state_ = std::allocate_shared(allocator); + } + + template + void post(Function function, const Allocator& allocator) { + using pending_type = handler_operation; + typename pending_type::storage_allocator storage(allocator); + auto* pending = + std::allocator_traits::allocate(storage, + 1); + // The guard also handles an exception from the user's function move constructor. + const auto release = [storage](pending_type* value) { + auto allocator_copy = storage; + std::allocator_traits::deallocate( + allocator_copy, value, 1); + }; + std::unique_ptr raw(pending, release); + std::allocator_traits::construct( + storage, pending, std::move(function), storage); + (void)raw.release(); + const auto state = state_; + state->post(pending, state); + } + + private: + void shutdown() override { + BOOST_ASSERT_MSG(emscripten_is_main_browser_thread(), + "main_thread_context must be destroyed on the browser main thread"); + if (state_) { + state_->stop(); + state_.reset(); + } + } + + std::shared_ptr state_; + }; + +public: + /** A standard Asio executor for nonsuspending handlers on the browser main thread. */ + class executor_type { + public: + /** Constructs an empty executor, usable only for assignment or comparison. */ + executor_type() = default; + + /** + Returns the context, which must still be alive. + + @return The execution context owning this executor. + */ + [[nodiscard]] main_thread_context& context() const noexcept { + return static_cast(owner_->context()); + } + + /** The browser runtime lifetime is controlled by the application. */ + void on_work_started() const noexcept { + } // NOLINT(readability-convert-member-functions-to-static) + + /** The browser runtime lifetime is controlled by the application. */ + void on_work_finished() const noexcept { + } // NOLINT(readability-convert-member-functions-to-static) + + /** + Dispatches inline on the browser main thread, otherwise posts. + + @tparam Function A nullary callable that does not suspend WebAssembly's stack. + @tparam Allocator A standard allocator for pending handler storage. + @param function The callable. + @param allocator The allocator used when dispatch must post. + */ + template + void dispatch(Function&& function, const Allocator& allocator) const { + if (emscripten_is_main_browser_thread()) { + std::forward(function)(); + return; + } + post(std::forward(function), allocator); + } + + /** + Posts without invoking inline, using allocator for pending handler storage. + + @tparam Function A nullary callable that does not suspend WebAssembly's stack. + @tparam Allocator A standard allocator for pending handler storage. + @param function The callable. + @param allocator The pending handler's allocator. + */ + template + void post(Function&& function, const Allocator& allocator) const { + owner_->post(std::forward(function), allocator); + } + + /** + Defers through the same main-thread queue as post. + + @tparam Function A nullary callable that does not suspend WebAssembly's stack. + @tparam Allocator A standard allocator for pending handler storage. + @param function The callable. + @param allocator The pending handler's allocator. + */ + template + void defer(Function&& function, const Allocator& allocator) const { + post(std::forward(function), allocator); + } + + /** + Compares the contexts owning two executors. + + @return True when the executors belong to the same context. + */ + friend bool operator==(const executor_type&, const executor_type&) = default; + + private: + friend class main_thread_context; + + explicit executor_type(service& owner) : owner_(&owner) {} + + service* owner_ = nullptr; + }; + + /** Constructs a queue on the browser's main runtime thread. */ + main_thread_context() : service_(boost::asio::use_service(*this)) { + service_.start(std::allocator()); + BOOST_ASSERT_MSG(emscripten_is_main_browser_thread(), + "main_thread_context must be constructed on the browser main thread"); + } + + /** + Constructs a main-thread context whose Asio service storage uses allocator. + + @tparam Allocator A standard allocator for context-owned C++ state. + @param allocator The allocator for context-owned C++ state. The Emscripten SDK + allocates its own proxy queue and notifications separately. + If a callback destroys this context, its allocator resource must remain alive + until that callback returns and the retained queue control is released. + */ + template + main_thread_context(std::allocator_arg_t /*tag*/, const Allocator& allocator) + : boost::asio::execution_context(std::allocator_arg, allocator), + service_(boost::asio::use_service(*this)) { + service_.start(allocator); + BOOST_ASSERT_MSG(emscripten_is_main_browser_thread(), + "main_thread_context must be constructed on the browser main thread"); + } + + /** + Returns an executor that can safely be copied to workers. + + @return An executor submitting work to this context on the browser main thread. + */ + [[nodiscard]] executor_type get_executor() noexcept { return executor_type(service_); } + +private: + service& service_; +}; + +} // namespace webcpp::asio::browser + +#endif +#endif // WEBCPP_ASIO_BROWSER_MAIN_THREAD_CONTEXT_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/src.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/src.hpp index 4fdacfe..00d857b 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/src.hpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/src.hpp @@ -9,6 +9,11 @@ #include +#if !WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#error \ + "webcpp::asio::browser::src requires the Emscripten browser bridge; use native/WASI Asio operations on this target" +#else + /** What a program on emscripten compiles once: the JavaScript functions asio calls (detail/browser_imports.hpp), the yield of the run family and the bridge's functions among them, @@ -23,6 +28,9 @@ #include #include #include +#ifdef __EMSCRIPTEN_PTHREADS__ +#include +#endif #include #include @@ -32,6 +40,34 @@ // ExitStatus is what exit() throws. EM_JS_DEPS has Emscripten link them. EM_JS_DEPS(webcpp_asio, "$Emval,_emval_decref,$stackSave,$stackRestore,$UTF8ToString,$ExitStatus"); +#ifdef __EMSCRIPTEN_PTHREADS__ +// Emscripten 6.0.11 routes worker poll through its main-thread proxy, but main-runtime +// poll takes the synchronous path even in a suspending entry stack. Reuse its own +// descriptor wait queues there; keep worker calls on the original proxy path. +EM_JS_DEPS(webcpp_asio_threaded_poll, "$doPollAsync"); +// clang-format off +EM_ASYNC_JS(int, webcpp_asio_main_poll, (void* descriptors, unsigned count, int timeout), { + return await doPollAsync(descriptors, count, timeout); +}); +// clang-format on + +// The linker reserves this spelling for its wrapped syscall import. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" int __real___syscall_poll(void* descriptors, unsigned count, int timeout); + +// --wrap=__syscall_poll selects this only in the pthread build. The pinned wasm32 +// libc import has three i32 arguments and an i32 result. Nonblocking poll uses a +// different import and remains nonsuspending, including inside browser callbacks. +// One definition is required, exactly as for the bridge export below. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming,misc-definitions-in-headers) +extern "C" int __wrap___syscall_poll(void* descriptors, unsigned count, int timeout) { + if (emscripten_is_main_runtime_thread()) { + return webcpp_asio_main_poll(descriptors, count, timeout); + } + return __real___syscall_poll(descriptors, count, timeout); +} +#endif + // clang-format off EM_ASYNC_JS(void, webcpp_asio_yield, (), { await new Promise(resolve => { @@ -63,8 +99,8 @@ EM_JS(emscripten::EM_VAL, webcpp_asio_function, (emscripten::EM_VAL token, void* const state = Emval.toValue(token); const address = bridge >>> 0; return Emval.toHandle(event => { - // After the runtime aborted, a trap or abort(), WebAssembly's heap may be what the trap - // left, so nothing enters it, as Emscripten's own callbacks do nothing then. + // Once Emscripten marks the runtime aborted, nothing enters WebAssembly, as its own + // callbacks do nothing then. A raw WebAssembly trap need not set ABORT. if (!state.alive || ABORT) { return; } @@ -165,4 +201,5 @@ extern "C" EMSCRIPTEN_KEEPALIVE void webcpp_asio_deliver(void* bridge, std::uint #endif } +#endif // WEBCPP_ASIO_HAS_BROWSER_BRIDGE #endif // WEBCPP_ASIO_BROWSER_SRC_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/transport.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/transport.hpp new file mode 100644 index 0000000..a8723d9 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/browser/transport.hpp @@ -0,0 +1,375 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_BROWSER_TRANSPORT_HPP +#define WEBCPP_ASIO_BROWSER_TRANSPORT_HPP + +#include + +#if !WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#error \ + "webcpp::asio::browser::transport requires the Emscripten browser bridge; use native/WASI Asio operations on this target" +#else + +#include // lint-world: preserve completion associations +#include // lint-world: unsupported browser operations +#include // lint-world: socket flags +#include +#include +#include + +namespace webcpp::asio::browser { + +/** + How the sockets of Protocol reach the network in the browser, which gives them none: every + operation fails with operation_not_supported. + + A later library (relays that carry TCP or UDP over a WebSocket or a WebRTC channel) + specialises it for a protocol; the specialisation is visible in every translation unit that + uses the socket type, before its first use. + + @tparam Protocol The protocol: ip::tcp or ip::udp. +*/ +template +class transport { +public: + /** The protocol endpoint type. */ + using endpoint_type = Protocol::endpoint; + + /** + Constructs an unsupported transport on executor. + @param executor The executor. + */ + explicit transport(boost::asio::any_io_executor executor) : executor_(std::move(executor)) {} + + /** Copies the executor so both transports remain usable after a move. + @param other The source transport. + */ + // NOLINTNEXTLINE(cert-oop11-cpp,performance-move-constructor-init) + transport(transport&& other) noexcept : executor_(other.executor_) {} + + /** Copies the executor, preserving the source transport. + @param other The source transport. + @return This transport. + */ + transport& operator=(transport&& other) noexcept { + executor_ = other.executor_; + return *this; + } + + /** Not copyable: a specialized transport may own a connection. */ + transport(const transport&) = delete; + /** Not copy-assignable: a specialized transport may own a connection. */ + transport& operator=(const transport&) = delete; + /** Releases the transport state. */ + ~transport() = default; + + /** Closes the resource-free default transport successfully. + @return Success. + */ + boost::system::error_code close() noexcept { return {}; } + + /** + Reports the default transport result without accessing a network. + @return operation_not_supported. + */ + boost::system::error_code connect(const endpoint_type& /*endpoint*/) { return not_supported(); } + + /** + Posts operation_not_supported without accessing a network. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_connect(const endpoint_type& /*endpoint*/, Handler&& handler) { + fail(std::forward(handler)); + } + + /** + Reports the default transport result without accessing a network. + @tparam MutableBufferSequence The operation argument type. + @param ec Receives operation_not_supported. + @return Zero. + */ + template + std::size_t read_some(const MutableBufferSequence& /*buffers*/, boost::system::error_code& ec) { + ec = not_supported(); + return 0; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam MutableBufferSequence The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_read_some(const MutableBufferSequence& /*buffers*/, Handler&& handler) { + fail(std::forward(handler), std::size_t{0}); + } + + /** + Reports the default transport result without accessing a network. + @tparam ConstBufferSequence The operation argument type. + @param ec Receives operation_not_supported. + @return Zero. + */ + template + std::size_t write_some(const ConstBufferSequence& /*buffers*/, boost::system::error_code& ec) { + ec = not_supported(); + return 0; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam ConstBufferSequence The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_write_some(const ConstBufferSequence& /*buffers*/, Handler&& handler) { + fail(std::forward(handler), std::size_t{0}); + } + + /** + Reports the default transport result without accessing a network. + @tparam ConstBufferSequence The operation argument type. + @param ec Receives operation_not_supported. + @return Zero. + */ + template + std::size_t send(const ConstBufferSequence& /*buffers*/, + boost::asio::socket_base::message_flags /*flags*/, + boost::system::error_code& ec) { + ec = not_supported(); + return 0; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam ConstBufferSequence The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_send(const ConstBufferSequence& /*buffers*/, + boost::asio::socket_base::message_flags /*flags*/, Handler&& handler) { + fail(std::forward(handler), std::size_t{0}); + } + + /** + Reports the default transport result without accessing a network. + @tparam MutableBufferSequence The operation argument type. + @param ec Receives operation_not_supported. + @return Zero. + */ + template + std::size_t receive(const MutableBufferSequence& /*buffers*/, + boost::asio::socket_base::message_flags /*flags*/, + boost::system::error_code& ec) { + ec = not_supported(); + return 0; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam MutableBufferSequence The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_receive(const MutableBufferSequence& /*buffers*/, + boost::asio::socket_base::message_flags /*flags*/, Handler&& handler) { + fail(std::forward(handler), std::size_t{0}); + } + + /** + Reports the default transport result without accessing a network. + @tparam ConstBufferSequence The operation argument type. + @param ec Receives operation_not_supported. + @return Zero. + */ + template + std::size_t send_to(const ConstBufferSequence& /*buffers*/, const endpoint_type& /*endpoint*/, + boost::asio::socket_base::message_flags /*flags*/, + boost::system::error_code& ec) { + ec = not_supported(); + return 0; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam ConstBufferSequence The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_send_to(const ConstBufferSequence& /*buffers*/, const endpoint_type& /*endpoint*/, + boost::asio::socket_base::message_flags /*flags*/, Handler&& handler) { + fail(std::forward(handler), std::size_t{0}); + } + + /** + Reports the default transport result without accessing a network. + @tparam MutableBufferSequence The operation argument type. + @param ec Receives operation_not_supported. + @return Zero. + */ + template + std::size_t receive_from(const MutableBufferSequence& /*buffers*/, endpoint_type& /*endpoint*/, + boost::asio::socket_base::message_flags /*flags*/, + boost::system::error_code& ec) { + ec = not_supported(); + return 0; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam MutableBufferSequence The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_receive_from(const MutableBufferSequence& /*buffers*/, endpoint_type& /*endpoint*/, + boost::asio::socket_base::message_flags /*flags*/, Handler&& handler) { + fail(std::forward(handler), std::size_t{0}); + } + + /** + Reports the default transport result without accessing a network. + @return operation_not_supported. + */ + boost::system::error_code bind(const endpoint_type& /*endpoint*/) { return not_supported(); } + + /** + Reports the default transport result without accessing a network. + @return operation_not_supported. + */ + boost::system::error_code listen(int /*backlog*/) { return not_supported(); } + + /** + Reports the default transport result without accessing a network. + @tparam Socket The operation argument type. + @return operation_not_supported. + */ + template + boost::system::error_code accept(Socket& /*peer*/) { + return not_supported(); + } + + /** + Posts operation_not_supported without accessing a network. + @tparam Socket The operation argument type. + @tparam Handler The completion handler type. + @param handler The handler to post with the unsupported-operation result. + */ + template + void async_accept(Socket& /*peer*/, Handler&& handler) { + fail(std::forward(handler)); + } + + /** + Reports the default transport result without accessing a network. + @return operation_not_supported. + */ + boost::system::error_code shutdown(boost::asio::socket_base::shutdown_type /*what*/) { + return not_supported(); + } + + /** + Reports the default transport result without accessing a network. + @return operation_not_supported. + */ + boost::system::error_code cancel() { return not_supported(); } + + /** + Reports the default transport result without accessing a network. + @tparam SettableSocketOption The operation argument type. + @return operation_not_supported. + */ + template + boost::system::error_code set_option(const SettableSocketOption& /*option*/) { + return not_supported(); + } + + /** + Reports the default transport result without accessing a network. + @tparam GettableSocketOption The operation argument type. + @return operation_not_supported. + */ + template + boost::system::error_code get_option(GettableSocketOption& /*option*/) const { + return not_supported(); + } + + /** + Reports the default transport result without accessing a network. + @param ec Receives operation_not_supported. + @return An unspecified endpoint. + */ + endpoint_type local_endpoint(boost::system::error_code& ec) const { + ec = not_supported(); + return endpoint_type(); + } + + /** + Reports the default transport result without accessing a network. + @param ec Receives operation_not_supported. + @return An unspecified endpoint. + */ + endpoint_type remote_endpoint(boost::system::error_code& ec) const { + ec = not_supported(); + return endpoint_type(); + } + + /** + Reports the default transport result without accessing a network. + @param ec Receives operation_not_supported. + @return Zero. + */ + std::size_t available(boost::system::error_code& ec) const { + ec = not_supported(); + return 0; + } + + /** + Reports the default transport result without accessing a network. + @return operation_not_supported. + */ + boost::system::error_code non_blocking(bool /*mode*/) { return not_supported(); } + + /** + Reports the default transport result without accessing a network. + @return False. + */ + [[nodiscard]] bool non_blocking() const noexcept { return false; } + +private: + static boost::system::error_code not_supported() noexcept { + return boost::asio::error::operation_not_supported; + } + + /** + Posts operation_not_supported without accessing a network. + @tparam Handler The completion handler type. + @tparam Values The operation argument type. + @param handler The handler to post with the unsupported-operation result. + @param values The completion values. + */ + template + void fail(Handler&& handler, Values... values) { + webcpp::asio::detail::post_completion( + executor_, boost::asio::append(std::forward(handler), not_supported(), + std::move(values)...)); + } + + boost::asio::any_io_executor executor_; +}; + +} // namespace webcpp::asio::browser + +#endif // WEBCPP_ASIO_HAS_BROWSER_BRIDGE +#endif // WEBCPP_ASIO_BROWSER_TRANSPORT_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/config.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/config.hpp index b160397..a5d560b 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/config.hpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/config.hpp @@ -6,14 +6,35 @@ /** The configuration of asio, which each of its headers includes first: whether - asio is built without exceptions. + asio is built without exceptions, target capabilities, and the default number + of handlers per turn. @see "Testing", in the guide. */ #ifndef WEBCPP_ASIO_CONFIG_HPP #define WEBCPP_ASIO_CONFIG_HPP -#include +#include // lint-world: inherit Boost's configured facilities +#include + +#ifndef WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN +/** + The default number of ready handlers processed in one turn on Emscripten. + + Define this nonnegative integer on the compiler command line to replace 100. + 0 is taken as 1 by io_context. Explicit context options override this default. + Use the same definition in every translation unit, including Cobalt's compiled + runner, and rebuild when changing it. Natively it does not change scheduling. + This is a handler count, not a time budget or a browser responsiveness guarantee. + + @see "The run family", in the guide. +*/ +#define WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN 100 +#endif + +#if WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN < 0 +#error "WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN must be a nonnegative integer" +#endif // MrDocs parses asio as a build with exceptions does, where the macro is not // defined: this definition, undone at once, is the one the reference lists, and @@ -21,8 +42,9 @@ #ifdef __MRDOCS__ /** Defined when asio is built without exceptions: automatically when the - compiler has none (`BOOST_NO_EXCEPTIONS`), or by the developer to disable them - in a build that has them. + collection has none (`WEBCPP_HAS_EXCEPTIONS` is not defined), or by the + developer to disable them in this library alone. `WEBCPP_NO_EXCEPTIONS` + disables them throughout the collection. asio raises an exception only where Boost.Asio's own interface throws: the throwing overloads of its sockets, resolver and `ssl::context` (an @@ -42,8 +64,141 @@ "asyncify-stack-size is below 8192 bytes, the least that asio's measured suspensions need, half of it left to the program: ask for 8192 or more" #endif -#if defined(BOOST_NO_EXCEPTIONS) && !defined(WEBCPP_ASIO_NO_EXCEPTIONS) +#if !defined(WEBCPP_HAS_EXCEPTIONS) && !defined(WEBCPP_ASIO_NO_EXCEPTIONS) #define WEBCPP_ASIO_NO_EXCEPTIONS #endif +// These are observations, never user switches. In particular, selecting the +// optional OpenSSL library is separate from having an OpenSSL-capable target. +#if defined(WEBCPP_ASIO_HAS_SOCKET_BACKEND) || defined(WEBCPP_ASIO_HAS_OPENSSL_BACKEND) || \ + defined(WEBCPP_ASIO_HAS_BROWSER_BRIDGE) || defined(WEBCPP_ASIO_HAS_BROWSER_WORKERS) || \ + defined(WEBCPP_ASIO_HAS_HOST_DNS) || defined(WEBCPP_ASIO_HAS_REVERSE_DNS) || \ + defined(WEBCPP_ASIO_HAS_WASI_STDIO) || defined(WEBCPP_ASIO_HAS_THREADS) || \ + defined(WEBCPP_ASIO_HAS_LOCAL_SOCKETS) || defined(WEBCPP_ASIO_HAS_SIGNALS) || \ + defined(WEBCPP_ASIO_HAS_SERIAL_PORT) +#error \ + "webcpp::asio: capability macros are derived by config.hpp; do not define WEBCPP_ASIO_HAS_* capabilities on the command line" +#else + +#ifdef WEBCPP_TARGET_EMSCRIPTEN +/** 1 when Emscripten supplies the JavaScript event and Promise bridge; otherwise 0. */ +#define WEBCPP_ASIO_HAS_BROWSER_BRIDGE 1 +/** 1 when native or WASI socket APIs back TCP/UDP; grants and options remain runtime facts. */ +#define WEBCPP_ASIO_HAS_SOCKET_BACKEND 0 +/** 1 when this target can link the source-built OpenSSL provider; it does not select it. */ +#define WEBCPP_ASIO_HAS_OPENSSL_BACKEND 0 +/** 1 when the host supplies forward address lookup; it does not imply reverse DNS. */ +#define WEBCPP_ASIO_HAS_HOST_DNS 0 +#else +/** 1 when Emscripten supplies the JavaScript event and Promise bridge; otherwise 0. */ +#define WEBCPP_ASIO_HAS_BROWSER_BRIDGE 0 +/** 1 when native or WASI socket APIs back TCP/UDP; grants and options remain runtime facts. */ +#define WEBCPP_ASIO_HAS_SOCKET_BACKEND 1 +/** 1 when this target can link the source-built OpenSSL provider; it does not select it. */ +#define WEBCPP_ASIO_HAS_OPENSSL_BACKEND 1 +/** 1 when the host supplies forward address lookup; it does not imply reverse DNS. */ +#define WEBCPP_ASIO_HAS_HOST_DNS 1 +#endif + +#ifdef WEBCPP_TARGET_NATIVE +/** 1 for native reverse lookup; WASI's address lookup interface is forward-only. */ +#define WEBCPP_ASIO_HAS_REVERSE_DNS 1 +#else +/** 1 for native reverse lookup; WASI's address lookup interface is forward-only. */ +#define WEBCPP_ASIO_HAS_REVERSE_DNS 0 +#endif + +#ifdef WEBCPP_TARGET_WASIP2 +/** 1 when the pollable WASIp2 CLI stream adapter is available; otherwise 0. */ +#define WEBCPP_ASIO_HAS_WASI_STDIO 1 +#else +/** 1 when the pollable WASIp2 CLI stream adapter is available; otherwise 0. */ +#define WEBCPP_ASIO_HAS_WASI_STDIO 0 +#endif + +#ifdef BOOST_ASIO_HAS_THREADS +/** 1 when this Boost.Asio configuration enables threads, including cooperative threads. */ +#define WEBCPP_ASIO_HAS_THREADS 1 +#else +/** 1 when this Boost.Asio configuration enables threads, including cooperative threads. */ +#define WEBCPP_ASIO_HAS_THREADS 0 +#endif + +#if defined(__EMSCRIPTEN_PTHREADS__) && WEBCPP_ASIO_HAS_THREADS +/** 1 for a pthread browser profile; isolation and worker availability are runtime facts. */ +#define WEBCPP_ASIO_HAS_BROWSER_WORKERS 1 +#else +/** 1 for a pthread browser profile; isolation and worker availability are runtime facts. */ +#define WEBCPP_ASIO_HAS_BROWSER_WORKERS 0 +#endif + +#if defined(WEBCPP_TARGET_NATIVE) && defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +/** 1 when native Boost.Asio enables local sockets; otherwise 0. */ +#define WEBCPP_ASIO_HAS_LOCAL_SOCKETS 1 +#else +/** 1 when native Boost.Asio enables local sockets; otherwise 0. */ +#define WEBCPP_ASIO_HAS_LOCAL_SOCKETS 0 +#endif +#if defined(WEBCPP_TARGET_NATIVE) && defined(BOOST_ASIO_HAS_SIGNAL) +/** 1 when native Boost.Asio enables process signals; WASI and browser events are not signals. */ +#define WEBCPP_ASIO_HAS_SIGNALS 1 +#else +/** 1 when native Boost.Asio enables process signals; WASI and browser events are not signals. */ +#define WEBCPP_ASIO_HAS_SIGNALS 0 +#endif +#if defined(WEBCPP_TARGET_NATIVE) && defined(BOOST_ASIO_HAS_SERIAL_PORT) +/** 1 when native Boost.Asio enables serial ports; otherwise 0. */ +#define WEBCPP_ASIO_HAS_SERIAL_PORT 1 +#else +/** 1 when native Boost.Asio enables serial ports; otherwise 0. */ +#define WEBCPP_ASIO_HAS_SERIAL_PORT 0 +#endif + +// A consumer can state requirements before including any library header. A +// zero or absent requirement leaves selection to the application at runtime. +#if defined(WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND) && WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND && \ + !WEBCPP_ASIO_HAS_SOCKET_BACKEND +#error \ + "webcpp::asio: this Emscripten target has no raw TCP/UDP socket backend; use a browser transport or a native/WASI target" +#endif +#if defined(WEBCPP_ASIO_REQUIRE_OPENSSL) && WEBCPP_ASIO_REQUIRE_OPENSSL +#if !WEBCPP_ASIO_HAS_OPENSSL_BACKEND +#error \ + "webcpp::asio: OpenSSL is unavailable in the browser profile; use browser-managed HTTPS/WSS or a native/WASI target" +#elif !defined(WEBCPP_ASIO_HAS_OPENSSL) || !WEBCPP_ASIO_HAS_OPENSSL +#error \ + "webcpp::asio: TLS requires /webcpp/asio//openssl or /webcpp/asio//tls; without B2, define WEBCPP_ASIO_HAS_OPENSSL=1 and link the matching libssl/libcrypto" +#endif +#endif +#if defined(WEBCPP_ASIO_REQUIRE_THREADS) && WEBCPP_ASIO_REQUIRE_THREADS && !WEBCPP_ASIO_HAS_THREADS +#error \ + "webcpp::asio: threads are disabled in this configuration; select a supported threading=multi profile (WASIp2 supports single only)" +#endif +#if defined(WEBCPP_ASIO_REQUIRE_LOCAL_SOCKETS) && WEBCPP_ASIO_REQUIRE_LOCAL_SOCKETS && \ + !WEBCPP_ASIO_HAS_LOCAL_SOCKETS +#error \ + "webcpp::asio: local sockets require native Boost.Asio support; WASI/browser targets must use TCP or a supplied byte stream" +#endif +#if defined(WEBCPP_ASIO_REQUIRE_SIGNALS) && WEBCPP_ASIO_REQUIRE_SIGNALS && !WEBCPP_ASIO_HAS_SIGNALS +#error \ + "webcpp::asio: process signals require a native target; use explicit application cancellation on WASI or in the browser" +#endif +#if defined(WEBCPP_ASIO_REQUIRE_SERIAL_PORT) && WEBCPP_ASIO_REQUIRE_SERIAL_PORT && \ + !WEBCPP_ASIO_HAS_SERIAL_PORT +#error \ + "webcpp::asio: serial ports require native Boost.Asio support; WASI/browser need a separate host adapter" +#endif +#if defined(WEBCPP_ASIO_REQUIRE_REVERSE_DNS) && WEBCPP_ASIO_REQUIRE_REVERSE_DNS && \ + !WEBCPP_ASIO_HAS_REVERSE_DNS +#error \ + "webcpp::asio: reverse DNS is unavailable on WASI/browser targets; use numeric endpoints or forward name lookup" +#endif + +#endif // derived capability macros + +#if defined(WEBCPP_TARGET_WASIP2) && defined(_REENTRANT) +#error \ + "webcpp::asio: WASIp2 has no supported pthread profile in the pinned SDK; select threading=single or WASIp3 cooperative threads" +#endif + #endif // WEBCPP_ASIO_CONFIG_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/browser_socket.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/browser_socket.hpp new file mode 100644 index 0000000..eec7c32 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/browser_socket.hpp @@ -0,0 +1,333 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_DETAIL_BROWSER_SOCKET_HPP +#define WEBCPP_ASIO_DETAIL_BROWSER_SOCKET_HPP + +#include + +#include // lint-world: socket completion token initiation +#include // lint-world: constrain context constructors +#include +#include +#include +#include +#include + +namespace webcpp::asio::detail { +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS +/** Throws a socket error through Boost's configured exception hook. */ +inline void throw_socket_error(boost::system::error_code ec) { + if (ec) { + boost::throw_exception(boost::system::system_error(ec)); + } +} +#endif +/** Shared browser socket state and forwarding, with no native file descriptor. */ +template +class browser_socket : public boost::asio::socket_base { +public: + /** The executor type. */ + using executor_type = Executor; + /** The protocol type. */ + using protocol_type = Protocol; + /** The endpoint type. */ + using endpoint_type = Protocol::endpoint; + + /** Constructs a closed socket on executor. */ + explicit browser_socket(const Executor& executor) + : executor_(executor), transport_state(executor) {} + + /** Constructs a closed socket on context. */ + template + requires std::is_convertible_v + explicit browser_socket(Context& context) : browser_socket(context.get_executor()) {} +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** Constructs and opens a socket for protocol. */ + browser_socket(const Executor& executor, const Protocol& protocol) : browser_socket(executor) { + open(protocol); + } + + /** Constructs and binds a socket to endpoint. */ + browser_socket(const Executor& executor, const endpoint_type& endpoint) + : browser_socket(executor, endpoint.protocol()) { + bind(endpoint); + } + + /** Constructs and opens a socket on context. */ + template + requires std::is_convertible_v + browser_socket(Context& context, const Protocol& protocol) + : browser_socket(context.get_executor(), protocol) {} + + /** Constructs and binds a socket on context. */ + template + requires std::is_convertible_v + browser_socket(Context& context, const endpoint_type& endpoint) + : browser_socket(context.get_executor(), endpoint) {} +#endif + /** Transfers state and leaves other closed. */ + // A moved-from socket keeps its executor, as Boost sockets do. + // NOLINTNEXTLINE(cert-oop11-cpp,performance-move-constructor-init) + browser_socket(browser_socket&& other) noexcept( + std::is_nothrow_copy_constructible_v && + std::is_nothrow_move_constructible_v> && + std::is_nothrow_copy_constructible_v) + // Keep the moved-from executor usable, matching Boost socket semantics. + // NOLINTNEXTLINE(cert-oop11-cpp,performance-move-constructor-init) + : executor_(other.executor_), + transport_state(std::move(other.transport_state)), + protocol_(other.protocol_), + open_(std::exchange(other.open_, false)) {} + + /** Transfers state and leaves other closed. */ + browser_socket& operator=(browser_socket&& other) noexcept( + std::is_nothrow_copy_assignable_v && + std::is_nothrow_move_assignable_v> && + std::is_nothrow_copy_assignable_v) { + if (this != &other) { + executor_ = other.executor_; + transport_state = std::move(other.transport_state); + protocol_ = other.protocol_; + open_ = std::exchange(other.open_, false); + } + return *this; + } + + /** Not copyable. */ + browser_socket(const browser_socket&) = delete; + /** Not copy-assignable. */ + browser_socket& operator=(const browser_socket&) = delete; + /** Destroys the transport state. */ + ~browser_socket() = default; + + /** Returns the associated executor. */ + [[nodiscard]] executor_type get_executor() const noexcept { return executor_; } + + /** Returns whether the local socket state is open. */ + [[nodiscard]] bool is_open() const noexcept { return open_; } + + /** Opens local state, or reports already_open. */ + boost::system::error_code open(const protocol_type& protocol, boost::system::error_code& ec) { + if (open_) { + ec = boost::asio::error::already_open; + } else { + protocol_ = protocol; + open_ = true; + ec.clear(); + } + return ec; + } + + /** Closes the transport and marks local state closed on success. */ + boost::system::error_code close(boost::system::error_code& ec) { + ec = transport_state.close(); + if (!ec) { + open_ = false; + } + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** Opens local state, throwing on failure. */ + void open(const protocol_type& protocol = protocol_type::v4()) { + boost::system::error_code ec; + open(protocol, ec); + throw_socket_error(ec); + } + + /** Closes local state. */ + void close() { + boost::system::error_code ec; + close(ec); + throw_socket_error(ec); + } +#endif + /** Returns the transport's recorded non-blocking mode. */ + [[nodiscard]] bool non_blocking() const noexcept { return transport_state.non_blocking(); } + + /** + Forwards cancel to the transport. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code cancel(boost::system::error_code& ec) { + ec = transport_state.cancel(); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards cancel, throwing on error. + */ + void cancel() { + boost::system::error_code ec; + cancel(ec); + webcpp::asio::detail::throw_socket_error(ec); + } +#endif + /** + Forwards bind to the transport. + @param endpoint The endpoint. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code bind(const endpoint_type& endpoint, boost::system::error_code& ec) { + ec = transport_state.bind(endpoint); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards bind, throwing on error. + @param endpoint The endpoint. + */ + void bind(const endpoint_type& endpoint) { + boost::system::error_code ec; + bind(endpoint, ec); + webcpp::asio::detail::throw_socket_error(ec); + } +#endif + /** + Forwards set_option to the transport. + @tparam Option The operation type. + @param option The option. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + boost::system::error_code set_option(const Option& option, boost::system::error_code& ec) { + ec = transport_state.set_option(option); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards set_option, throwing on error. + @tparam Option The operation type. + @param option The option. + */ + template + void set_option(const Option& option) { + boost::system::error_code ec; + set_option(option, ec); + webcpp::asio::detail::throw_socket_error(ec); + } +#endif + /** + Forwards get_option to the transport. + @tparam Option The operation type. + @param option The option. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + template + boost::system::error_code get_option(Option& option, boost::system::error_code& ec) const { + ec = transport_state.get_option(option); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards get_option, throwing on error. + @tparam Option The operation type. + @param option The option. + */ + template + void get_option(Option& option) const { + boost::system::error_code ec; + get_option(option, ec); + webcpp::asio::detail::throw_socket_error(ec); + } +#endif + /** + Forwards local_endpoint to the transport. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + endpoint_type local_endpoint(boost::system::error_code& ec) const { + return transport_state.local_endpoint(ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards local_endpoint, throwing on error. + @return The operation result. + */ + [[nodiscard]] endpoint_type local_endpoint() const { + boost::system::error_code ec; + auto result = local_endpoint(ec); + webcpp::asio::detail::throw_socket_error(ec); + return result; + } +#endif + /** + Forwards remote_endpoint to the transport. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + endpoint_type remote_endpoint(boost::system::error_code& ec) const { + return transport_state.remote_endpoint(ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards remote_endpoint, throwing on error. + @return The operation result. + */ + [[nodiscard]] endpoint_type remote_endpoint() const { + boost::system::error_code ec; + auto result = remote_endpoint(ec); + webcpp::asio::detail::throw_socket_error(ec); + return result; + } +#endif + /** + Forwards available to the transport. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + std::size_t available(boost::system::error_code& ec) const { + return transport_state.available(ec); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards available, throwing on error. + @return The operation result. + */ + [[nodiscard]] std::size_t available() const { + boost::system::error_code ec; + const auto result = available(ec); + webcpp::asio::detail::throw_socket_error(ec); + return result; + } +#endif + /** + Forwards non_blocking to the transport. + @param mode The mode. + @param ec Receives the transport error, or success. + @return The result; ec receives any error. + */ + boost::system::error_code non_blocking(bool mode, boost::system::error_code& ec) { + ec = transport_state.non_blocking(mode); + return ec; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Forwards non_blocking, throwing on error. + @param mode The mode. + */ + void non_blocking(bool mode) { + boost::system::error_code ec; + non_blocking(mode, ec); + webcpp::asio::detail::throw_socket_error(ec); + } +#endif +private: + executor_type executor_; + +protected: + browser::transport transport_state; + +private: + protocol_type protocol_ = protocol_type::v4(); + bool open_ = false; +}; +} // namespace webcpp::asio::detail +#endif // WEBCPP_ASIO_DETAIL_BROWSER_SOCKET_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/post_completion.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/post_completion.hpp new file mode 100644 index 0000000..19bbecb --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/post_completion.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_DETAIL_POST_COMPLETION_HPP +#define WEBCPP_ASIO_DETAIL_POST_COMPLETION_HPP + +#include + +#include // lint-world: preserve an erased executor +#include // lint-world: recover an ordinary context executor without erasing its allocator +#include // lint-world: completion always enters through a post +#include + +namespace webcpp::asio::detail { +/** Posts without erasing an ordinary io_context executor's allocator property. */ +template +void post_completion(const boost::asio::any_io_executor& executor, Handler&& handler) { + using plain = boost::asio::io_context::executor_type; + using tracked = decltype(boost::asio::prefer( + std::declval(), boost::asio::execution::outstanding_work_t::tracked)); + if (const auto* concrete = executor.target()) { + boost::asio::post(*concrete, std::forward(handler)); + } else if (const auto* concrete = executor.target()) { + boost::asio::post(*concrete, std::forward(handler)); + } else { + // Keep custom executor and strand semantics; they own their dispatch allocation policy. + boost::asio::post(executor, std::forward(handler)); + } +} +} // namespace webcpp::asio::detail +#endif // WEBCPP_ASIO_DETAIL_POST_COMPLETION_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/wasi_pollable_descriptor.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/wasi_pollable_descriptor.hpp new file mode 100644 index 0000000..d6da3ae --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/detail/wasi_pollable_descriptor.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_DETAIL_WASI_POLLABLE_DESCRIPTOR_HPP +#define WEBCPP_ASIO_DETAIL_WASI_POLLABLE_DESCRIPTOR_HPP +#include +#include +#include +#include + +namespace webcpp::asio::detail { +/** Stable storage borrowed by the pinned wasi-libc descriptor table. + Close the descriptor before destroying this storage or its pollable. */ +struct wasi_pollable_descriptor { + /** Opaque storage for the pinned libc descriptor, owned by this object. */ + alignas(std::max_align_t) std::array opaque{}; + /** Whether libc currently borrows this object. */ + bool active = false; + /** Borrowed native WASIp2 pollable handle. */ + std::int32_t handle = 0; +}; +} // namespace webcpp::asio::detail + +/** Registers borrowed storage as a read-readiness-only descriptor. + @param storage Stable descriptor state, alive until close returns. + @return The descriptor, or -1 with errno set. */ +extern "C" int webcpp_asio_wasi_pollable_descriptor( + webcpp::asio::detail::wasi_pollable_descriptor* storage); +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/io_context.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/io_context.hpp index e2e063e..2c56d70 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/io_context.hpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/io_context.hpp @@ -10,13 +10,17 @@ #include #include // lint-world: the program's event loop, asio's purpose -#ifdef __EMSCRIPTEN__ +#ifdef WEBCPP_TARGET_EMSCRIPTEN #include #include #include #include // lint-world: the unarmed timer that makes the reactor #include +#ifdef __EMSCRIPTEN_PTHREADS__ +#include +#include +#endif #endif #include @@ -31,16 +35,20 @@ struct io_context_options { At most this many handlers run in one turn of the run family, which yields to the browser after a turn that reaches it. - 0 is taken as 1. + Defaults to WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN. 0 is taken as 1. */ - std::size_t max_handlers_per_turn = 1000; + std::size_t max_handlers_per_turn = WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN; }; /** Boost.Asio's io_context, whose run family on emscripten suspends into the browser's event loop and yields to it after every turn of max_handlers_per_turn handlers. - Natively it is Boost's, and its options change nothing. + Natively and on WASIp2/P3 it uses Boost's run family, and its options change nothing. + In a threaded browser build each context and its JavaScript bridge stay on their + constructing thread. Other threads post through its executor; the run family + rejects a runner on another thread. Multiple simultaneous runners of one browser + context are unsupported because JavaScript values are thread-local. @see "The run family", in the guide. */ @@ -109,15 +117,15 @@ class io_context : public boost::asio::io_context { options_.max_handlers_per_turn = n == 0 ? 1 : n; } -#ifdef __EMSCRIPTEN__ +#ifdef WEBCPP_TARGET_EMSCRIPTEN // run and run_one hide Boost's, which are not virtual: run to compose them with the turn // limit, and run_one so that the whole run family is this class's; hence the exemption from // bugprone-derived-method-shadowing-base-method. // - // Each of the six is called on main's stack alone: one called while another runs, from a - // handler or from a JavaScript event while run waits, or while the bridge delivers an event, - // asserts and returns 0 having run nothing. Each admits once, first, and then calls only - // private code that admits nothing (run_until_unchecked, compose, drain) or Boost's own, + // Each of the six is called on a suspension-enabled entry stack alone: one called while another + // runs, from a handler or from a JavaScript event while run waits, or while the bridge delivers + // an event, asserts and returns 0 having run nothing. Each admits once, first, and then calls + // only private code that admits nothing (run_until_unchecked, compose, drain) or Boost's own, // never another public member, whose admission would refuse the call its caller flagged. /** @@ -227,9 +235,19 @@ class io_context : public boost::asio::io_context { Tip: not noexcept, since whether the bridge delivers is read from JavaScript. */ [[nodiscard]] bool admitted() const { +#ifdef __EMSCRIPTEN_PTHREADS__ + // The bridge owns thread-local JavaScript handles. Check affinity before reading one. + const bool owner = pthread_equal(owner_, pthread_self()) != 0; + BOOST_ASSERT_MSG(owner, + "webcpp::asio: a threaded browser io_context runs only on the thread " + "that constructed it; post through its executor from other threads"); + if (!owner) { + return false; + } +#endif const bool allowed = !running_ && !bridge_.delivering(); BOOST_ASSERT_MSG(allowed, - "webcpp::asio: the run family is called on main's stack alone, " + "webcpp::asio: the run family is called on its entry stack alone, " "never from a handler or a browser event"); return allowed; } @@ -308,7 +326,7 @@ class io_context : public boost::asio::io_context { } io_context_options options_; -#ifdef __EMSCRIPTEN__ +#ifdef WEBCPP_TARGET_EMSCRIPTEN // Never armed: its construction makes the reactor, which the scheduler then waits on, so a // run with work and no timer of the program's own suspends in select, which a post wakes, // rather than in ::pause(), which nothing wakes (measured with Emscripten 6.0.11; @@ -316,6 +334,10 @@ class io_context : public boost::asio::io_context { boost::asio::steady_timer reactor_{*this}; // lint-world: never armed // The bridge whose deliveries the run family refuses to run inside, looked up once. browser::bridge& bridge_ = boost::asio::use_service(*this); +#ifdef __EMSCRIPTEN_PTHREADS__ + // The context and its JavaScript bridge stay on their creating thread. + pthread_t owner_ = pthread_self(); +#endif // Whether a call of the run family is active on this context. bool running_ = false; #endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/basic_resolver.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/basic_resolver.hpp new file mode 100644 index 0000000..95e9cae --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/basic_resolver.hpp @@ -0,0 +1,274 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_IP_BASIC_RESOLVER_HPP +#define WEBCPP_ASIO_IP_BASIC_RESOLVER_HPP + +#include + +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: native resolver semantics + +namespace webcpp::asio::ip { +/** + Boost's native resolver. + @tparam InternetProtocol The internet protocol. + @tparam Executor The associated executor. +*/ +template +using basic_resolver = boost::asio::ip::basic_resolver; +} // namespace webcpp::asio::ip +#else +#include // lint-world: preserve handler associations +#include // lint-world: input storage uses the token allocator +#include // lint-world: completion token initiation +#include // lint-world: resolver error values +#include // lint-world: an unspecified address without DNS +#include // lint-world: Boost resolver result entries +#include // lint-world: Boost resolver flags +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace webcpp::asio::ip::detail { +/** Maps an empty, numeric or supported named service to its port. */ +inline std::optional port_of(std::string_view service, + boost::asio::ip::resolver_base::flags flags) noexcept { + if (service.empty()) { + return 0; + } + if (service.find_first_not_of("0123456789") == std::string_view::npos) { + std::uint32_t port = 0; + const auto result = std::from_chars(service.data(), service.data() + service.size(), port); + if (result.ec == std::errc{} && port <= 65535) { + return static_cast(port); + } + return std::nullopt; + } + if ((flags & boost::asio::ip::resolver_base::numeric_service) != + static_cast(0)) { + return std::nullopt; + } + if (service == "http" || service == "ws") { + return 80; + } + if (service == "https" || service == "wss") { + return 443; + } + return std::nullopt; +} +} // namespace webcpp::asio::ip::detail + +namespace webcpp::asio::ip { +/** + Preserves a host and service for browser transports without querying DNS. + @tparam InternetProtocol The internet protocol. + @tparam Executor The associated executor. + @see "Sockets and transports", in the guide. +*/ +template +class basic_resolver : public boost::asio::ip::resolver_base { +public: + /** The associated executor type. */ + using executor_type = Executor; + /** The internet protocol type. */ + using protocol_type = InternetProtocol; + /** The protocol endpoint type. */ + using endpoint_type = InternetProtocol::endpoint; + /** Boost's sequence of resolver entries. */ + using results_type = boost::asio::ip::basic_resolver_results; + + /** + Constructs a resolver on executor. + @param executor The completion executor. + */ + explicit basic_resolver(executor_type executor) : executor_(std::move(executor)) {} + + /** + Constructs a resolver on context. + @tparam ExecutionContext An execution context type. + @param context The context that runs completions. + */ + template + requires std::is_convertible_v + explicit basic_resolver(ExecutionContext& context) : basic_resolver(context.get_executor()) {} + + /** Returns the associated executor. + @return The executor. + */ + [[nodiscard]] executor_type get_executor() const noexcept { return executor_; } + + /** Leaves already-computed, posted results unchanged. */ + // Boost's resolver exposes cancel as a non-static member. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void cancel() {} + + /** + Constructs an entry retaining host and service, with an unspecified address. + @param host The host name retained verbatim. + @param service An empty, numeric or supported named service. + @param ec Receives success or service_not_found. + @return One entry on success, otherwise an empty sequence. + */ + results_type resolve(std::string_view host, std::string_view service, + boost::system::error_code& ec) { + return resolve(host, service, static_cast(0), ec); + } + + /** + Constructs a forward result under the service parsing flags. + @param host The host name retained verbatim. + @param service The service retained verbatim. + @param resolve_flags Only numeric_service affects parsing. + @param ec Receives success or service_not_found. + @return One entry on success, otherwise an empty sequence. + */ + // Preserve Boost's non-static member interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + results_type resolve(std::string_view host, std::string_view service, flags resolve_flags, + boost::system::error_code& ec) { + const auto port = detail::port_of(service, resolve_flags); + if (!port) { + ec = boost::asio::error::service_not_found; + return {}; + } + ec.clear(); + return results_type::create(endpoint_type(boost::asio::ip::address_v4::any(), *port), + std::string(host), std::string(service)); + } + + /** + Refuses reverse resolution without accessing DNS. + @param ec Receives operation_not_supported. + @return An empty sequence. + */ + // Preserve Boost's non-static member interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + results_type resolve(const endpoint_type& /*endpoint*/, boost::system::error_code& ec) { + ec = boost::asio::error::operation_not_supported; + return {}; + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Constructs a forward result, throwing on an unsupported service. + @param host The original host. + @param service The original service. + @return One resolver entry. + */ + results_type resolve(std::string_view host, std::string_view service) { + return resolve(host, service, static_cast(0)); + } + + /** + Constructs a forward result with flags, throwing on an unsupported service. + @param host The original host. + @param service The original service. + @param resolve_flags The service parsing flags. + @return One resolver entry. + */ + results_type resolve(std::string_view host, std::string_view service, flags resolve_flags) { + boost::system::error_code ec; + auto result = resolve(host, service, resolve_flags, ec); + if (ec) { + boost::throw_exception(boost::system::system_error(ec)); + } + return result; + } + + /** + Refuses reverse resolution by throwing operation_not_supported. + @param endpoint The endpoint. + @return An empty sequence if the exception hook returns. + */ + results_type resolve(const endpoint_type& endpoint) { + boost::system::error_code ec; + auto result = resolve(endpoint, ec); + if (ec) { + boost::throw_exception(boost::system::system_error(ec)); + } + return result; + } +#endif + /** + Posts a forward resolution result. + @tparam ResolveToken The completion token type. + @param host The original host, copied before returning. + @param service The original service, copied before returning. + @param token The completion token. + @return The token result for void(error_code, results_type). + */ + template + auto async_resolve(std::string_view host, std::string_view service, ResolveToken&& token) { + return async_resolve(host, service, static_cast(0), + std::forward(token)); + } + + /** + Posts a forward result with service parsing flags. + + Copies the inputs with the token's associated allocator before returning. + Deferred tokens retain those copies and compute the result only when initiated. + Bind an allocator to the deferred token to select its input storage allocator. + @tparam ResolveToken The completion token type. + @param host The original host, copied before returning. + @param service The original service, copied before returning. + @param resolve_flags The service parsing flags. + @param token The completion token. + @return The token result for void(error_code, results_type). + */ + template + auto async_resolve(std::string_view host, std::string_view service, flags resolve_flags, + ResolveToken&& token) { + using input_allocator = + std::allocator_traits>>:: + template rebind_alloc; + using input_string = std::basic_string, input_allocator>; + const input_allocator allocator(boost::asio::get_associated_allocator(token)); + return boost::asio::async_initiate( + [this](auto handler, const input_string& name, const input_string& port, flags mode) { + boost::system::error_code ec; + auto result = resolve(name, port, mode, ec); + webcpp::asio::detail::post_completion( + executor_, boost::asio::append(std::move(handler), ec, std::move(result))); + }, + token, input_string(host, allocator), input_string(service, allocator), resolve_flags); + } + + /** + Posts operation_not_supported for reverse resolution. + @tparam ResolveToken The completion token type. + @param endpoint The endpoint. + @param token The completion token. + @return The token result for void(error_code, results_type). + */ + template + auto async_resolve(const endpoint_type& endpoint, ResolveToken&& token) { + return boost::asio::async_initiate( + [this](auto handler, const endpoint_type& peer) { + boost::system::error_code ec; + auto result = resolve(peer, ec); + webcpp::asio::detail::post_completion( + executor_, boost::asio::append(std::move(handler), ec, std::move(result))); + }, + token, endpoint); + } + +private: + executor_type executor_; +}; +} // namespace webcpp::asio::ip +#endif +#endif // WEBCPP_ASIO_IP_BASIC_RESOLVER_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/tcp.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/tcp.hpp new file mode 100644 index 0000000..6a41b95 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/tcp.hpp @@ -0,0 +1,77 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_IP_TCP_HPP +#define WEBCPP_ASIO_IP_TCP_HPP +#include + +#include +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: native protocol alias + +namespace webcpp::asio::ip { +/** Boost's native TCP protocol. */ +using boost::asio::ip::tcp; +} // namespace webcpp::asio::ip +#else +#include // lint-world: portable protocol constants +#include // lint-world: Boost endpoint layout for the browser protocol +#include +#include + +namespace webcpp::asio::ip { +/** The browser TCP protocol, with operations supplied by a transport. */ +class tcp { +public: + /** The endpoint type. */ + using endpoint = boost::asio::ip::basic_endpoint; + /** The resolver type. */ + using resolver = basic_resolver; + /** The socket type. */ + using socket = basic_stream_socket; + /** The acceptor type. */ + using acceptor = basic_socket_acceptor; + + /** Returns the IPv4 protocol. + @return The IPv4 protocol. */ + static tcp v4() noexcept { return tcp(BOOST_ASIO_OS_DEF(AF_INET)); } + + /** Returns the IPv6 protocol. + @return The IPv6 protocol. */ + static tcp v6() noexcept { return tcp(BOOST_ASIO_OS_DEF(AF_INET6)); } + + /** Returns the socket type constant. + @return The socket type. */ + // Match the InternetProtocol member signature used by Boost. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + [[nodiscard]] int type() const noexcept { return BOOST_ASIO_OS_DEF(SOCK_STREAM); } + + /** Returns the protocol number. + @return The protocol number. */ + // Match the InternetProtocol member signature used by Boost. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + [[nodiscard]] int protocol() const noexcept { return BOOST_ASIO_OS_DEF(IPPROTO_TCP); } + + /** Returns the address family. + @return The address family. */ + [[nodiscard]] int family() const noexcept { return family_; } + + /** Compares address families. + @param a The first protocol. + @param b The second protocol. + * + @return Whether they match. */ + friend bool operator==(const tcp& a, const tcp& b) noexcept = default; + +private: + /** Constructs a protocol for an address family. */ + explicit tcp(int family) : family_(family) {} + + int family_; +}; +} // namespace webcpp::asio::ip +#endif +#endif // WEBCPP_ASIO_IP_TCP_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/udp.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/udp.hpp new file mode 100644 index 0000000..fc4976b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ip/udp.hpp @@ -0,0 +1,74 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_IP_UDP_HPP +#define WEBCPP_ASIO_IP_UDP_HPP +#include + +#include +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: native protocol alias + +namespace webcpp::asio::ip { +/** Boost's native UDP protocol. */ +using boost::asio::ip::udp; +} // namespace webcpp::asio::ip +#else +#include // lint-world: portable protocol constants +#include // lint-world: Boost endpoint layout for the browser protocol +#include + +namespace webcpp::asio::ip { +/** The browser UDP protocol, with operations supplied by a transport. */ +class udp { +public: + /** The endpoint type. */ + using endpoint = boost::asio::ip::basic_endpoint; + /** The resolver type. */ + using resolver = basic_resolver; + /** The socket type. */ + using socket = basic_datagram_socket; + + /** Returns the IPv4 protocol. + @return The IPv4 protocol. */ + static udp v4() noexcept { return udp(BOOST_ASIO_OS_DEF(AF_INET)); } + + /** Returns the IPv6 protocol. + @return The IPv6 protocol. */ + static udp v6() noexcept { return udp(BOOST_ASIO_OS_DEF(AF_INET6)); } + + /** Returns the socket type constant. + @return The socket type. */ + // Match the InternetProtocol member signature used by Boost. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + [[nodiscard]] int type() const noexcept { return BOOST_ASIO_OS_DEF(SOCK_DGRAM); } + + /** Returns the protocol number. + @return The protocol number. */ + // Match the InternetProtocol member signature used by Boost. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + [[nodiscard]] int protocol() const noexcept { return BOOST_ASIO_OS_DEF(IPPROTO_UDP); } + + /** Returns the address family. + @return The address family. */ + [[nodiscard]] int family() const noexcept { return family_; } + + /** Compares address families. + @param a The first protocol. + @param b The second protocol. + * + @return Whether they match. */ + friend bool operator==(const udp& a, const udp& b) noexcept = default; + +private: + /** Constructs a protocol for an address family. */ + explicit udp(int family) : family_(family) {} + + int family_; +}; +} // namespace webcpp::asio::ip +#endif +#endif // WEBCPP_ASIO_IP_UDP_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ssl.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ssl.hpp new file mode 100644 index 0000000..4ff3629 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/ssl.hpp @@ -0,0 +1,565 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_SSL_HPP +#define WEBCPP_ASIO_SSL_HPP + +#include + +#if WEBCPP_ASIO_HAS_OPENSSL_BACKEND +#if !defined(WEBCPP_ASIO_HAS_OPENSSL) || !WEBCPP_ASIO_HAS_OPENSSL +#error \ + "webcpp::asio: needs OpenSSL on native and WASI targets, and it is not linked. In the program's Jamfile, add /webcpp/asio//openssl beside /webcpp/asio//asio, as in: exe app : app.cpp /webcpp/asio//asio /webcpp/asio//openssl ; b2 builds the pinned OpenSSL sources (git submodule update --init third_party/libs/openssl). (without b2: define WEBCPP_ASIO_HAS_OPENSSL=1 and link libssl and libcrypto)" +#else +#include // lint-world: native TLS with explicitly linked OpenSSL + +namespace webcpp::asio { +/** Boost's TLS types on native and WASI targets, with OpenSSL explicitly linked. */ +namespace ssl = boost::asio::ssl; +} // namespace webcpp::asio +#endif +#else +#include // lint-world: certificate and key buffer signatures +#include // lint-world: error-code setting overloads +#include +#include +#include +#include +#include +#include +#include + +namespace webcpp::asio::ssl { +/** The peer verification bitmask type. */ +using verify_mode = int; +/** Requests no peer verification. */ +inline constexpr verify_mode verify_none = 0x00; +/** Requests peer verification. */ +inline constexpr verify_mode verify_peer = 0x01; +/** Requires a peer certificate when peer verification is requested. */ +inline constexpr verify_mode verify_fail_if_no_peer_cert = 0x02; +/** Requests a client certificate only once. */ +inline constexpr verify_mode verify_client_once = 0x04; + +/** Names the TLS methods and option values compatible with Boost and OpenSSL 3. */ +class context_base { +public: + /** The TLS method names in Boost's enumeration order. */ + enum method { + /** The sslv2 generic method. */ + sslv2, + /** The sslv2 client method. */ + sslv2_client, + /** The sslv2 server method. */ + sslv2_server, + /** The sslv3 generic method. */ + sslv3, + /** The sslv3 client method. */ + sslv3_client, + /** The sslv3 server method. */ + sslv3_server, + /** The tlsv1 generic method. */ + tlsv1, + /** The tlsv1 client method. */ + tlsv1_client, + /** The tlsv1 server method. */ + tlsv1_server, + /** The sslv23 generic method. */ + sslv23, + /** The sslv23 client method. */ + sslv23_client, + /** The sslv23 server method. */ + sslv23_server, + /** The tlsv11 generic method. */ + tlsv11, + /** The tlsv11 client method. */ + tlsv11_client, + /** The tlsv11 server method. */ + tlsv11_server, + /** The tlsv12 generic method. */ + tlsv12, + /** The tlsv12 client method. */ + tlsv12_client, + /** The tlsv12 server method. */ + tlsv12_server, + /** The tlsv13 generic method. */ + tlsv13, + /** The tlsv13 client method. */ + tlsv13_client, + /** The tlsv13 server method. */ + tlsv13_server, + /** The tls generic method. */ + tls, + /** The tls client method. */ + tls_client, + /** The tls server method. */ + tls_server, + }; + + /** The certificate or key representation. */ + enum file_format { + /** ASN.1 encoding. */ + asn1, + /** PEM encoding. */ + pem, + }; + + /** The TLS option bitmask type. */ + using options = std::uint64_t; + /** Requests the OpenSSL 3 compatibility workaround bits. */ + static constexpr options default_workarounds = 0x80000850ULL; + /** Retains the OpenSSL 3 legacy single-use DH option. */ + static constexpr options single_dh_use = 0; + /** Retains the OpenSSL 3 legacy SSLv2 disabling option. */ + static constexpr options no_sslv2 = 0; + /** Requests disabling SSLv3. */ + static constexpr options no_sslv3 = 0x02000000ULL; + /** Requests disabling TLSv1. */ + static constexpr options no_tlsv1 = 0x04000000ULL; + /** Requests disabling TLSv1.1. */ + static constexpr options no_tlsv1_1 = 0x10000000ULL; + /** Requests disabling TLSv1.2. */ + static constexpr options no_tlsv1_2 = 0x08000000ULL; + /** Requests disabling TLSv1.3. */ + static constexpr options no_tlsv1_3 = 0x20000000ULL; + /** Requests disabling compression. */ + static constexpr options no_compression = 0x00020000ULL; + /** The legacy context-level verification bitmask alias. */ + using verify_mode = ssl::verify_mode; + /** The legacy context-level verify_none value. */ + static constexpr verify_mode verify_none = ssl::verify_none; + /** The legacy context-level verify_peer value. */ + static constexpr verify_mode verify_peer = ssl::verify_peer; + /** The legacy context-level verify_fail_if_no_peer_cert value. */ + static constexpr verify_mode verify_fail_if_no_peer_cert = ssl::verify_fail_if_no_peer_cert; + /** The legacy context-level verify_client_once value. */ + static constexpr verify_mode verify_client_once = ssl::verify_client_once; + +protected: + /** Prevents deletion through the constants-only base. */ + ~context_base() = default; +}; + +/** Names the handshake roles for browser stream adapters. */ +class stream_base { +public: + /** Which endpoint starts the handshake. */ + enum handshake_type { + /** The client role. */ + client, + /** The server role. */ + server, + }; + +protected: + /** Prevents deletion through the constants-only base. */ + ~stream_base() = default; +}; + +/** Owns the host name requested for certificate verification. */ +class host_name_verification { +public: + /** + Copies the verification host so temporary input storage is safe. + @param host The expected host name. + */ + explicit host_name_verification(std::string_view host) : host_(host) {} + + /** + Returns the owned host name as a view. + @return A view valid until this object changes or is destroyed. + */ + [[nodiscard]] std::string_view host() const noexcept { return host_; } + +private: + std::string host_; +}; + +/** Identifies the recorded verification callback without executing it. */ +enum class verify_callback_kind : std::uint8_t { + /** No callback was supplied. */ + none, + /** A host-name verification request. */ + host_name_verification, + /** Any other verification callback. */ + other, +}; + +/** + Records TLS settings without implementing TLS or reading certificate files. + + Browser stream adapters decide which settings their transport can honor. + @see "Explanation: TLS settings", in the guide. +*/ +class context : public context_base { +public: + /** + Constructs an empty record using the default memory resource. + @param selected The requested TLS method. + */ + explicit context(method selected) : context(selected, std::pmr::get_default_resource()) {} + + /** + Constructs a record whose verification host uses resource. + @param selected The requested TLS method. + @param resource The host storage resource, or null for the default resource. + */ + context(method selected, std::pmr::memory_resource* resource) + : method_(selected), + host_(resource != nullptr ? resource : std::pmr::get_default_resource()) {} + + /** Transfers the record and its host storage. + @param other The source record. + */ + context(context&& other) noexcept = default; + /** Moves the record, retaining the destination's memory resource. + @param other The source record. + @return This record. + */ + // PMR assignment can allocate when the source and destination resources differ. + // NOLINTBEGIN(bugprone-unsafe-to-allow-exceptions,performance-noexcept-move-constructor) + context& operator=(context&& other) noexcept( + std::is_nothrow_move_assignable_v) = default; + // NOLINTEND(bugprone-unsafe-to-allow-exceptions,performance-noexcept-move-constructor) + /** A context cannot be copied. */ + context(const context&) = delete; + /** A context cannot be copy-assigned. */ + context& operator=(const context&) = delete; + /** Releases the recorded host storage. */ + ~context() = default; + + /** + Records the verification callback kind and, for host verification, its name. + @tparam VerifyCallback The callback type. + @param callback The verification request; it is never invoked here. + @param ec Receives success. + */ + template + void set_verify_callback(const VerifyCallback& callback, boost::system::error_code& ec) { + if constexpr (std::is_same_v, host_name_verification>) { + host_ = callback.host(); + callback_ = verify_callback_kind::host_name_verification; + } else { + host_.clear(); + callback_ = verify_callback_kind::other; + } + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records the verification callback without an error-code argument. + @tparam VerifyCallback The callback type. + @param callback The verification request. + */ + template + void set_verify_callback(const VerifyCallback& callback) { + boost::system::error_code ec; + set_verify_callback(callback, ec); + } +#endif + /** + Records the requested verification mode. + @param mode The requested verification bitmask. + @param ec Receives success. + */ + void set_verify_mode(verify_mode mode, boost::system::error_code& ec) { + verify_mode_ = mode; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records the requested verification mode. + @param mode The requested verification bitmask. + */ + void set_verify_mode(verify_mode mode) { + boost::system::error_code ec; + set_verify_mode(mode, ec); + } +#endif + /** + Records a request for default verification paths. + @param ec Receives success. + */ + void set_default_verify_paths(boost::system::error_code& ec) { + default_paths_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a request for default verification paths. + */ + void set_default_verify_paths() { + boost::system::error_code ec; + set_default_verify_paths(ec); + } +#endif + /** + Adds requested TLS option bits. + @param value The option bits to add. + @param ec Receives success. + */ + void set_options(options value, boost::system::error_code& ec) { + options_ |= value; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Adds requested TLS option bits. + @param value The option bits to add. + */ + void set_options(options value) { + boost::system::error_code ec; + set_options(value, ec); + } +#endif + /** + Records a request to add certificate roots. + @param ca The certificate authority data. + @param ec Receives success. + */ + void add_certificate_authority([[maybe_unused]] const boost::asio::const_buffer& ca, + boost::system::error_code& ec) { + roots_added_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a request to add certificate roots. + @param ca The certificate authority data. + */ + void add_certificate_authority(const boost::asio::const_buffer& ca) { + boost::system::error_code ec; + add_certificate_authority(ca, ec); + } +#endif + /** + Records a root-file request without accessing the file. + @param filename The requested root certificate file. + @param ec Receives success. + */ + void load_verify_file([[maybe_unused]] std::string_view filename, + boost::system::error_code& ec) { + roots_added_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a root-file request without accessing the file. + @param filename The requested root certificate file. + */ + void load_verify_file(std::string_view filename) { + boost::system::error_code ec; + load_verify_file(filename, ec); + } +#endif + /** + Records a root-directory request without accessing it. + @param path The requested root certificate directory. + @param ec Receives success. + */ + void add_verify_path([[maybe_unused]] std::string_view path, boost::system::error_code& ec) { + roots_added_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a root-directory request without accessing it. + @param path The requested root certificate directory. + */ + void add_verify_path(std::string_view path) { + boost::system::error_code ec; + add_verify_path(path, ec); + } +#endif + /** + Records a client certificate request. + @param certificate The certificate bytes. + @param format The certificate encoding. + @param ec Receives success. + */ + void use_certificate([[maybe_unused]] const boost::asio::const_buffer& certificate, + [[maybe_unused]] file_format format, boost::system::error_code& ec) { + credentials_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a client certificate request. + @param certificate The certificate bytes. + @param format The certificate encoding. + */ + void use_certificate(const boost::asio::const_buffer& certificate, file_format format) { + boost::system::error_code ec; + use_certificate(certificate, format, ec); + } +#endif + /** + Records a certificate-file request without accessing it. + @param filename The requested certificate file. + @param format The certificate encoding. + @param ec Receives success. + */ + void use_certificate_file([[maybe_unused]] std::string_view filename, + [[maybe_unused]] file_format format, boost::system::error_code& ec) { + credentials_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a certificate-file request without accessing it. + @param filename The requested certificate file. + @param format The certificate encoding. + */ + void use_certificate_file(std::string_view filename, file_format format) { + boost::system::error_code ec; + use_certificate_file(filename, format, ec); + } +#endif + /** + Records a client certificate chain request. + @param chain The certificate chain bytes. + @param ec Receives success. + */ + void use_certificate_chain([[maybe_unused]] const boost::asio::const_buffer& chain, + boost::system::error_code& ec) { + credentials_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a client certificate chain request. + @param chain The certificate chain bytes. + */ + void use_certificate_chain(const boost::asio::const_buffer& chain) { + boost::system::error_code ec; + use_certificate_chain(chain, ec); + } +#endif + /** + Records a chain-file request without accessing it. + @param filename The requested chain file. + @param ec Receives success. + */ + void use_certificate_chain_file([[maybe_unused]] std::string_view filename, + boost::system::error_code& ec) { + credentials_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a chain-file request without accessing it. + @param filename The requested chain file. + */ + void use_certificate_chain_file(std::string_view filename) { + boost::system::error_code ec; + use_certificate_chain_file(filename, ec); + } +#endif + /** + Records a client private key request. + @param key The private key bytes. + @param format The key encoding. + @param ec Receives success. + */ + void use_private_key([[maybe_unused]] const boost::asio::const_buffer& key, + [[maybe_unused]] file_format format, boost::system::error_code& ec) { + credentials_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a client private key request. + @param key The private key bytes. + @param format The key encoding. + */ + void use_private_key(const boost::asio::const_buffer& key, file_format format) { + boost::system::error_code ec; + use_private_key(key, format, ec); + } +#endif + /** + Records a private-key-file request without accessing it. + @param filename The requested key file. + @param format The key encoding. + @param ec Receives success. + */ + void use_private_key_file([[maybe_unused]] std::string_view filename, + [[maybe_unused]] file_format format, boost::system::error_code& ec) { + credentials_ = true; + ec.clear(); + } +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + /** + Records a private-key-file request without accessing it. + @param filename The requested key file. + @param format The key encoding. + */ + void use_private_key_file(std::string_view filename, file_format format) { + boost::system::error_code ec; + use_private_key_file(filename, format, ec); + } +#endif + /** + Returns the recorded setting. + @return The requested TLS method. + */ + [[nodiscard]] method recorded_method() const noexcept { return method_; } + + /** + Returns the recorded setting. + @return The requested verification mode. + */ + [[nodiscard]] verify_mode recorded_verify_mode() const noexcept { return verify_mode_; } + + /** + Returns the recorded setting. + @return Whether default verification paths were requested. + */ + [[nodiscard]] bool default_verify_paths() const noexcept { return default_paths_; } + + /** + Returns the recorded setting. + @return The verification callback kind. + */ + [[nodiscard]] verify_callback_kind recorded_callback() const noexcept { return callback_; } + + /** + Returns the recorded setting. + @return The recorded verification host. + */ + [[nodiscard]] std::string_view verification_host() const noexcept { return host_; } + + /** + Returns the recorded setting. + @return Whether additional certificate roots were requested. + */ + [[nodiscard]] bool roots_added() const noexcept { return roots_added_; } + + /** + Returns the recorded setting. + @return Whether client credentials were requested. + */ + [[nodiscard]] bool client_credentials() const noexcept { return credentials_; } + + /** + Returns the recorded setting. + @return The accumulated TLS option bits. + */ + [[nodiscard]] options recorded_options() const noexcept { return options_; } + +private: + method method_; + std::pmr::string host_; + verify_mode verify_mode_ = verify_none; + options options_ = 0; + verify_callback_kind callback_ = verify_callback_kind::none; + bool default_paths_ = false; + bool roots_added_ = false; + bool credentials_ = false; +}; +} // namespace webcpp::asio::ssl +#endif +#endif // WEBCPP_ASIO_SSL_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/tls_client_context.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/tls_client_context.hpp new file mode 100644 index 0000000..98a6972 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/tls_client_context.hpp @@ -0,0 +1,177 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_TLS_CLIENT_CONTEXT_HPP +#define WEBCPP_ASIO_TLS_CLIENT_CONTEXT_HPP + +#include + +#include +#include +#include +#include + +#ifndef WEBCPP_TARGET_EMSCRIPTEN +#include +#include +#include +#include +#include +#endif + +namespace webcpp::asio { +/** Errors produced while preparing an independently owned TLS client context. */ +enum class tls_context_error : int { + /** The replacement contains no CAs, invalid PEM, or non-certificate data. */ + invalid_ca_bundle = 1, + /** OpenSSL could not allocate or initialize the requested context or trust store. */ + initialization_failed = 2, + /** The browser owns TLS and cannot use an OpenSSL client context. */ + unsupported_target = 3, +}; + +namespace detail { +/** The stable category for TLS context preparation failures. */ +class tls_context_category final : public boost::system::error_category { +public: + /** Keeps error identity across hidden shared-library boundaries. */ + constexpr tls_context_category() noexcept + : boost::system::error_category(0x6173696f2e746c73ULL) {} + + /** Returns the category name. */ + const char* name() const noexcept override { return "webcpp.asio.tls"; } + + /** Describes a context error without exposing certificate contents. */ + std::string message(int value) const override { + switch (static_cast(value)) { + case tls_context_error::invalid_ca_bundle: + return "invalid or empty CA certificate bundle"; + case tls_context_error::initialization_failed: + return "TLS client context initialization failed"; + case tls_context_error::unsupported_target: + return "TLS is managed by the browser on this target"; + } + return "unknown TLS client context error"; + } +}; +} // namespace detail + +/** + Converts a TLS context preparation error to its stable error code. + + Category equality is stable across native shared-library boundaries, including + hidden visibility. The library defining a returned category must remain loaded + while a caller uses the error code or its category's virtual functions. + @param value The context preparation error. + @return The corresponding code in the webcpp.asio.tls category. +*/ +inline boost::system::error_code make_error_code(tls_context_error value) noexcept { + static const detail::tls_context_category category; + return {static_cast(value), category}; +} + +/** + Creates a verifying TLS client context trusting only the supplied authorities. + + Native and WASIp2/P3 contexts require TLS 1.2 or newer and enable peer verification. + Input consists of one or more PEM CA certificates separated only by whitespace. + The certificates are copied into an independent OpenSSL store; input need not + outlive this call. No system or bundled roots are added. No context is returned + if any certificate is invalid. Configure hostname verification and SNI on each + connection. OpenSSL owns allocations; no Asio allocator is used for its store. + + @param ca_pem The complete replacement PEM authority set. + @return The context, or a tls_context_error; browser targets return unsupported_target. + @see "How-to: configure trusted certificate authorities", in the guide. +*/ +inline boost::system::result make_tls_client_context(std::string_view ca_pem) { +#ifdef WEBCPP_TARGET_EMSCRIPTEN + (void)ca_pem; + return make_error_code(tls_context_error::unsupported_target); +#else + constexpr std::string_view whitespace = " \t\r\n"; + constexpr std::string_view begin = "-----BEGIN CERTIFICATE-----"; + constexpr std::string_view end = "-----END CERTIFICATE-----"; + if (ca_pem.find_first_not_of(whitespace) == std::string_view::npos) { + return make_error_code(tls_context_error::invalid_ca_bundle); + } + SSL_CTX* raw = SSL_CTX_new(TLS_client_method()); + if (raw == nullptr) { + return make_error_code(tls_context_error::initialization_failed); + } + // The context must remain movable into result; const would prevent that. + // NOLINTNEXTLINE(misc-const-correctness) + ssl::context context(raw); + if (SSL_CTX_set_min_proto_version(raw, TLS1_2_VERSION) != 1) { + return make_error_code(tls_context_error::initialization_failed); + } + SSL_CTX_set_options(raw, SSL_OP_NO_COMPRESSION); + SSL_CTX_set_verify(raw, SSL_VERIFY_PEER, nullptr); + while (true) { + const auto next = ca_pem.find_first_not_of(whitespace); + if (next == std::string_view::npos) { + break; + } + ca_pem.remove_prefix(next); + const auto finish = ca_pem.find(end); + if (!ca_pem.starts_with(begin) || finish == std::string_view::npos) { + return make_error_code(tls_context_error::invalid_ca_bundle); + } + const auto length = finish + end.size(); + // Parentheses prevent the Windows max macro from expanding this function name. + // NOLINTNEXTLINE(readability-redundant-parentheses) + if (length > static_cast((std::numeric_limits::max)())) { + return make_error_code(tls_context_error::invalid_ca_bundle); + } + const std::unique_ptr input( + BIO_new_mem_buf(ca_pem.data(), static_cast(length)), &BIO_free); + if (!input) { + return make_error_code(tls_context_error::initialization_failed); + } + unsigned char* der = nullptr; + long der_length = 0; + if (PEM_bytes_read_bio( + &der, &der_length, nullptr, PEM_STRING_X509, input.get(), + [](char*, int, int, void*) { return 0; }, nullptr) != 1) { + return make_error_code(tls_context_error::invalid_ca_bundle); + } + const auto free_der = [](unsigned char* bytes) { OPENSSL_free(bytes); }; + const std::unique_ptr decoded(der, free_der); + const unsigned char* cursor = decoded.get(); + const std::unique_ptr cert( + d2i_X509(nullptr, &cursor, der_length), &X509_free); + if (!cert || cursor != decoded.get() + der_length || X509_check_ca(cert.get()) <= 0) { + return make_error_code(tls_context_error::invalid_ca_bundle); + } + if (X509_STORE_add_cert(SSL_CTX_get_cert_store(raw), cert.get()) != 1) { + return make_error_code(tls_context_error::initialization_failed); + } + ca_pem.remove_prefix(length); + } + return context; +#endif +} + +/** + Creates a verifying TLS client context using WebCPP's embedded Mozilla CA snapshot. + + No certificate files, system store, environment settings or network update are + read. Updating embedded roots requires rebuilding and redeploying the program. + The protocol floor, allocation and per-connection requirements are the same as + the replacement overload. Link /webcpp/asio//tls to supply its dependencies. + + @return The context, or a tls_context_error; browser targets return unsupported_target. + @see "How-to: configure trusted certificate authorities", in the guide. +*/ +inline boost::system::result make_tls_client_context() { +#ifdef WEBCPP_TARGET_EMSCRIPTEN + return make_error_code(tls_context_error::unsupported_target); +#else + return make_tls_client_context(webcpp::asio::detail::ca_certificates::pem); +#endif +} +} // namespace webcpp::asio +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/wasi/stdio_stream.hpp b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/wasi/stdio_stream.hpp new file mode 100644 index 0000000..1711bc4 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/wasi/stdio_stream.hpp @@ -0,0 +1,447 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#ifndef WEBCPP_ASIO_WASI_STDIO_STREAM_HPP +#define WEBCPP_ASIO_WASI_STDIO_STREAM_HPP + +#include +#if defined(__MRDOCS__) || defined(WEBCPP_ASIO_REFERENCE) +#include // lint-world: names the readiness executor +#include +#include + +namespace webcpp::asio::wasi { +/** A WASIp2 CLI AsyncReadStream and AsyncWriteStream driven by pollables. + + Owns resource handles, without closing libc's stdin/stdout descriptors. + Only one read and one write may be outstanding at once. Operations retain + buffers until completion and preserve allocator, executor and cancellation + associations. Host imports may still block according to the host's behavior. + @see "Build for WASIp2", in the guide. */ +class stdio_stream { +public: + /** The executor used for readiness. */ + using executor_type = boost::asio::io_context::executor_type; + /** This stream is its own lowest layer. */ + using lowest_layer_type = stdio_stream; + /** Acquires CLI resources using the executor's context allocator. + @param executor Drives asynchronous readiness. */ + explicit stdio_stream(executor_type const& executor); + /** Cancels pending operations and releases resources after their completion. */ + ~stdio_stream(); + /** Forbids copied resource ownership. */ + stdio_stream(stdio_stream const&) = delete; + /** Forbids copied resource ownership. */ + stdio_stream& operator=(stdio_stream const&) = delete; + /** Transfers resource ownership. */ + stdio_stream(stdio_stream&&); + /** Forbids replacing a stream that may have pending operations. */ + stdio_stream& operator=(stdio_stream&&) = delete; + /** Returns the readiness executor. + @return The executor. */ + [[nodiscard]] executor_type get_executor() const noexcept; + /** Returns this stream. + @return This stream. */ + lowest_layer_type& lowest_layer() noexcept; + /** Cancels outstanding operations; subsequent operations remain usable. */ + void cancel(); + /** Cancels outstanding operations and disables subsequent operations. */ + void close(); + /** Reads a partial sequence asynchronously. + @tparam Buffers Mutable buffer sequence. + @tparam Token Completion token for void(error_code, size_t). + @param buffers Destination storage, alive until completion. + @param token Receives the error and byte count. + @return The completion token's result. */ + template + auto async_read_some(Buffers const& buffers, Token&& token); + /** Writes a partial sequence asynchronously. + @tparam Buffers Const buffer sequence. + @tparam Token Completion token for void(error_code, size_t). + @param buffers Source storage, alive until completion. + @param token Receives the error and byte count. + @return The completion token's result. */ + template + auto async_write_some(Buffers const& buffers, Token&& token); + /** Reads synchronously. + @tparam Buffers Mutable buffer sequence. + @param buffers Destination bytes. + @param error Receives failure. + @return Bytes read. */ + template + std::size_t read_some(Buffers const& buffers, boost::system::error_code& error); + /** Writes synchronously. + @tparam Buffers Const buffer sequence. + @param buffers Source bytes. + @param error Receives failure. + @return Bytes written. */ + template + std::size_t write_some(Buffers const& buffers, boost::system::error_code& error); + /** Reads synchronously and throws on failure. + @tparam Buffers Mutable buffer sequence. + @param buffers Destination bytes. + @return Bytes read. */ + template + std::size_t read_some(Buffers const& buffers); + /** Writes synchronously and throws on failure. + @tparam Buffers Const buffer sequence. + @param buffers Source bytes. + @return Bytes written. */ + template + std::size_t write_some(Buffers const& buffers); +}; + +/** Cancels the channel for Beast timeouts. + @param stream Channel to close. */ +void beast_close_socket(stdio_stream& stream); +} // namespace webcpp::asio::wasi +#elif !WEBCPP_ASIO_HAS_WASI_STDIO +#error \ + "webcpp::asio::wasi::stdio_stream requires WASIp2 CLI streams; use a supplied stream or native descriptor adapter on other targets" +#else +#include +#include +#include // lint-world: preserve completion associations +#include // lint-world: borrow the caller's I/O buffers +#include // lint-world: compose pollable I/O and preserve associations +#include // lint-world: caller-owned readiness context +#include // lint-world: wait on CLI pollables +#include // lint-world: defer initiation onto the executor +#include +#include +#include +#include +#include +#include +#include + +namespace webcpp::asio::wasi { +/** A byte stream over WASIp2 CLI input and output. + + Asynchronous operations wait on native pollables through Asio. They preserve + associated executors, allocators and cancellation. The stream acquires its own + resource handles; it never closes libc's stdin/stdout descriptors. Keep buffers + alive until completion. Only one read and one write may be outstanding at once. + A host implementation may still block inside an otherwise nonblocking import. +*/ +class stdio_stream { +public: + /** Executor that drives stream readiness. */ + using executor_type = boost::asio::io_context::executor_type; + /** This stream has no additional transport layer. */ + using lowest_layer_type = stdio_stream; + +private: + struct state { + executor_type executor; + boost::asio::posix::stream_descriptor input_wait; + boost::asio::posix::stream_descriptor output_wait; + detail::wasi_pollable_descriptor input_storage{}; + detail::wasi_pollable_descriptor output_storage{}; + streams_own_input_stream_t input = stdin_get_stdin(); + streams_own_output_stream_t output = stdout_get_stdout(); + poll_own_pollable_t input_ready = + streams_method_input_stream_subscribe(streams_borrow_input_stream(input)); + poll_own_pollable_t output_ready = + streams_method_output_stream_subscribe(streams_borrow_output_stream(output)); + boost::system::error_code initialization_error; + std::uint64_t generation = 0; + bool closed = false; + + explicit state(const executor_type& value) + : executor(value), input_wait(value), output_wait(value) { + auto const assign = [&](auto& storage, auto& descriptor, auto ready) { + storage.handle = ready.__handle; + int const fd = webcpp_asio_wasi_pollable_descriptor(&storage); + if (fd < 0) { + initialization_error.assign(errno, boost::system::system_category()); + } else { + boost::system::error_code error; + descriptor.assign(fd, error); + if (error) { + ::close(fd); + initialization_error = error; + } + } + }; + assign(input_storage, input_wait, input_ready); + assign(output_storage, output_wait, output_ready); + } + + ~state() { + boost::system::error_code ignored; + // The descriptor is closed even when close reports an error. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(input_wait.close(ignored)); + // The descriptor is closed even when close reports an error. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(output_wait.close(ignored)); + poll_pollable_drop_own(input_ready); + poll_pollable_drop_own(output_ready); + streams_input_stream_drop_own(input); + streams_output_stream_drop_own(output); + } + + void cancel() { + ++generation; + boost::system::error_code ignored; + // Only an unassigned descriptor can fail; generation still cancels the operation. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(input_wait.cancel(ignored)); + // Only an unassigned descriptor can fail; generation still cancels the operation. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(output_wait.cancel(ignored)); + } + + std::size_t read(boost::asio::mutable_buffer buffer, + boost::system::error_code& error) const { + wasip2_list_u8_t bytes{}; + streams_stream_error_t failure{}; + if (!streams_method_input_stream_read(streams_borrow_input_stream(input), + std::min(buffer.size(), 65536), + &bytes, &failure)) { + if (failure.tag == STREAMS_STREAM_ERROR_CLOSED) { + error = boost::asio::error::eof; + } else { + error = boost::asio::error::fault; + } + streams_stream_error_free(&failure); + return 0; + } + auto const count = bytes.len; + if (count != 0u) { + std::memcpy(buffer.data(), bytes.ptr, count); + } + wasip2_list_u8_free(&bytes); + error = (count != 0u) ? boost::system::error_code{} : boost::asio::error::would_block; + return count; + } + + std::size_t write(boost::asio::const_buffer buffer, boost::system::error_code& error) { + std::uint64_t capacity = 0; + streams_stream_error_t failure{}; + if (!streams_method_output_stream_check_write(streams_borrow_output_stream(output), + &capacity, &failure)) { + streams_stream_error_free(&failure); + error = boost::asio::error::broken_pipe; + return 0; + } + if (capacity == 0) { + error = boost::asio::error::would_block; + return 0; + } + auto const count = std::min( + buffer.size(), static_cast(std::min(capacity, 4096))); + wasip2_list_u8_t bytes{ + .ptr = reinterpret_cast(const_cast(buffer.data())), + .len = count, + }; + if (!streams_method_output_stream_write(streams_borrow_output_stream(output), &bytes, + &failure)) { + streams_stream_error_free(&failure); + error = boost::asio::error::broken_pipe; + return 0; + } + // Request delivery before the protocol switches from writing to reading. + // A subsequent check-write/pollable wait observes flush completion. + if (!streams_method_output_stream_flush(streams_borrow_output_stream(output), + &failure)) { + streams_stream_error_free(&failure); + error = boost::asio::error::broken_pipe; + return count; + } + error.clear(); + return count; + } + }; + + std::shared_ptr state_; + + template + struct transfer_operation { + std::shared_ptr shared; + Buffer first; + std::uint64_t generation = 0; + + // Initiation only posts. Resumption has a separate signature so the + // composed operation cannot complete recursively inside initiation. + template + void operator()(Self& self) { + generation = shared->generation; + self.reset_cancellation_state(boost::asio::enable_total_cancellation()); + boost::asio::post(shared->executor, + boost::asio::append(std::move(self), boost::system::error_code{})); + } + + template + void operator()(Self& self, boost::system::error_code error) { + if (self.cancelled() != boost::asio::cancellation_type::none || shared->closed || + generation != shared->generation) { + error = boost::asio::error::operation_aborted; + } + if (!error) { + error = shared->initialization_error; + } + if (error || first.size() == 0) { + self.complete(error, 0); + return; + } + std::size_t count = 0; + if constexpr (Writing) { + count = shared->write(first, error); + } else { + count = shared->read(first, error); + } + if (error != boost::asio::error::would_block) { + self.complete(error, count); + return; + } + auto& descriptor = Writing ? shared->output_wait : shared->input_wait; + descriptor.async_wait(boost::asio::posix::stream_descriptor::wait_read, + std::move(self)); + } + }; + + template + auto async_some(Buffers const& buffers, Token&& token) { + using buffer_type = + std::conditional_t; + buffer_type first; + for (auto it = boost::asio::buffer_sequence_begin(buffers), + end = boost::asio::buffer_sequence_end(buffers); + it != end; ++it) { + if (boost::asio::buffer_size(*it) != 0) { + first = buffer_type(*it); + break; + } + } + return boost::asio::async_compose( + transfer_operation{.shared = state_, .first = first}, token, + state_->executor); + } + + template + std::size_t sync_some(Buffers const& buffers, boost::system::error_code& error) { + if (state_->closed) { + error = boost::asio::error::operation_aborted; + return 0; + } + if (state_->initialization_error) { + error = state_->initialization_error; + return 0; + } + for (auto it = boost::asio::buffer_sequence_begin(buffers), + end = boost::asio::buffer_sequence_end(buffers); + it != end; ++it) { + if (boost::asio::buffer_size(*it) == 0) { + continue; + } + for (;;) { + std::size_t count = 0; + if constexpr (Writing) { + count = state_->write(boost::asio::const_buffer(*it), error); + } else { + count = state_->read(boost::asio::mutable_buffer(*it), error); + } + if (error != boost::asio::error::would_block) { + return count; + } + poll_method_pollable_block( + poll_borrow_pollable(Writing ? state_->output_ready : state_->input_ready)); + } + } + error.clear(); + return 0; + } + +public: + /** Acquires independent CLI resource handles using the executor's context allocator. */ + explicit stdio_stream(const executor_type& executor) + : state_(std::allocate_shared( + boost::asio::execution_context::allocator(executor.context()), executor)) {} + + /** Cancels pending operations without closing the application's descriptors. */ + ~stdio_stream() { + if (state_) { + state_->closed = true; + state_->cancel(); + } + } + + stdio_stream(stdio_stream const&) = delete; + stdio_stream& operator=(stdio_stream const&) = delete; + stdio_stream(stdio_stream&&) = default; + stdio_stream& operator=(stdio_stream&&) = delete; + + /** Returns the executor. */ + [[nodiscard]] executor_type get_executor() const noexcept { return state_->executor; } + + /** Returns this stream, which is its own lowest layer. */ + // lint-std: boost::asio::posix::basic_descriptor::lowest_layer returns itself + lowest_layer_type& lowest_layer() noexcept { return *this; } + + /** Cancels outstanding operations. Subsequent operations remain usable. */ + void cancel() { state_->cancel(); } + + /** Cancels and disables subsequent operations. */ + void close() { + state_->closed = true; + state_->cancel(); + } + + /** Reads a partial buffer sequence asynchronously. */ + template + auto async_read_some(Buffers const& buffers, Token&& token) { + return async_some(buffers, std::forward(token)); + } + + /** Writes a partial buffer sequence asynchronously. */ + template + auto async_write_some(Buffers const& buffers, Token&& token) { + return async_some(buffers, std::forward(token)); + } + + /** Reads synchronously, reporting failures through error. */ + template + std::size_t read_some(Buffers const& buffers, boost::system::error_code& error) { + return sync_some(buffers, error); + } + + /** Writes synchronously, reporting failures through error. */ + template + std::size_t write_some(Buffers const& buffers, boost::system::error_code& error) { + return sync_some(buffers, error); + } + + /** Reads synchronously, throwing on failure when exceptions are enabled. */ + template + std::size_t read_some(Buffers const& buffers) { + boost::system::error_code error; + auto count = read_some(buffers, error); + if (error) { + boost::throw_exception(boost::system::system_error(error)); + } + return count; + } + + /** Writes synchronously, throwing on failure when exceptions are enabled. */ + template + std::size_t write_some(Buffers const& buffers) { + boost::system::error_code error; + auto count = write_some(buffers, error); + if (error) { + boost::throw_exception(boost::system::system_error(error)); + } + return count; + } +}; + +/** Allows Beast timeouts to cancel the supplied channel without socket shutdown. */ +inline void beast_close_socket(stdio_stream& stream) { + stream.close(); +} +} // namespace webcpp::asio::wasi +#endif +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/webcpp-asio-loader.mjs b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/webcpp-asio-loader.mjs new file mode 100644 index 0000000..4fd36e2 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/include/webcpp/asio/webcpp-asio-loader.mjs @@ -0,0 +1,38 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Loads the artifact named by the build's manifest (doc: #asio-building-loader). +// A supported JSPI runtime selects JSPI; other runtimes select Asyncify. + +/** Whether scope has JavaScript Promise Integration. */ +export function supportsJspi(scope = globalThis) { + return typeof scope.WebAssembly?.Suspending === 'function' +} + +/** The selected variant and its script path, relative to the manifest. */ +export function pick(manifest, jspi = supportsJspi()) { + const variant = jspi ? 'jspi' : 'asyncify' + const script = manifest?.[variant]?.script + if (typeof script !== 'string') { + throw new Error(`the manifest names no ${variant} artifact`) + } + return {variant, script} +} + +/** Fetches the manifest, imports its selected artifact and awaits the module factory. */ +export async function load(manifestUrl, options = {}) { + const {jspi = supportsJspi(), module = {}, fetch = globalThis.fetch, + importModule = url => import(url)} = options + const base = new URL(manifestUrl, globalThis.location?.href ?? import.meta.url) + const response = await fetch(base.href) + if (!response.ok) { + throw new Error(`${base.href}: ${response.status} ${response.statusText}`) + } + const {variant, script} = pick(await response.json(), jspi) + const artifactBase = response.url || base + const factory = (await importModule(new URL(script, artifactBase).href)).default + return {variant, module: await factory(module)} +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/meta/libraries.json b/libraries/asio/openspec/changes/genesis/reference/source/meta/libraries.json index 7f987e3..64224a4 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/meta/libraries.json +++ b/libraries/asio/openspec/changes/genesis/reference/source/meta/libraries.json @@ -2,7 +2,7 @@ "key": "asio", "name": "asio", "authors": ["R"], - "description": "Boost.Asio natively, and in the browser Boost.Asio's own io_context suspended into the page's event loop.", + "description": "Boost.Asio and Cobalt for native, browser and WASIp2/P3 targets, with explicit platform capabilities.", "category": ["Concurrent", "IO"], "maintainers": ["R "], "cxxstd": "20", diff --git a/libraries/asio/openspec/changes/genesis/reference/source/src/cobalt_main.cpp b/libraries/asio/openspec/changes/genesis/reference/source/src/cobalt_main.cpp new file mode 100644 index 0000000..a1449f2 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/src/cobalt_main.cpp @@ -0,0 +1,96 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2022 Klemens Morgenstern (klemens.morgenstern@gmx.net) +// Distributed under the Boost Software License, Version 1.0. + +// Boost 1.92's entry-point setup with webcpp's bounded run loop. These definitions replace +// Boost.Cobalt's src/main.cpp; compiling them probes the internal main_promise interface. +#include + +#include // lint-world: starts the application's coroutine +#include + +#include + +#if !defined(WEBCPP_TARGET_WASIP2) && !defined(WEBCPP_TARGET_WASIP3) +#include // lint-world: preserves Cobalt's signal cancellation +#include +#endif + +#ifdef WEBCPP_TARGET_EMSCRIPTEN +#include +#endif + +namespace boost::cobalt::detail { + +// Match Boost's non-static promise interface even when no signal set needs cleanup. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +auto main_promise::final_suspend() noexcept -> std::suspend_never { +#if !defined(WEBCPP_TARGET_WASIP2) && !defined(WEBCPP_TARGET_WASIP3) + system::error_code ec; + if (signal_set != nullptr) { + // Preserve Boost's nonthrowing cleanup; the return duplicates ec. + // NOLINTNEXTLINE(bugprone-unused-return-value) + signal_set->cancel(ec); + } +#endif + return {}; +} + +int main_promise::run_main(::boost::cobalt::main mn) { + int result = -1; + { + webcpp::asio::io_context ctx{BOOST_ASIO_CONCURRENCY_HINT_1}; + boost::cobalt::this_thread::set_executor(ctx.get_executor()); + mn.promise->result = &result; + mn.promise->exec.emplace(ctx.get_executor()); + mn.promise->exec_ = mn.promise->exec->get_executor(); + const auto coroutine = std::coroutine_handle::from_promise(*mn.promise); +#if defined(WEBCPP_TARGET_WASIP2) || defined(WEBCPP_TARGET_WASIP3) + // WASI has no POSIX process-signal delivery. wasi-libc's optional signal + // emulation does not provide host SIGINT/SIGTERM notifications. Omit that + // bridge, including its headers and final-suspend cleanup, but retain + // Cobalt's internal cancellation signal. Host-requested graceful shutdown + // needs an explicit application protocol; stopping the context is not a + // substitute for cancelling operations and allowing cleanup to run. + mn.promise->signal_set = nullptr; +#else + asio::basic_signal_set signals{ctx, SIGINT, SIGTERM}; + mn.promise->signal_set = &signals; + + struct signal_wait { + asio::basic_signal_set& signals; + asio::cancellation_signal& cancellation; + + void operator()(system::error_code ec, int signal_number) const { + if (signal_number == SIGINT) { + cancellation.emit(asio::cancellation_type::total); + } + if (signal_number == SIGTERM) { + cancellation.emit(asio::cancellation_type::terminal); + } + if (!ec) { + signals.async_wait(*this); + } + } + }; + + signals.async_wait(signal_wait{.signals = signals, .cancellation = mn.promise->signal}); +#endif + asio::post(ctx.get_executor(), [coroutine] { coroutine.resume(); }); + ctx.run(); // lint-run: Cobalt's application event loop + } +#ifdef WEBCPP_TARGET_EMSCRIPTEN + // Destroy the context before exiting; a suspended Asyncify main loses a returned status. + if (emscripten_has_asyncify() == 1) { + std::exit(result); + } +#endif + return result; +} + +} // namespace boost::cobalt::detail diff --git a/libraries/asio/openspec/changes/genesis/reference/source/src/openssl_on_webassembly.hpp b/libraries/asio/openspec/changes/genesis/reference/source/src/openssl_on_webassembly.hpp new file mode 100644 index 0000000..acd8088 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/src/openssl_on_webassembly.hpp @@ -0,0 +1,15 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_SRC_OPENSSL_ON_WEBASSEMBLY_HPP +#define WEBCPP_ASIO_SRC_OPENSSL_ON_WEBASSEMBLY_HPP + +// Forced into every source when an Emscripten program names the OpenSSL target. +#if defined(__EMSCRIPTEN__) || defined(WEBCPP_TEST_ASIO_AS_WEBASSEMBLY) +#error \ + "webcpp::asio: /webcpp/asio//openssl is named in a build for Emscripten, whose browser profile does not link OpenSSL: there is a record of the TLS settings and links no library, and nothing of OpenSSL would be in the .wasm. In the program's Jamfile, name OpenSSL for native and WASI builds alone, by a condition in the project's requirements: project : requirements @native-openssl ; rule native-openssl ( properties * ) { if ! emscripten in $(properties) { return /webcpp/asio//openssl ; } } (without b2: link OpenSSL into native and WASI programs only)" +#endif +#endif // WEBCPP_ASIO_SRC_OPENSSL_ON_WEBASSEMBLY_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/Jamfile index 4266d85..c320797 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/Jamfile +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/Jamfile @@ -8,29 +8,95 @@ project : requirements /webcpp/asio//asio ; import webcpp ; -webcpp.targets native emscripten ; +webcpp.targets native emscripten wasip3 ; +webcpp.original node : browser ; -webcpp.headers-alone asio : ../include : asio.hpp asio/*.hpp ; +webcpp.run tls_client_context : tls_client_context_test.cpp + : /webcpp/asio//tls + : native wasip3 ; +# Hidden category singletons in the executable and shared object compare equal. +lib tls_error_peer : tls_error_peer.cpp + : shared hidden WEBCPP_TEST_ERROR_EXPORT + /webcpp/asio//tls ; +explicit tls_error_peer ; +webcpp.run tls_error_shared : tls_error_shared_test.cpp + : tls_error_peer /webcpp/asio//tls hidden : native ; +webcpp.headers-alone asio : ../include : asio/tls_client_context.hpp + : /webcpp/asio//tls : native wasip3 ; +webcpp.run tls_client_context_browser : tls_client_context_browser_test.cpp : : emscripten ; + +webcpp.run wasi_core : wasi_core_test.cpp : : native wasip3 ; +webcpp.run wasi_contract : wasi_contract_test.cpp : : native wasip3 ; +webcpp.run wasi_udp_gather : wasi_udp_gather_test.cpp : : native wasip3 ; +webcpp.run wasi_coroutine : wasi_coroutine_test.cpp : : native wasip3 ; +for local handling in on off +{ + webcpp.run asio_coroutine_exceptions_$(handling) : wasi_coroutine_test.cpp + : $(handling) : emscripten ; + webcpp.run asio_coroutine_exceptions_$(handling)_asyncify : wasi_coroutine_test.cpp + : $(handling) asyncify : emscripten ; + .asyncify += asio_coroutine_exceptions_$(handling)_asyncify ; + webcpp.run cobalt_network_exceptions_$(handling) : cobalt_network_test.cpp + : /webcpp/asio//cobalt $(handling) : native ; +} +webcpp.run cobalt_network_wasi : cobalt_network_test.cpp + : /webcpp/asio//cobalt : wasip3 ; +webcpp.run cobalt_io : cobalt_io_test.cpp : /webcpp/asio//cobalt : native wasip3 ; +webcpp.run cobalt_accept_cancel : cobalt_accept_cancel_test.cpp + : /webcpp/asio//cobalt : native wasip3 ; +webcpp.run cobalt_wasi : cobalt_test.cpp : /webcpp/asio//cobalt : wasip3 ; +# The SDK supports cooperative WASIp3 threads only with exceptions disabled. +webcpp.run cobalt_thread : cobalt_thread_test.cpp + : /webcpp/asio//cobalt multi + clang-wasip3:off : native wasip3 ; +explicit cobalt_thread ; +# Compile the real runner independently of Cobalt's compiled I/O sources. +# This must not require wasi-libc's process-signal emulation. +webcpp.compile cobalt_main_wasip3 : ../src/cobalt_main.cpp + : BOOST_COBALT_NO_LIB=1 : wasip3 ; +webcpp.run wasi_core_threads : wasi_core_test.cpp + : multi WEBCPP_TEST_WASI_THREADS + clang-wasip3:off : native wasip3 ; +explicit wasi_core_threads ; + +webcpp.headers-alone asio : ../include : asio.hpp asio/basic_datagram_socket.hpp asio/basic_socket_acceptor.hpp + asio/basic_stream_socket.hpp asio/basic_waitable_timer.hpp asio/config.hpp + asio/io_context.hpp asio/steady_timer.hpp asio/system_timer.hpp asio/ip/*.hpp ; # The browser's headers name Emscripten's own, and compile on emscripten # alone. -webcpp.headers-alone asio : ../include : asio/browser/*.hpp asio/detail/*.hpp : : emscripten ; +webcpp.headers-alone asio : ../include : asio/browser/async_await.hpp + asio/browser/async_wait_event.hpp asio/browser/bridge.hpp asio/browser/error.hpp + asio/browser/src.hpp asio/browser/transport.hpp asio/detail/browser_*.hpp + asio/detail/post_completion.hpp asio/detail/flag_scope.hpp : : emscripten ; +webcpp.headers-alone asio : ../include : asio/browser/main_thread_context.hpp + : multi : emscripten ; -# config.hpp defines WEBCPP_ASIO_NO_EXCEPTIONS exactly when the build has no -# exceptions, and keeps it when a developer defines it in a build that has -# them. +# config.hpp follows the collection exception setting and preserves a +# developer definition that disables this library alone. webcpp.compile config : config_test.cpp ; +webcpp.compile config_all_off : config_test.cpp : WEBCPP_NO_EXCEPTIONS ; webcpp.compile config_developer_defined : config_test.cpp : WEBCPP_ASIO_NO_EXCEPTIONS WEBCPP_TEST_ASIO_DEVELOPER_DEFINED ; # The names of asio are Boost.Asio's: the io_context derives from Boost's and # keeps its options, and the timers are Boost's own. webcpp.run names : names_test.cpp ; +# Compiler configuration selects the default. Explicit context options +# still win. +webcpp.run names_custom_default : names_test.cpp + : WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN=1000 + WEBCPP_TEST_TURN_LIMIT=1000 ; +webcpp.run names_zero_default : names_test.cpp + : WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN=0 + WEBCPP_TEST_TURN_LIMIT=1 ; +webcpp.compile-fail negative_default_refused : config_test.cpp + : WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN=-1 ; # Every test of the browser runs in each variant, with exceptions and without # them: jspi, the default, in the emscripten lane; asyncify in the own lane # asyncify. A test joins by its name. em_js loads every EM_JS of asio and of # browser_values.hpp: a function that does not parse fails it before main. -local browser-tests = reactor run_family turn_limit bridge bridge_abort em_js ; +local browser-tests = reactor run_family turn_limit bridge bridge_abort em_js timers allocation promise event sockets transport resolver ; for local test in $(browser-tests) { webcpp.run $(test) : $(test)_test.cpp : : emscripten ; @@ -43,6 +109,15 @@ for local test in $(browser-tests) .asyncify += $(test)_asyncify $(test)_asyncify_no_exceptions ; } +# An optimized JSPI link must retain the native stack helpers used by the +# bridge's JavaScript. Debug runtime dependencies can hide missing exports. +for local handling in on off +{ + webcpp.run bridge_optimized_link_exceptions_$(handling) : bridge_test.cpp + : release -O3 $(handling) + : emscripten ; +} + # Through the bridge, a program can neither deliver an event outside the # count its JavaScript functions keep, deliver being private, nor set what # delivering() reads. The control compiles; each refusal must not. @@ -80,11 +155,35 @@ for local suspend in jspi asyncify # The run family keeps Boost's meaning natively too, where it is Boost's own. webcpp.run run_family_native : run_family_test.cpp : : native ; +webcpp.run timers_native : timers_test.cpp : : native ; +webcpp.run run_family_wasip3 : run_family_test.cpp : : wasip3 ; +webcpp.run timers_wasip3 : timers_test.cpp : : wasip3 ; +# Allocation instrumentation observes calls that compiler builtins may elide +# or reorder across its measurement flags. Keep the calls observable in this +# test alone, including release; application and size builds stay unchanged. +local allocation-native-requirements = clang:-fno-builtin + gcc:-fno-builtin ; +local allocation-wasi-requirements = -fno-builtin + -Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=aligned_alloc,--wrap=posix_memalign,--wrap=pipe,--wrap=write,--wrap=close ; +webcpp.run allocation_wasip3 : allocation_test.cpp + : $(allocation-wasi-requirements) : wasip3 ; +webcpp.run allocation_threads : allocation_test.cpp + : multi $(allocation-native-requirements) + clang-wasip3:off + clang-wasip3:-Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=aligned_alloc,--wrap=posix_memalign,--wrap=pipe,--wrap=write,--wrap=close + : native wasip3 ; +webcpp.lane threads : cobalt_thread wasi_core_threads allocation_threads : native wasip3 ; +webcpp.run allocation_native : allocation_test.cpp + : $(allocation-native-requirements) : native ; +webcpp.run allocation_native_release : allocation_test.cpp + : release $(allocation-native-requirements) : native ; # Throws and catches across a suspension need exceptions, whatever the build # asks: WebAssembly's under jspi, JavaScript's under asyncify (the feature's -# composition), and natively for the twin. -webcpp.run exceptions : exceptions_test.cpp : on : native emscripten ; +# composition), and natively for the twin. WASIp3 uses its single-threaded +# runtime here because the cooperative SDK has no exception runtime. +webcpp.run exceptions : exceptions_test.cpp + : on clang-wasip3:single : native emscripten wasip3 ; webcpp.run exceptions_asyncify : exceptions_test.cpp : on asyncify : emscripten ; .asyncify += exceptions_asyncify ; @@ -109,6 +208,12 @@ for local build in $(.asyncify-stack-builds) $(handling) : emscripten ; .asyncify += $(name) ; + local cobalt-name = cobalt_stack_$(build)_exceptions_$(handling) ; + webcpp.run $(cobalt-name) : cobalt_stack_test.cpp + : /webcpp/asio//cobalt asyncify + $(.asyncify-stack-$(build)) $(handling) + : emscripten ; + .asyncify += $(cobalt-name) ; } } @@ -148,4 +253,80 @@ webcpp.run-fail return_after_suspension_asyncify : return_after_suspension_test. : asyncify : emscripten ; .asyncify += never_finishes_asyncify return_after_suspension_asyncify ; +# Cobalt's entry point uses the same program in all three environments. +for local test in cobalt cobalt_status +{ + local runner = run ; + if $(test) = cobalt_status { runner = run-fail ; } + for local handling in on off + { + local requirements = /webcpp/asio//cobalt $(handling) ; + local name = $(test)_exceptions_$(handling) ; + webcpp.$(runner) $(name)_native : $(test)_test.cpp : $(requirements) : native ; + webcpp.$(runner) $(name) : $(test)_test.cpp : $(requirements) : emscripten ; + webcpp.$(runner) $(name)_asyncify : $(test)_test.cpp + : $(requirements) asyncify : emscripten ; + .asyncify += $(name)_asyncify ; + } +} + +# A driver checks the actual status, so a trap cannot satisfy run-fail. +webcpp.drive cobalt_exit_wasi : cobalt_status_test.cpp : /webcpp/asio//cobalt + : cobalt_status_driver.mjs : : wasip3 ; +webcpp.lane cobalt_wasip3 : cobalt_exit_wasi : wasip3 ; +for local handling in on off +{ + local name = cobalt_exit_exceptions_$(handling) ; + local requirements = /webcpp/asio//cobalt $(handling) ; + webcpp.drive $(name) : cobalt_status_test.cpp : $(requirements) + : cobalt_status_driver.mjs : : native emscripten ; + webcpp.drive $(name)_asyncify : cobalt_status_test.cpp + : $(requirements) asyncify : cobalt_status_driver.mjs : : emscripten ; + .cobalt += $(name) ; + .cobalt-emscripten += $(name)_asyncify ; + .asyncify += $(name)_asyncify ; +} +webcpp.lane cobalt : $(.cobalt) : native emscripten ; +webcpp.lane cobalt_asyncify : $(.cobalt-emscripten) : emscripten ; + +for local handling in on off +{ + local name = promise_cobalt_exceptions_$(handling) ; + local requirements = /webcpp/asio//cobalt $(handling) ; + webcpp.run $(name) : promise_cobalt_test.cpp : $(requirements) : emscripten ; + webcpp.run $(name)_asyncify : promise_cobalt_test.cpp + : $(requirements) asyncify : emscripten ; + .asyncify += $(name)_asyncify ; +} + +.asyncify += ssl_asyncify ssl_asyncify_no_exceptions ; webcpp.lane asyncify : $(.asyncify) : emscripten ; + +webcpp.run ssl : ssl_test.cpp : /webcpp/asio//openssl-tests + : native wasip3 emscripten ; +webcpp.run ssl_no_exceptions : ssl_test.cpp + : /webcpp/asio//openssl-tests off : native wasip3 emscripten ; +webcpp.run ssl_asyncify : ssl_test.cpp + : /webcpp/asio//openssl-tests asyncify : emscripten ; +webcpp.run ssl_asyncify_no_exceptions : ssl_test.cpp + : /webcpp/asio//openssl-tests asyncify off : emscripten ; +webcpp.compile-diagnostic ssl_without_openssl : ssl_without_openssl_test.cpp : : native ; + +webcpp.compile-diagnostic openssl_on_webassembly : openssl_on_webassembly_test.cpp + : WEBCPP_TEST_ASIO_AS_WEBASSEMBLY : native ; +webcpp.compile-fail openssl_named_on_emscripten : openssl_named_test.cpp + : /webcpp/asio//openssl : emscripten ; + +webcpp.headers-alone asio : ../include : asio/ssl.hpp + : /webcpp/asio//openssl-tests : native emscripten wasip3 ; + +webcpp.compile-fail openssl_named_c_on_emscripten : openssl_named_c_test.c + : /webcpp/asio//openssl : emscripten ; + +# The TLS lane drives real loopback peers with the shared certificate fixtures. +build-project tls ; + +build-project wasip2 ; +build-project capabilities ; +build-project capability_wasi ; +build-project wasip2_tls_cobalt ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/allocation_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/allocation_test.cpp new file mode 100644 index 0000000..69fccef --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/allocation_test.cpp @@ -0,0 +1,1068 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Allocation attribution (doc: #asio-allocation): context services and bound operations use +// the supplied allocator. The unbound-handler control catches C-library allocation bypasses. +// C allocation hooks and the stack-backed select are adapted from trystero's allocation test. + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _MSC_VER +#include +#else +#include +#endif +#ifdef __EMSCRIPTEN__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#elif defined(__wasi__) +#include +#include +#elif defined(__APPLE__) +#include +#endif + +namespace { + +// What the replaced operator new and the C library's allocation functions count +// while counting is set: global and mutable, since an operator new can reach +// nothing else. +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::size_t operator_new_calls = 0; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::size_t c_allocations = 0; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +bool counting = false; +// Set while operator new takes its memory from the C library, which then +// counts nothing: that allocation is operator new's, counted once. +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +bool inside_operator_new = false; +// Runtime allocation attribution, set only around measured platform runtime calls. +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::uint8_t inside_runtime = 0; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::size_t runtime_allocations = 0; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::size_t aligned_allocations = 0; + +#if defined(_MSC_VER) || (defined(__wasi__) && !defined(_REENTRANT)) +/** Whether the calling thread is the one the test counts on: single-threaded WASI and MSVC count + * every thread. */ +bool on_counted_thread() noexcept { + return true; +} + +void count_this_thread() noexcept {} +#else +// The thread main runs on: the C library's allocations are reported from every thread +// (malloc_logger is process-wide, the replaced functions serve every thread), and a +// system thread allocating during a window is not the application's, nor may it touch the +// counts. Atomic, since every thread reads it. +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::atomic counted_thread{}; + +/** Whether the calling thread is the one the test counts on. */ +bool on_counted_thread() noexcept { + return pthread_equal(pthread_self(), counted_thread.load(std::memory_order_relaxed)) != 0; +} + +void count_this_thread() noexcept { + counted_thread.store(pthread_self(), std::memory_order_relaxed); +} +#endif + +} // namespace + +// AddressSanitizer replaces the C library's allocation functions with its own +// allocator, which none of the hooks below sees, so a build with it counts none. +#ifdef __SANITIZE_ADDRESS__ +#define WEBCPP_TEST_ASIO_ADDRESS_SANITIZER 1 +#elif defined(__has_feature) +#if __has_feature(address_sanitizer) +#define WEBCPP_TEST_ASIO_ADDRESS_SANITIZER 1 +#endif +#endif + +// The C library's allocations, seen where a program can see them: glibc's +// functions are replaced and forward to glibc's own (__libc_*), Emscripten's +// dlmalloc defines its functions weak and keeps emscripten_builtin_*, and +// macOS reports every allocation to malloc_logger, and WASI uses linker wrappers. +// MSVC's are not counted, nor +// any under AddressSanitizer. +#ifdef WEBCPP_TEST_ASIO_ADDRESS_SANITIZER +// Nothing of the C library is counted. +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) +#define WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS 1 +#ifdef __GLIBC__ +extern "C" { +void* __libc_malloc(std::size_t size); +void* __libc_calloc(std::size_t count, std::size_t size); +void* __libc_realloc(void* pointer, std::size_t size); +void* __libc_memalign(std::size_t alignment, std::size_t size); +void __libc_free(void* pointer); +} +#define WEBCPP_TEST_C_MALLOC __libc_malloc +#define WEBCPP_TEST_C_CALLOC __libc_calloc +#define WEBCPP_TEST_C_REALLOC __libc_realloc +#define WEBCPP_TEST_C_MEMALIGN __libc_memalign +#define WEBCPP_TEST_C_FREE __libc_free +#else +#define WEBCPP_TEST_C_MALLOC emscripten_builtin_malloc +#define WEBCPP_TEST_C_CALLOC emscripten_builtin_calloc +#define WEBCPP_TEST_C_REALLOC emscripten_builtin_realloc +#define WEBCPP_TEST_C_MEMALIGN emscripten_builtin_memalign +#define WEBCPP_TEST_C_FREE emscripten_builtin_free +#endif + +namespace { + +void* observe_allocation(void* pointer, bool aligned = false) { + if (on_counted_thread() && counting && !inside_operator_new) { + if (inside_runtime != 0) { + ++runtime_allocations; + } else if (aligned) { + ++aligned_allocations; + } else { + ++c_allocations; + } + } + return pointer; +} + +} // namespace + +// The C library's allocation functions, replaced for this program alone: the C library declares +// them with parameter names of its own, and cert-dcl58-cpp takes a replacement of what +// declares for a change to namespace std. +// NOLINTBEGIN(readability-inconsistent-declaration-parameter-name,cert-dcl58-cpp) +extern "C" { +void* malloc(std::size_t size) { + return observe_allocation(WEBCPP_TEST_C_MALLOC(size)); +} + +void* calloc(std::size_t count, std::size_t size) { + return observe_allocation(WEBCPP_TEST_C_CALLOC(count, size)); +} + +void* realloc(void* pointer, std::size_t size) { + return observe_allocation(WEBCPP_TEST_C_REALLOC(pointer, size)); +} + +void free(void* pointer) { + WEBCPP_TEST_C_FREE(pointer); +} + +void* memalign(std::size_t alignment, std::size_t size) { + return observe_allocation(WEBCPP_TEST_C_MEMALIGN(alignment, size), true); +} + +void* aligned_alloc(std::size_t alignment, std::size_t size) { + return observe_allocation(WEBCPP_TEST_C_MEMALIGN(alignment, size), true); +} + +int posix_memalign(void** out, std::size_t alignment, std::size_t size) { + if (alignment < sizeof(void*) || (alignment & (alignment - 1)) != 0) { + return EINVAL; + } + void* pointer = observe_allocation(WEBCPP_TEST_C_MEMALIGN(alignment, size), true); + if (pointer == nullptr) { + return ENOMEM; + } + *out = pointer; + return 0; +} +} +// NOLINTEND(readability-inconsistent-declaration-parameter-name,cert-dcl58-cpp) + +#ifdef __EMSCRIPTEN__ +// Emscripten's select() is a poll() over an array of pollfd it callocs on every +// call (system/lib/libc/musl/src/select/select.c), and Asio's reactor calls it on +// every wait of the io_context the test drives. This one keeps the array on the stack, so +// that the count sees the application's allocations rather than the C library's wait. +namespace { + +unsigned requested_event(int fd, const fd_set* set, unsigned event) { + return set != nullptr && FD_ISSET(fd, set) ? event : 0U; +} + +void clear_set(fd_set* set) { + if (set != nullptr) { + FD_ZERO(set); + } +} + +int ready_event(const pollfd& descriptor, fd_set* set, unsigned events) { + if (set != nullptr && (static_cast(descriptor.revents) & events) != 0) { + FD_SET(descriptor.fd, set); + return 1; + } + return 0; +} + +} // namespace + +// select's C declaration requires a mutable timeval pointer, although this implementation +// does not change it. +extern "C" int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, + timeval* timeout) { // NOLINT(misc-const-correctness) + if (nfds < 0 || nfds > FD_SETSIZE) { + errno = EINVAL; + return -1; + } + std::array fds{}; + int n = 0; + for (int fd = 0; fd < nfds; ++fd) { + const unsigned events = requested_event(fd, readfds, POLLIN) | + requested_event(fd, writefds, POLLOUT) | + requested_event(fd, exceptfds, POLLPRI); + if (events != 0) { + fds[n++] = pollfd{.fd = fd, .events = static_cast(events), .revents = 0}; + } + } + const int milliseconds = + timeout == nullptr ? -1 + : static_cast((timeout->tv_sec * 1000) + (timeout->tv_usec / 1000)); + const int ready = poll(fds.data(), static_cast(n), milliseconds); + if (ready < 0) { + return ready; + } + clear_set(readfds); + clear_set(writefds); + clear_set(exceptfds); + int count = 0; + for (int i = 0; i < n && ready > 0; ++i) { + count += ready_event(fds[i], readfds, POLLIN | POLLHUP | POLLERR); + count += ready_event(fds[i], writefds, POLLOUT | POLLERR); + count += ready_event(fds[i], exceptfds, POLLPRI); + } + return count; +} +#endif + +#elif defined(__wasi__) +#define WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS 1 + +// WASI libc owns its allocator symbols. Linker wrapping observes callers without +// replacing libc's implementation or recursively counting its internal calls. +// The linker requires the __real_ and __wrap_ symbol prefixes. +// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" { +void* __real_malloc(std::size_t size); +void* __real_calloc(std::size_t count, std::size_t size); +void* __real_realloc(void* pointer, std::size_t size); +void* __real_aligned_alloc(std::size_t alignment, std::size_t size); +int __real_posix_memalign(void** pointer, std::size_t alignment, std::size_t size); +int __real_pipe(int* descriptors); +ssize_t __real_write(int descriptor, const void* bytes, std::size_t size); +int __real_close(int descriptor); +} +// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +#define WEBCPP_TEST_C_MEMALIGN __real_aligned_alloc + +namespace { +// Descriptor ownership lets the wrapper distinguish pipe buffers from other writes. +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +fd_set wasi_pipe_writers{}; + +void* observe_wasi_allocation(void* pointer, bool aligned = false) { + if (on_counted_thread() && counting && !inside_operator_new) { + if (inside_runtime != 0) { + ++runtime_allocations; + } else if (aligned) { + ++aligned_allocations; + } else { + ++c_allocations; + } + } + return pointer; +} +} // namespace + +// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" { +// wasi-libc owns the pipe descriptors and the messages written to their queue. +// These calls cannot invoke the application's Asio completion handlers. +int __wrap_pipe(int* descriptors) { + const auto previous = std::exchange(inside_runtime, 1); + const int result = __real_pipe(descriptors); + inside_runtime = previous; + if (result == 0 && descriptors[1] < FD_SETSIZE) { + FD_SET(descriptors[1], &wasi_pipe_writers); + } + return result; +} + +ssize_t __wrap_write(int descriptor, const void* bytes, std::size_t size) { + const auto previous = inside_runtime; + if (descriptor >= 0 && descriptor < FD_SETSIZE && FD_ISSET(descriptor, &wasi_pipe_writers)) { + inside_runtime = 1; + } + const auto result = __real_write(descriptor, bytes, size); + inside_runtime = previous; + return result; +} + +int __wrap_close(int descriptor) { + const int result = __real_close(descriptor); + if (result == 0 && descriptor >= 0 && descriptor < FD_SETSIZE) { + FD_CLR(descriptor, &wasi_pipe_writers); + } + return result; +} + +void* __wrap_malloc(std::size_t size) { + return observe_wasi_allocation(__real_malloc(size)); +} + +void* __wrap_calloc(std::size_t count, std::size_t size) { + return observe_wasi_allocation(__real_calloc(count, size)); +} + +void* __wrap_realloc(void* pointer, std::size_t size) { + return observe_wasi_allocation(__real_realloc(pointer, size)); +} + +void* __wrap_aligned_alloc(std::size_t alignment, std::size_t size) { + return observe_wasi_allocation(__real_aligned_alloc(alignment, size), true); +} + +int __wrap_posix_memalign(void** pointer, std::size_t alignment, std::size_t size) { + const int status = __real_posix_memalign(pointer, alignment, size); + if (status == 0) { + (void)observe_wasi_allocation(*pointer, true); + } + return status; +} +} +// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) + +#elif defined(__APPLE__) +#define WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS 1 + +// libsystem_malloc's hook, which it calls on every allocation and release: a global of its own, +// which the test sets. +extern "C" { +using malloc_logger_type = void(std::uint32_t type, std::uintptr_t, std::uintptr_t, std::uintptr_t, + std::uintptr_t, std::uint32_t); +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +extern malloc_logger_type* malloc_logger; +} + +namespace { + +constexpr std::uint32_t malloc_log_allocate = 2; + +void count_c_allocation(std::uint32_t type, std::uintptr_t /*zone*/, std::uintptr_t /*size*/, + std::uintptr_t /*other*/, std::uintptr_t /*result*/, + std::uint32_t /*frames*/) { + if (on_counted_thread() && counting && !inside_operator_new && + (type & malloc_log_allocate) != 0) { + if (inside_runtime != 0) { + ++runtime_allocations; + } else { + ++c_allocations; + } + } +} + +} // namespace +#endif + +namespace { + +/** Memory for operator new, from the C library, uncounted there. */ +void* take(std::size_t size, std::size_t alignment) { +#ifdef _MSC_VER + return _aligned_malloc(size, alignment); +#elif defined(WEBCPP_TEST_C_MEMALIGN) + return WEBCPP_TEST_C_MEMALIGN(alignment, size); +#else + // Only the measured thread touches this flag; accessing thread-local storage here can + // allocate on macOS and recursively enter malloc_logger before the flag exists. + const bool measured = on_counted_thread(); + const bool previous = measured ? std::exchange(inside_operator_new, true) : false; + void* pointer = std::aligned_alloc(alignment, size); + if (measured) { + inside_operator_new = previous; + } + return pointer; +#endif +} + +void release(void* pointer) noexcept { +#ifdef _MSC_VER + _aligned_free(pointer); +#elif defined(WEBCPP_TEST_C_FREE) + WEBCPP_TEST_C_FREE(pointer); +#else + // Only the measured thread touches this flag; accessing thread-local storage here can + // allocate on macOS and recursively enter malloc_logger before the flag exists. + const bool measured = on_counted_thread(); + const bool previous = measured ? std::exchange(inside_operator_new, true) : false; + std::free(pointer); + if (measured) { + inside_operator_new = previous; + } +#endif +} + +/** Uncounted, aligned storage; a zero-size request still owns a non-null block. */ +void* allocate_storage(std::size_t size, std::size_t alignment) noexcept { + alignment = alignment < sizeof(void*) ? sizeof(void*) : alignment; + if (size > std::numeric_limits::max() - (alignment - 1)) { + return nullptr; + } + const std::size_t rounded = + size == 0 ? alignment : (size + alignment - 1) / alignment * alignment; + return take(rounded, alignment); +} + +/** Counts a global allocation once, even when its storage comes from the C library. */ +void* allocate(std::size_t size, std::size_t alignment) noexcept { + if (on_counted_thread() && counting) { + ++operator_new_calls; + } + return allocate_storage(size, alignment); +} + +void* allocate_or_throw(std::size_t size, std::size_t alignment) { + void* pointer = allocate(size, alignment); + if (pointer == nullptr) { + boost::throw_exception(std::bad_alloc()); + } + return pointer; +} + +/** A standard allocator whose rebinds share a counter, bypassing the global hooks. */ +template +struct counted { + using value_type = T; + std::size_t* given; + + explicit counted(std::size_t* counter) : given(counter) {} + + // Allocator rebind conversions must be implicit (Allocator requirements). + template + // NOLINTNEXTLINE(misc-explicit-constructor) + counted(const counted& other) : given(other.given) {} + + T* allocate(std::size_t n) { + if (n > std::numeric_limits::max() / sizeof(T)) { + boost::throw_exception(std::bad_alloc()); + } + auto* pointer = static_cast(allocate_storage(n * sizeof(T), alignof(T))); + if (pointer == nullptr) { + boost::throw_exception(std::bad_alloc()); + } + ++*given; + return pointer; + } + + void deallocate(T* pointer, std::size_t /*n*/) noexcept { release(pointer); } + + template + bool operator==(const counted& other) const noexcept { + return given == other.given; + } +}; + +/** Counts only the tested scope, including object destruction; reports are outside it. */ +class allocation_window { +public: + allocation_window() { + operator_new_calls = 0; + c_allocations = 0; + aligned_allocations = 0; + runtime_allocations = 0; + counting = true; + } + + ~allocation_window() { counting = false; } + + allocation_window(const allocation_window&) = delete; + allocation_window& operator=(const allocation_window&) = delete; +}; + +/** Marks only Asyncify's allocation of unwind data; returns whether the variant uses it. */ +bool mark_the_runtime_s_allocations() { +#ifdef __EMSCRIPTEN__ + // clang-format off + const int variant = EM_ASM_INT({ + if (typeof Asyncify !== 'object') { + return -1; + } + if (typeof Asyncify.allocateData !== 'function') { + return typeof Asyncify.isAsyncExport === 'function' ? 0 : -1; + } + const flag = $0; + const allocate = Asyncify.allocateData; + Asyncify.allocateData = function(...values) { + const previous = HEAPU8[flag]; + HEAPU8[flag] = 1; + try { + return allocate.apply(this, values); + } finally { + HEAPU8[flag] = previous; + } + }; + return 1; + }, &inside_runtime); + // clang-format on + BOOST_TEST_GE(variant, 0); + return variant == 1; +#else + return false; +#endif +} + +void report(const char* name, std::size_t given = 0) { + std::printf("%s: given=%zu new=%zu c=%zu aligned=%zu runtime=%zu\n", name, given, + operator_new_calls, c_allocations, aligned_allocations, runtime_allocations); +} + +#ifdef __EMSCRIPTEN__ +/** A host-storage resource using the same uncounted backing as counted. */ +class counted_resource final : public std::pmr::memory_resource { +public: + explicit counted_resource(std::size_t& allocations) : allocations_(allocations) {} + +private: + void* do_allocate(std::size_t bytes, std::size_t alignment) override { + void* result = allocate_storage(bytes, alignment); + if (result == nullptr) { + boost::throw_exception(std::bad_alloc()); + } + ++allocations_; + return result; + } + + void do_deallocate(void* pointer, std::size_t /*bytes*/, std::size_t /*alignment*/) override { + release(pointer); + } + + [[nodiscard]] bool do_is_equal(const std::pmr::memory_resource& other) const noexcept override { + return this == &other; + } + + std::size_t& allocations_; +}; + +void tls_host_storage_uses_the_resource() { + namespace ssl = webcpp::asio::ssl; + // The request object owns its input independently of the context's recorded copy. + // Construct it before measuring the copy into the context's supplied resource. + const ssl::host_name_verification verification( + "a-long-host-name-that-exceeds-small-string-storage.example.com"); + std::size_t given = 0; + counted_resource resource(given); + bool recorded = false; + { + const allocation_window window; + ssl::context context(ssl::context::tlsv12_client, &resource); + boost::system::error_code ec; + context.set_verify_callback(verification, ec); + recorded = !ec && context.verification_host() == + "a-long-host-name-that-exceeds-small-string-storage.example.com"; + } + report("TLS host allocator", given); + BOOST_TEST(recorded); + BOOST_TEST_EQ(given, 1U); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_EQ(c_allocations, 0U); + BOOST_TEST_EQ(aligned_allocations, 0U); +} + +/** Long resolver inputs belong to the allocator bound before initiation. */ +void resolver_inputs_use_the_associated_allocator() { + using resolver = webcpp::asio::ip::tcp::resolver; + std::size_t given = 0; + std::size_t completions = 0; + bool correct = false; + webcpp::asio::io_context io(std::allocator_arg, counted(&given)); + resolver names(io); + { + const allocation_window window; + names.async_resolve( + "a-host-name-longer-than-small-string-storage.example.com", + "an-unsupported-service-longer-than-small-string-storage", + boost::asio::bind_allocator( + counted(&given), + [&](boost::system::error_code ec, const resolver::results_type& results) { + correct = ec == boost::asio::error::service_not_found && results.empty(); + ++completions; + })); + names.cancel(); + io.run(); // lint-run: observes the real posted resolver completion + } + report("resolver invalid inputs", given); + BOOST_TEST(correct); + BOOST_TEST_EQ(completions, 1U); + BOOST_TEST_GT(given, 0U); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_EQ(c_allocations, 0U); + BOOST_TEST_EQ(aligned_allocations, 0U); + + std::string host = "a-host-name-longer-than-small-string-storage.example.com"; + std::string service = "00000000000000000000000000000000000443"; + const auto before = given; + auto deferred = [&] { + const allocation_window window; + return names.async_resolve( + host, service, + boost::asio::bind_allocator(counted(&given), boost::asio::deferred)); + }(); + report("resolver deferred captures", given - before); + // No result entry exists yet: Boost's result storage would allocate globally. + BOOST_TEST_GT(given, before); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_EQ(c_allocations, 0U); + BOOST_TEST_EQ(aligned_allocations, 0U); + host.assign("changed"); + service.assign("invalid"); + correct = false; + std::move(deferred)([&](boost::system::error_code ec, const resolver::results_type& results) { + correct = !ec && results.size() == 1 && + results.begin()->host_name() == + "a-host-name-longer-than-small-string-storage.example.com" && + results.begin()->service_name() == "00000000000000000000000000000000000443" && + results.begin()->endpoint().port() == 443; + ++completions; + }); + names.cancel(); + BOOST_TEST_EQ(completions, 1U); + io.restart(); + io.run(); // lint-run: a deferred resolution keeps its copied inputs until initiation + BOOST_TEST(correct); + BOOST_TEST_EQ(completions, 2U); +} + +/** Each delivered event posts through its associated allocator, never runs inline. */ +class counted_registration final : public webcpp::asio::browser::registration { +public: + counted_registration(webcpp::asio::io_context& io, std::size_t* given, std::size_t* received) + : io_(io), given_(given), received_(received) {} + + bool deliver(const emscripten::val& /*event*/) override { + boost::asio::post( + io_, boost::asio::bind_allocator(counted(given_), [this] { ++*received_; })); + return false; + } + + void shutdown() noexcept override {} + +private: + webcpp::asio::io_context& io_; + std::size_t* given_; + std::size_t* received_; +}; +#endif + +// tag::supplied-allocator[] +void the_user_s_allocator_takes_everything() { + std::size_t given = 0; + std::size_t posted = 0; + std::size_t timed = 0; + bool timer_succeeded = false; +#ifdef __EMSCRIPTEN__ + std::size_t received = 0; + std::size_t promised = 0; + std::size_t events = 0; + std::size_t connected = 0; + bool values_correct = true; +#endif + { + const allocation_window window; + webcpp::asio::io_context io(std::allocator_arg, counted(&given)); + webcpp::asio::steady_timer timer(io, std::chrono::milliseconds(5)); + timer.async_wait( + boost::asio::bind_allocator(counted(&given), [&](boost::system::error_code ec) { + ++timed; + timer_succeeded = !ec; + })); + for (std::size_t i = 0; i < 10; ++i) { + boost::asio::post( + io, boost::asio::bind_allocator(counted(&given), [&posted] { ++posted; })); + } +#ifdef __EMSCRIPTEN__ + webcpp::asio::ip::tcp::socket socket(io); + socket.async_connect( + {boost::asio::ip::address_v4::loopback(), 80}, + boost::asio::bind_allocator(counted(&given), [&](boost::system::error_code ec) { + ++connected; + values_correct = + values_correct && ec == boost::asio::error::operation_not_supported; + })); + counted_registration listener(io, &given, &received); + auto& bridge = boost::asio::use_service(io); + const std::uint64_t key = bridge.add(listener); + const emscripten::val deliver = bridge.function(key); + deliver(1); + deliver(2); + const auto target = emscripten::val::global("EventTarget").new_(); + webcpp::asio::browser::async_wait_event( + io.get_executor(), target, "message", + boost::asio::bind_allocator(counted(&given), + [&](boost::system::error_code ec, const emscripten::val&) { + values_correct = values_correct && !ec; + ++events; + })); + target.call("dispatchEvent", + emscripten::val::global("Event").new_(emscripten::val("message"))); + for (const bool rejected : {false, true}) { + auto promise = emscripten::val::global("Promise").call( + rejected ? "reject" : "resolve", 42); + webcpp::asio::browser::async_await( + io.get_executor(), promise, + boost::asio::bind_allocator( + counted(&given), + [&, rejected](boost::system::error_code ec, const emscripten::val& value) { + ++promised; + values_correct = + values_correct && value.as() == 42 && + (rejected ? ec == webcpp::asio::browser::error::promise_rejected : !ec); + })); + } +#endif + io.run(); // lint-run: the test's event loop +#ifdef __EMSCRIPTEN__ + bridge.remove(key); +#endif + } + report("supplied allocator", given); + BOOST_TEST_EQ(posted, 10U); + BOOST_TEST_EQ(timed, 1U); + BOOST_TEST(timer_succeeded); +#ifdef __EMSCRIPTEN__ + BOOST_TEST_EQ(received, 2U); + BOOST_TEST_EQ(promised, 2U); + BOOST_TEST_EQ(events, 1U); + BOOST_TEST_EQ(connected, 1U); + BOOST_TEST(values_correct); +#endif + BOOST_TEST_GT(given, 0U); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_EQ(c_allocations, 0U); + BOOST_TEST_EQ(aligned_allocations, 0U); +} + +// end::supplied-allocator[] + +/** Real platform operations prove runtime attribution independently of the Asio context. */ +void the_counters_separate_runtime_allocations(bool asyncify) { +#if defined(__EMSCRIPTEN__) && defined(WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS) + { + const allocation_window window; + emscripten_sleep(0); + } + report("explicit suspension"); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_EQ(c_allocations + aligned_allocations, 0U); + BOOST_TEST_EQ(inside_runtime, 0U); + if (asyncify) { + BOOST_TEST_GT(runtime_allocations, 0U); + } else { + BOOST_TEST_EQ(runtime_allocations, 0U); + } +#elif defined(__wasi__) && defined(WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS) + (void)asyncify; + std::array descriptors{}; + int status = 0; + { + const allocation_window window; + status = ::pipe(descriptors.data()); + } + report("WASI libc pipe storage"); + BOOST_TEST_EQ(status, 0); + BOOST_TEST_GT(runtime_allocations, 0U); + BOOST_TEST_EQ(operator_new_calls + c_allocations + aligned_allocations, 0U); + BOOST_TEST_EQ(inside_runtime, 0U); + if (status == 0) { + ssize_t written = 0; + { + const allocation_window window; + written = ::write(descriptors[1], "x", 1); + } + report("WASI libc pipe message"); + BOOST_TEST_EQ(written, 1); + BOOST_TEST_GT(runtime_allocations, 0U); + BOOST_TEST_EQ(operator_new_calls + c_allocations + aligned_allocations, 0U); + BOOST_TEST_EQ(inside_runtime, 0U); + char received = 0; + BOOST_TEST_EQ(::read(descriptors[0], &received, 1), 1); + BOOST_TEST_EQ(received, 'x'); + ::close(descriptors[0]); + ::close(descriptors[1]); + } +#else + (void)asyncify; +#endif +} + +void the_counters_see_an_unbound_handler() { +#ifdef WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS + std::size_t given = 0; + std::size_t ran = 0; + webcpp::asio::io_context io(std::allocator_arg, counted(&given)); + { + const allocation_window window; + boost::asio::post(io, [&ran] { ++ran; }); + } + report("unbound handler"); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_GT(c_allocations + aligned_allocations, 0U); + BOOST_TEST_EQ(runtime_allocations, 0U); + io.run(); // lint-run: the control's event loop, outside its allocation window + BOOST_TEST_EQ(ran, 1U); +#else + std::puts("unbound handler: C allocation counting unavailable on this platform/build"); +#endif +} + +/** Tests one direct global allocation call, which cannot be elided like a new-expression. */ +void check_new_form(auto make, bool array, bool aligned) { + void* pointer = nullptr; + { + const allocation_window window; + pointer = make(); + } + BOOST_TEST(pointer != nullptr); + BOOST_TEST_EQ(operator_new_calls, 1U); + BOOST_TEST_EQ(c_allocations + aligned_allocations, 0U); + if (aligned) { + BOOST_TEST_EQ(reinterpret_cast(pointer) % 64, 0U); + if (array) { + ::operator delete[](pointer, std::align_val_t{64}); + } else { + ::operator delete(pointer, std::align_val_t{64}); + } + } else if (array) { + ::operator delete[](pointer); + } else { + ::operator delete(pointer); + } +} + +void the_counters_see_every_new_form() { + check_new_form([] { return ::operator new(37); }, false, false); + check_new_form([] { return ::operator new[](37); }, true, false); + check_new_form([] { return ::operator new(37, std::nothrow); }, false, false); + check_new_form([] { return ::operator new[](37, std::nothrow); }, true, false); + check_new_form([] { return ::operator new(37, std::align_val_t{64}); }, false, true); + check_new_form([] { return ::operator new[](37, std::align_val_t{64}); }, true, true); + check_new_form([] { return ::operator new(37, std::align_val_t{64}, std::nothrow); }, false, + true); + check_new_form([] { return ::operator new[](37, std::align_val_t{64}, std::nothrow); }, true, + true); + std::puts("global new controls: all eight forms counted once"); +} + +void the_counters_see_c_and_aligned_allocations() { +#ifdef WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS + void* volatile pointer = nullptr; + void* volatile resized = nullptr; + { + const allocation_window window; + pointer = std::malloc(48); + resized = std::realloc(pointer, 96); + } + BOOST_TEST(resized != nullptr); + std::free(resized != nullptr ? resized : pointer); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_GE(c_allocations, 2U); + { + const allocation_window window; + pointer = std::calloc(2, 48); + } + BOOST_TEST(pointer != nullptr); + std::free(pointer); + BOOST_TEST_GT(c_allocations, 0U); + { + const allocation_window window; + pointer = std::aligned_alloc(64, 128); + } + BOOST_TEST(pointer != nullptr); + std::free(pointer); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_GT(c_allocations + aligned_allocations, 0U); + void* aligned_pointer = nullptr; + int status = 0; + { + const allocation_window window; + status = posix_memalign(&aligned_pointer, 64, 128); + } + BOOST_TEST_EQ(status, 0); + BOOST_TEST(aligned_pointer != nullptr); + BOOST_TEST_EQ(reinterpret_cast(aligned_pointer) % 64, 0U); + std::free(aligned_pointer); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_GT(c_allocations + aligned_allocations, 0U); +#if defined(__GLIBC__) || defined(__EMSCRIPTEN__) + { + const allocation_window window; + pointer = memalign(64, 128); + } + BOOST_TEST(pointer != nullptr); + BOOST_TEST_EQ(reinterpret_cast(pointer) % 64, 0U); + std::free(pointer); + BOOST_TEST_EQ(operator_new_calls, 0U); + BOOST_TEST_GT(aligned_allocations, 0U); +#endif + std::puts("C allocation controls: ordinary and platform aligned entry points observed"); +#else + std::puts("C allocation controls: unavailable on this platform/build"); +#endif +} + +} // namespace + +// The standard declares implementation-reserved parameter names; these are program replacements. +// NOLINTBEGIN(readability-inconsistent-declaration-parameter-name) +void* operator new(std::size_t size) { + return allocate_or_throw(size, alignof(std::max_align_t)); +} + +void* operator new(std::size_t size, const std::nothrow_t& /*tag*/) noexcept { + return allocate(size, alignof(std::max_align_t)); +} + +void* operator new(std::size_t size, std::align_val_t alignment) { + return allocate_or_throw(size, static_cast(alignment)); +} + +void* operator new(std::size_t size, std::align_val_t alignment, + const std::nothrow_t& /*tag*/) noexcept { + return allocate(size, static_cast(alignment)); +} + +void operator delete(void* pointer) noexcept { + release(pointer); +} + +void operator delete(void* pointer, std::size_t /*size*/) noexcept { + release(pointer); +} + +void operator delete(void* pointer, std::align_val_t /*alignment*/) noexcept { + release(pointer); +} + +void operator delete(void* pointer, std::size_t /*size*/, std::align_val_t /*alignment*/) noexcept { + release(pointer); +} + +void operator delete(void* pointer, const std::nothrow_t& /*tag*/) noexcept { + release(pointer); +} + +void operator delete(void* pointer, std::align_val_t /*alignment*/, + const std::nothrow_t& /*tag*/) noexcept { + release(pointer); +} + +void* operator new[](std::size_t size) { + return allocate_or_throw(size, alignof(std::max_align_t)); +} + +void* operator new[](std::size_t size, const std::nothrow_t& /*tag*/) noexcept { + return allocate(size, alignof(std::max_align_t)); +} + +void* operator new[](std::size_t size, std::align_val_t alignment) { + return allocate_or_throw(size, static_cast(alignment)); +} + +void* operator new[](std::size_t size, std::align_val_t alignment, + const std::nothrow_t& /*tag*/) noexcept { + return allocate(size, static_cast(alignment)); +} + +void operator delete[](void* pointer) noexcept { + release(pointer); +} + +void operator delete[](void* pointer, std::size_t /*size*/) noexcept { + release(pointer); +} + +void operator delete[](void* pointer, std::align_val_t /*alignment*/) noexcept { + release(pointer); +} + +void operator delete[](void* pointer, std::size_t /*size*/, + std::align_val_t /*alignment*/) noexcept { + release(pointer); +} + +void operator delete[](void* pointer, const std::nothrow_t& /*tag*/) noexcept { + release(pointer); +} + +void operator delete[](void* pointer, std::align_val_t /*alignment*/, + const std::nothrow_t& /*tag*/) noexcept { + release(pointer); +} + +// NOLINTEND(readability-inconsistent-declaration-parameter-name) + +int main() { + count_this_thread(); +#if defined(WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS) && defined(__APPLE__) && !defined(__EMSCRIPTEN__) + auto* previous_logger = malloc_logger; + malloc_logger = &count_c_allocation; +#endif +#ifndef __EMSCRIPTEN__ + // Darwin's first access to Asio's thread-call-stack TLS asks dyld for storage. Initialize + // that thread runtime explicitly; the measured context and every operation are still new. + { + boost::asio::io_context startup; + BOOST_TEST(!startup.get_executor().running_in_this_thread()); + } +#endif + const bool asyncify = mark_the_runtime_s_allocations(); + the_counters_see_every_new_form(); + the_counters_see_c_and_aligned_allocations(); + the_counters_separate_runtime_allocations(asyncify); + the_user_s_allocator_takes_everything(); +#ifdef __EMSCRIPTEN__ + tls_host_storage_uses_the_resource(); + resolver_inputs_use_the_associated_allocator(); +#endif + the_counters_see_an_unbound_handler(); +#if defined(WEBCPP_TEST_ASIO_COUNTS_C_ALLOCATIONS) && defined(__APPLE__) && !defined(__EMSCRIPTEN__) + malloc_logger = previous_logger; +#endif + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_stack_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_stack_test.cpp index f8d2a20..90686ac 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_stack_test.cpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_stack_test.cpp @@ -7,20 +7,22 @@ // Asyncify's stack (doc: #asio-building-asyncify-stack): every suspension of the run family, the // reactor's wait and the yield, under each member that makes one, is measured as the bytes its // unwind wrote into the stack Asyncify saves it in, and leaves at least half of that stack to -// the program's own frames above the call. The measurement is exact and the same on every run: -// it is read from Asyncify's own data when the unwind stops, never inferred from whether a -// smaller stack would trap. Each path prints its bytes. +// the program's own frames above the call. It is read from Asyncify's own data when the unwind +// stops, never inferred from whether a smaller stack would trap. Reactor cases must reach a +// blocking poll, not just suspend in the initial nonblocking poll. Each path prints its bytes. #include -#include + +#include "asyncify_watch.hpp" #include #include #include +#include +#include #include #include -#include #include #include @@ -28,85 +30,44 @@ #include #include -EM_JS_DEPS(webcpp_test_asio_asyncify_stack, "$Asyncify"); - -// Watches every unwind from here on: when one stops, the bytes it wrote are its data's position -// less the stack's start, which is its limit less Asyncify's stack size. It reads Emscripten's -// private runtime, which may change: a reading that finds no unwind, or no byte written, fails. -// clang-format off -EM_JS(void, test_watch_unwinds, (), { - const watch = {deepest : 0, unwinds : 0}; - globalThis.webcppAsyncifyWatch = watch; - const stop = Asyncify.maybeStopUnwind; - Asyncify.maybeStopUnwind = function() { - const data = Asyncify.currData; - if (data && Asyncify.state === Asyncify.State.Unwinding && !Asyncify.exportCallStack.length) { - const start = HEAPU32[(data + 4) >> 2] - Asyncify.StackSize; - watch.deepest = Math.max(watch.deepest, HEAPU32[data >> 2] - start); - ++watch.unwinds; - } - return stop.call(Asyncify); - }; -}); -// clang-format on - namespace { using namespace std::chrono_literals; +using webcpp::test::measure; -/** The unwinds seen since the last reset, and the stack Asyncify saves each in. */ -struct unwinds { - static void reset() { +/** A context held by work that only a JavaScript macrotask can release, after run waits. */ +struct reactor_wait { + webcpp::asio::io_context io; + boost::asio::executor_work_guard guard{ + io.get_executor()}; + bool fired = false; + int timeout; + + reactor_wait() + : timeout(emscripten_set_timeout( + [](void* address) { + auto* state = static_cast(address); + boost::asio::post(state->io, [state] { + state->fired = true; + state->guard.reset(); + }); + }, + 0, this)) { + // Delay entry past the old timer's expiry to pin the measurement-path regression. EM_ASM({ - globalThis.webcppAsyncifyWatch.deepest = 0; - globalThis.webcppAsyncifyWatch.unwinds = 0; + const until = performance.now() + 25; + while (performance.now() < until) { + } }); } - /** The bytes the deepest unwind since the last reset wrote. */ - static std::size_t deepest() { - return static_cast( - EM_ASM_INT({ return globalThis.webcppAsyncifyWatch.deepest; })); - } - - static std::size_t count() { - return static_cast( - EM_ASM_INT({ return globalThis.webcppAsyncifyWatch.unwinds; })); - } - - /** ASYNCIFY_STACK_SIZE, as the program was linked with it. */ - static std::size_t stack_size() { - return static_cast(EM_ASM_INT({ return Asyncify.StackSize; })); - } -}; - -/** - Measures the unwinds of one path, which call makes on a fresh io_context, and checks that the - deepest leaves half of the stack. - - @param path What call does, as printed. - @param call Runs the io_context through the path. -*/ -template -void measure(std::string_view path, Call call) { - unwinds::reset(); - call(); - const std::size_t deepest = unwinds::deepest(); - std::cout << path << ": " << deepest << " bytes of " << unwinds::stack_size() << '\n'; - BOOST_TEST_GE(unwinds::count(), 1U); - BOOST_TEST_GT(deepest, 0U); - BOOST_TEST_LE(2 * deepest, unwinds::stack_size()); -} - -/** A context whose one handler is a timer's, so that the run family suspends in its wait. */ -struct timer_wait { - webcpp::asio::io_context io; - webcpp::asio::steady_timer timer{io, 1ms}; - bool fired = false; + // Cancel a pending callback if a timed run returned before the macrotask could execute. + ~reactor_wait() { emscripten_clear_timeout(timeout); } - timer_wait() { - timer.async_wait([this](boost::system::error_code) { fired = true; }); - } + reactor_wait(const reactor_wait&) = delete; + reactor_wait& operator=(const reactor_wait&) = delete; + reactor_wait(reactor_wait&&) = delete; + reactor_wait& operator=(reactor_wait&&) = delete; }; /** A context with two handlers ready and a limit of one, so that the run family yields once. */ @@ -122,49 +83,63 @@ struct yield_once { void every_suspension_leaves_half_the_stack() { measure("run, the reactor's wait", [] { - timer_wait state; + reactor_wait state; state.io.run(); // lint-run: the path measured BOOST_TEST(state.fired); }); - measure("run, the yield", [] { - yield_once state; - state.io.run(); // lint-run: the path measured - BOOST_TEST_EQ(state.ran, 2U); - }); + measure( + "run, the yield", + [] { + yield_once state; + state.io.run(); // lint-run: the path measured + BOOST_TEST_EQ(state.ran, 2U); + }, + false); measure("run_one, the reactor's wait", [] { - timer_wait state; + reactor_wait state; state.io.run_one(); // lint-run: the path measured BOOST_TEST(state.fired); }); measure("run_for, the reactor's wait", [] { - timer_wait state; + reactor_wait state; state.io.run_for(10s); // lint-run: the path measured BOOST_TEST(state.fired); }); - measure("run_for, the yield", [] { - yield_once state; - state.io.run_for(10s); // lint-run: the path measured - BOOST_TEST_EQ(state.ran, 2U); - }); + measure( + "run_for, the yield", + [] { + yield_once state; + state.io.run_for(10s); // lint-run: the path measured + BOOST_TEST_EQ(state.ran, 2U); + }, + false); measure("run_until, the reactor's wait", [] { - timer_wait state; + reactor_wait state; state.io.run_until(std::chrono::steady_clock::now() + 10s); BOOST_TEST(state.fired); }); + measure( + "run_until, the yield", + [] { + yield_once state; + state.io.run_until(std::chrono::steady_clock::now() + 10s); + BOOST_TEST_EQ(state.ran, 2U); + }, + false); measure("run_one_for, the reactor's wait", [] { - timer_wait state; + reactor_wait state; state.io.run_one_for(10s); BOOST_TEST(state.fired); }); measure("run_one_until, the reactor's wait", [] { - timer_wait state; + reactor_wait state; state.io.run_one_until(std::chrono::steady_clock::now() + 10s); BOOST_TEST(state.fired); }); #ifndef WEBCPP_ASIO_NO_EXCEPTIONS // JavaScript-based exceptions call what a try encloses through an import of their own. measure("run inside a try, the reactor's wait", [] { - timer_wait state; + reactor_wait state; try { state.io.run(); // lint-run: the path measured } catch (const std::runtime_error&) { @@ -173,7 +148,7 @@ void every_suspension_leaves_half_the_stack() { BOOST_TEST(state.fired); }); measure("run inside a catch block, the reactor's wait", [] { - timer_wait state; + reactor_wait state; try { throw std::runtime_error("before run"); } catch (const std::runtime_error&) { diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_watch.hpp b/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_watch.hpp new file mode 100644 index 0000000..192d246 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/asyncify_watch.hpp @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_TEST_ASIO_ASYNCIFY_WATCH_HPP +#define WEBCPP_TEST_ASIO_ASYNCIFY_WATCH_HPP + +#include +#include +#include + +#include +#include +#include + +EM_JS_DEPS(webcpp_test_asio_asyncify_stack, "$Asyncify,$doPollAsync"); + +// Watches every unwind from here on: when one stops, the bytes it wrote are its data's position +// less the stack's start, which is its limit less Asyncify's stack size. It reads Emscripten's +// private runtime, which may change: a reading that finds no unwind, or no byte written, fails. +// Count blocking polls too: an expired C++ timer can finish in poll_one, measuring only the +// initial nonblocking poll's shorter path while still reporting an unwind. +// clang-format off +EM_JS(void, test_watch_unwinds, (), { + const watch = {deepest : 0, unwinds : 0, waits : 0}; + globalThis.webcppAsyncifyWatch = watch; + const poll = doPollAsync; + doPollAsync = function(fds, nfds, timeout) { + if (timeout !== 0) { + ++watch.waits; + } + return poll(fds, nfds, timeout); + }; + const stop = Asyncify.maybeStopUnwind; + Asyncify.maybeStopUnwind = function() { + const data = Asyncify.currData; + if (data && Asyncify.state === Asyncify.State.Unwinding && !Asyncify.exportCallStack.length) { + const start = HEAPU32[(data + 4) >> 2] - Asyncify.StackSize; + watch.deepest = Math.max(watch.deepest, HEAPU32[data >> 2] - start); + ++watch.unwinds; + } + return stop.call(Asyncify); + }; +}); +// clang-format on + +namespace webcpp::test { + +/** The unwinds seen since the last reset, and the stack Asyncify saves each in. */ +struct unwinds { + static void reset() { + EM_ASM({ + globalThis.webcppAsyncifyWatch.deepest = 0; + globalThis.webcppAsyncifyWatch.unwinds = 0; + globalThis.webcppAsyncifyWatch.waits = 0; + }); + } + + /** The bytes the deepest unwind since the last reset wrote. */ + static std::size_t deepest() { + return static_cast( + EM_ASM_INT({ return globalThis.webcppAsyncifyWatch.deepest; })); + } + + static std::size_t count() { + return static_cast( + EM_ASM_INT({ return globalThis.webcppAsyncifyWatch.unwinds; })); + } + + /** Polls that can wait, excluding the initial nonblocking reactor poll. */ + static std::size_t waits() { + return static_cast( + EM_ASM_INT({ return globalThis.webcppAsyncifyWatch.waits; })); + } + + /** ASYNCIFY_STACK_SIZE, as the program was linked with it. */ + static std::size_t stack_size() { + return static_cast(EM_ASM_INT({ return Asyncify.StackSize; })); + } +}; + +/** + Measures the unwinds of one path, which call makes on a fresh io_context, and checks that the + deepest leaves half of the stack. + + @param path What call does, as printed. + @param call Runs the io_context through the path. + @param waits Whether the path must reach a blocking reactor poll. +*/ +template +void measure(std::string_view path, Call call, bool waits = true) { + unwinds::reset(); + call(); + const std::size_t deepest = unwinds::deepest(); + std::cout << path << ": " << deepest << " bytes of " << unwinds::stack_size() << '\n'; + if (waits) { + BOOST_TEST_GE(unwinds::waits(), 1U); + } + BOOST_TEST_GE(unwinds::count(), 1U); + BOOST_TEST_GT(deepest, 0U); + BOOST_TEST_LE(2 * deepest, unwinds::stack_size()); +} + +} // namespace webcpp::test + +#endif // WEBCPP_TEST_ASIO_ASYNCIFY_WATCH_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/Jamfile new file mode 100644 index 0000000..27fbc81 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/Jamfile @@ -0,0 +1,88 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# Each driver receives the JSPI artifact beside its manifest. Node and +# headless Chrome load both actual variants. +# The parent test project links asio. The driver only consumes finished +# programs; put that dependency on page_program instead. +project : requirements -/webcpp/asio//asio ; + +import webcpp ; + +webcpp.targets emscripten ; +webcpp.original node ; + +# tag::page-variants[] +webcpp.variants page_program : page_program.cpp : /webcpp/asio//asio ; +# end::page-variants[] +webcpp.drive loader_node : .//page_program + : page_program.variants.json 60 + : loader_test.mjs ; + +webcpp.variants idle_program : idle_program.cpp : /webcpp/asio//asio ; +webcpp.variants render_program : render_program.cpp : /webcpp/asio//asio ; +webcpp.variants render_unlimited_program : render_unlimited_program.cpp + : /webcpp/asio//asio ; + +# Chrome startup and the three-second idle observation fit within 120 s. +webcpp.drive browser_idle : .//idle_program + : idle_program.variants.json 120 + : run.mjs : --mode idle ; +webcpp.drive browser_render : .//render_program + : render_program.variants.json + render_unlimited_program.variants.json 120 + : run.mjs : --mode render ; +webcpp.drive browser_loader : .//page_program + : page_program.variants.json 120 + : run.mjs : --mode loader ; +webcpp.drive browser_startup : .//page_program + : page_program.variants.json 120 + : startup_test.mjs ; + +webcpp.lane browser : loader_node browser_idle browser_render browser_loader + browser_startup : emscripten ; + +# The threaded profile retains the selected suspension mechanism. A pool starts +# browser workers before a handler needs them. Applications choose its size. +webcpp.drive browser_workers : worker_program.cpp + : multi 60 /webcpp/asio//asio + /webcpp//node-test -sPTHREAD_POOL_SIZE=1 + : run.mjs : --mode workers ; + +# Assertions normally diagnose invalid runner affinity. This executable observes +# the same guard's release-build result without terminating the test process. +webcpp.drive browser_worker_affinity : worker_program.cpp + : multi 60 /webcpp/asio//asio + /webcpp//node-test -sPTHREAD_POOL_SIZE=1 + BOOST_DISABLE_ASSERTS WEBCPP_TEST_WORKER_AFFINITY + : run.mjs : --mode workers ; + +webcpp.drive browser_worker_main : main_profile_program.cpp + : multi 60 /webcpp/asio//asio + /webcpp//node-test + : run.mjs : --mode workers ; + +webcpp.drive browser_worker_cobalt : ../cobalt_thread_test.cpp + : multi 60 /webcpp/asio//cobalt + /webcpp//node-test -sPTHREAD_POOL_SIZE=1 + : run.mjs : --mode workers ; + +webcpp.lane browser-workers : browser_workers browser_worker_affinity + browser_worker_main browser_worker_cobalt : emscripten ; + +# This dependency-only probe is compiled for header/tooling coverage. Run its +# JSPI and Asyncify artifacts explicitly to characterize pthread return values. +webcpp.compile browser_pthread_return_probe : probes/pthread_return.cpp + : multi : emscripten ; + +# A test-only trampoline catches the deliberate C++ exception before it crosses +# the SDK's callback boundary. Its queue and notification remain the real SDK's. +webcpp.drive browser_worker_move_failure : move_failure_program.cpp + : multi on 60 + /webcpp/asio//asio /webcpp//node-test + -Wl,--wrap=emscripten_proxy_async + : run.mjs : --mode workers ; +webcpp.lane browser-worker-exceptions : browser_worker_move_failure : emscripten ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/chrome_startup.mjs b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/chrome_startup.mjs new file mode 100644 index 0000000..55195c2 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/chrome_startup.mjs @@ -0,0 +1,96 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Browser startup has its own deadline inside the driver's overall bound. +import assert from 'node:assert/strict' +import {existsSync, readFileSync, readdirSync} from 'node:fs' +import {homedir} from 'node:os' +import {join} from 'node:path' +import {setTimeout as delay} from 'node:timers/promises' + +export const findChrome = () => { + if (process.env.CHROME) return process.env.CHROME + assert.equal(process.platform, 'darwin', 'set CHROME to the Chrome executable') + const cache = join(homedir(), 'Library/Caches/ms-playwright') + const shells = existsSync(cache) ? readdirSync(cache) + .filter(name => /^chromium_headless_shell-\d+$/.test(name)) + .sort((a, b) => Number(b.split('-').at(-1)) - Number(a.split('-').at(-1))) : [] + for (const shell of shells) { + for (const arch of ['arm64', 'x64']) { + const path = join(cache, shell, `chrome-headless-shell-mac-${arch}`, 'chrome-headless-shell') + if (existsSync(path)) return path + } + } + throw new Error('no cached headless Chrome found; set CHROME') +} + +export const waitForChrome = async (chrome, profile, {timeout = 30000, requestTimeout = 1000} = {}) => { + const stopped = new AbortController() + let failure + let said = '' + let stage = 'waiting for DevToolsActivePort (file has not appeared)' + let lastResponse = '(none)' + const onError = error => { + failure = `Chrome failed to start: ${error.message}` + stopped.abort() + } + const onExit = (code, signal) => { + failure = `Chrome exited during startup (code ${code}, signal ${signal})` + stopped.abort() + } + const onData = data => { said = (said + data).slice(-8000) } + chrome.on('error', onError) + chrome.on('exit', onExit) + chrome.stderr?.on('data', onData) + if (chrome.exitCode !== null || chrome.signalCode !== null) { + onExit(chrome.exitCode, chrome.signalCode) + } + const deadline = performance.now() + timeout + try { + while (!failure && performance.now() < deadline) { + let port = '' + try { + port = readFileSync(join(profile, 'DevToolsActivePort'), 'utf8').split('\n')[0] + stage = `waiting for valid DevToolsActivePort (read ${JSON.stringify(port.slice(0, 128))})` + } catch (error) { + if (error.code !== 'ENOENT') throw error + } + if (/^\d+$/.test(port) && Number(port) > 0 && Number(port) <= 65535) { + const devtools = `http://127.0.0.1:${port}` + const endpoint = `${devtools}/json/version` + try { + const remaining = Math.max(1, Math.ceil(deadline - performance.now())) + const signal = AbortSignal.any([stopped.signal, + AbortSignal.timeout(Math.min(requestTimeout, remaining))]) + const response = await fetch(endpoint, {signal}) + lastResponse = `HTTP ${response.status} ${response.statusText}` + if (!response.ok) throw new Error(`HTTP ${response.status} ${response.statusText}`) + const version = await response.json() + if (typeof version.Browser !== 'string' || !version.Browser) { + throw new Error('missing Browser in discovery response') + } + if (!failure) return {devtools, version} + } catch (error) { + const cause = error.cause?.code ? ` (${error.cause.code})` : '' + stage = `${endpoint}: ${error.name}: ${error.message}${cause}` + } + } + if (!failure && performance.now() < deadline) { + await delay(Math.min(50, deadline - performance.now()), undefined, + {signal: stopped.signal}).catch(error => { + if (error.name !== 'AbortError') throw error + }) + } + } + throw new Error(`${failure ?? `Chrome startup timed out after ${timeout} ms`}; ` + + `last stage: ${stage}; last discovery response: ${lastResponse}; ` + + `stderr: ${said || '(empty)'}`) + } finally { + chrome.off('error', onError) + chrome.off('exit', onExit) + chrome.stderr?.off('data', onData) + } +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/idle_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/idle_program.cpp new file mode 100644 index 0000000..bf24b0e --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/idle_program.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// An idle page must suspend without polling (specification section 9). +#include + +#include + +#include + +int main() { + webcpp::asio::io_context io; + auto const guard = boost::asio::make_work_guard(io); + std::puts("idle"); + io.run(); // lint-run: the page waits for work that the guard keeps outstanding + return 0; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/loader_test.mjs b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/loader_test.mjs new file mode 100644 index 0000000..7617081 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/loader_test.mjs @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Detects and selects a variant, then loads both real artifacts built by b2. +// Completion is signalled by the program's output, never inferred from a fixed delay. +import assert from 'node:assert/strict' +import {readFileSync} from 'node:fs' +import {createServer} from 'node:http' +import {once} from 'node:events' +import {dirname, join} from 'node:path' +import {pathToFileURL} from 'node:url' +import {load, pick, supportsJspi} from '../../include/webcpp/asio/webcpp-asio-loader.mjs' + +const program = process.argv.at(-1) +const manifestPath = join(dirname(program), 'page_program.variants.json') +const manifestUrl = pathToFileURL(manifestPath) +const fetchFile = async url => ({ok: true, status: 200, statusText: 'OK', + json: async () => JSON.parse(readFileSync(new URL(url), 'utf8'))}) + +assert.equal(supportsJspi({WebAssembly: {Suspending: function () {}}}), true) +assert.equal(supportsJspi({WebAssembly: {Suspending: true}}), false) +assert.equal(supportsJspi({WebAssembly: {}}), false) +assert.equal(supportsJspi({}), false) +const fixture = { + jspi: {script: './nested/modern.mjs'}, + asyncify: {script: '../fallback/compatible.mjs'} +} +assert.deepEqual(pick(fixture, true), {variant: 'jspi', script: './nested/modern.mjs'}) +assert.deepEqual(pick(fixture, false), {variant: 'asyncify', script: '../fallback/compatible.mjs'}) +assert.deepEqual(pick(fixture), supportsJspi() ? pick(fixture, true) : pick(fixture, false)) +for (const invalid of [null, {}, {jspi: {script: 7}}]) { + assert.throws(() => pick(invalid, true), /no jspi artifact/) +} +assert.throws(() => pick({jspi: fixture.jspi}, false), /no asyncify artifact/) + +// URL resolution, module options and the returned factory result are observable loader contracts. +const options = {noInitialRun: true} +const instance = {loaded: true} +let imported +let passed +const selected = await load('https://example.invalid/app/config/variants.json', { + jspi: false, + module: options, + fetch: async url => { + assert.equal(url, 'https://example.invalid/app/config/variants.json') + return {ok: true, json: async () => fixture} + }, + importModule: async url => { + imported = url + return {default: async argument => { passed = argument; return instance }} + } +}) +assert.equal(imported, 'https://example.invalid/app/fallback/compatible.mjs') +assert.equal(passed, options) +assert.deepEqual(selected, {variant: 'asyncify', module: instance}) +await assert.rejects(load(manifestUrl, { + fetch: async () => ({ok: false, status: 404, statusText: 'Not Found'}) +}), /404 Not Found/) +const failure = new Error('module import failed') +await assert.rejects(load(manifestUrl, { + jspi: true, fetch: fetchFile, importModule: async () => { throw failure } +}), error => error === failure) + +// A real HTTP redirect changes the base of the manifest's relative artifact paths. +const server = createServer((request, response) => { + if (request.url === '/latest/variants.json') { + response.writeHead(302, {Location: '/releases/v2/variants.json'}) + response.end() + } else { + response.writeHead(200, {'Content-Type': 'application/json'}) + response.end(JSON.stringify(fixture)) + } +}) +server.listen(0, '127.0.0.1') +await once(server, 'listening') +try { + const origin = `http://127.0.0.1:${server.address().port}` + await load(`${origin}/latest/variants.json`, { + jspi: true, + importModule: async url => { + assert.equal(url, `${origin}/releases/v2/nested/modern.mjs`) + return {default: async () => instance} + } + }) +} finally { + await new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve())) +} + +for (const jspi of [true, false]) { + const lines = [] + let completed + const completion = new Promise(resolve => { completed = resolve }) + const {variant, module} = await load(manifestUrl, { + jspi, + fetch: fetchFile, + module: {print: line => { lines.push(line); completed() }} + }) + assert.equal(variant, jspi ? 'jspi' : 'asyncify') + assert.equal(typeof module, 'object') + // The driver bounds a missing completion at 60 seconds and fails the test. + await completion + assert.deepEqual(lines, ['ran 3 handlers']) + console.log(`loader: ${variant}: ran 3 handlers`) +} +console.log('loader: ok') diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/main_profile_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/main_profile_program.cpp new file mode 100644 index 0000000..7952876 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/main_profile_program.cpp @@ -0,0 +1,41 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// A threaded build keeps the ordinary main-thread run and DOM-event contract. +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +struct state { + webcpp::asio::io_context io; + boost::asio::executor_work_guard work{ + io.get_executor()}; + int completed = 0; +}; +} // namespace + +extern "C" EMSCRIPTEN_KEEPALIVE void complete_main(state* pending) { + boost::asio::post(pending->io, [pending] { + BOOST_TEST(emscripten_is_main_browser_thread()); + ++pending->completed; + pending->work.reset(); + }); +} + +int main() { + state pending; + EM_ASM({ setTimeout(function() { _complete_main($0); }, 30); }, &pending); + BOOST_TEST_EQ(pending.io.run(), 1U); // lint-run: ordinary browser main entry stack + BOOST_TEST_EQ(pending.completed, 1); + std::puts("worker profile main complete"); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/move_failure_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/move_failure_program.cpp new file mode 100644 index 0000000..3b1ebc6 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/move_failure_program.cpp @@ -0,0 +1,135 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Catch the deliberately thrown handler move at the caller's SDK boundary, so +// the real browser queue can finish normally and allocation release is observable. +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace { +struct move_failure : std::exception { + bool* caught; + + explicit move_failure(bool* observed) : caught(observed) {} + + [[nodiscard]] const char* what() const noexcept override { return "deliberate handler move"; } +}; + +struct forwarded_call { + void (*function)(void*); + void* argument; +}; + +void catch_move_failure(void* argument) { + const std::unique_ptr pending(static_cast(argument)); + try { + pending->function(pending->argument); + } catch (const move_failure& failure) { + *failure.caught = true; + } +} + +class counting_resource final : public std::pmr::memory_resource { +public: + int live = 0; + +private: + void* do_allocate(std::size_t bytes, std::size_t alignment) override { + ++live; + return std::pmr::new_delete_resource()->allocate(bytes, alignment); + } + + void do_deallocate(void* pointer, std::size_t bytes, std::size_t alignment) override { + --live; + std::pmr::new_delete_resource()->deallocate(pointer, bytes, alignment); + } + + [[nodiscard]] bool do_is_equal(const std::pmr::memory_resource& other) const noexcept override { + return this == &other; + } +}; + +struct throwing_move { + bool* armed; + bool* caught; + int* calls; + + throwing_move(bool& enabled, bool& observed, int& invoked) + : armed(&enabled), caught(&observed), calls(&invoked) {} + + // Deliberately exercise the executor's exceptional move cleanup. + // NOLINTNEXTLINE(bugprone-exception-escape,performance-noexcept-move-constructor) + throwing_move(throwing_move&& other) + : armed(other.armed), caught(other.caught), calls(other.calls) { + if (*armed) { + throw move_failure{caught}; + } + } + + throwing_move(const throwing_move&) = delete; + throwing_move& operator=(const throwing_move&) = delete; + throwing_move& operator=(throwing_move&&) = delete; + ~throwing_move() = default; + + void operator()() const { ++*calls; } +}; + +EM_ASYNC_JS(void, settle_move_failure, (), + { await new Promise(function(resolve) { setTimeout(resolve, 30); }); }); +} // namespace + +// These are the linker's required ABI spellings, used only by this fixture. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" bool __real_emscripten_proxy_async(em_proxying_queue* queue, pthread_t thread, + void (*function)(void*), void* argument); + +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" bool __wrap_emscripten_proxy_async(em_proxying_queue* queue, pthread_t thread, + void (*function)(void*), void* argument) { + auto forwarded = std::make_unique(function, argument); + if (!__real_emscripten_proxy_async(queue, thread, catch_move_failure, forwarded.get())) { + return false; + } + // The queued SDK callback now owns this trampoline. + (void)forwarded.release(); // NOLINT(bugprone-unused-return-value) + return true; +} + +int main() { + counting_resource allocations; + bool armed = false; + bool caught = false; + int calls = 0; + { + webcpp::asio::browser::main_thread_context context; + boost::asio::post( + context.get_executor(), + boost::asio::bind_allocator(std::pmr::polymorphic_allocator(&allocations), + throwing_move(armed, caught, calls))); + boost::asio::post( + context.get_executor(), + boost::asio::bind_allocator(std::pmr::polymorphic_allocator(&allocations), + [&] { ++calls; })); + armed = true; + settle_move_failure(); + BOOST_TEST(caught); + BOOST_TEST_EQ(calls, 0); + BOOST_TEST_EQ(allocations.live, 0); + } + BOOST_TEST_EQ(allocations.live, 0); + std::puts("worker throwing move cleanup complete"); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/package-lock.json b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/package-lock.json new file mode 100644 index 0000000..c4608cf --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/package-lock.json @@ -0,0 +1,10 @@ +{ + "name": "webcpp-asio-browser-tests", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "webcpp-asio-browser-tests" + } + } +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/package.json b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/package.json new file mode 100644 index 0000000..db850d6 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/package.json @@ -0,0 +1,6 @@ +{ + "name": "webcpp-asio-browser-tests", + "private": true, + "type": "module", + "description": "The browser lane's drivers: node built-ins only." +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/page.html b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/page.html new file mode 100644 index 0000000..a245778 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/page.html @@ -0,0 +1,39 @@ + + + +asio browser lane + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/page_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/page_program.cpp new file mode 100644 index 0000000..0a3370d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/page_program.cpp @@ -0,0 +1,32 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// A page program loaded by the browser lane (doc: #asio-building-loader). +#include + +#include "../browser_values.hpp" + +#include + +#include + +// tag::page-program[] +int main() { + webcpp::asio::io_context io; + int ran = 0; + for (int i = 0; i < 3; ++i) { + boost::asio::post(io, [&ran] { ++ran; }); + } + io.run(); // lint-run: the page's event loop, suspended into the browser's + if (ran != 3) { + std::puts("handler count mismatch"); + return 1; + } + std::puts("ran 3 handlers"); + return 0; +} + +// end::page-program[] diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/probes/pthread_return.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/probes/pthread_return.cpp new file mode 100644 index 0000000..ade2d12 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/probes/pthread_return.cpp @@ -0,0 +1,63 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// A dependency-only witness: a suspended pthread entry must return its own value. +#include +#include +#include +#include + +// clang-format off +EM_ASYNC_JS(int, suspend_worker, (), { + await new Promise(resolve => setTimeout(resolve, 20)); + return 42; +}); + +// clang-format on + +extern "C" EMSCRIPTEN_KEEPALIVE int try_join_worker(pthread_t thread, void** value) { + return pthread_tryjoin_np(thread, value); +} + +// clang-format off +EM_ASYNC_JS(int, join_worker, (pthread_t thread, void** value, int busy), { + const deadline = performance.now() + 5000; + let status; + while ((status = _try_join_worker(thread, value)) === busy) { + if (performance.now() > deadline) throw new Error('worker did not exit'); + await new Promise(resolve => setTimeout(resolve, 5)); + } + return status; +}); + +// clang-format on + +void* worker(void* /*unused*/) { + const int result = suspend_worker(); + std::printf("worker suspended result %d\n", result); + return reinterpret_cast(result); +} + +int main() { + pthread_t thread{}; + const int created = pthread_create(&thread, nullptr, worker, nullptr); + if (created != 0) { + return created; + } + void* value = nullptr; + const int joined = join_worker(thread, &value, EBUSY); + std::printf("join result %d value %ld\n", joined, reinterpret_cast(value)); + const int status = joined || reinterpret_cast(value) != 42; + EM_ASM( + { + if (Module['webcppTestFinished']) { + Module['webcppTestFinished']($0); + } + }, + status); + std::puts("worker runtime complete"); + return status; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/render_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/render_program.cpp new file mode 100644 index 0000000..449b2d9 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/render_program.cpp @@ -0,0 +1,46 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Continuous ready work exposes whether the page gets animation opportunities. +#include + +#include + +#include +#include +#include +#include + +namespace { + +struct spinner { + webcpp::asio::io_context& io; + std::chrono::steady_clock::time_point deadline; + std::size_t& handlers; +}; + +// As in turn_limit_test, a bound function pointer avoids a false recursive-call +// diagnostic: post queues this handler; it never calls spin on this stack. +void spin(spinner const* state) { + ++state->handlers; + if (std::chrono::steady_clock::now() < state->deadline) { + boost::asio::post(state->io, std::bind_front(&spin, state)); + } +} + +} // namespace + +int main() { + webcpp::asio::io_context io; + std::size_t handlers = 0; + auto const deadline = std::chrono::steady_clock::now() + std::chrono::seconds(1); + spinner const state{.io = io, .deadline = deadline, .handlers = handlers}; + boost::asio::post(io, std::bind_front(&spin, &state)); + std::puts("spinning"); + io.run(); // lint-run: the page yields after each bounded turn + std::printf("done %zu\n", handlers); + return 0; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/render_unlimited_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/render_unlimited_program.cpp new file mode 100644 index 0000000..d14ad2d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/render_unlimited_program.cpp @@ -0,0 +1,46 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Continuous ready work exposes whether the page gets animation opportunities. +#include + +#include + +#include +#include +#include +#include + +namespace { + +struct spinner { + webcpp::asio::io_context& io; + std::chrono::steady_clock::time_point deadline; + std::size_t& handlers; +}; + +// As in turn_limit_test, a bound function pointer avoids a false recursive-call +// diagnostic: post queues this handler; it never calls spin on this stack. +void spin(spinner const* state) { + ++state->handlers; + if (std::chrono::steady_clock::now() < state->deadline) { + boost::asio::post(state->io, std::bind_front(&spin, state)); + } +} + +} // namespace + +int main() { + webcpp::asio::io_context io; + std::size_t handlers = 0; + auto const deadline = std::chrono::steady_clock::now() + std::chrono::seconds(1); + spinner const state{.io = io, .deadline = deadline, .handlers = handlers}; + boost::asio::post(io, std::bind_front(&spin, &state)); + std::puts("spinning"); + static_cast(io).run(); // lint-run: Boost's own run, the control + std::printf("done %zu\n", handlers); + return 0; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/run.mjs b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/run.mjs new file mode 100644 index 0000000..e1b5196 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/run.mjs @@ -0,0 +1,306 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The real browser checks: idle waits, animation opportunities and variant loading. +// node run.mjs --mode +// CHROME names the browser; on macOS the newest cached Playwright headless shell is used. +// Each invocation owns its loopback server, Chrome process and temporary profile. +import assert from 'node:assert/strict' +import {spawn} from 'node:child_process' +import {once} from 'node:events' +import {mkdtempSync, readFileSync, rmSync} from 'node:fs' +import {createServer} from 'node:http' +import {tmpdir} from 'node:os' +import {dirname, extname, join, resolve, sep} from 'node:path' +import {setTimeout as delay} from 'node:timers/promises' +import {fileURLToPath} from 'node:url' +import {findChrome, waitForChrome} from './chrome_startup.mjs' + +const args = process.argv.slice(2) +assert.equal(args.length, 3, 'usage: run.mjs --mode ') +assert.equal(args[0], '--mode') +const mode = args[1] +assert.ok(['idle', 'render', 'loader', 'workers'].includes(mode), `unknown mode ${mode}`) +const workerVariant = args[2].includes('asyncify') ? 'asyncify' : 'jspi' +const here = dirname(fileURLToPath(import.meta.url)) +const build = dirname(resolve(args[2])) + +const left = {chrome: null, profile: null, server: null, sockets: new Set()} +const exited = child => child.exitCode !== null || child.signalCode !== null +let cleaning +const cleanUp = () => (cleaning ??= (async () => { + for (const socket of left.sockets) socket.close() + if (left.chrome && !exited(left.chrome) && left.chrome.pid) { + const ended = once(left.chrome, 'exit') + const stubborn = setTimeout(() => left.chrome.kill('SIGKILL'), 5000) + left.chrome.kill() + try { await ended } finally { clearTimeout(stubborn) } + } + if (left.server) { + left.server.closeAllConnections() + await new Promise(resolve => left.server.close(resolve)) + } + if (left.profile) rmSync(left.profile, {recursive: true, force: true, maxRetries: 3}) +})()) +for (const [signal, code] of [['SIGHUP', 129], ['SIGINT', 130], ['SIGTERM', 143]]) { + process.on(signal, () => cleanUp().finally(() => process.exit(code))) +} + +const types = {'.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', + '.wasm': 'application/wasm', '.json': 'application/json'} +const roots = {'/build/': build, '/loader/': resolve(here, '../../include/webcpp/asio'), '/': here} +const startServer = async () => { + const server = createServer((request, response) => { + try { + const path = decodeURIComponent(new URL(request.url, 'http://127.0.0.1').pathname) + const [prefix, root] = Object.entries(roots).find(([prefix]) => path.startsWith(prefix)) + const file = resolve(root, path.slice(prefix.length)) + if (!file.startsWith(root + sep)) { + response.writeHead(404).end() + return + } + const content = readFileSync(file) + response.writeHead(200, {'Content-Type': types[extname(file)] ?? 'application/octet-stream', + 'Cross-Origin-Opener-Policy': 'same-origin', + 'Cross-Origin-Embedder-Policy': 'require-corp'}) + .end(content) + } catch { + response.writeHead(404).end() + } + }) + left.server = server + server.listen(0, '127.0.0.1') + await once(server, 'listening') + return `http://127.0.0.1:${server.address().port}` +} + +const startChrome = async () => { + left.profile = mkdtempSync(join(tmpdir(), `asio-browser-${process.pid}-`)) + const executable = findChrome() + const chrome = spawn(executable, [ + '--headless=new', '--remote-debugging-address=127.0.0.1', '--remote-debugging-port=0', + `--user-data-dir=${left.profile}`, '--no-first-run', '--no-default-browser-check', + '--disable-component-update', '--disable-background-networking', '--disable-sync', + '--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1', 'about:blank' + ], {stdio: ['ignore', 'ignore', 'pipe']}) + left.chrome = chrome + const {devtools, version} = await waitForChrome(chrome, left.profile) + console.log(`browser ${mode}: ${version.Browser}`) + return devtools +} + +// Installed before any program code; only page calls are recorded, not driver polling. +function observeIdle() { + window.timers = [] + for (const name of ['setTimeout', 'setInterval']) { + const original = window[name] + window[name] = (callback, delay = 0, ...rest) => { + window.timers.push({name, delay, at: performance.now()}) + return original(callback, delay, ...rest) + } + } + const post = MessagePort.prototype.postMessage + MessagePort.prototype.postMessage = function (...values) { + window.timers.push({name: 'postMessage', delay: 0, at: performance.now()}) + return post.apply(this, values) + } +} + +function observeTurns() { + window.turns = {posted: [], resumed: []} + const Channel = window.MessageChannel + const descriptor = Object.getOwnPropertyDescriptor(MessagePort.prototype, 'onmessage') + window.MessageChannel = class extends Channel { + constructor() { + super() + const post = this.port2.postMessage.bind(this.port2) + this.port2.postMessage = value => { + window.turns.posted.push(performance.now()) + post(value) + } + Object.defineProperty(this.port1, 'onmessage', { + get() { return descriptor.get.call(this) }, + set(handler) { + descriptor.set.call(this, event => { + window.turns.resumed.push(performance.now()) + handler(event) + }) + } + }) + } + } +} + +const openPage = async (devtools, base, program, variant) => { + const target = await (await fetch(`${devtools}/json/new?about:blank`, {method: 'PUT'})).json() + const ws = new WebSocket(target.webSocketDebuggerUrl) + left.sockets.add(ws) + const pending = new Map() + const problems = [] + let id = 0 + const send = (method, params = {}) => new Promise((resolve, reject) => { + const current = ++id + const timer = setTimeout(() => { + pending.delete(current) + reject(new Error(`${method} did not answer within 10 s`)) + }, 10000) + pending.set(current, {resolve, reject, timer}) + ws.send(JSON.stringify({id: current, method, params})) + }) + ws.addEventListener('message', event => { + const message = JSON.parse(event.data) + const waiting = pending.get(message.id) + if (waiting) { + clearTimeout(waiting.timer) + pending.delete(message.id) + if (message.error) waiting.reject(new Error(JSON.stringify(message.error))) + else waiting.resolve(message.result) + } + if (message.method === 'Runtime.exceptionThrown') { + const details = message.params.exceptionDetails + problems.push(details.exception?.description ?? details.text) + } + if (message.method === 'Runtime.consoleAPICalled' && message.params.type === 'error') { + problems.push(message.params.args.map(arg => arg.value ?? arg.description).join(' ')) + } + }) + ws.addEventListener('close', () => { + left.sockets.delete(ws) + for (const entry of pending.values()) { + clearTimeout(entry.timer) + entry.reject(new Error('Chrome debugging connection closed')) + } + pending.clear() + }) + await new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error('Chrome WebSocket connection timed out')), 10000) + ws.addEventListener('open', () => { clearTimeout(timer); resolve() }, {once: true}) + ws.addEventListener('error', () => { clearTimeout(timer); reject(new Error('Chrome WebSocket failed')) }, {once: true}) + }) + await send('Runtime.enable') + await send('Page.enable') + if (variant === 'asyncify') { + await send('Page.addScriptToEvaluateOnNewDocument', {source: 'delete WebAssembly.Suspending'}) + } + const observer = mode === 'idle' ? observeIdle : observeTurns + if (mode !== 'loader' && mode !== 'workers') { + await send('Page.addScriptToEvaluateOnNewDocument', {source: `(${observer.toString()})()`}) + } + await send('Page.navigate', {url: mode === 'workers' + ? `${base}/worker_page.html?script=/build/${program}&variant=${variant}` + : `${base}/page.html?manifest=/build/${program}.variants.json`}) + const snapshot = async () => { + const result = await send('Runtime.evaluate', { + expression: '({report: window.report, timers: window.timers, turns: window.turns})', + returnByValue: true + }) + assert.ok(!result.exceptionDetails, JSON.stringify(result.exceptionDetails)) + assert.deepEqual(problems, [], 'Chrome reported an exception or console.error') + const state = result.result.value + assert.ok(!state.report?.error, state.report?.error) + return state + } + return { + snapshot, + async waitFor(line) { + const deadline = Date.now() + 20000 + while (Date.now() < deadline) { + const state = await snapshot() + if (state.report?.variant && state.report.lines.some(entry => line.test(entry.line))) { + assert.equal(state.report.variant, variant) + return state + } + await delay(25) + } + const last = await snapshot() + throw new Error(`${program} (${variant}) did not complete ${line} within 20 s: ${JSON.stringify({lines: last.report?.lines, variant: last.report?.variant, timers: last.timers})}`) + }, + async close() { + ws.close() + await fetch(`${devtools}/json/close/${target.id}`) + } + } +} + +const renderStats = ({report, turns}, limited) => { + const start = report.lines.find(entry => entry.line === 'spinning') + const finish = report.lines.find(entry => /^done \d+$/.test(entry.line)) + assert.ok(start && finish && finish.at > start.at, 'missing render interval') + const handlers = Number(finish.line.split(' ')[1]) + assert.ok(handlers > 0, 'no handlers ran') + const frames = report.frames.filter(at => at > start.at && at < finish.at).length + if (!limited) { + assert.equal(frames, 0, 'the unlimited control yielded animation callbacks') + assert.equal(turns.posted.length, 0, 'the unlimited control used the bounded yield') + return {frames, handlers} + } + assert.ok(frames > 0, 'STOP: headless Chrome produced no animation callbacks; owner decision required') + assert.ok(frames >= 10, `only ${frames} animation callbacks during the limited run`) + assert.ok(turns.posted.length > 0, 'no bounded turns were observed') + assert.equal(turns.posted.length, turns.resumed.length, 'a yielded turn never resumed') + const durations = turns.posted.map((at, index) => at - (index ? turns.resumed[index - 1] : start.at)) + assert.ok(durations.every(value => value >= 0 && Number.isFinite(value)), 'invalid turn timestamps') + durations.sort((a, b) => a - b) + return {frames, handlers, turns: durations.length, + p95: durations[Math.ceil(0.95 * durations.length) - 1], max: durations.at(-1)} +} + +try { + const base = await startServer() + const devtools = await startChrome() + for (const variant of mode === 'workers' ? [workerVariant] : ['jspi', 'asyncify']) { + const programs = mode === 'render' ? ['render_program', 'render_unlimited_program'] + : [mode === 'workers' ? resolve(args[2]).split(sep).at(-1) + : mode === 'idle' ? 'idle_program' : 'page_program'] + for (const program of programs) { + const page = await openPage(devtools, base, program, variant) + try { + if (mode === 'workers') { + const {report} = await page.waitFor(/^(worker .* complete|cobalt: thread coroutine completed and joined)$/) + assert.equal(report.status, 0, JSON.stringify(report)) + assert.equal(report.isolated, true) + if (!program.includes('cobalt') && !program.includes('worker_return') && + !program.includes('move_failure')) { + const worker = !program.includes('_main-') + assert.ok(report.polls.some(poll => poll.worker === worker && poll.timeout > 0), + `missing ${worker ? 'original worker proxy' : 'main adapter'} wait: ${JSON.stringify(report.polls)}`) + } + console.log(`workers ${variant}: ${program} completed with status 0`) + for (const warning of report.warnings) console.log(`SDK notice: ${warning}`) + } else if (mode === 'loader') { + const {report} = await page.waitFor(/^ran 3 handlers$/) + assert.deepEqual(report.lines.map(entry => entry.line), ['ran 3 handlers']) + console.log(`loader ${variant}: ran 3 handlers`) + } else if (mode === 'idle') { + await page.waitFor(/^idle$/) + await delay(3000) + const {report, timers} = await page.snapshot() + const start = report.lines.find(entry => entry.line === 'idle').at + const recorded = timers.filter(entry => entry.at >= start) + assert.equal(recorded.length, 1, JSON.stringify(recorded)) + assert.equal(recorded[0].name, 'setTimeout', JSON.stringify(recorded)) + assert.ok(recorded[0].delay > 0 && recorded[0].delay <= 300000, JSON.stringify(recorded)) + console.log(`idle ${variant}: one setTimeout(${recorded[0].delay}), no polling in 3 s`) + } else { + const limited = program === 'render_program' + const result = renderStats(await page.waitFor(/^done \d+$/), limited) + if (limited) { + console.log(`render ${variant}: ${result.frames} frames, ${result.handlers} handlers in 1 s, ${result.turns} turns, turn p95 ${result.p95.toFixed(3)} ms, max ${result.max.toFixed(3)} ms`) + assert.ok(result.p95 <= 8, `STOP: ${variant} turn p95 exceeds 8 ms; owner decision required`) + } else { + console.log(`control ${variant}: ${result.frames} frames, ${result.handlers} handlers in 1 s`) + } + } + } finally { await page.close() } + } + } + console.log(`browser ${mode}: ok`) +} catch (error) { + console.error(error) + process.exitCode = 1 +} finally { + await cleanUp() +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/startup_test.mjs b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/startup_test.mjs new file mode 100644 index 0000000..f4da8b1 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/startup_test.mjs @@ -0,0 +1,87 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Exercise startup failures at the process/HTTP boundary, then delay a real +// Chrome launch beyond the former ten-second limit and load both real variants. +import assert from 'node:assert/strict' +import {spawn} from 'node:child_process' +import {once} from 'node:events' +import {mkdtempSync, rmSync, writeFileSync} from 'node:fs' +import {createServer} from 'node:http' +import {tmpdir} from 'node:os' +import {join} from 'node:path' +import {fileURLToPath} from 'node:url' +import {findChrome, waitForChrome} from './chrome_startup.mjs' + +const scratch = mkdtempSync(join(tmpdir(), 'asio-startup-test-')) +const fixture = async (response, check) => { + const profile = mkdtempSync(join(scratch, 'profile-')) + const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 10000)']) + const server = response && createServer(response) + try { + if (server) { + server.listen(0, '127.0.0.1') + await once(server, 'listening') + writeFileSync(join(profile, 'DevToolsActivePort'), `${server.address().port}\n`) + } + await check(child, profile) + } finally { + if (child.exitCode === null && child.signalCode === null) { + const ended = once(child, 'exit') + child.kill() + await ended + } + if (server) { + server.closeAllConnections() + await new Promise(resolve => server.close(resolve)) + } + } +} + +try { + await fixture(null, async (child, profile) => { + await assert.rejects(waitForChrome(child, profile, {timeout: 200}), + /startup timed out.*waiting for DevToolsActivePort/s) + }) + await fixture((request, response) => response.writeHead(503).end('not ready'), + async (child, profile) => { + await assert.rejects(waitForChrome(child, profile, {timeout: 1000}), + /startup timed out.*\/json\/version.*HTTP 503/s) + }) + await fixture(() => {}, async (child, profile) => { + const start = performance.now() + await assert.rejects(waitForChrome(child, profile, {timeout: 250, requestTimeout: 100}), + /startup timed out.*\/json\/version.*TimeoutError/s) + assert.ok(performance.now() - start < 5000, 'an unanswered discovery request escaped its bound') + }) + await fixture(null, async (child, profile) => { + const waiting = waitForChrome(child, profile) + child.kill('SIGTERM') + await assert.rejects(waiting, /Chrome exited during startup.*SIGTERM/s) + }) + const missing = spawn(join(scratch, 'no-such-chrome')) + await assert.rejects(waitForChrome(missing, scratch), /Chrome failed to start.*ENOENT/s) + + const wrapper = join(scratch, 'delayed-chrome') + const quoted = `'${findChrome().replaceAll("'", "'\\''")}'` + writeFileSync(wrapper, `#!/bin/sh\nsleep 11\nexec ${quoted} "$@"\n`, {mode: 0o700}) + const driver = spawn(process.execPath, [fileURLToPath(new URL('./run.mjs', import.meta.url)), + '--mode', 'loader', process.argv.at(-1)], { + env: {...process.env, CHROME: wrapper}, stdio: ['ignore', 'pipe', 'pipe'] + }) + let output = '' + driver.stdout.on('data', data => { output += data }) + driver.stderr.on('data', data => { output += data }) + const bound = setTimeout(() => driver.kill(), 55000) + let status + try { [status] = await once(driver, 'close') } finally { clearTimeout(bound) } + assert.equal(status, 0, output) + assert.match(output, /browser loader: ok/) + process.stdout.write(output) + console.log('browser startup: bounded failures and delayed real Chrome passed') +} finally { + rmSync(scratch, {recursive: true, force: true}) +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/worker_page.html b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/worker_page.html new file mode 100644 index 0000000..7f50eaf --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/worker_page.html @@ -0,0 +1,47 @@ + + + +asio browser workers + + diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser/worker_program.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/worker_program.cpp new file mode 100644 index 0000000..1dcf12b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser/worker_program.cpp @@ -0,0 +1,214 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The worker waits in the real reactor. Timer completion crosses to the browser main +// executor, touches the DOM and posts back to wake the original worker context. +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace { +struct allocation_counts { + int allocated = 0; + int live = 0; +}; + +template +struct tracking_allocator { + using value_type = T; + allocation_counts* counts; + + explicit tracking_allocator(allocation_counts& value) : counts(&value) {} + + template + explicit tracking_allocator(const tracking_allocator& other) : counts(other.counts) {} + + T* allocate(std::size_t count) { + ++counts->allocated; + ++counts->live; + return std::allocator{}.allocate(count); + } + + void deallocate(T* value, std::size_t count) { + --counts->live; + std::allocator{}.deallocate(value, count); + } + + template + bool operator==(const tracking_allocator& other) const { + return counts == other.counts; + } +}; + +struct results { + webcpp::asio::browser::main_thread_context main; + std::atomic done{0}; + std::atomic errors{0}; + int callbacks = 0; + int cancellations = 0; +}; + +void* run_worker(void* pointer) { + auto& result = *static_cast(pointer); + webcpp::asio::io_context io; + auto work = boost::asio::make_work_guard(io); + int returned = 0; + const auto return_to_worker = [&] { + boost::asio::post(io, [&] { + if (emscripten_is_main_browser_thread()) { + ++result.errors; + } + if (++returned == 2) { + work.reset(); + } + }); + }; + boost::asio::cancellation_signal signal; + boost::asio::steady_timer cancelled(io, std::chrono::hours(1)); + cancelled.async_wait(boost::asio::bind_cancellation_slot( + signal.slot(), boost::asio::bind_executor(result.main.get_executor(), [&](auto ec) { + if (ec != boost::asio::error::operation_aborted || + !emscripten_is_main_browser_thread()) { + ++result.errors; + } + ++result.cancellations; + return_to_worker(); + }))); + signal.emit(boost::asio::cancellation_type::all); + boost::asio::steady_timer timer(io, std::chrono::milliseconds(30)); + timer.async_wait(boost::asio::bind_executor(result.main.get_executor(), [&](auto ec) { + if (ec || !emscripten_is_main_browser_thread()) { + ++result.errors; + } + MAIN_THREAD_EM_ASM({ document.body.dataset.workerHandoff = 'complete'; }); + ++result.callbacks; +#ifdef WEBCPP_TEST_WORKER_AFFINITY + // An invalid main-thread runner is rejected before reading the worker's JS handles. + if (io.run() != 0) { // lint-run: reject main-thread entry before suspension + ++result.errors; + } +#endif + return_to_worker(); + })); + if (io.run() != 4) { // lint-run: worker-owned context, real timer and wakeup + ++result.errors; + } + result.done.store(1); + return nullptr; +} + +EM_ASYNC_JS(void, wait_worker, (const void* done), { + const deadline = performance.now() + 5000; + while (!Atomics.load(HEAP32, done >>> 2)) { + if (performance.now() > deadline) + throw new Error('worker context did not finish'); + await new Promise(function(resolve) { setTimeout(resolve, 5); }); + } +}); + +EM_ASYNC_JS(void, settle, (), + { await new Promise(function(resolve) { setTimeout(resolve, 30); }); }); +} // namespace + +int main() { + results result; + pthread_t thread{}; + BOOST_TEST_EQ(pthread_create(&thread, nullptr, run_worker, &result), 0); + wait_worker(&result.done); + int joined = EBUSY; + for (int attempt = 0; attempt < 100 && joined == EBUSY; ++attempt) { + joined = pthread_tryjoin_np(thread, nullptr); + if (joined == EBUSY) { + settle(); + } + } + BOOST_TEST_EQ(joined, 0); + BOOST_TEST_EQ(result.errors.load(), 0); + BOOST_TEST_EQ(result.cancellations, 1); + BOOST_TEST_EQ(result.callbacks, 1); + BOOST_TEST_EQ( + EM_ASM_INT({ return Object.is(document.body.dataset.workerHandoff, 'complete'); }), 1); + + allocation_counts allocations; + int allocated_calls = 0; + boost::asio::post(result.main.get_executor(), + boost::asio::bind_allocator(tracking_allocator(allocations), [&] { + BOOST_TEST_EQ(allocations.live, 0); + ++allocated_calls; + })); + BOOST_TEST_EQ(allocated_calls, 0); + BOOST_TEST(allocations.allocated > 0); + settle(); + BOOST_TEST_EQ(allocated_calls, 1); + + int discarded = 0; + std::weak_ptr lifetime; + { + webcpp::asio::browser::main_thread_context shutdown; + const auto kept = std::make_shared(42); + lifetime = kept; + boost::asio::post(shutdown.get_executor(), + boost::asio::bind_allocator(tracking_allocator(allocations), + [kept, &discarded] { ++discarded; })); + } + BOOST_TEST(lifetime.expired()); + BOOST_TEST_EQ(allocations.live, 0); + settle(); + BOOST_TEST_EQ(discarded, 0); + allocation_counts context_allocations; + { + const webcpp::asio::browser::main_thread_context allocated_context( + std::allocator_arg, tracking_allocator(context_allocations)); + BOOST_TEST(context_allocations.allocated > 0); + } + BOOST_TEST_EQ(context_allocations.live, 0); + allocation_counts reentrant_context_allocations; + allocation_counts reentrant_handler_allocations; + int reentrant_calls = 0; + std::weak_ptr discarded_lifetime; + auto reentrant = std::make_unique( + std::allocator_arg, tracking_allocator(reentrant_context_allocations)); + boost::asio::post( + reentrant->get_executor(), + boost::asio::bind_allocator(tracking_allocator(reentrant_handler_allocations), [&] { + ++reentrant_calls; + reentrant.reset(); + BOOST_TEST(discarded_lifetime.expired()); + BOOST_TEST_EQ(reentrant_handler_allocations.live, 0); + })); + { + const auto held = std::make_shared(42); + discarded_lifetime = held; + boost::asio::post( + reentrant->get_executor(), + boost::asio::bind_allocator(tracking_allocator(reentrant_handler_allocations), + [held, &reentrant_calls] { ++reentrant_calls; })); + } + settle(); + BOOST_TEST_EQ(reentrant_calls, 1); + BOOST_TEST_EQ(reentrant_context_allocations.live, 0); + BOOST_TEST_EQ(reentrant_handler_allocations.live, 0); + std::printf("worker handoff and shutdown complete\n"); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/browser_values.hpp b/libraries/asio/openspec/changes/genesis/reference/source/test/browser_values.hpp index a668242..f2b6ff8 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/browser_values.hpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/browser_values.hpp @@ -88,6 +88,28 @@ EM_JS(void, test_count_reports, (), { globalThis.webcppTestReported = 0; globalThis.reportError = () => { ++globalThis.webcppTestReported; }; }); +EM_JS(emscripten::EM_VAL, test_never_settles, (), { + return Emval.toHandle(new Promise(() => {})); +}); +// Tracks the exact listener functions registered on this test target. +EM_JS(int, test_listener_count, (emscripten::EM_VAL handle), { + const target = Emval.toValue(handle); + if (!target.webcppListeners) { + const listeners = new Set(); + target.webcppListeners = listeners; + const add = target.addEventListener.bind(target); + const remove = target.removeEventListener.bind(target); + target.addEventListener = (type, listener, options) => { + listeners.add(listener); + add(type, listener, options); + }; + target.removeEventListener = (type, listener, options) => { + listeners.delete(listener); + remove(type, listener, options); + }; + } + return target.webcppListeners.size; +}); // clang-format on #endif // WEBCPP_TEST_ASIO_BROWSER_VALUES_HPP diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/Jamfile new file mode 100644 index 0000000..d778423 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/Jamfile @@ -0,0 +1,49 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project : requirements /webcpp/asio//asio ; +import webcpp ; +webcpp.targets native wasip2 wasip3 emscripten ; + +webcpp.compile capabilities : capabilities_test.cpp ; +webcpp.compile config : ../config_test.cpp ; +webcpp.compile-fail forged_capability : requirements_test.cpp + : WEBCPP_ASIO_HAS_SOCKET_BACKEND=1 ; +webcpp.compile-diagnostic forged_diagnostic : diagnostics_test.cpp + : WEBCPP_TEST_FORGED WEBCPP_ASIO_HAS_SOCKET_BACKEND=1 ; + +webcpp.compile-diagnostic missing_tls : diagnostics_test.cpp + : WEBCPP_TEST_REQUIRE_TLS WEBCPP_ASIO_REQUIRE_OPENSSL=1 + : native wasip2 wasip3 ; +webcpp.compile-diagnostic disabled_tls : diagnostics_test.cpp + : WEBCPP_TEST_DISABLED_TLS WEBCPP_ASIO_HAS_OPENSSL=0 + : native wasip2 wasip3 ; +webcpp.compile-diagnostic browser_header : diagnostics_test.cpp + : WEBCPP_TEST_BROWSER_HEADER : native wasip2 wasip3 ; +webcpp.compile-diagnostic worker_header : diagnostics_test.cpp + : single WEBCPP_TEST_WORKER_HEADER ; +webcpp.compile-diagnostic stdio_header : diagnostics_test.cpp + : WEBCPP_TEST_STDIO_HEADER : native wasip3 ; + +webcpp.compile-fail require_THREADS : requirements_test.cpp + : single WEBCPP_ASIO_REQUIRE_THREADS=1 : wasip2 wasip3 ; +for local requirement in LOCAL_SOCKETS SIGNALS SERIAL_PORT REVERSE_DNS +{ + webcpp.compile-fail require_$(requirement) : requirements_test.cpp + : WEBCPP_ASIO_REQUIRE_$(requirement)=1 + : wasip2 wasip3 ; +} +webcpp.compile require_socket : requirements_test.cpp + : WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND=1 : native wasip2 wasip3 ; +webcpp.compile-fail browser_requires_socket : requirements_test.cpp + : WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND=1 : emscripten ; +webcpp.compile-fail browser_requires_tls : requirements_test.cpp + : WEBCPP_ASIO_REQUIRE_OPENSSL=1 : emscripten ; +webcpp.compile-fail browser_requires_stdio : diagnostics_test.cpp + : WEBCPP_TEST_STDIO_HEADER : emscripten ; + +# Includes alone must not ban a browser transport chosen at runtime. +webcpp.compile portable_browser : portable_browser_test.cpp : : emscripten ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/capabilities_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/capabilities_test.cpp new file mode 100644 index 0000000..1a3ba25 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/capabilities_test.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include + +// The same public consumer exposes target capabilities before any feature header. +#ifdef WEBCPP_TARGET_EMSCRIPTEN +static_assert(WEBCPP_ASIO_HAS_BROWSER_BRIDGE == 1); +static_assert(WEBCPP_ASIO_HAS_SOCKET_BACKEND == 0); +static_assert(WEBCPP_ASIO_HAS_OPENSSL_BACKEND == 0); +static_assert(WEBCPP_ASIO_HAS_HOST_DNS == 0); +#else +static_assert(WEBCPP_ASIO_HAS_BROWSER_BRIDGE == 0); +static_assert(WEBCPP_ASIO_HAS_SOCKET_BACKEND == 1); +static_assert(WEBCPP_ASIO_HAS_OPENSSL_BACKEND == 1); +static_assert(WEBCPP_ASIO_HAS_HOST_DNS == 1); +#endif + +#ifdef WEBCPP_TARGET_WASIP2 +static_assert(WEBCPP_ASIO_HAS_WASI_STDIO == 1); +#else +static_assert(WEBCPP_ASIO_HAS_WASI_STDIO == 0); +#endif + +#ifndef WEBCPP_TARGET_NATIVE +static_assert(WEBCPP_ASIO_HAS_REVERSE_DNS == 0); +static_assert(WEBCPP_ASIO_HAS_LOCAL_SOCKETS == 0); +static_assert(WEBCPP_ASIO_HAS_SIGNALS == 0); +static_assert(WEBCPP_ASIO_HAS_SERIAL_PORT == 0); +#endif + +#ifdef BOOST_ASIO_HAS_THREADS +static_assert(WEBCPP_ASIO_HAS_THREADS == 1); +#else +static_assert(WEBCPP_ASIO_HAS_THREADS == 0); +#endif + +#ifdef __EMSCRIPTEN_PTHREADS__ +static_assert(WEBCPP_ASIO_HAS_BROWSER_WORKERS == 1); +#else +static_assert(WEBCPP_ASIO_HAS_BROWSER_WORKERS == 0); +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/diagnostics_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/diagnostics_test.cpp new file mode 100644 index 0000000..8a5e681 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/diagnostics_test.cpp @@ -0,0 +1,25 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#if defined(WEBCPP_TEST_FORGED) +// expected-error@webcpp/asio/config.hpp:* {{capability macros are derived by config.hpp}} +#include +#elif defined(WEBCPP_TEST_REQUIRE_TLS) +// expected-error@webcpp/asio/config.hpp:* {{requires /webcpp/asio//openssl or /webcpp/asio//tls}} +#include +#elif defined(WEBCPP_TEST_DISABLED_TLS) +// expected-error@webcpp/asio/ssl.hpp:* {{needs OpenSSL on native and WASI targets, and it is not +// linked}} +#include +#elif defined(WEBCPP_TEST_BROWSER_HEADER) +// expected-error@webcpp/asio/browser/bridge.hpp:* {{requires the Emscripten browser bridge}} +#include +#elif defined(WEBCPP_TEST_WORKER_HEADER) +// expected-error@webcpp/asio/browser/main_thread_context.hpp:* {{requires Emscripten pthreads}} +#include +#elif defined(WEBCPP_TEST_STDIO_HEADER) +// expected-error@webcpp/asio/wasi/stdio_stream.hpp:* {{requires WASIp2 CLI streams}} +#include +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/portable_browser_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/portable_browser_test.cpp new file mode 100644 index 0000000..5b3bf6d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/portable_browser_test.cpp @@ -0,0 +1,16 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#define WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND 0 +#define WEBCPP_ASIO_REQUIRE_OPENSSL 0 +#include +#include +#include +#include + +// These settings are also consumed by browser-native WSS or custom transports. +static_assert(requires(webcpp::asio::ssl::context& context, boost::system::error_code& error) { + context.set_verify_mode(webcpp::asio::ssl::verify_peer, error); +}); diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/requirements_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/requirements_test.cpp new file mode 100644 index 0000000..046e6fd --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capabilities/requirements_test.cpp @@ -0,0 +1,6 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/Jamfile new file mode 100644 index 0000000..9deb2e0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/Jamfile @@ -0,0 +1,24 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +project : requirements /webcpp/asio//asio ; +import webcpp ; +webcpp.targets native wasip2 wasip3 ; +webcpp.run datagrams : datagrams_test.cpp : : native wasip2 wasip3 ; +webcpp.run resolver : ../wasip2/resolver_test.cpp : : wasip3 ; +webcpp.run resolver_progress : resolver_progress_test.cpp + : -Wl,--wrap=webcpp_asio_wasip3_lookup + -Wl,--wrap=wasip3_subtask_drop : wasip3 ; +webcpp.run send_retry : send_retry_test.cpp : -Wl,--wrap=send : wasip2 wasip3 ; +webcpp.run resolver_empty_list : resolver_empty_result_test.cpp + : -Wl,--wrap=webcpp_asio_wasip3_lookup : wasip3 ; +webcpp.run resolver_empty_message : resolver_empty_result_test.cpp + : WEBCPP_TEST_EMPTY_ERROR_MESSAGE + -Wl,--wrap=webcpp_asio_wasip3_lookup : wasip3 ; +webcpp.run resolver_runners : resolver_runners_test.cpp + : multi off + -Wl,--wrap=webcpp_asio_wasip3_lookup + -Wl,--wrap=wasip3_waitable_join : wasip3 ; +webcpp.lane wasi-dns-threads : resolver_runners : wasip3 ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/datagrams_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/datagrams_test.cpp new file mode 100644 index 0000000..495acdd --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/datagrams_test.cpp @@ -0,0 +1,295 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../wasip2/counting_allocator.hpp" + +namespace { +namespace asio = boost::asio; +using udp = webcpp::asio::ip::udp; +#if defined(__wasip2__) || defined(__wasip3__) +constexpr std::size_t buffer_count = 80; +#else +constexpr std::size_t buffer_count = 16; +#endif + +void connected_send() { + webcpp::asio::io_context context; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + boost::system::error_code connection_error; + BOOST_TEST_EQ(sender.connect(receiver.local_endpoint(), connection_error), + boost::system::error_code{}); + BOOST_TEST_EQ(connection_error, boost::system::error_code{}); + if (connection_error) { + return; + } + std::array pieces{}; + pieces.fill(asio::buffer("x", 1)); + boost::system::error_code error; + BOOST_TEST_EQ(sender.send(pieces, 0, error), buffer_count); + BOOST_TEST_EQ(error, boost::system::error_code{}); + if (!error) { + std::array received{}; + BOOST_TEST_EQ(receiver.receive(asio::buffer(received)), buffer_count); + BOOST_TEST(std::string(received.data(), buffer_count) == std::string(buffer_count, 'x')); + } + counts allocations; + int completed = 0; + sender.async_send(pieces, + asio::bind_allocator(allocator(allocations), + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(allocations.live, 0U); + BOOST_TEST_EQ(ec, boost::system::error_code{}); + BOOST_TEST_EQ(size, buffer_count); + error = ec; + ++completed; + })); + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: finish the public connected datagram operation + BOOST_TEST_EQ(completed, 1); + if (!error) { + std::array received{}; + BOOST_TEST_EQ(receiver.receive(asio::buffer(received)), buffer_count); + BOOST_TEST(std::string(received.data(), buffer_count) == std::string(buffer_count, 'x')); + } +} + +void scatter_receive(bool connected, bool asynchronous) { + counts context_allocations; + webcpp::asio::io_context context(std::allocator_arg, allocator(context_allocations)); + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, {asio::ip::address_v4::loopback(), 0}); + if (connected) { + boost::system::error_code connection_error; + BOOST_TEST_EQ(receiver.connect(sender.local_endpoint(), connection_error), + boost::system::error_code{}); + BOOST_TEST_EQ(connection_error, boost::system::error_code{}); + if (connection_error) { + return; + } + } + std::array bytes{}; + std::array pieces{}; + for (std::size_t index = 0; index != pieces.size(); ++index) { + pieces[index] = asio::buffer(&bytes[index], 1); + } + const std::string payload(100, 's'); + sender.send_to(asio::buffer(payload), receiver.local_endpoint()); + udp::endpoint peer; + boost::system::error_code error; + if (asynchronous) { + counts allocations; + int completed = 0; + auto handler = asio::bind_allocator(allocator(allocations), + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(allocations.live, 0U); + BOOST_TEST_EQ(ec, boost::system::error_code{}); + BOOST_TEST_EQ(size, buffer_count); + error = ec; + ++completed; + }); + if (connected) { + receiver.async_receive(pieces, handler); + } else { + receiver.async_receive_from(pieces, peer, handler); + } + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: finish the public scattered datagram receive + BOOST_TEST_EQ(completed, 1); + } else { + [[maybe_unused]] const auto before = context_allocations.allocations; + auto const size = connected ? receiver.receive(pieces, 0, error) + : receiver.receive_from(pieces, peer, 0, error); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(size, buffer_count); +#if defined(__wasip2__) || defined(__wasip3__) + BOOST_TEST_EQ(context_allocations.allocations, before + 1); +#endif + } + if (!error) { + BOOST_TEST(std::string(bytes.data(), bytes.size()) == std::string(buffer_count, 's')); + if (!connected) { + BOOST_TEST(peer == sender.local_endpoint()); + } + receiver.non_blocking(true); + BOOST_TEST_EQ(receiver.receive(asio::buffer(bytes), 0, error), 0U); + BOOST_TEST(error == asio::error::would_block || error == asio::error::try_again); + } +} + +void cancel_scatter() { + webcpp::asio::io_context context; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + std::array bytes{}; + const std::array pieces{ + asio::buffer(bytes.data(), 1), + asio::buffer(&bytes[1], 1), + }; + asio::cancellation_signal cancellation; + counts allocations; + int completed = 0; + receiver.async_receive( + pieces, asio::bind_allocator(allocator(allocations), + asio::bind_cancellation_slot( + cancellation.slot(), + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST_EQ(allocations.live, 0U); + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST_EQ(size, 0U); + ++completed; + }))); + cancellation.emit(asio::cancellation_type::all); + context.run(); // lint-run: deliver cancellation of the pending scattered receive + BOOST_TEST_EQ(completed, 1); +} + +void datagram_boundaries() { + counts context_counts; + webcpp::asio::io_context context(std::allocator_arg, allocator(context_counts)); + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + sender.connect(receiver.local_endpoint()); + const std::array empty{}; + std::array received{}; + boost::system::error_code error; + BOOST_TEST_EQ(sender.send(empty, 0, error), 0U); + BOOST_TEST(!error); + udp::endpoint peer; +#if defined(__wasip2__) || defined(__wasip3__) + std::array const no_capacity{}; + BOOST_TEST_EQ(receiver.receive_from(no_capacity, peer, 0, error), 0U); +#else + // macOS needs positive capacity to consume an empty datagram. + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(received), peer, 0, error), 0U); +#endif + BOOST_TEST(!error); + sender.send(asio::buffer("discard", 7)); +#if defined(__wasip2__) || defined(__wasip3__) + BOOST_TEST_EQ(receiver.receive_from(no_capacity, peer, 0, error), 0U); +#else + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(received), peer, 0, error), 7U); +#endif + BOOST_TEST(!error); + sender.send(asio::buffer("next", 4)); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(received), peer), 4U); + BOOST_TEST(std::string(received.data(), 4) == "next"); + + const std::string too_large(65536, 'x'); + const std::array oversized{ + asio::buffer(too_large.data(), 65535), + asio::buffer(too_large.data() + 65535, 1), + }; + const auto before = context_counts.allocations; + BOOST_TEST_EQ(sender.send(oversized, 0, error), 0U); + BOOST_TEST_EQ(error, asio::error::message_size); + BOOST_TEST_EQ(context_counts.allocations, before); + int rejected = 0; + sender.async_send(oversized, [&](boost::system::error_code ec, std::size_t size) { +#ifdef BOOST_ASIO_HAS_IOCP + // Upstream forwards the IOCP error, observed as ERROR_INVALID_USER_BUFFER for this send. + const boost::system::error_code invalid_buffer(ERROR_INVALID_USER_BUFFER, + boost::system::system_category()); + BOOST_TEST(ec == asio::error::message_size || ec == invalid_buffer); +#else + BOOST_TEST_EQ(ec, asio::error::message_size); +#endif + BOOST_TEST_EQ(size, 0U); + ++rejected; + }); + BOOST_TEST_EQ(rejected, 0); + context.run(); // lint-run: oversized connected sends fail through deferred completion + BOOST_TEST_EQ(rejected, 1); + receiver.non_blocking(true); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(received), peer, 0, error), 0U); + BOOST_TEST(error == asio::error::would_block || error == asio::error::try_again); +} + +[[maybe_unused]] void asynchronous_empty_buffers() { + webcpp::asio::io_context context; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, {asio::ip::address_v4::loopback(), 0}); + sender.connect(receiver.local_endpoint()); + receiver.connect(sender.local_endpoint()); + const std::array empty{}; + std::array const no_capacity{}; + int completed = 0; + sender.async_send(empty, [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(!error); + BOOST_TEST_EQ(size, 0U); + ++completed; + }); + receiver.async_receive(no_capacity, [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(!error); + BOOST_TEST_EQ(size, 0U); + ++completed; + }); + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: empty buffers still send and consume a complete datagram + BOOST_TEST_EQ(completed, 2); + context.restart(); + sender.send(asio::buffer("discard", 7)); + udp::endpoint peer; + receiver.async_receive_from(no_capacity, peer, + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(!error); + BOOST_TEST_EQ(size, 0U); + BOOST_TEST(peer == sender.local_endpoint()); + ++completed; + }); + context.run(); // lint-run: a zero-capacity scattered receive discards the datagram remainder + BOOST_TEST_EQ(completed, 3); + sender.send(asio::buffer("next", 4)); + std::array bytes{}; + BOOST_TEST_EQ(receiver.receive(asio::buffer(bytes)), 4U); + BOOST_TEST(std::string(bytes.data(), 4) == "next"); +} + +void abandoned_receive() { + counts allocations; + bool completed = false; + std::array bytes{}; + const std::array pieces{ + asio::buffer(bytes.data(), 1), + asio::buffer(&bytes[1], 1), + }; + { + webcpp::asio::io_context context; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + receiver.async_receive( + pieces, asio::bind_allocator( + allocator(allocations), + [&](boost::system::error_code, std::size_t) { completed = true; })); + BOOST_TEST(allocations.live != 0U); + } + BOOST_TEST(!completed); + BOOST_TEST_EQ(allocations.live, 0U); +} + +} // namespace + +int main() { + connected_send(); + for (bool const connected : {false, true}) { + for (bool const asynchronous : {false, true}) { + scatter_receive(connected, asynchronous); + } + } + cancel_scatter(); + datagram_boundaries(); + abandoned_receive(); +#if defined(__wasip2__) || defined(__wasip3__) + asynchronous_empty_buffers(); +#endif + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_empty_result_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_empty_result_test.cpp new file mode 100644 index 0000000..c5932d8 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_empty_result_test.cpp @@ -0,0 +1,65 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include "../wasip2/counting_allocator.hpp" + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" std::uint32_t __wrap_webcpp_asio_wasip3_lookup([[maybe_unused]] const char* name, + [[maybe_unused]] std::size_t size, + void* result) { + auto* bytes = static_cast(result); +#ifdef WEBCPP_TEST_EMPTY_ERROR_MESSAGE + bytes[0] = 1; + bytes[sizeof(void*)] = IP_NAME_LOOKUP_ERROR_CODE_OTHER; + bytes[2 * sizeof(void*)] = 1; + const wasip3_string_t message{.ptr = reinterpret_cast(1), .len = 0}; + std::memcpy(bytes + (3 * sizeof(void*)), &message, sizeof(message)); +#else + bytes[0] = 0; + const ip_name_lookup_list_ip_address_t addresses{ + // Empty canonical allocations encode their alignment in the pointer. + // NOLINTNEXTLINE(performance-no-int-to-ptr) + .ptr = reinterpret_cast(alignof(ip_name_lookup_ip_address_t)), + .len = 0, + }; + std::memcpy(bytes + sizeof(void*), &addresses, sizeof(addresses)); +#endif + return WASIP3_SUBTASK_RETURNED; +} + +int main() { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + webcpp::asio::io_context context; + tcp::resolver resolver(context); + counts allocations; + int completed = 0; + resolver.async_resolve("empty.test.invalid", "443", + asio::bind_allocator(allocator(allocations), + [&](boost::system::error_code error, + const tcp::resolver::results_type& results) { +#ifdef WEBCPP_TEST_EMPTY_ERROR_MESSAGE + BOOST_TEST_EQ(error, asio::error::no_recovery); +#else + BOOST_TEST_EQ(error, asio::error::host_not_found); +#endif + BOOST_TEST(results.empty()); + BOOST_TEST_EQ(allocations.live, 0U); + ++completed; + })); + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: canonical zero-byte allocations are sentinels, not freeable storage + BOOST_TEST_EQ(completed, 1); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_progress_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_progress_test.cpp new file mode 100644 index 0000000..5693d3e --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_progress_test.cpp @@ -0,0 +1,173 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../wasip2/counting_allocator.hpp" + +namespace { +struct test_state { + int lookups = 0; + wasip3_subtask_t pending_handle = 0; + int pending_releases = 0; +}; + +test_state& state() { + static test_state value; + return value; +} +} // namespace + +// Delay the native host boundary deterministically. This retains real component +// subtask/waitable/timer scheduling while avoiding reliance on DNS latency. +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" std::uint32_t __wrap_webcpp_asio_wasip3_lookup(const char* name, + [[maybe_unused]] std::size_t size, + void* result) { + ++state().lookups; + if (std::strncmp(name, "cancel.", 7) == 0) { + auto const status = monotonic_clock_wait_for(1000000000); + state().pending_handle = WASIP3_SUBTASK_HANDLE(status); + return status; + } + auto* address = static_cast( + std::calloc(1, sizeof(ip_name_lookup_ip_address_t))); + address->tag = SOCKETS_IP_ADDRESS_IPV4; + address->val.ipv4 = {.f0 = 127, .f1 = 0, .f2 = 0, .f3 = 1}; + const ip_name_lookup_list_ip_address_t addresses{.ptr = address, .len = 1}; + auto* bytes = static_cast(result); + bytes[0] = 0; + std::memcpy(bytes + sizeof(void*), &addresses, sizeof(addresses)); + return monotonic_clock_wait_for(50000000); +} + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" void __real_wasip3_subtask_drop(wasip3_subtask_t); + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" void __wrap_wasip3_subtask_drop(wasip3_subtask_t handle) { + if (handle == state().pending_handle && handle != 0) { + state().pending_handle = 0; + ++state().pending_releases; + } + __real_wasip3_subtask_drop(handle); +} + +namespace { +void pending_cancellation(bool per_operation) { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + webcpp::asio::io_context context; + tcp::resolver resolver(context); + counts allocations; + asio::cancellation_signal cancellation; + int completed = 0; + const auto before = state().pending_releases; + resolver.async_resolve( + "cancel.test.invalid", "443", + asio::bind_allocator( + allocator(allocations), + asio::bind_cancellation_slot( + cancellation.slot(), + [&](boost::system::error_code error, const tcp::resolver::results_type& result) { + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST(result.empty()); + BOOST_TEST_EQ(allocations.live, 0U); + BOOST_TEST_EQ(state().pending_releases, before + 1); + ++completed; + }))); + BOOST_TEST_EQ(context.poll_one(), 1U); + BOOST_TEST(state().pending_handle != 0); + if (per_operation) { + cancellation.emit(asio::cancellation_type::all); + } else { + resolver.cancel(); + } + context + .run(); // lint-run: release a genuinely pending host subtask before cancellation delivery + BOOST_TEST_EQ(completed, 1); + BOOST_TEST_EQ(state().pending_handle, 0U); +} + +void pending_shutdown() { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + counts allocations; + const auto before = state().pending_releases; + { + webcpp::asio::io_context context; + tcp::resolver resolver(context); + resolver.async_resolve( + "cancel.test.invalid", "443", + asio::bind_allocator(allocator(allocations), + [](boost::system::error_code, const tcp::resolver::results_type&) { + BOOST_ERROR("abandoned resolver completion"); + })); + BOOST_TEST_EQ(context.poll_one(), 1U); + BOOST_TEST(state().pending_handle != 0); + } + BOOST_TEST_EQ(allocations.live, 0U); + BOOST_TEST_EQ(state().pending_releases, before + 1); + BOOST_TEST_EQ(state().pending_handle, 0U); +} + +} // namespace + +int main() { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + webcpp::asio::io_context context; + tcp::resolver resolver(context); + counts allocations; + bool resolved = false; + bool timer_fired = false; + auto lazy = resolver.async_resolve("delayed.test.invalid", "443", asio::deferred); + BOOST_TEST_EQ(state().lookups, 0); + BOOST_TEST_EQ(context.poll(), 0U); + context.restart(); + std::move(lazy)(asio::bind_allocator( + allocator(allocations), + [&](boost::system::error_code error, const tcp::resolver::results_type& result) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(result.size(), 1U); + BOOST_TEST(timer_fired); + BOOST_TEST_EQ(allocations.live, 0U); + if (!result.empty()) { + BOOST_TEST_EQ(result.begin()->endpoint().port(), 443); + } + resolved = true; + })); + BOOST_TEST_EQ(state().lookups, 0); + BOOST_TEST(!resolved); + webcpp::asio::steady_timer timer(context, std::chrono::milliseconds(1)); + timer.async_wait([&](boost::system::error_code error) { + BOOST_TEST(!error); + BOOST_TEST(!resolved); + BOOST_TEST_EQ(state().lookups, 1); + timer_fired = true; + }); + context.run(); // lint-run: prove the native pending lookup permits unrelated timer progress + BOOST_TEST(resolved); + BOOST_TEST(timer_fired); + BOOST_TEST_EQ(allocations.live, 0U); + pending_cancellation(false); + pending_cancellation(true); + pending_shutdown(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_runners_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_runners_test.cpp new file mode 100644 index 0000000..e3b08f4 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/resolver_runners_test.cpp @@ -0,0 +1,97 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../wasip2/counting_allocator.hpp" + +namespace { +struct test_state { + std::atomic pending_handle{0}; + std::atomic poll_owns_waitable{false}; +}; + +test_state& state() { + static test_state value; + return value; +} +} // namespace + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" std::uint32_t __wrap_webcpp_asio_wasip3_lookup([[maybe_unused]] const char* name, + [[maybe_unused]] std::size_t size, + [[maybe_unused]] void const* result) { + auto const status = monotonic_clock_wait_for(1000000000); + state().pending_handle = WASIP3_SUBTASK_HANDLE(status); + return status; +} + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" void __real_wasip3_waitable_join(std::uint32_t, wasip3_waitable_set_t); + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" void __wrap_wasip3_waitable_join(std::uint32_t waitable, wasip3_waitable_set_t set) { + __real_wasip3_waitable_join(waitable, set); + if (waitable != 0 && waitable == state().pending_handle.load()) { + state().poll_owns_waitable = set != 0; + } +} + +int main() { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + for (bool const per_operation : {false, true}) { + webcpp::asio::io_context context; + tcp::resolver resolver(context); + asio::cancellation_signal cancellation; + counts allocations; + std::atomic completed{0}; + resolver.async_resolve( + "pending.test.invalid", "443", + asio::bind_allocator( + allocator(allocations), + asio::bind_cancellation_slot( + cancellation.slot(), [&](boost::system::error_code error, + const tcp::resolver::results_type& results) { + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST(results.empty()); + BOOST_TEST_EQ(allocations.live, 0U); + ++completed; + }))); + BOOST_TEST_EQ(context.poll_one(), 1U); + std::thread runner([&] { + context.run(); // lint-run: one runner owns the libc waitable poll during cancellation + }); + const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(500); + while (!state().poll_owns_waitable && std::chrono::steady_clock::now() < deadline) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + BOOST_TEST(state().poll_owns_waitable.load()); + if (per_operation) { + cancellation.emit(asio::cancellation_type::all); + } else { + resolver.cancel(); + } + context.run(); // lint-run: a second runner must not destroy storage still borrowed by poll + runner.join(); + BOOST_TEST_EQ(completed.load(), 1); + BOOST_TEST_EQ(allocations.live, 0U); + BOOST_TEST(!state().poll_owns_waitable.load()); + } + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/send_retry_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/send_retry_test.cpp new file mode 100644 index 0000000..c44e51b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/capability_wasi/send_retry_test.cpp @@ -0,0 +1,90 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../wasip2/counting_allocator.hpp" + +namespace { +struct test_state { + int sending_socket = -1; + int attempts = 0; +}; + +test_state& state() { + static test_state value; + return value; +} +} // namespace + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" ssize_t __real_send(int, const void*, size_t, int); + +// The linker --wrap protocol requires this exact native boundary symbol. +// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming) +extern "C" ssize_t __wrap_send(int socket, const void* data, size_t size, int flags) { + if (socket == state().sending_socket && ++state().attempts == 1) { + errno = EAGAIN; + return -1; + } + return __real_send(socket, data, size, flags); +} + +int main() { + namespace asio = boost::asio; + using udp = webcpp::asio::ip::udp; + for (bool const gather : {false, true}) { + webcpp::asio::io_context context; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + sender.connect(receiver.local_endpoint()); + state().sending_socket = sender.native_handle(); + state().attempts = 0; + counts allocations; + int completed = 0; + int received = 0; + std::array data{}; + udp::endpoint peer; + receiver.async_receive_from(asio::buffer(data), peer, + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(!error); + BOOST_TEST_EQ(size, 2U); + BOOST_TEST(std::string_view(data.data(), 2) == "ab"); + ++received; + }); + auto handler = asio::bind_allocator(allocator(allocations), + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(!error); + BOOST_TEST_EQ(size, 2U); + BOOST_TEST_EQ(allocations.live, 0U); + ++completed; + }); + const std::array pieces{asio::buffer("a", 1), asio::buffer("b", 1)}; + if (gather) { + sender.async_send(pieces, handler); + } else { + sender.async_send(asio::buffer("ab", 2), handler); + } + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: retry the transient native send after real write readiness + BOOST_TEST_EQ(completed, 1); + BOOST_TEST(state().attempts >= 2); + BOOST_TEST_EQ(received, 1); + receiver.non_blocking(true); + boost::system::error_code error; + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 0U); + BOOST_TEST(error == asio::error::would_block || error == asio::error::try_again); + state().sending_socket = -1; + } + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_accept_cancel_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_accept_cancel_test.cpp new file mode 100644 index 0000000..6fe770f --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_accept_cancel_test.cpp @@ -0,0 +1,66 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// A separately compiled acceptor must receive the common composition fix too. +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace cobalt = boost::cobalt; +namespace io = cobalt::io; + +namespace { + +// GCC 14 misidentifies Cobalt's placement coroutine allocation and sized delete. +// Both use the resource stored before the frame; GCC 15 accepts these functions. +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 14 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmismatched-new-delete" +#endif + +cobalt::promise accept_stream(io::acceptor& listener) { + const auto [error, socket] = co_await cobalt::as_tuple(listener.accept()); + BOOST_TEST(error == boost::asio::error::operation_aborted); + BOOST_TEST(!socket.is_open()); +} + +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 14 +#pragma GCC diagnostic pop +#endif + +} // namespace + +cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await cobalt::this_coro::executor; + boost::asio::steady_timer watchdog(exec, std::chrono::seconds(5)); + watchdog.async_wait([](boost::system::error_code error) { + if (!error) { + static_cast(std::fputs("pending accept did not receive cancellation\n", stderr)); + std::abort(); + } + }); + io::acceptor listener({io::tcp_v4, "127.0.0.1", 0}, exec); + // The promise eagerly initiates accept. No client connects to this listener. + auto pending = accept_stream(listener); + BOOST_TEST(!pending.ready()); + boost::asio::post(exec, [&pending] { pending.cancel(); }); + co_await pending; + watchdog.cancel(); + std::puts("cobalt: pending composed accept cancelled through its promise"); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_io_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_io_test.cpp new file mode 100644 index 0000000..88d5277 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_io_test.cpp @@ -0,0 +1,141 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The public target must link Cobalt's compiled I/O wrappers and core APIs. +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace cobalt = boost::cobalt; +namespace io = cobalt::io; + +namespace { + +// GCC 14 misidentifies Cobalt's placement coroutine allocation and sized delete. +// Both use the resource stored before the frame; GCC 15 accepts these functions. +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 14 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmismatched-new-delete" +#endif + +cobalt::promise accept_client(io::acceptor& listener, io::stream_socket& peer) { + const auto [error] = co_await cobalt::as_tuple(listener.accept(peer)); + BOOST_TEST(!error); +} + +cobalt::task answer() { + co_return 42; +} + +cobalt::task refused_connection(const cobalt::executor& exec) { + // Select a local port, then close it: a bound, non-listening socket can time out + // instead of refusing connections on macOS. + io::stream_socket reservation({io::tcp_v4, "127.0.0.1", 0}, exec); + const auto endpoint = reservation.local_endpoint(); + if (!BOOST_TEST(endpoint.has_value())) { + co_return; + } + BOOST_TEST(reservation.close().has_value()); + io::stream_socket client(exec); + const auto [error] = co_await cobalt::as_tuple(client.connect(*endpoint)); + BOOST_TEST_EQ(error, + boost::asio::error::make_error_code(boost::asio::error::connection_refused)); +} + +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 14 +#pragma GCC diagnostic pop +#endif + +} // namespace + +cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await cobalt::this_coro::executor; + boost::asio::steady_timer watchdog(exec, std::chrono::seconds(10)); + watchdog.async_wait([](boost::system::error_code error) { + if (!error) { + std::abort(); + } + }); + BOOST_TEST_EQ(co_await answer(), 42); + + io::acceptor listener({io::tcp_v4, "127.0.0.1", 0}, exec); + io::stream_socket server(exec); + io::stream_socket client(exec); + auto accepting = accept_client(listener, server); + const auto [connect_error] = + co_await cobalt::as_tuple(client.connect(listener.local_endpoint())); + if (!BOOST_TEST(!connect_error)) { + co_return webcpp::test::exit_status(boost::report_errors()); + } + co_await accepting; + constexpr std::string_view message = "Cobalt I/O on WASIp3"; + std::array bytes{}; + const auto [write_error, written] = + co_await cobalt::as_tuple(io::write(client, io::buffer(message))); + BOOST_TEST(!write_error); + BOOST_TEST_EQ(written, message.size()); + const auto [read_error, received] = + co_await cobalt::as_tuple(io::read(server, io::buffer(bytes))); + BOOST_TEST(!read_error); + BOOST_TEST_EQ(received, message.size()); + BOOST_TEST(std::string_view(bytes.data(), received) == message); + boost::asio::post(exec, [&client] { BOOST_TEST(client.cancel().has_value()); }); + const auto [cancel_error, cancelled] = + co_await cobalt::as_tuple(client.read_some(io::buffer(bytes))); + BOOST_TEST(cancel_error == boost::asio::error::operation_aborted); + BOOST_TEST_EQ(cancelled, 0U); + BOOST_TEST(server.shutdown(io::socket::shutdown_type::shutdown_send).has_value()); + const auto [eof_error, eof_size] = + co_await cobalt::as_tuple(client.read_some(io::buffer(bytes))); + BOOST_TEST(eof_error == boost::asio::error::eof); + BOOST_TEST_EQ(eof_size, 0U); + + co_await refused_connection(exec); + + io::datagram_socket left({io::udp_v4, "127.0.0.1", 0}, exec); + io::datagram_socket right({io::udp_v4, "127.0.0.1", 0}, exec); + const auto left_endpoint = left.local_endpoint(); + const auto right_endpoint = right.local_endpoint(); + if (!BOOST_TEST(left_endpoint && right_endpoint)) { + co_return webcpp::test::exit_status(boost::report_errors()); + } + const auto [left_error] = co_await cobalt::as_tuple(left.connect(*right_endpoint)); + const auto [right_error] = co_await cobalt::as_tuple(right.connect(*left_endpoint)); + BOOST_TEST(!left_error && !right_error); + const auto [send_error, sent] = co_await cobalt::as_tuple(left.send(io::buffer(message))); + BOOST_TEST(!send_error); + BOOST_TEST_EQ(sent, message.size()); + bytes.fill('\0'); + const auto [receive_error, size] = co_await cobalt::as_tuple(right.receive(io::buffer(bytes))); + BOOST_TEST(!receive_error); + BOOST_TEST_EQ(size, message.size()); + BOOST_TEST(std::string_view(bytes.data(), size) == message); + boost::asio::post(exec, [&right] { BOOST_TEST(right.cancel().has_value()); }); + const auto [udp_cancel_error, udp_cancelled] = + co_await cobalt::as_tuple(right.receive(io::buffer(bytes))); + BOOST_TEST(udp_cancel_error == boost::asio::error::operation_aborted); + BOOST_TEST_EQ(udp_cancelled, 0U); + + io::resolver resolver(exec); + const auto [resolve_error, endpoints] = co_await cobalt::as_tuple( + resolver.resolve("127.0.0.1", "443", io::resolver::flags::numeric_host)); + BOOST_TEST(!resolve_error); + BOOST_TEST(!endpoints.empty()); + watchdog.cancel(); + std::puts("cobalt: compiled I/O, task, TCP, UDP, cancellation, EOF and resolver checked"); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_network_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_network_test.cpp new file mode 100644 index 0000000..7271da3 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_network_test.cpp @@ -0,0 +1,117 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Exercise Asio sockets through Cobalt's completion token, not Cobalt's I/O wrappers. +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace asio = boost::asio; +namespace cobalt = boost::cobalt; +using tcp = webcpp::asio::ip::tcp; +using udp = webcpp::asio::ip::udp; + +cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await cobalt::this_coro::executor; + asio::steady_timer watchdog(exec, std::chrono::seconds(5)); + watchdog.async_wait([](boost::system::error_code error) { + if (!error) { + static_cast(std::fputs("cobalt network test timed out\n", stderr)); + std::abort(); + } + }); + + tcp::acceptor acceptor(exec, {asio::ip::address_v4::loopback(), 0}); + tcp::socket server(exec); + tcp::socket client(exec); + asio::steady_timer accepted(exec, std::chrono::steady_clock::time_point::max()); + bool accept_done = false; + boost::system::error_code accept_error; + acceptor.async_accept(server, [&](boost::system::error_code error) { + accept_error = error; + accept_done = true; + accepted.cancel(); + }); + const auto [connect_error] = + co_await cobalt::as_tuple(client.async_connect(acceptor.local_endpoint(), cobalt::use_op)); + if (!BOOST_TEST(!connect_error)) { + co_return webcpp::test::exit_status(boost::report_errors()); + } + if (!accept_done) { + const auto [wait_error] = co_await cobalt::as_tuple(accepted.async_wait(cobalt::use_op)); + BOOST_TEST(wait_error == asio::error::operation_aborted); + } + if (!BOOST_TEST(accept_done && !accept_error)) { + co_return webcpp::test::exit_status(boost::report_errors()); + } + + constexpr std::string_view message = "cobalt network"; + std::array incoming{}; + const auto [write_error, written] = + co_await cobalt::as_tuple(asio::async_write(client, asio::buffer(message), cobalt::use_op)); + if (!BOOST_TEST(!write_error)) { + co_return webcpp::test::exit_status(boost::report_errors()); + } + BOOST_TEST_EQ(written, message.size()); + const auto [read_error, received] = + co_await cobalt::as_tuple(asio::async_read(server, asio::buffer(incoming), cobalt::use_op)); + BOOST_TEST(!read_error); + BOOST_TEST_EQ(received, message.size()); + BOOST_TEST(std::string_view(incoming.data(), received) == message); + + asio::post(exec, [&client] { client.cancel(); }); + const auto [cancel_error, cancelled_bytes] = + co_await cobalt::as_tuple(client.async_read_some(asio::buffer(incoming), cobalt::use_op)); + BOOST_TEST(cancel_error == asio::error::operation_aborted); + BOOST_TEST_EQ(cancelled_bytes, 0U); + server.shutdown(tcp::socket::shutdown_send); + const auto [eof_error, eof_bytes] = + co_await cobalt::as_tuple(client.async_read_some(asio::buffer(incoming), cobalt::use_op)); + BOOST_TEST(eof_error == asio::error::eof); + BOOST_TEST_EQ(eof_bytes, 0U); + + udp::socket receiver(exec, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(exec, udp::v4()); + udp::endpoint peer; + const auto [send_error, sent] = co_await cobalt::as_tuple( + sender.async_send_to(asio::buffer(message), receiver.local_endpoint(), cobalt::use_op)); + if (!BOOST_TEST(!send_error)) { + co_return webcpp::test::exit_status(boost::report_errors()); + } + BOOST_TEST_EQ(sent, message.size()); + incoming.fill('\0'); + const auto [receive_error, datagram_size] = co_await cobalt::as_tuple( + receiver.async_receive_from(asio::buffer(incoming), peer, cobalt::use_op)); + BOOST_TEST(!receive_error); + BOOST_TEST_EQ(datagram_size, message.size()); + BOOST_TEST(std::string_view(incoming.data(), datagram_size) == message); + + asio::post(exec, [&receiver] { receiver.cancel(); }); + const auto [udp_cancel_error, udp_cancel_size] = co_await cobalt::as_tuple( + receiver.async_receive_from(asio::buffer(incoming), peer, cobalt::use_op)); + BOOST_TEST(udp_cancel_error == asio::error::operation_aborted); + BOOST_TEST_EQ(udp_cancel_size, 0U); + watchdog.cancel(); + std::puts("cobalt: TCP, UDP, cancellation and EOF checked"); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_stack_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_stack_test.cpp new file mode 100644 index 0000000..2705265 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_stack_test.cpp @@ -0,0 +1,91 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Measure actual Asyncify unwinds through run_main, including forced reactor waits. +#include "asyncify_watch.hpp" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace cobalt = boost::cobalt; +using watch = webcpp::test::unwinds; + +namespace { + +void check_stack(const char* path, bool waits) { + std::cout << path << ": " << watch::deepest() << " bytes of " << watch::stack_size() << '\n'; + BOOST_TEST_GT(watch::count(), 0U); + BOOST_TEST_GT(watch::deepest(), 0U); + BOOST_TEST_LE(2 * watch::deepest(), watch::stack_size()); + if (waits) { + BOOST_TEST_GT(watch::waits(), 0U); + } +} + +struct pending_cobalt { + cobalt::executor exec; + cobalt::io::steady_timer timer; +}; + +} // namespace + +cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + webcpp::test::bound(std::chrono::seconds(15)); + test_watch_unwinds(); + // Cobalt's awaiter has static members called by the compiler's co_await expansion. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await cobalt::this_coro::executor; + watch::reset(); + for (int i = 0; i < 2000; ++i) { + co_await boost::asio::post(exec, cobalt::use_op); + } + check_stack("co_main, the yield", false); + + // Only a JavaScript macrotask posts cancellation. Until then the timer cannot expire, + // so the event loop must suspend in a blocking poll, even on a heavily loaded host. + pending_cobalt pending{ + .exec = exec, + .timer = {std::chrono::steady_clock::time_point::max(), exec}, + }; + watch::reset(); + const auto cobalt_timeout = emscripten_set_timeout( + [](void* raw) { + auto* state = static_cast(raw); + boost::asio::post(state->exec, [state] { state->timer.cancel(); }); + }, + 0, &pending); + auto [cobalt_error] = co_await cobalt::as_tuple(pending.timer.wait()); + emscripten_clear_timeout(cobalt_timeout); + BOOST_TEST(cobalt_error == boost::asio::error::operation_aborted); + check_stack("co_main, Cobalt timer wait", true); + + boost::asio::steady_timer timer(exec, std::chrono::steady_clock::time_point::max()); + watch::reset(); + const auto asio_timeout = emscripten_set_timeout( + [](void* raw) { + auto* state = static_cast(raw); + boost::asio::post(state->get_executor(), [state] { state->cancel(); }); + }, + 0, &timer); + auto [asio_error] = co_await cobalt::as_tuple(timer.async_wait(cobalt::use_op)); + emscripten_clear_timeout(asio_timeout); + BOOST_TEST(asio_error == boost::asio::error::operation_aborted); + check_stack("co_main, Asio timer wait", true); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_status_driver.mjs b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_status_driver.mjs new file mode 100644 index 0000000..cec92d3 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_status_driver.mjs @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// A nonzero exit alone is insufficient: traps and unfinished main also fail. +import assert from 'node:assert/strict' +import {spawnSync} from 'node:child_process' +import {extname, resolve} from 'node:path' + +const program = resolve(process.argv.at(-1)) +const wasm = extname(program) === '.wasm' +const command = wasm ? (process.env.WASMTIME || 'wasmtime') : + extname(program) === '.js' ? process.execPath : program +const args = wasm ? ['run', '-S', 'p3', '-W', 'component-model-async=y', + '-W', 'component-model-threading=y', '-W', 'timeout=8s', program] : + command === program ? [] : [program] +// EXIT_RUNTIME=0 retains the runtime. Debug Asyncify emits this exact notice. +const notice = status => `program exited (with status: ${status}), but keepRuntimeAlive() ` + + 'is set (counter=0) due to an async operation, so halting execution but not exiting ' + + 'the runtime or preventing further async execution (you can use emscripten_force_exit, ' + + 'if you want to force a true shutdown)\n' +for (const status of [7, 0]) { + const extra = status === 0 ? ['zero'] : [] + const result = spawnSync(command, [...args, ...extra], {encoding: 'utf8', timeout: 10000}) + assert.ifError(result.error) + assert.equal(result.signal, null, result.stderr) + const expected = wasm && status !== 0 ? 1 : status + assert.equal(result.status, expected, result.stdout + result.stderr) + assert.equal(result.stdout.trim(), `cobalt: returning ${status}`) + assert.ok(result.stderr === '' || result.stderr === notice(status), result.stderr) + console.log(`cobalt: return ${status}, exact host exit status ${expected}`) +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_status_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_status_test.cpp new file mode 100644 index 0000000..d3b74ba --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_status_test.cpp @@ -0,0 +1,29 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// No exit_status helper: the runner itself must preserve co_return after suspension. +#include +#include +#include +#include +#include + +#include +#include + +boost::cobalt::main co_main(int argc, [[maybe_unused]] char** argv) { + // Cobalt's awaiter has static members called by the compiler's co_await expansion. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await boost::cobalt::this_coro::executor; + boost::asio::steady_timer timer(exec, std::chrono::milliseconds(20)); + auto [error] = co_await boost::cobalt::as_tuple(timer.async_wait(boost::cobalt::use_op)); + if (error) { + co_return 3; + } + const int result = argc > 1 ? 0 : 7; + std::printf("cobalt: returning %d\n", result); + co_return result; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_test.cpp new file mode 100644 index 0000000..30b0e98 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_test.cpp @@ -0,0 +1,76 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// An unchanged Cobalt entry point must receive webcpp's turn limit and run both timer APIs. +#include "page_timeout.hpp" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +// The build supplies an independent expectation for configuration regressions. +#ifndef WEBCPP_TEST_TURN_LIMIT +#define WEBCPP_TEST_TURN_LIMIT 100 +#endif + +using namespace std::chrono_literals; +namespace cobalt = boost::cobalt; + +cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // Cobalt's awaiter has static members called by the compiler's co_await expansion. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await cobalt::this_coro::executor; + const webcpp::test::yield_counter yields; + int seen = 0; + std::size_t since = 0; + std::size_t longest = 0; + for (std::size_t i = 0; i < 5000; ++i) { + co_await boost::asio::post(exec, cobalt::use_op); + const int now = yields.count(); + if (now != seen) { + seen = now; + since = 0; + } + longest = std::max(longest, ++since); + } +#ifdef __EMSCRIPTEN__ + BOOST_TEST_GE(yields.count(), 4999 / WEBCPP_TEST_TURN_LIMIT); + BOOST_TEST_EQ(longest, std::min(5000, WEBCPP_TEST_TURN_LIMIT)); + BOOST_TEST_GT(longest, 0U); + // Observe the host timer separately: its scheduling delay does not define the turn limit. + webcpp::test::page_timeout timeout; + const auto deadline = std::chrono::steady_clock::now() + 10s; + const int before = yields.count(); + while (!timeout.ran() && std::chrono::steady_clock::now() < deadline) { + co_await boost::asio::post(exec, cobalt::use_op); + } + BOOST_TEST(timeout.ran()); + BOOST_TEST_GT(yields.count(), before); +#else + BOOST_TEST_EQ(yields.count(), 0); + BOOST_TEST_EQ(longest, 5000U); +#endif + cobalt::io::steady_timer cobalt_timer(50ms, exec); + auto [cobalt_error] = co_await cobalt::as_tuple(cobalt_timer.wait()); + BOOST_TEST(!cobalt_error); + boost::asio::steady_timer asio_timer(exec, 20ms); + auto [asio_error] = co_await cobalt::as_tuple(asio_timer.async_wait(cobalt::use_op)); + BOOST_TEST(!asio_error); + std::puts("cobalt: turns and timers passed"); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_thread_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_thread_test.cpp new file mode 100644 index 0000000..f2ac4d8 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/cobalt_thread_test.cpp @@ -0,0 +1,37 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace { + +boost::cobalt::thread worker(std::atomic& completed) { + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await boost::cobalt::this_coro::executor; + co_await boost::asio::post(exec, boost::cobalt::use_op); + completed.store(42); +} + +} // namespace + +boost::cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + std::atomic completed{0}; + auto operation = worker(completed); + co_await operation; + BOOST_TEST_EQ(completed.load(), 42); + std::puts("cobalt: thread coroutine completed and joined"); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/config_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/config_test.cpp index fc3c62a..1ed808a 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/config_test.cpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/config_test.cpp @@ -5,10 +5,9 @@ // https://www.boost.org/LICENSE_1_0.txt) // defines WEBCPP_ASIO_NO_EXCEPTIONS exactly when the -// build has no exceptions, and keeps the developer's own definition in a build -// that has them. test/Jamfile builds this file twice: as the build asks, and -// with the macro defined as a developer defines it, on the command line, which -// WEBCPP_TEST_ASIO_DEVELOPER_DEFINED tells this file. +// collection has no exceptions, and keeps the developer's own definition in a build +// that has them. test/Jamfile builds this file as the build asks, with all webcpp exceptions +// disabled, and with the library macro defined by the developer. #include @@ -22,6 +21,11 @@ #ifndef WEBCPP_ASIO_NO_EXCEPTIONS #error "config.hpp drops WEBCPP_ASIO_NO_EXCEPTIONS, which the developer defined" #endif -#elif defined(BOOST_NO_EXCEPTIONS) != defined(WEBCPP_ASIO_NO_EXCEPTIONS) -#error "WEBCPP_ASIO_NO_EXCEPTIONS is not defined exactly when the build has no exceptions" +#elif defined(WEBCPP_HAS_EXCEPTIONS) == defined(WEBCPP_ASIO_NO_EXCEPTIONS) +#error "WEBCPP_ASIO_NO_EXCEPTIONS must follow the collection exception configuration" +#endif + +#if !defined(WEBCPP_TARGET_NATIVE) && !defined(WEBCPP_TARGET_EMSCRIPTEN) && \ + !defined(WEBCPP_TARGET_WASIP2) && !defined(WEBCPP_TARGET_WASIP3) +#error "Asio must expose the collection target configuration" #endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/event_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/event_test.cpp new file mode 100644 index 0000000..e125171 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/event_test.cpp @@ -0,0 +1,205 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Event waits receive once and release listeners (doc: #asio-events). +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "browser_values.hpp" + +namespace { +using namespace std::chrono_literals; +using emscripten::val; +using webcpp::asio::browser::async_wait_event; + +void one_event_per_wait() { + webcpp::asio::io_context io; + const auto target = val::take_ownership(test_event_target()); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); + int called = 0; + async_wait_event( + io.get_executor(), target, "message", [&](boost::system::error_code ec, const val& event) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(event["detail"].as(), 5); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); + ++called; + async_wait_event(io.get_executor(), target, "message", + [&](boost::system::error_code second_ec, const val& second) { + BOOST_TEST(!second_ec); + BOOST_TEST_EQ(second["detail"].as(), 6); + ++called; + }); + test_dispatch_after(target.as_handle(), 20, 6); + }); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 1); + BOOST_TEST_EQ(called, 0); + test_dispatch_after(target.as_handle(), 20, 5); + io.run(); // lint-run: deliver two distinct events to two waits + BOOST_TEST_EQ(called, 2); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); +} + +void cancellation_removes_the_listener(boost::asio::cancellation_type kind) { + webcpp::asio::io_context io; + const auto target = val::take_ownership(test_event_target()); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); + boost::asio::cancellation_signal signal; + int called = 0; + async_wait_event(io.get_executor(), target, "message", + boost::asio::bind_cancellation_slot( + signal.slot(), [&](boost::system::error_code ec, const val& event) { + BOOST_TEST(ec == boost::asio::error::operation_aborted); + BOOST_TEST(event.isUndefined()); + ++called; + })); + signal.emit(boost::asio::cancellation_type::none); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 1); + signal.emit(kind); + signal.emit(kind); + BOOST_TEST_EQ(called, 0); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); + test_dispatch_after(target.as_handle(), 20, 5); + webcpp::asio::steady_timer observer(io, 50ms); + observer.async_wait([](boost::system::error_code) {}); + io.run(); // lint-run: cancellation completes once, before the ignored late event + BOOST_TEST_EQ(called, 1); + BOOST_TEST(!signal.slot().has_handler()); +} + +void a_deferred_type_owns_its_string() { + webcpp::asio::io_context io; + const auto target = val::take_ownership(test_event_target()); + std::string text = "messages and more"; + auto pending = async_wait_event(io.get_executor(), target, std::string_view(text.data(), 7), + boost::asio::deferred); + text.assign(text.size(), 'x'); + int called = 0; + std::move(pending)([&](boost::system::error_code ec, const val& event) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(event["detail"].as(), 5); + ++called; + }); + test_dispatch_after(target.as_handle(), 20, 5); + io.run(); // lint-run: the event type owns its bytes across deferred initiation + BOOST_TEST_EQ(called, 1); +} + +void destruction_removes_the_listener() { + const auto target = val::take_ownership(test_event_target()); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); + const auto held = std::make_shared(0); + boost::asio::cancellation_signal signal; + { + webcpp::asio::io_context io; + async_wait_event( + io.get_executor(), target, "message", + boost::asio::bind_cancellation_slot( + signal.slot(), [held](boost::system::error_code, const val&) { ++*held; })); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 1); + BOOST_TEST_GT(held.use_count(), 1); + BOOST_TEST_EQ(io.run_for(20ms), 0U); // lint-run: an event wait owns outstanding work + BOOST_TEST(!io.stopped()); + } + BOOST_TEST_EQ(held.use_count(), 1); + BOOST_TEST_EQ(test_listener_count(target.as_handle()), 0); + BOOST_TEST(!signal.slot().has_handler()); + signal.emit(boost::asio::cancellation_type::total); + webcpp::asio::io_context observer; + webcpp::asio::steady_timer timer(observer, 50ms); + timer.async_wait([](boost::system::error_code) {}); + test_dispatch_after(target.as_handle(), 20, 5); + observer.run(); // lint-run: a destroyed context receives nothing + BOOST_TEST_EQ(*held, 0); +} + +void associated_executor_receives_success() { + webcpp::asio::io_context source; + webcpp::asio::io_context completion; + int called = 0; + const auto input = val::take_ownership(test_event_target()); + async_wait_event( + source.get_executor(), input, "message", + boost::asio::bind_executor(completion.get_executor(), + [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(value["detail"].as(), 7); + ++called; + })); + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(!completion.stopped()); + test_dispatch_after(input.as_handle(), 0, 7); + source.run(); // lint-run: settle the operation and queue its completion + completion.run(); // lint-run: deliver without restarting the associated context + BOOST_TEST_EQ(called, 1); + BOOST_TEST(completion.stopped()); +} + +void associated_executor_keeps_work() { + webcpp::asio::io_context completion; + int called = 0; + { + webcpp::asio::io_context source; + boost::asio::cancellation_signal signal; + const auto input = val::take_ownership(test_event_target()); + async_wait_event(source.get_executor(), input, "message", + boost::asio::bind_executor( + completion.get_executor(), + boost::asio::bind_cancellation_slot( + signal.slot(), [&](boost::system::error_code ec, const val&) { + BOOST_TEST(ec == boost::asio::error::operation_aborted); + ++called; + }))); + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(!completion.stopped()); + signal.emit(boost::asio::cancellation_type::total); + source.run(); // lint-run: transfer cancellation to the associated executor + completion.run(); // lint-run: deliver without restarting the associated context + BOOST_TEST_EQ(called, 1); + } + completion.restart(); + { + webcpp::asio::io_context source; + const auto input = val::take_ownership(test_event_target()); + async_wait_event( + source.get_executor(), input, "message", + boost::asio::bind_executor(completion.get_executor(), + [&](boost::system::error_code, const val&) { ++called; })); + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(!completion.stopped()); + } + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(completion.stopped()); + BOOST_TEST_EQ(called, 1); +} + +} // namespace + +int main() { + associated_executor_keeps_work(); + associated_executor_receives_success(); + one_event_per_wait(); + for (const auto kind : { + boost::asio::cancellation_type::terminal, + boost::asio::cancellation_type::partial, + boost::asio::cancellation_type::total, + }) { + cancellation_removes_the_listener(kind); + } + a_deferred_type_owns_its_string(); + destruction_removes_the_listener(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/exceptions_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/exceptions_test.cpp index 9764b08..3d29ece 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/exceptions_test.cpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/exceptions_test.cpp @@ -9,7 +9,7 @@ // nothing when no handler throws; a run called inside a catch block suspends and resumes there; // a handler's exception thrown after run suspended reaches main's catch, and the next run after // it is no nested call; and so does one thrown after the run family yielded to the browser, -// 2,000 handlers having filled two turns of the default limit first. +// 2,000 handlers having filled twenty turns of the default limit first. #include #include @@ -95,7 +95,7 @@ void a_throw_after_a_yield_reaches_main() { BOOST_TEST(caught); BOOST_TEST_EQ(ran, 2000U); #ifdef __EMSCRIPTEN__ - BOOST_TEST_EQ(yields.count(), 2); + BOOST_TEST_EQ(yields.count(), 20); #else BOOST_TEST_EQ(yields.count(), 0); #endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/names_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/names_test.cpp index d42c875..a8341a6 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/names_test.cpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/names_test.cpp @@ -21,6 +21,11 @@ #include #include +// The build supplies an independent expectation for configuration regressions. +#ifndef WEBCPP_TEST_TURN_LIMIT +#define WEBCPP_TEST_TURN_LIMIT 100 +#endif + static_assert(std::is_base_of_v); static_assert(std::is_convertible_v); static_assert(std::is_same_v, boost::asio::basic_waitable_timer>); +#ifndef __EMSCRIPTEN__ +static_assert(std::is_same_v, + boost::asio::basic_stream_socket>); +static_assert(std::is_same_v, + boost::asio::basic_datagram_socket>); +static_assert(std::is_same_v, + boost::asio::basic_socket_acceptor>); +static_assert(std::is_same_v); +static_assert(std::is_same_v); +static_assert(std::is_same_v); +static_assert(std::is_same_v); +static_assert(std::is_same_v); +static_assert(std::is_same_v); +#endif + namespace { void options_are_kept() { webcpp::asio::io_context io; - BOOST_TEST_EQ(io.max_handlers_per_turn(), 1000U); + BOOST_TEST_EQ(io.max_handlers_per_turn(), WEBCPP_TEST_TURN_LIMIT); io.max_handlers_per_turn(250); BOOST_TEST_EQ(io.max_handlers_per_turn(), 250U); io.max_handlers_per_turn(0); @@ -58,7 +78,7 @@ void a_posted_handler_runs() { // Boost's idiom, a concurrency hint of 1, with the options or without. void a_concurrency_hint_is_boost_s() { webcpp::asio::io_context io{1}; - BOOST_TEST_EQ(io.max_handlers_per_turn(), 1000U); + BOOST_TEST_EQ(io.max_handlers_per_turn(), WEBCPP_TEST_TURN_LIMIT); const webcpp::asio::io_context hinted( BOOST_ASIO_CONCURRENCY_HINT_1, webcpp::asio::io_context_options{.max_handlers_per_turn = 8}); diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_named_c_test.c b/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_named_c_test.c new file mode 100644 index 0000000..1213c62 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_named_c_test.c @@ -0,0 +1,10 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The forced include also refuses C sources that name the OpenSSL target. +int main(void) { + return 0; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_named_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_named_test.cpp new file mode 100644 index 0000000..07fbdc4 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_named_test.cpp @@ -0,0 +1,10 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Naming the OpenSSL target must refuse this program on WebAssembly. +int main() { + return 0; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_on_webassembly_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_on_webassembly_test.cpp new file mode 100644 index 0000000..6990fdc --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/openssl_on_webassembly_test.cpp @@ -0,0 +1,9 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// expected-error@*:* {{is named in a build for Emscripten, whose browser profile does not link +// OpenSSL}} +#include "../src/openssl_on_webassembly.hpp" diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/promise_cobalt_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/promise_cobalt_test.cpp new file mode 100644 index 0000000..27de6a8 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/promise_cobalt_test.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Cobalt tokens await JavaScript promises (doc: #asio-promises). +#include +#include +#include +#include +#include +#include +#include +#include +#include "browser_values.hpp" + +boost::cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await boost::cobalt::this_coro::executor; + const auto value = co_await webcpp::asio::browser::async_await( + exec, emscripten::val::take_ownership(test_promise_after(20, 42, false)), + boost::cobalt::use_op); + BOOST_TEST_EQ(value.as(), 42); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + bool caught = false; + try { + co_await webcpp::asio::browser::async_await( + exec, emscripten::val::take_ownership(test_promise_after(20, 9, true)), + boost::cobalt::use_op); + } catch (const boost::system::system_error& error) { + caught = error.code() == webcpp::asio::browser::error::promise_rejected; + } + BOOST_TEST(caught); +#endif + auto [ec, reason] = co_await boost::cobalt::as_tuple(webcpp::asio::browser::async_await( + exec, emscripten::val::take_ownership(test_promise_after(20, 9, true)), + boost::cobalt::use_op)); + BOOST_TEST(ec == webcpp::asio::browser::error::promise_rejected); + BOOST_TEST_EQ(reason.as(), 9); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/promise_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/promise_test.cpp new file mode 100644 index 0000000..8c0151b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/promise_test.cpp @@ -0,0 +1,273 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Promise values, cancellation and lifetime (doc: #asio-promises). +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "browser_values.hpp" +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS +#include +#include +#endif +#include +#include +#include +#include + +namespace { +using namespace std::chrono_literals; +using webcpp::asio::browser::async_await; +namespace error = webcpp::asio::browser::error; +using emscripten::val; + +void resolved_and_rejected_promises() { + webcpp::asio::io_context io; + int called = 0; + async_await(io.get_executor(), val::take_ownership(test_promise_after(20, 42, false)), + [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(value.as(), 42); + ++called; + }); + async_await(io.get_executor(), val::take_ownership(test_promise_after(20, 9, true)), + [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(ec == error::promise_rejected); + BOOST_TEST_EQ(std::string_view(ec.category().name()), "webcpp.asio"); + BOOST_TEST_EQ(ec.value(), 1); + BOOST_TEST_EQ(ec.message(), "the promise was rejected"); + BOOST_TEST_EQ(value.as(), 9); + ++called; + }); + io.run(); // lint-run: the test's event loop + BOOST_TEST_EQ(called, 2); + BOOST_TEST_EQ(error::category().message(99), "unknown webcpp.asio error"); +} + +void completion_tokens_work() { + webcpp::asio::io_context io; + int called = 0; + auto pending = async_await(io.get_executor(), val(7), boost::asio::deferred); + std::move(pending)([&](boost::system::error_code ec, const val& value) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(value.as(), 7); + ++called; + }); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + boost::asio::co_spawn( + io, + [&]() -> boost::asio::awaitable { + const auto value = + co_await async_await(io.get_executor(), val(8), boost::asio::use_awaitable); + BOOST_TEST_EQ(value.as(), 8); + }, + [&](const std::exception_ptr& exception) { + BOOST_TEST(!exception); + ++called; + }); +#endif + io.run(); // lint-run: the test's event loop +#ifdef WEBCPP_ASIO_NO_EXCEPTIONS + BOOST_TEST_EQ(called, 1); +#else + BOOST_TEST_EQ(called, 2); +#endif +} + +void cancellation_completes_before_settlement(boost::asio::cancellation_type kind) { + webcpp::asio::io_context io; + boost::asio::cancellation_signal signal; + int called = 0; + async_await(io.get_executor(), val::take_ownership(test_promise_after(1000, 42, false)), + boost::asio::bind_cancellation_slot( + signal.slot(), [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(ec == boost::asio::error::operation_aborted); + BOOST_TEST(value.isUndefined()); + ++called; + })); + webcpp::asio::steady_timer timer(io, 20ms); + timer.async_wait([&](boost::system::error_code ec) { + BOOST_TEST(!ec); + signal.emit(kind); + signal.emit(kind); + }); + const auto before = std::chrono::steady_clock::now(); + io.run(); // lint-run: the test's event loop + BOOST_TEST(std::chrono::steady_clock::now() - before < 500ms); + BOOST_TEST_EQ(called, 1); + BOOST_TEST(!signal.slot().has_handler()); + // Keep the context alive through the late settlement, which must not complete again. + io.restart(); + timer.expires_after(1100ms); + timer.async_wait([](boost::system::error_code) {}); + io.run(); // lint-run: observe the discarded late settlement + BOOST_TEST_EQ(called, 1); +} + +void never_settling_promises_keep_work() { + webcpp::asio::io_context io; + boost::asio::cancellation_signal signal; + int called = 0; + async_await(io.get_executor(), val::take_ownership(test_never_settles()), + boost::asio::bind_cancellation_slot( + signal.slot(), [&](boost::system::error_code ec, const val&) { + BOOST_TEST(ec == boost::asio::error::operation_aborted); + ++called; + })); + signal.emit(boost::asio::cancellation_type::none); + BOOST_TEST_EQ(io.run_for(200ms), 0U); // lint-run: a pending promise owns work + BOOST_TEST(!io.stopped()); + BOOST_TEST_EQ(called, 0); + signal.emit(boost::asio::cancellation_type::total); + BOOST_TEST_EQ(io.run(), 1U); // lint-run: drain the posted cancellation + BOOST_TEST_EQ(called, 1); +} + +void destruction_releases_the_handler() { + const auto held = std::make_shared(0); + boost::asio::cancellation_signal signal; + { + webcpp::asio::io_context io; + async_await(io.get_executor(), val::take_ownership(test_never_settles()), + boost::asio::bind_cancellation_slot( + signal.slot(), [held](boost::system::error_code, const val&) { ++*held; })); + BOOST_TEST_GT(held.use_count(), 1); + } + BOOST_TEST_EQ(held.use_count(), 1); + BOOST_TEST_EQ(*held, 0); + BOOST_TEST(!signal.slot().has_handler()); + signal.emit(boost::asio::cancellation_type::total); +} + +void settlement_after_destruction_finds_nothing() { + int called = 0; + { + webcpp::asio::io_context io; + async_await(io.get_executor(), val::take_ownership(test_promise_after(30, 1, false)), + [&](boost::system::error_code, const val&) { ++called; }); + } + webcpp::asio::io_context observer; + webcpp::asio::steady_timer timer(observer, 100ms); + timer.async_wait([](boost::system::error_code) {}); + observer.run(); // lint-run: let the abandoned promise settle + BOOST_TEST_EQ(called, 0); +} + +void boundary_values_are_posted() { + webcpp::asio::io_context io; + bool initiated = false; + int called = 0; + auto promise = val::global("Promise").call("resolve", 5); + async_await(io.get_executor(), promise, [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(initiated); + BOOST_TEST(!ec); + BOOST_TEST_EQ(value.as(), 5); + ++called; + }); + async_await(io.get_executor(), val(6), [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(initiated); + BOOST_TEST(!ec); + BOOST_TEST_EQ(value.as(), 6); + ++called; + }); + auto rejected = val::global("Promise").call("reject", val::undefined()); + async_await(io.get_executor(), rejected, [&](boost::system::error_code ec, const val& reason) { + BOOST_TEST(initiated); + BOOST_TEST(ec == error::promise_rejected); + BOOST_TEST(reason.isUndefined()); + ++called; + }); + BOOST_TEST_EQ(called, 0); + initiated = true; + io.run(); // lint-run: the test's event loop + BOOST_TEST_EQ(called, 3); +} + +void associated_executor_receives_success() { + webcpp::asio::io_context source; + webcpp::asio::io_context completion; + int called = 0; + const auto input = val(7); + async_await(source.get_executor(), input, + boost::asio::bind_executor(completion.get_executor(), + [&](boost::system::error_code ec, const val& value) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(value.as(), 7); + ++called; + })); + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(!completion.stopped()); + + source.run(); // lint-run: settle the operation and queue its completion + completion.run(); // lint-run: deliver without restarting the associated context + BOOST_TEST_EQ(called, 1); + BOOST_TEST(completion.stopped()); +} + +void associated_executor_keeps_work() { + webcpp::asio::io_context completion; + int called = 0; + { + webcpp::asio::io_context source; + boost::asio::cancellation_signal signal; + const auto input = val::take_ownership(test_never_settles()); + async_await(source.get_executor(), input, + boost::asio::bind_executor( + completion.get_executor(), + boost::asio::bind_cancellation_slot( + signal.slot(), [&](boost::system::error_code ec, const val&) { + BOOST_TEST(ec == boost::asio::error::operation_aborted); + ++called; + }))); + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(!completion.stopped()); + signal.emit(boost::asio::cancellation_type::total); + source.run(); // lint-run: transfer cancellation to the associated executor + completion.run(); // lint-run: deliver without restarting the associated context + BOOST_TEST_EQ(called, 1); + } + completion.restart(); + { + webcpp::asio::io_context source; + const auto input = val::take_ownership(test_never_settles()); + async_await( + source.get_executor(), input, + boost::asio::bind_executor(completion.get_executor(), + [&](boost::system::error_code, const val&) { ++called; })); + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(!completion.stopped()); + } + BOOST_TEST_EQ(completion.poll(), 0U); + BOOST_TEST(completion.stopped()); + BOOST_TEST_EQ(called, 1); +} + +} // namespace + +int main() { + associated_executor_keeps_work(); + associated_executor_receives_success(); + resolved_and_rejected_promises(); + completion_tokens_work(); + for (const auto kind : { + boost::asio::cancellation_type::terminal, + boost::asio::cancellation_type::partial, + boost::asio::cancellation_type::total, + }) { + cancellation_completes_before_settlement(kind); + } + never_settling_promises_keep_work(); + destruction_releases_the_handler(); + settlement_after_destruction_finds_nothing(); + boundary_values_are_posted(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/resolver_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/resolver_test.cpp new file mode 100644 index 0000000..50ace5b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/resolver_test.cpp @@ -0,0 +1,144 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +using resolver = webcpp::asio::ip::tcp::resolver; + +void check_entry(const resolver::results_type& results, std::string_view host, + std::string_view service, std::uint16_t port) { + BOOST_TEST_EQ(results.size(), 1U); + if (results.empty()) { + return; + } + BOOST_TEST(results.begin()->host_name() == host); + BOOST_TEST(results.begin()->service_name() == service); + BOOST_TEST(results.begin()->endpoint().address().is_unspecified()); + BOOST_TEST_EQ(results.begin()->endpoint().port(), port); +} + +void services_and_errors() { + webcpp::asio::io_context io; + resolver r(io); + + struct expected_port { + std::string_view service; + bool found; + std::uint16_t port; + }; + + constexpr auto services = std::to_array({ + {.service = "80", .found = true, .port = 80}, + {.service = "0", .found = true, .port = 0}, + {.service = "65535", .found = true, .port = 65535}, + {.service = "65536", .found = false, .port = 0}, + {.service = "http", .found = true, .port = 80}, + {.service = "ws", .found = true, .port = 80}, + {.service = "https", .found = true, .port = 443}, + {.service = "wss", .found = true, .port = 443}, + {.service = "WS", .found = false, .port = 0}, + {.service = "80x", .found = false, .port = 0}, + {.service = "", .found = true, .port = 0}, + {.service = "-1", .found = false, .port = 0}, + {.service = "+80", .found = false, .port = 0}, + {.service = " 80", .found = false, .port = 0}, + {.service = "99999999999999999999999", .found = false, .port = 0}, + }); + boost::system::error_code ec; + for (const auto& entry : services) { + const auto results = r.resolve("example.com", entry.service, ec); + if (entry.found) { + BOOST_TEST(!ec); + check_entry(results, "example.com", entry.service, entry.port); + } else { + BOOST_TEST(ec == boost::asio::error::service_not_found); + BOOST_TEST(results.empty()); + } + } + BOOST_TEST(r.resolve("h", "https", resolver::numeric_service, ec).empty()); + BOOST_TEST(ec == boost::asio::error::service_not_found); + check_entry(r.resolve("h", "443", resolver::numeric_service, ec), "h", "443", 443); + BOOST_TEST(!ec); + const auto entry = r.resolve("example.com", "https", ec); + webcpp::asio::ip::tcp::socket socket(io); + BOOST_TEST(socket.connect(*entry.begin(), ec) == boost::asio::error::operation_not_supported); + const webcpp::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address_v4::loopback(), 80); + BOOST_TEST(r.resolve(endpoint, ec).empty()); + BOOST_TEST(ec == boost::asio::error::operation_not_supported); + webcpp::asio::ip::udp::resolver udp(io); + const auto datagram = udp.resolve("example.com", "53", ec); + BOOST_TEST(!ec); + BOOST_TEST_EQ(datagram.begin()->endpoint().port(), 53); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + bool caught = false; + try { + (void)r.resolve("h", "nope"); + } catch (const boost::system::system_error& error) { + caught = error.code() == boost::asio::error::service_not_found; + } + BOOST_TEST(caught); +#endif +} + +void asynchronous_results() { + webcpp::asio::io_context io; + resolver r(io.get_executor()); + BOOST_TEST(r.get_executor() == io.get_executor()); + bool returned = false; + unsigned calls = 0; + auto handler = [&](boost::system::error_code ec, const resolver::results_type& results) { + BOOST_TEST(returned); + BOOST_TEST(!ec); + check_entry(results, "example.com", "https", 443); + ++calls; + }; + r.async_resolve("example.com", "https", handler); + std::string host = "example.com"; + std::string service = "https"; + auto deferred = r.async_resolve(host, service, boost::asio::deferred); + host = "changed"; + service = "nope"; + std::move(deferred)(handler); + r.async_resolve("h", "https", resolver::numeric_service, + [&](boost::system::error_code ec, const resolver::results_type& results) { + BOOST_TEST(returned); + BOOST_TEST(ec == boost::asio::error::service_not_found); + BOOST_TEST(results.empty()); + ++calls; + }); + const webcpp::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address_v4::loopback(), 80); + auto reverse = r.async_resolve(endpoint, boost::asio::deferred); + std::move(reverse)([&](boost::system::error_code ec, const resolver::results_type& results) { + BOOST_TEST(returned); + BOOST_TEST(ec == boost::asio::error::operation_not_supported); + BOOST_TEST(results.empty()); + ++calls; + }); + r.cancel(); // Results already computed remain queued. + BOOST_TEST_EQ(calls, 0U); + returned = true; + io.run(); // lint-run: the resolver test drains posted completions + BOOST_TEST_EQ(calls, 4U); +} +} // namespace + +int main() { + services_and_errors(); + asynchronous_results(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/run_family_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/run_family_test.cpp index 3e05e08..162b51c 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/run_family_test.cpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/run_family_test.cpp @@ -4,7 +4,7 @@ // accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) -// The run family keeps Boost.Asio's meaning on every target (doc: #asio-invariant-3): run +// The run family keeps Boost.Asio's meaning on every target (doc: #asio-run): run // returns out of work with the count of the handlers it ran, run_one runs one, run waits for a // timer, the four timed forms return at their deadline, and stop and restart are Boost's. At // the inputs' edges: a deadline ends a run whose handlers are always ready, though every turn @@ -108,9 +108,13 @@ void stop_and_restart() { ++ran; io.stop(); }); - boost::asio::post(io, [&ran] { ++ran; }); BOOST_TEST_EQ(io.run(), 1U); // lint-run: the test's event loop BOOST_TEST(io.stopped()); + // IOCP may dispatch earlier queued completions before its stop packet. + // Post after the stopped run to test restart without assuming that ordering. + boost::asio::post(io, [&ran] { ++ran; }); + BOOST_TEST_EQ(io.run(), 0U); // lint-run: a stopped context must not dispatch the new work + BOOST_TEST_EQ(ran, 1); io.restart(); BOOST_TEST_EQ(io.run(), 1U); // lint-run: the test's event loop BOOST_TEST_EQ(ran, 2); diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/sockets_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/sockets_test.cpp new file mode 100644 index 0000000..db3c9af --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/sockets_test.cpp @@ -0,0 +1,375 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Browser socket operations fail as values unless a transport supplies them (doc: #asio-sockets). +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +namespace net = webcpp::asio; +using boost::system::error_code; +const auto unsupported = boost::asio::error::operation_not_supported; + +template +void posted(net::io_context& io, Start start) { + int called = 0; + bool initiated = false; + auto check_value = [](const auto& value) { + if constexpr (requires { value.is_open(); }) { + BOOST_TEST(!value.is_open()); + } else { + BOOST_TEST_EQ(value, 0U); + } + }; + auto handler = [&](error_code ec, const auto&... values) { + (check_value(values), ...); + BOOST_TEST(initiated); + BOOST_TEST(ec == unsupported); + ++called; + }; + start(handler); + BOOST_TEST_EQ(called, 0); + initiated = true; + io.restart(); + io.run(); // lint-run: drain the callback completion + BOOST_TEST_EQ(called, 1); + initiated = false; + auto pending = start(boost::asio::deferred); + std::move(pending)(handler); + BOOST_TEST_EQ(called, 1); + initiated = true; + io.restart(); + io.run(); // lint-run: drain the deferred completion + BOOST_TEST_EQ(called, 2); +} +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS +template +void throws_unsupported(Call call) { + bool caught = false; + try { + call(); + } catch (const boost::system::system_error& error) { + caught = error.code() == unsupported; + } + BOOST_TEST(caught); +} +#endif + +template +void common(Socket& socket, Protocol protocol) { + error_code ec; + BOOST_TEST(!socket.is_open()); + BOOST_TEST(socket.open(protocol, ec) == ec); + BOOST_TEST(!ec); + BOOST_TEST(socket.is_open()); + BOOST_TEST(socket.open(protocol, ec) == ec); + BOOST_TEST(ec == boost::asio::error::already_open); + boost::asio::socket_base::reuse_address option; + BOOST_TEST(socket.cancel(ec) == ec); + BOOST_TEST(ec == unsupported); + BOOST_TEST(socket.set_option(option, ec) == ec); + BOOST_TEST(ec == unsupported); + BOOST_TEST(socket.get_option(option, ec) == ec); + BOOST_TEST(ec == unsupported); + socket.local_endpoint(ec); + BOOST_TEST(ec == unsupported); + BOOST_TEST(socket.non_blocking(true, ec) == ec); + BOOST_TEST(ec == unsupported); + BOOST_TEST(!socket.non_blocking()); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { socket.cancel(); }); + throws_unsupported([&] { socket.set_option(option); }); + throws_unsupported([&] { socket.get_option(option); }); + throws_unsupported([&] { (void)socket.local_endpoint(); }); + throws_unsupported([&] { socket.non_blocking(true); }); +#endif + BOOST_TEST(socket.close(ec) == ec); + BOOST_TEST(!ec); + BOOST_TEST(!socket.is_open()); + BOOST_TEST(socket.close(ec) == ec); + BOOST_TEST(!ec); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + socket.open(protocol); + BOOST_TEST(socket.is_open()); + socket.close(); + BOOST_TEST(!socket.is_open()); +#endif +} + +void all_socket_operations() { + net::io_context io; + net::ip::tcp::socket tcp(io); + net::ip::udp::socket udp(io.get_executor()); + net::ip::tcp::acceptor acceptor(io); + common(tcp, net::ip::tcp::v4()); + common(udp, net::ip::udp::v6()); + common(acceptor, net::ip::tcp::v4()); + std::array bytes{}; + const auto buffer = boost::asio::buffer(bytes); + const net::ip::tcp::endpoint tcp_endpoint(boost::asio::ip::address_v4::loopback(), 80); + error_code ec; + BOOST_TEST(tcp.connect(tcp_endpoint, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { tcp.connect(tcp_endpoint); }); +#endif + BOOST_TEST(tcp.shutdown(boost::asio::socket_base::shutdown_both, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { tcp.shutdown(boost::asio::socket_base::shutdown_both); }); +#endif + tcp.read_some(buffer, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.read_some(buffer); }); +#endif + tcp.write_some(buffer, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.write_some(buffer); }); +#endif + tcp.send(buffer, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.send(buffer); }); +#endif + tcp.send(buffer, 0, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.send(buffer, 0); }); +#endif + tcp.receive(buffer, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.receive(buffer); }); +#endif + tcp.receive(buffer, 0, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.receive(buffer, 0); }); +#endif + tcp.remote_endpoint(ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.remote_endpoint(); }); +#endif + tcp.available(ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)tcp.available(); }); +#endif +} + +void synchronous_datagram_operations() { + net::io_context io; + net::ip::udp::socket udp(io); + std::array bytes{}; + const auto buffer = boost::asio::buffer(bytes); + net::ip::udp::endpoint udp_endpoint(boost::asio::ip::address_v4::loopback(), 53); + error_code ec; + BOOST_TEST(udp.connect(udp_endpoint, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { udp.connect(udp_endpoint); }); +#endif + BOOST_TEST(udp.bind(udp_endpoint, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { udp.bind(udp_endpoint); }); +#endif + BOOST_TEST(udp.shutdown(boost::asio::socket_base::shutdown_both, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { udp.shutdown(boost::asio::socket_base::shutdown_both); }); +#endif + udp.send(buffer, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.send(buffer); }); +#endif + udp.send(buffer, 0, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.send(buffer, 0); }); +#endif + udp.receive(buffer, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.receive(buffer); }); +#endif + udp.receive(buffer, 0, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.receive(buffer, 0); }); +#endif + udp.send_to(buffer, udp_endpoint, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.send_to(buffer, udp_endpoint); }); +#endif + udp.send_to(buffer, udp_endpoint, 0, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.send_to(buffer, udp_endpoint, 0); }); +#endif + udp.receive_from(buffer, udp_endpoint, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.receive_from(buffer, udp_endpoint); }); +#endif + udp.receive_from(buffer, udp_endpoint, 0, ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.receive_from(buffer, udp_endpoint, 0); }); +#endif + udp.remote_endpoint(ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.remote_endpoint(); }); +#endif + udp.available(ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)udp.available(); }); +#endif +} + +void synchronous_acceptor_operations() { + net::io_context io; + net::ip::tcp::acceptor acceptor(io); + net::ip::tcp::socket peer(io); + const net::ip::tcp::endpoint tcp_endpoint(boost::asio::ip::address_v4::loopback(), 80); + error_code ec; + BOOST_TEST(acceptor.bind(tcp_endpoint, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { acceptor.bind(tcp_endpoint); }); +#endif + BOOST_TEST(acceptor.listen(ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { acceptor.listen(); }); +#endif + BOOST_TEST(acceptor.listen(4, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { acceptor.listen(4); }); +#endif + BOOST_TEST(acceptor.accept(peer, ec) == ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { acceptor.accept(peer); }); +#endif + acceptor.accept(ec); + BOOST_TEST(ec == unsupported); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + throws_unsupported([&] { (void)acceptor.accept(); }); +#endif +} + +void asynchronous_socket_operations() { + net::io_context io; + net::ip::tcp::socket tcp(io); + net::ip::udp::socket udp(io); + net::ip::tcp::acceptor acceptor(io); + net::ip::tcp::socket peer(io); + std::array bytes{}; + const auto buffer = boost::asio::buffer(bytes); + const net::ip::tcp::endpoint tcp_endpoint(boost::asio::ip::address_v4::loopback(), 80); + net::ip::udp::endpoint udp_endpoint(boost::asio::ip::address_v4::loopback(), 53); + posted(io, [&](auto token) { return tcp.async_connect(tcp_endpoint, std::move(token)); }); + posted(io, [&](auto token) { return tcp.async_read_some(buffer, std::move(token)); }); + posted(io, [&](auto token) { return tcp.async_write_some(buffer, std::move(token)); }); + posted(io, [&](auto token) { return tcp.async_send(buffer, std::move(token)); }); + posted(io, [&](auto token) { return tcp.async_send(buffer, 0, std::move(token)); }); + posted(io, [&](auto token) { return tcp.async_receive(buffer, std::move(token)); }); + posted(io, [&](auto token) { return tcp.async_receive(buffer, 0, std::move(token)); }); + posted(io, [&](auto token) { return udp.async_connect(udp_endpoint, std::move(token)); }); + posted(io, [&](auto token) { return udp.async_send(buffer, std::move(token)); }); + posted(io, [&](auto token) { return udp.async_send(buffer, 0, std::move(token)); }); + posted(io, [&](auto token) { return udp.async_receive(buffer, std::move(token)); }); + posted(io, [&](auto token) { return udp.async_receive(buffer, 0, std::move(token)); }); + posted(io, + [&](auto token) { return udp.async_send_to(buffer, udp_endpoint, std::move(token)); }); + posted(io, [&](auto token) { + return udp.async_send_to(buffer, udp_endpoint, 0, std::move(token)); + }); + posted(io, [&](auto token) { + return udp.async_receive_from(buffer, udp_endpoint, std::move(token)); + }); + posted(io, [&](auto token) { + return udp.async_receive_from(buffer, udp_endpoint, 0, std::move(token)); + }); + posted(io, [&](auto token) { return acceptor.async_accept(peer, std::move(token)); }); + posted(io, [&](auto token) { return acceptor.async_accept(std::move(token)); }); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + net::ip::tcp::socket opened(io, net::ip::tcp::v4()); + BOOST_TEST(opened.is_open()); + const net::ip::tcp::socket moved(std::move(opened)); + BOOST_TEST(moved.is_open()); + // The moved-from state is part of the socket contract. + // NOLINTNEXTLINE(bugprone-use-after-move) + BOOST_TEST(!opened.is_open()); + throws_unsupported([&] { const net::ip::tcp::socket bound(io, tcp_endpoint); }); + throws_unsupported([&] { const net::ip::udp::socket bound(io, udp_endpoint); }); + throws_unsupported([&] { const net::ip::tcp::acceptor bound(io, tcp_endpoint); }); +#endif +} + +// Reusing the moved-from object is part of the socket contract. +// NOLINTBEGIN(bugprone-use-after-move) +template +void moved_sources_remain_usable(Protocol protocol, Start start) { + net::io_context io; + Socket source(io); + error_code ec; + source.open(protocol, ec); + BOOST_TEST(!ec); + Socket destination(std::move(source)); + BOOST_TEST(!source.is_open()); + source.open(protocol, ec); + BOOST_TEST(!ec); + posted(io, [&](auto token) { return start(source, std::move(token)); }); + destination = std::move(source); + BOOST_TEST(!source.is_open()); + source.open(protocol, ec); + BOOST_TEST(!ec); + posted(io, [&](auto token) { return start(source, std::move(token)); }); +} + +// NOLINTEND(bugprone-use-after-move) + +void moved_sockets_keep_their_transport() { + moved_sources_remain_usable( + net::ip::tcp::v4(), + [](auto& socket, auto token) { return socket.async_connect({}, std::move(token)); }); + moved_sources_remain_usable( + net::ip::udp::v4(), + [](auto& socket, auto token) { return socket.async_connect({}, std::move(token)); }); + moved_sources_remain_usable( + net::ip::tcp::v4(), + [](auto& socket, auto token) { return socket.async_accept(std::move(token)); }); +} + +} // namespace + +int main() { + moved_sockets_keep_their_transport(); + all_socket_operations(); + synchronous_datagram_operations(); + synchronous_acceptor_operations(); + asynchronous_socket_operations(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/ssl_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/ssl_test.cpp new file mode 100644 index 0000000..c39f1df --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/ssl_test.cpp @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#ifdef __EMSCRIPTEN__ +#include + +namespace { +void recorded_settings() { + namespace ssl = webcpp::asio::ssl; + ssl::context context(ssl::context::tlsv12_client); + BOOST_TEST(context.recorded_method() == ssl::context::tlsv12_client); + BOOST_TEST_EQ(context.recorded_verify_mode(), ssl::verify_none); + BOOST_TEST(!context.default_verify_paths()); + BOOST_TEST(context.recorded_callback() == ssl::verify_callback_kind::none); + BOOST_TEST(!context.roots_added()); + BOOST_TEST(!context.client_credentials()); + boost::system::error_code ec = boost::asio::error::operation_aborted; + context.set_verify_mode(ssl::verify_peer, ec); + BOOST_TEST(!ec); + BOOST_TEST_EQ(context.recorded_verify_mode(), ssl::verify_peer); + context.set_default_verify_paths(ec); + BOOST_TEST(!ec); + BOOST_TEST(context.default_verify_paths()); + context.set_verify_callback(ssl::host_name_verification("example.com"), ec); + BOOST_TEST(!ec); + BOOST_TEST(context.recorded_callback() == ssl::verify_callback_kind::host_name_verification); + BOOST_TEST(context.verification_host() == "example.com"); + context.set_verify_callback([](bool, auto&) { return true; }, ec); + BOOST_TEST(!ec); + BOOST_TEST(context.recorded_callback() == ssl::verify_callback_kind::other); + BOOST_TEST(context.verification_host().empty()); + context.add_certificate_authority(boost::asio::buffer("root"), ec); + BOOST_TEST(!ec); + BOOST_TEST(context.roots_added()); + context.use_private_key(boost::asio::buffer("key"), ssl::context::pem, ec); + BOOST_TEST(!ec); + BOOST_TEST(context.client_credentials()); + context.set_options(ssl::context::default_workarounds | ssl::context::no_sslv3, ec); + BOOST_TEST(!ec); + BOOST_TEST_EQ(context.recorded_options(), + ssl::context::default_workarounds | ssl::context::no_sslv3); + // Every input-setting form records intent without reading a file or parsing a certificate. + auto succeeds = [&](auto setting) { + ssl::context current(ssl::context::tls_client); + ec = boost::asio::error::operation_aborted; + setting(current, ec); + BOOST_TEST(!ec); + return current; + }; + BOOST_TEST( + succeeds([](auto& c, auto& e) { c.load_verify_file("missing.pem", e); }).roots_added()); + BOOST_TEST(succeeds([](auto& c, auto& e) { c.add_verify_path("missing", e); }).roots_added()); + BOOST_TEST(succeeds([](auto& c, auto& e) { + c.use_certificate(boost::asio::buffer("cert"), ssl::context::pem, e); + }).client_credentials()); + BOOST_TEST(succeeds([](auto& c, auto& e) { + c.use_certificate_file("missing", ssl::context::pem, e); + }).client_credentials()); + BOOST_TEST(succeeds([](auto& c, auto& e) { + c.use_certificate_chain(boost::asio::buffer("cert"), e); + }).client_credentials()); + BOOST_TEST(succeeds([](auto& c, auto& e) { + c.use_certificate_chain_file("missing", e); + }).client_credentials()); + BOOST_TEST(succeeds([](auto& c, auto& e) { + c.use_private_key_file("missing", ssl::context::pem, e); + }).client_credentials()); +#ifndef WEBCPP_ASIO_NO_EXCEPTIONS + context.set_verify_mode(ssl::verify_peer); + context.set_default_verify_paths(); + context.set_verify_callback(ssl::host_name_verification("other.example")); + context.add_certificate_authority(boost::asio::buffer("root")); + context.load_verify_file("missing"); + context.add_verify_path("missing"); + context.use_certificate(boost::asio::buffer("cert"), ssl::context::pem); + context.use_certificate_file("missing", ssl::context::pem); + context.use_certificate_chain(boost::asio::buffer("cert")); + context.use_certificate_chain_file("missing"); + context.use_private_key(boost::asio::buffer("key"), ssl::context::pem); + context.use_private_key_file("missing", ssl::context::pem); + context.set_options(ssl::context::no_tlsv1); +#endif + // A verification object owns its name, including when constructed from a temporary. + const ssl::host_name_verification host(std::string(100, 'x')); + BOOST_TEST_EQ(host.host().size(), 100U); + context.set_verify_callback(host, ec); + BOOST_TEST_EQ(context.verification_host().size(), 100U); +} +} // namespace +#else +static_assert(std::is_same_v); +static_assert(std::is_same_v); +#endif +int main() { +#ifdef __EMSCRIPTEN__ + recorded_settings(); +#else + const webcpp::asio::ssl::context context(webcpp::asio::ssl::context::tlsv12_client); +#endif + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/ssl_without_openssl_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/ssl_without_openssl_test.cpp new file mode 100644 index 0000000..b81b75b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/ssl_without_openssl_test.cpp @@ -0,0 +1,9 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// expected-error@webcpp/asio/ssl.hpp:* {{needs OpenSSL on native and WASI targets, and it is not +// linked}} +#include diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/timers_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/timers_test.cpp new file mode 100644 index 0000000..5228880 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/timers_test.cpp @@ -0,0 +1,158 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Boost's timers and Beast's timeouts keep their completion and cancellation semantics +// through webcpp's run family on both targets (doc: #asio-invariant-8). A lost timer, +// registration-order scheduling, dropped cancellation or a stalled Beast timeout fails here. + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace { + +using namespace std::chrono_literals; + +void steady_timers_complete_in_deadline_order() { + std::cout << "case: steady timers complete in deadline order\n"; + webcpp::asio::io_context io; + const auto start = std::chrono::steady_clock::now(); + webcpp::asio::steady_timer sixty(io, start + 60ms); + webcpp::asio::steady_timer twenty(io, start + 20ms); + webcpp::asio::steady_timer forty(io, start + 40ms); + std::vector order; + const auto record = [&order](auto delay) { + return [&order, delay](boost::system::error_code ec) { + BOOST_TEST(!ec); + order.push_back(delay.count()); + std::cout << "completed steady timer: " << delay.count() << " ms\n"; + }; + }; + sixty.async_wait(record(60ms)); + twenty.async_wait(record(20ms)); + forty.async_wait(record(40ms)); + BOOST_TEST_EQ(io.run(), 3U); // lint-run: the test's event loop + const std::array expected{20, 40, 60}; + BOOST_TEST_ALL_EQ(order.begin(), order.end(), expected.begin(), expected.end()); +} + +void a_system_timer_completes() { + std::cout << "case: a system timer completes\n"; + webcpp::asio::io_context io; + webcpp::asio::system_timer timer(io, 30ms); + std::size_t completions = 0; + timer.async_wait([&completions](boost::system::error_code ec) { + ++completions; + BOOST_TEST(!ec); + std::cout << "system timer error code: " << ec.value() << "\n"; + }); + BOOST_TEST_EQ(io.run(), 1U); // lint-run: the test's event loop + BOOST_TEST_EQ(completions, 1U); +} + +void cancelling_a_timer_aborts_its_wait() { + std::cout << "case: cancelling a timer aborts its wait\n"; + webcpp::asio::io_context io; + webcpp::asio::steady_timer timer(io, 10s); + std::size_t completions = 0; + timer.async_wait([&completions](boost::system::error_code ec) { + ++completions; + BOOST_TEST(ec == boost::asio::error::operation_aborted); + std::cout << "cancelled timer: " << ec.message() << "\n"; + }); + BOOST_TEST_EQ(timer.cancel(), 1U); + BOOST_TEST_EQ(completions, 0U); + BOOST_TEST_EQ(io.run(), 1U); // lint-run: the test's event loop + BOOST_TEST_EQ(completions, 1U); +} + +// tag::slot-cancellation[] +void a_cancellation_slot_aborts_only_its_wait() { + std::cout << "case: a cancellation slot aborts only its wait\n"; + webcpp::asio::io_context io; + boost::asio::cancellation_signal signal; + const auto start = std::chrono::steady_clock::now(); + webcpp::asio::steady_timer timer(io, start + 10s); + webcpp::asio::steady_timer trigger(io, start + 10ms); + std::size_t cancelled = 0; + std::size_t other = 0; + std::size_t emitted = 0; + timer.async_wait( + boost::asio::bind_cancellation_slot(signal.slot(), [&](boost::system::error_code ec) { + ++cancelled; + BOOST_TEST(ec == boost::asio::error::operation_aborted); + BOOST_TEST_EQ(emitted, 1U); + BOOST_TEST_EQ(other, 0U); + // The unbound wait is still pending. Cancel it explicitly to finish the case. + BOOST_TEST_EQ(timer.cancel(), 1U); + std::cout << "slot cancellation: " << ec.message() << "\n"; + })); + timer.async_wait([&](boost::system::error_code ec) { + ++other; + BOOST_TEST(ec == boost::asio::error::operation_aborted); + BOOST_TEST_EQ(cancelled, 1U); + }); + trigger.async_wait([&](boost::system::error_code ec) { + BOOST_TEST(!ec); + ++emitted; + signal.emit(boost::asio::cancellation_type::terminal); + }); + io.run(); // lint-run: the test's event loop + BOOST_TEST_EQ(emitted, 1U); + BOOST_TEST_EQ(cancelled, 1U); + BOOST_TEST_EQ(other, 1U); +} + +// end::slot-cancellation[] + +// tag::beast-timeout[] +void beast_s_handshake_timeout_fires() { + std::cout << "case: Beast's handshake timeout fires\n"; + webcpp::asio::io_context io; + boost::beast::test::stream peer(io); + boost::beast::websocket::stream ws(io); + boost::beast::websocket::stream_base::timeout timeout{}; + timeout.handshake_timeout = 100ms; + timeout.idle_timeout = boost::beast::websocket::stream_base::none(); + timeout.keep_alive_pings = false; + ws.set_option(timeout); + ws.next_layer().connect(peer); + std::size_t completions = 0; + ws.async_accept([&completions](boost::system::error_code ec) { + ++completions; + BOOST_TEST(ec == boost::beast::error::timeout); + std::cout << "handshake: " << ec.message() << "\n"; + }); + io.run(); // lint-run: the test's event loop + BOOST_TEST_EQ(completions, 1U); +} + +// end::beast-timeout[] + +} // namespace + +int main() { + steady_timers_complete_in_deadline_order(); + a_system_timer_completes(); + cancelling_a_timer_aborts_its_wait(); + a_cancellation_slot_aborts_only_its_wait(); + beast_s_handshake_timeout_fires(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/Jamfile new file mode 100644 index 0000000..1b2bd78 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/Jamfile @@ -0,0 +1,65 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +import webcpp ; +webcpp.targets native wasip3 ; +webcpp.original python3 ; + +# These are the real OpenSSL/Cobalt fixtures, now part of recurring CI rather +# than executables requiring a manual request. Both thread profiles are kept. +# MSVC's shared CRT forces B2 threading=multi. S fixtures select its static CRT +# so the provider actually configures no-threads. +local tests ; +for local threading in single multi +{ + local runtime ; + if $(threading) = single { runtime = msvc:static ; } + for local exceptions in "on" "off" + { + local targets = native wasip3 ; + if $(threading) = multi && $(exceptions) = "on" { targets = native ; } + for local mode in client embedded cobalt state cancel + { + local source ; + switch $(mode) + { + case client : source = tls_client ; + case embedded : source = tls_client_embedded ; + case cobalt : source = cobalt_ssl_client ; + case state : source = cobalt_ssl_state ; + case cancel : source = cobalt_ssl_cancel ; + } + local name = $(mode)-$(threading)-$(exceptions) ; + webcpp.drive $(name) : ../../../../tools/openssl/test//$(source) + : $(threading) $(exceptions) + $(runtime) 180 + : driver.py : $(mode) : $(targets) ; + tests += $(name) ; + } + } +} +webcpp.drive entropy : ../../../../tools/openssl/test//entropy + : off single 60 + : driver.py : entropy : wasip3 ; +webcpp.drive entropy-threads : ../../../../tools/openssl/test//threads + : off multi 60 + : driver.py : threads : native wasip3 ; +webcpp.lane tls-integration : $(tests) entropy entropy-threads : native wasip3 ; + +# Test the exact native archives before this real TLS consumer links them. +# The opt-in feature isolates the upstream suite from ordinary consumer builds. +for local threading in single multi +{ + local runtime ; + if $(threading) = single { runtime = msvc:static ; } + webcpp.drive upstream-$(threading) : ../../../../tools/openssl/test//tls_client + : release $(threading) on + $(runtime) on 180 + : driver.py : client : native ; +} +webcpp.lane openssl-upstream : upstream-single upstream-multi : native ; +webcpp.lane openssl-upstream-msvc-14.3 : upstream-single upstream-multi : native ; +webcpp.lane openssl-upstream-msvc-14.5 : upstream-single upstream-multi : native ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls/driver.py b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/driver.py new file mode 100644 index 0000000..5319e79 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/driver.py @@ -0,0 +1,34 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Run the shared real-peer TLS fixtures from the Asio recurring test lane.""" + +from pathlib import Path +import subprocess +import sys + + +def main() -> None: + mode, executable = sys.argv[1:] + program = str(Path(executable).resolve()) + root = Path(__file__).resolve().parents[4] + if mode in ('entropy', 'threads'): + command = ([str(root / 'tools/boost/asio-wasip3/run.sh'), program] + if program.endswith('.wasm') else [program]) + subprocess.run(command, check=True, timeout=30) + if mode == 'entropy': + subprocess.run([*command, 'fail-entropy'], check=True, timeout=30) + return + options = {'client': ['--require-sni'], 'embedded': ['--embedded'], + 'cobalt': ['--embedded', '--require-sni'], 'state': ['--state-test'], + 'cancel': ['--state-test']} + fixture = root / 'tools/openssl/test/tls.py' + subprocess.run([sys.executable, str(fixture), program, *options[mode]], + check=True, timeout=150) + + +if __name__ == '__main__': + main() diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls/package-lock.json b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/package-lock.json new file mode 100644 index 0000000..488c3f0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "webcpp-asio-tls-fixture", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "webcpp-asio-tls-fixture", + "version": "0.0.0", + "license": "BSL-1.0" + } + } +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls/package.json b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/package.json new file mode 100644 index 0000000..38ef57f --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls/package.json @@ -0,0 +1,6 @@ +{ + "name": "webcpp-asio-tls-fixture", + "version": "0.0.0", + "private": true, + "license": "BSL-1.0" +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls_client_context_browser_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_client_context_browser_test.cpp new file mode 100644 index 0000000..e09cefb --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_client_context_browser_test.cpp @@ -0,0 +1,17 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +int main() { + const auto expected = + webcpp::asio::make_error_code(webcpp::asio::tls_context_error::unsupported_target); + BOOST_TEST_EQ(webcpp::asio::make_tls_client_context().error(), expected); + BOOST_TEST_EQ(webcpp::asio::make_tls_client_context("unused").error(), expected); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls_client_context_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_client_context_test.cpp new file mode 100644 index 0000000..6f3682f --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_client_context_test.cpp @@ -0,0 +1,62 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include +#include +#include +#include + +// Windows callers can define this before including the public TLS factory. +#ifdef max +#undef max +#endif +// The lowercase name reproduces the Windows SDK macro. +// NOLINTNEXTLINE(readability-identifier-naming) +#define max(left, right) ((left) > (right) ? (left) : (right)) +#include +#undef max + +int main() { + auto defaults = webcpp::asio::make_tls_client_context(); + BOOST_TEST(defaults.has_value()); + if (!defaults) { + return webcpp::test::exit_status(boost::report_errors()); + } + auto* handle = defaults->native_handle(); + BOOST_TEST_EQ(SSL_CTX_get_verify_mode(handle), SSL_VERIFY_PEER); + BOOST_TEST_EQ(SSL_CTX_get_min_proto_version(handle), TLS1_2_VERSION); + const auto* roots = X509_STORE_get0_objects(SSL_CTX_get_cert_store(handle)); + BOOST_TEST_GT(sk_X509_OBJECT_num(roots), 1); + BOOST_TEST_EQ(static_cast(sk_X509_OBJECT_num(roots)), + webcpp::asio::detail::ca_certificates::count); + + // Supplying one authority must replace, not append to, public trust. + const std::string_view pem = webcpp::asio::detail::ca_certificates::pem; + constexpr std::string_view end = "-----END CERTIFICATE-----"; + const auto first = pem.substr(0, pem.find(end) + end.size()); + auto replacement = webcpp::asio::make_tls_client_context(first); + BOOST_TEST(replacement.has_value()); + if (replacement) { + const auto* store = SSL_CTX_get_cert_store(replacement->native_handle()); + BOOST_TEST_EQ(sk_X509_OBJECT_num(X509_STORE_get0_objects(store)), 1); + BOOST_TEST_EQ(SSL_CTX_get_verify_mode(replacement->native_handle()), SSL_VERIFY_PEER); + } + for (const std::string& invalid : { + std::string{}, + std::string("garbage"), + std::string(first) + "\n-----BEGIN CERTIFICATE-----\ntruncated", + std::string(first) + "\ntrailing garbage", + std::string("-----BEGIN CERTIFICATE-----\nAAAA\n-----END CERTIFICATE-----"), + }) { + BOOST_TEST(!webcpp::asio::make_tls_client_context(invalid)); + } + // Failure cannot contaminate subsequent independent contexts. + BOOST_TEST(webcpp::asio::make_tls_client_context().has_value()); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_peer.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_peer.cpp new file mode 100644 index 0000000..3ce18c1 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_peer.cpp @@ -0,0 +1,12 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include "tls_error_peer.hpp" +#include + +boost::system::error_code webcpp::test::tls_error_from_library(int value) { + return webcpp::asio::make_error_code(static_cast(value)); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_peer.hpp b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_peer.hpp new file mode 100644 index 0000000..343ed67 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_peer.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_TEST_TLS_ERROR_PEER_HPP +#define WEBCPP_TEST_TLS_ERROR_PEER_HPP + +#include +#include + +namespace webcpp::test { +#ifdef WEBCPP_TEST_ERROR_EXPORT +BOOST_SYMBOL_EXPORT +#else +BOOST_SYMBOL_IMPORT +#endif +boost::system::error_code tls_error_from_library(int value); +} // namespace webcpp::test +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_shared_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_shared_test.cpp new file mode 100644 index 0000000..3ab5a14 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/tls_error_shared_test.cpp @@ -0,0 +1,29 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include "tls_error_peer.hpp" + +int main() { + using webcpp::asio::tls_context_error; + for (const auto value : { + tls_context_error::invalid_ca_bundle, + tls_context_error::initialization_failed, + tls_context_error::unsupported_target, + }) { + const auto local = webcpp::asio::make_error_code(value); + const auto imported = webcpp::test::tls_error_from_library(static_cast(value)); + BOOST_TEST_NE(&local.category(), &imported.category()); + BOOST_TEST_EQ(local.value(), imported.value()); + BOOST_TEST_CSTR_EQ(local.category().name(), imported.category().name()); + BOOST_TEST(local == imported); + BOOST_TEST(local.default_error_condition() == imported.default_error_condition()); + BOOST_TEST(local != boost::system::errc::make_error_code( + boost::system::errc::operation_not_permitted)); + } + return boost::report_errors(); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/transport_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/transport_test.cpp new file mode 100644 index 0000000..3e858fd --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/transport_test.cpp @@ -0,0 +1,133 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +struct test_protocol { + using endpoint = boost::asio::ip::basic_endpoint; + + static test_protocol v4() { return {}; } + + static test_protocol v6() { return {true}; } + + [[nodiscard]] int family() const { return ipv6 ? AF_INET6 : AF_INET; } + + static int type() { return SOCK_STREAM; } + + static int protocol() { return IPPROTO_TCP; } + + bool ipv6 = false; +}; + +// The observation belongs to this context, not to process-wide mutable state. +struct observations : boost::asio::execution_context::service { + // Asio identifies each service type through its static id. + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-throwing-static-initialization,cert-err58-cpp) + static inline boost::asio::execution_context::id id; + + explicit observations(boost::asio::execution_context& context) : service(context) {} + + test_protocol::endpoint peer; + unsigned calls = 0; + unsigned closes = 0; + bool delay = false; + +private: + void shutdown() override {} +}; + +} // namespace + +namespace webcpp::asio::browser { +template <> +class transport { +public: + explicit transport(const boost::asio::any_io_executor& executor) + : executor_(executor), + seen_(boost::asio::use_service( + boost::asio::query(executor, boost::asio::execution::context))) {} + + boost::system::error_code connect(const test_protocol::endpoint& peer) { + seen_.peer = peer; + ++seen_.calls; + return {}; + } + + template + void async_connect(const test_protocol::endpoint& peer, Handler&& handler) { + if (seen_.delay) { + timer_ = std::make_unique(executor_, std::chrono::hours(1)); + timer_->async_wait(std::forward(handler)); + return; + } + const auto ec = connect(peer); + webcpp::asio::detail::post_completion( + executor_, boost::asio::append(std::forward(handler), ec)); + } + + boost::system::error_code close() { + ++seen_.closes; + timer_.reset(); + return {}; + } + +private: + std::unique_ptr timer_; + boost::asio::any_io_executor executor_; + observations& seen_; +}; +} // namespace webcpp::asio::browser + +int main() { + webcpp::asio::io_context io; + webcpp::asio::basic_stream_socket socket(io); + auto& seen = boost::asio::use_service(io); + const test_protocol::endpoint peer(boost::asio::ip::address_v4::loopback(), 8080); + boost::system::error_code ec; + BOOST_TEST(socket.connect(peer, ec) == ec); + BOOST_TEST(!ec); + BOOST_TEST(seen.peer == peer); + BOOST_TEST_EQ(seen.calls, 1U); + bool returned = false; + unsigned completed = 0; + auto handler = [&](boost::system::error_code result) { + BOOST_TEST(returned); + BOOST_TEST(!result); + ++completed; + }; + socket.async_connect(peer, handler); + auto operation = socket.async_connect(peer, boost::asio::deferred); + std::move(operation)(handler); + BOOST_TEST_EQ(completed, 0U); + returned = true; + io.run(); // lint-run: the test drives its queued completions + BOOST_TEST_EQ(completed, 2U); + BOOST_TEST_EQ(seen.calls, 3U); + BOOST_TEST(seen.peer == peer); + io.restart(); + seen.delay = true; + BOOST_TEST(socket.open(test_protocol::v4(), ec) == ec); + BOOST_TEST(!ec); + socket.async_connect(peer, [&](boost::system::error_code result) { + BOOST_TEST(result == boost::asio::error::operation_aborted); + ++completed; + }); + BOOST_TEST(socket.close(ec) == ec); + BOOST_TEST(!ec); + BOOST_TEST(!socket.is_open()); + BOOST_TEST_EQ(seen.closes, 1U); + io.poll(); + BOOST_TEST_EQ(completed, 3U); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/turn_limit_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/turn_limit_test.cpp index c22dbe0..d0aa636 100644 --- a/libraries/asio/openspec/changes/genesis/reference/source/test/turn_limit_test.cpp +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/turn_limit_test.cpp @@ -72,14 +72,14 @@ void spin(turn* state) { } // Every turn runs the limit exactly and then yields, under run: a yield between each two of the -// five turns, and none after the last, whose last handler leaves the context out of work. +// fifty turns, and none after the last, whose last handler leaves the context out of work. void run_yields_every_turn() { turn state; state.until = 5000; boost::asio::post(state.io, std::bind_front(&spin, &state)); BOOST_TEST_EQ(state.io.run(), 5000U); // lint-run: the test's event loop - BOOST_TEST_EQ(state.longest, 1000U); - BOOST_TEST_EQ(state.yields.count(), 4); + BOOST_TEST_EQ(state.longest, 100U); + BOOST_TEST_EQ(state.yields.count(), 49); } // The same under run_for, whose deadline is never reached: twenty turns, nineteen yields. diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_contract_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_contract_test.cpp new file mode 100644 index 0000000..995ddb6 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_contract_test.cpp @@ -0,0 +1,187 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace asio = boost::asio; +using tcp = webcpp::asio::ip::tcp; +using udp = webcpp::asio::ip::udp; + +int main() { + webcpp::asio::io_context context; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + std::array data{}; + udp::endpoint peer; + boost::system::error_code error; + + // Empty datagrams are messages and must reach the receiver. + int empty_sent = 0; + int empty_received = 0; + receiver.async_receive_from(asio::buffer(data), peer, + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(ec, boost::system::error_code{}); + BOOST_TEST_EQ(size, 0U); + ++empty_received; + }); + sender.async_send_to(asio::const_buffer{}, receiver.local_endpoint(), + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(ec, boost::system::error_code{}); + if (ec) { + receiver.cancel(); + } + BOOST_TEST_EQ(size, 0U); + ++empty_sent; + }); + context.run(); // lint-run: deliver a zero-length datagram + BOOST_TEST_EQ(empty_sent, 1); + BOOST_TEST_EQ(empty_received, 1); + + std::array pieces{asio::buffer("a", 1), asio::buffer("b", 1)}; + const auto sent = sender.send_to(pieces, receiver.local_endpoint(), 0, error); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(sent, 2U); +#if defined(__wasip2__) || defined(__wasip3__) + // Scatter the same datagram across every nonempty output buffer. + const std::array outputs{ + asio::buffer(data.data(), 1), + asio::buffer(data.data() + 1, 1), + }; + BOOST_TEST_EQ(receiver.receive_from(outputs, peer, 0, error), 2U); +#else + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 2U); +#endif + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST(std::string(data.data(), 2) == "ab"); + + // Container buffers containing only one nonempty buffer remain supported. + pieces = {asio::const_buffer{}, asio::buffer("z", 1)}; + BOOST_TEST_EQ(sender.send_to(pieces, receiver.local_endpoint(), 0, error), 1U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 1U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(data[0], 'z'); + +#if defined(__wasip2__) || defined(__wasip3__) + // Empty buffers must not hide payload beyond Asio's native iovec limit. + std::array distant{}; + distant.front() = asio::buffer("a", 1); + distant.back() = asio::buffer("b", 1); + BOOST_TEST_EQ(sender.send_to(distant, receiver.local_endpoint(), 0, error), 2U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 2U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST(std::string(data.data(), 2) == "ab"); + distant.front() = asio::const_buffer{}; + BOOST_TEST_EQ(sender.send_to(distant, receiver.local_endpoint(), 0, error), 1U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 1U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(data[0], 'b'); + + BOOST_TEST_EQ(sender.send_to(asio::buffer("ab", 2), receiver.local_endpoint()), 2U); + std::array distant_outputs{}; + distant_outputs.front() = asio::buffer(data.data(), 1); + distant_outputs.back() = asio::buffer(data.data() + 1, 1); + BOOST_TEST_EQ(receiver.receive_from(distant_outputs, peer, 0, error), 2U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST(std::string(data.data(), 2) == "ab"); +#endif + + // Both connected scalar and vectored empty operations keep UDP semantics. + sender.connect(receiver.local_endpoint()); + BOOST_TEST_EQ(sender.send(asio::const_buffer{}, 0, error), 0U); + BOOST_TEST_EQ(error, boost::system::error_code{}); +#if defined(__wasip2__) || defined(__wasip3__) + BOOST_TEST_EQ(receiver.receive_from(asio::mutable_buffer{}, peer, 0, error), 0U); +#else + // macOS may return from a zero-capacity receive before consuming a packet. + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 0U); +#endif + BOOST_TEST_EQ(error, boost::system::error_code{}); + const std::array empty_inputs{}; +#if defined(__wasip2__) || defined(__wasip3__) + const std::array empty_outputs{}; +#endif + BOOST_TEST_EQ(sender.send(empty_inputs, 0, error), 0U); + BOOST_TEST_EQ(error, boost::system::error_code{}); +#if defined(__wasip2__) || defined(__wasip3__) + BOOST_TEST_EQ(receiver.receive_from(empty_outputs, peer, 0, error), 0U); +#else + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 0U); +#endif + BOOST_TEST_EQ(error, boost::system::error_code{}); + +#if defined(__wasip2__) || defined(__wasip3__) + receiver.non_blocking(true); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(data), peer, 0, error), 0U); + BOOST_TEST(error == asio::error::would_block || error == asio::error::try_again); + receiver.non_blocking(false); +#endif + + // Use an independent socket so prior traffic cannot satisfy this receive. + udp::socket cancel_receiver(context, {asio::ip::address_v4::loopback(), 0}); + // Preserve asynchronous cancellation with no incoming datagram. + context.restart(); + int cancelled = 0; + cancel_receiver.async_receive_from(asio::buffer(data), peer, + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(ec, asio::error::operation_aborted); + BOOST_TEST_EQ(size, 0U); + ++cancelled; + }); + asio::post(context, [&] { cancel_receiver.cancel(); }); + context.run(); // lint-run: complete cancellation through the executor + BOOST_TEST_EQ(cancelled, 1); + +#if defined(__wasip2__) || defined(__wasip3__) + tcp::socket socket(context, tcp::v4()); + BOOST_TEST_EQ(socket.set_option(asio::socket_base::linger(true, 1), error), + asio::error::operation_not_supported); + BOOST_TEST_EQ(error, asio::error::operation_not_supported); + BOOST_TEST(!socket.at_mark(error)); + BOOST_TEST_EQ(error, asio::error::operation_not_supported); + const auto numeric = asio::ip::make_address_v6("fe80::1%12", error); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(numeric.scope_id(), 12U); + BOOST_TEST(numeric.to_string() == "fe80::1%12"); + static_cast(asio::ip::make_address_v6("fe80::1%eth0", error)); + BOOST_TEST_EQ(error, asio::error::invalid_argument); +#endif + + context.restart(); + tcp::resolver resolver(context); + const auto synchronous = resolver.resolve( + "127.0.0.1", "80", + asio::ip::resolver_base::numeric_host | asio::ip::resolver_base::numeric_service, error); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST(!synchronous.empty()); + int resolved = 0; + resolver.async_resolve( + "localhost", "80", + [&](boost::system::error_code ec, const tcp::resolver::results_type& addresses) { + BOOST_TEST_EQ(ec, boost::system::error_code{}); + BOOST_TEST(!addresses.empty()); + ++resolved; + }); + BOOST_TEST_EQ(resolved, 0); + context.run(); // lint-run: resolve through the configured executor + BOOST_TEST_EQ(resolved, 1); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_core_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_core_test.cpp new file mode 100644 index 0000000..0bc9e7b --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_core_test.cpp @@ -0,0 +1,239 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace asio = boost::asio; +using tcp = webcpp::asio::ip::tcp; +using udp = webcpp::asio::ip::udp; +using namespace std::chrono_literals; + +namespace { + +void test_timers() { + webcpp::asio::io_context context; + bool posted = false; + int expired = 0; + int cancelled = 0; + webcpp::asio::steady_timer timer(context, 20ms); + webcpp::asio::steady_timer cancelled_timer(context, 1h); + timer.async_wait([&](boost::system::error_code error) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST(posted); + ++expired; + }); + cancelled_timer.async_wait([&](boost::system::error_code error) { + BOOST_TEST(error == asio::error::operation_aborted); + ++cancelled; + }); + asio::post(context, [&] { + posted = true; + BOOST_TEST_EQ(cancelled_timer.cancel(), 1U); + }); + context.run(); // lint-run: test the application's event loop + BOOST_TEST_EQ(expired, 1); + BOOST_TEST_EQ(cancelled, 1); +} + +void test_tcp() { + webcpp::asio::io_context context; + tcp::acceptor acceptor(context, {asio::ip::address_v4::loopback(), 0}); + tcp::socket server(context); + tcp::socket client(context); + const std::string message = "hello WASIp3"; + std::array server_data{}; + std::array client_data{}; + int exchanged = 0; + acceptor.async_accept(server, [&](boost::system::error_code error) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + if (error) { + return; + } + const std::array input = { + asio::mutable_buffer{}, + asio::buffer(server_data.data(), 6), + asio::buffer(server_data.data() + 6, 6), + }; + asio::async_read( + server, input, [&](boost::system::error_code read_error, std::size_t size) { + BOOST_TEST_EQ(read_error, boost::system::error_code{}); + BOOST_TEST_EQ(size, message.size()); + asio::async_write(server, asio::buffer(server_data), + [&](boost::system::error_code write_error, std::size_t written) { + BOOST_TEST_EQ(write_error, boost::system::error_code{}); + BOOST_TEST_EQ(written, message.size()); + ++exchanged; + }); + }); + }); + const std::array pieces = { + asio::const_buffer{}, + asio::buffer(message.data(), 6), + asio::buffer(message.data() + 6, 6), + }; + client.async_connect(acceptor.local_endpoint(), [&](boost::system::error_code error) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + if (error) { + return; + } + asio::async_write( + client, pieces, [&](boost::system::error_code write_error, std::size_t size) { + BOOST_TEST_EQ(write_error, boost::system::error_code{}); + BOOST_TEST_EQ(size, message.size()); + asio::async_read( + client, asio::buffer(client_data), + [&](boost::system::error_code read_error, std::size_t received) { + BOOST_TEST_EQ(read_error, boost::system::error_code{}); + BOOST_TEST_EQ(received, message.size()); + BOOST_TEST(std::string(client_data.data(), received) == message); + ++exchanged; + }); + }); + }); + context.run(); // lint-run: drive both peers without an external server + BOOST_TEST_EQ(exchanged, 2); + +#if defined(__wasip2__) || defined(__wasip3__) + // A long empty prefix must not turn a stream operation into a no-op. + context.restart(); + std::array late_input{}; + std::array late_output{}; + late_input.back() = asio::buffer("x", 1); + late_output.back() = asio::buffer(server_data.data(), 1); + int late_completions = 0; + server.async_read_some(late_output, [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(size, 1U); + BOOST_TEST_EQ(server_data[0], 'x'); + ++late_completions; + }); + client.async_write_some(late_input, [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(size, 1U); + ++late_completions; + }); + context.run(); // lint-run: transfer data beyond an empty iovec prefix + BOOST_TEST_EQ(late_completions, 2); +#endif + + context.restart(); + int eof = 0; + server.shutdown(tcp::socket::shutdown_send); + client.async_read_some(asio::buffer(client_data), + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(error == asio::error::eof); + BOOST_TEST_EQ(size, 0U); + ++eof; + }); + context.run(); // lint-run: observe the peer's write shutdown + BOOST_TEST_EQ(eof, 1); + + context.restart(); + int read_cancelled = 0; + server.async_read_some(asio::buffer(server_data), + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST(error == asio::error::operation_aborted); + BOOST_TEST_EQ(size, 0U); + ++read_cancelled; + }); + asio::post(context, [&] { server.cancel(); }); + context.run(); // lint-run: complete TCP read cancellation + BOOST_TEST_EQ(read_cancelled, 1); +} + +void test_udp() { + webcpp::asio::io_context context; + const std::string message = "hello WASIp3"; + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + udp::endpoint peer; + std::array datagram{}; + int received_datagrams = 0; + receiver.async_receive_from(asio::buffer(datagram), peer, + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(size, message.size()); + BOOST_TEST(std::string(datagram.data(), size) == message); + ++received_datagrams; + }); + sender.async_send_to(asio::buffer(message), receiver.local_endpoint(), + [&](boost::system::error_code error, std::size_t size) { + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(size, message.size()); + }); + context.run(); // lint-run: drive a local datagram exchange + BOOST_TEST_EQ(received_datagrams, 1); +} + +#ifdef WEBCPP_TEST_WASI_THREADS +void test_threads() { +#ifndef BOOST_ASIO_HAS_THREADS +#error "The threaded test must compile Asio with thread support" +#endif + webcpp::asio::io_context context; + auto work = asio::make_work_guard(context); + int awakened = 0; + int wake_cancelled = 0; + webcpp::asio::steady_timer pending(context, 1h); + pending.async_wait([&](boost::system::error_code error) { + BOOST_TEST(error == asio::error::operation_aborted); + ++wake_cancelled; + }); + std::thread worker([&] { + std::this_thread::sleep_for(20ms); + asio::post(context, [&] { + ++awakened; + pending.cancel(); + work.reset(); + }); + }); + context.run(); // lint-run: wait for work posted by another thread + worker.join(); + BOOST_TEST_EQ(awakened, 1); + BOOST_TEST_EQ(wake_cancelled, 1); + + context.restart(); + std::atomic completions{0}; + for (int i = 0; i < 32; ++i) { + asio::post(context, [&] { ++completions; }); + } + std::thread runner([&] { + context.run(); // lint-run: share a context between two runners + }); + context.run(); // lint-run: the application's second runner + runner.join(); + BOOST_TEST_EQ(completions.load(), 32); +} +#endif + +} // namespace + +int main() { + test_timers(); + test_tcp(); + test_udp(); +#ifdef WEBCPP_TEST_WASI_THREADS + test_threads(); +#endif + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_coroutine_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_coroutine_test.cpp new file mode 100644 index 0000000..178dbdd --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_coroutine_test.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace asio = boost::asio; + +namespace { + +asio::awaitable wait_for_timer() { + const auto executor = co_await asio::this_coro::executor; + webcpp::asio::steady_timer timer(executor, std::chrono::milliseconds(5)); + auto [error] = co_await timer.async_wait(asio::as_tuple(asio::use_awaitable)); + BOOST_TEST(!error); + co_return error ? 0 : 42; +} + +} // namespace + +int main() { + webcpp::asio::io_context context; + int completions = 0; + asio::co_spawn(context, wait_for_timer(), [&](const std::exception_ptr& error, int value) { + BOOST_TEST(!error); + BOOST_TEST_EQ(value, 42); + ++completions; + }); + context.run(); // lint-run: resume an awaitable after a timer completion + BOOST_TEST_EQ(completions, 1); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_udp_gather_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_udp_gather_test.cpp new file mode 100644 index 0000000..1c7db12 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasi_udp_gather_test.cpp @@ -0,0 +1,243 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace { +namespace asio = boost::asio; +using udp = webcpp::asio::ip::udp; + +struct allocation_counts { + std::size_t calls = 0; + std::size_t live = 0; +}; + +template +struct counting_allocator { + using value_type = T; + allocation_counts* counts; + + explicit counting_allocator(allocation_counts& state) : counts(&state) {} + + template + explicit counting_allocator(const counting_allocator& other) noexcept + : counts(other.counts) {} + + T* allocate(std::size_t n) { + T* result = std::allocator{}.allocate(n); + ++counts->calls; + ++counts->live; + return result; + } + + void deallocate(T* pointer, std::size_t n) noexcept { + --counts->live; + std::allocator{}.deallocate(pointer, n); + } + + template + bool operator==(const counting_allocator& other) const noexcept { + return counts == other.counts; + } +}; + +// Wait for delivery after a successful send; the WASI launcher bounds the test. +void expect_packet(udp::socket& receiver, std::string_view expected) { + std::array bytes{}; + udp::endpoint peer; + boost::system::error_code error; + receiver.non_blocking(false); + const auto received = receiver.receive_from(asio::buffer(bytes), peer, 0, error); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(received, expected.size()); + BOOST_TEST(std::string_view(bytes.data(), received) == expected); + receiver.non_blocking(true); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(bytes), peer, 0, error), 0U); + BOOST_TEST(error == asio::error::would_block || error == asio::error::try_again); +} + +template +void check_sends(webcpp::asio::io_context& context, udp::socket& sender, udp::socket& receiver, + const Buffers& buffers, std::string_view expected) { + boost::system::error_code error; + BOOST_TEST_EQ(sender.send_to(buffers, receiver.local_endpoint(), 0, error), expected.size()); + BOOST_TEST_EQ(error, boost::system::error_code{}); + if (!error) { + expect_packet(receiver, expected); + } + + allocation_counts handler_allocations; + int completions = 0; + context.restart(); + sender.async_send_to(buffers, receiver.local_endpoint(), 0, + asio::bind_allocator(counting_allocator(handler_allocations), + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(ec, boost::system::error_code{}); + BOOST_TEST_EQ(size, expected.size()); + BOOST_TEST_EQ(handler_allocations.live, 0U); + error = ec; + ++completions; + })); + BOOST_TEST_EQ(completions, 0); + context.run(); // lint-run: complete the UDP send and release its owned storage + BOOST_TEST_EQ(completions, 1); + BOOST_TEST_EQ(handler_allocations.live, 0U); + if (!error) { + expect_packet(receiver, expected); + } +} + +void test_gather() { + allocation_counts context_allocations; + webcpp::asio::io_context context(std::allocator_arg, + counting_allocator(context_allocations)); + udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + receiver.non_blocking(true); + + const std::string header = "HEADER:"; + const std::string body = "Hello"; + const std::array pieces{ + asio::const_buffer{}, + asio::buffer(header), + asio::const_buffer{}, + asio::buffer(body), + }; + check_sends(context, sender, receiver, pieces, "HEADER:Hello"); + +#if defined(__wasip2__) || defined(__wasip3__) + // Gather the original sequence, before Asio's 64-entry iovec adapter. + std::array many{}; + many.fill(asio::buffer("x", 1)); + check_sends(context, sender, receiver, many, std::string(80, 'x')); + many.fill(asio::const_buffer{}); + many.front() = asio::buffer(header); + many.back() = asio::buffer(body); + check_sends(context, sender, receiver, many, "HEADER:Hello"); +#endif + + const std::array single{ + asio::const_buffer{}, + asio::buffer(body), + asio::const_buffer{}, + }; + check_sends(context, sender, receiver, single, "Hello"); + const std::array empty{}; + check_sends(context, sender, receiver, empty, ""); + +#if defined(__wasip2__) || defined(__wasip3__) + boost::system::error_code error; + const auto before = context_allocations.calls; + BOOST_TEST_EQ(sender.send_to(pieces, receiver.local_endpoint(), 0, error), 12U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(context_allocations.calls, before + 1); + if (!error) { + expect_packet(receiver, "HEADER:Hello"); + } + const auto after = context_allocations.calls; + BOOST_TEST_EQ(sender.send_to(single, receiver.local_endpoint(), 0, error), body.size()); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(sender.send_to(empty, receiver.local_endpoint(), 0, error), 0U); + BOOST_TEST_EQ(error, boost::system::error_code{}); + BOOST_TEST_EQ(context_allocations.calls, after); + // Drain these two messages separately; expect_packet checks for an empty queue. + std::array bytes{}; + udp::endpoint peer; + receiver.non_blocking(false); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(bytes), peer, 0, error), body.size()); + BOOST_TEST_EQ(error, boost::system::error_code{}); + expect_packet(receiver, ""); + + allocation_counts handler_allocations; + context.restart(); + int completed = 0; + const auto context_before_async = context_allocations.calls; + sender.async_send_to(pieces, receiver.local_endpoint(), + asio::bind_allocator(counting_allocator(handler_allocations), + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(ec, boost::system::error_code{}); + BOOST_TEST_EQ(size, 12U); + BOOST_TEST_EQ(handler_allocations.live, 0U); + error = ec; + ++completed; + })); + // One allocation owns the operation; a second owns the gathered bytes. + BOOST_TEST_EQ(handler_allocations.calls, 2U); + BOOST_TEST_EQ(context_allocations.calls, context_before_async); + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: check associated-allocator ownership through completion + BOOST_TEST_EQ(completed, 1); + if (!error) { + expect_packet(receiver, "HEADER:Hello"); + } + + // Reject an oversized datagram before allocating or reading its buffers. + const std::string large(65536, 'x'); + const std::array oversized{ + asio::buffer(large.data(), 65535), + asio::buffer(large.data() + 65535, 1), + }; + const auto before_oversized = context_allocations.calls; + BOOST_TEST_EQ(sender.send_to(oversized, receiver.local_endpoint(), 0, error), 0U); + BOOST_TEST_EQ(error, asio::error::message_size); + BOOST_TEST_EQ(context_allocations.calls, before_oversized); + context.restart(); + int rejected = 0; + sender.async_send_to(oversized, receiver.local_endpoint(), + [&](boost::system::error_code ec, std::size_t size) { + BOOST_TEST_EQ(ec, asio::error::message_size); + BOOST_TEST_EQ(size, 0U); + ++rejected; + }); + BOOST_TEST_EQ(rejected, 0); + context.run(); // lint-run: report invalid input through normal asynchronous completion + BOOST_TEST_EQ(rejected, 1); + receiver.non_blocking(true); + BOOST_TEST_EQ(receiver.receive_from(asio::buffer(bytes), peer, 0, error), 0U); + BOOST_TEST(error == asio::error::would_block || error == asio::error::try_again); +#endif +} + +#if defined(__wasip2__) || defined(__wasip3__) +void test_shutdown() { + allocation_counts allocations; + int completions = 0; + { + webcpp::asio::io_context context; + const udp::socket receiver(context, {asio::ip::address_v4::loopback(), 0}); + udp::socket sender(context, udp::v4()); + const std::array pieces{asio::buffer("a", 1), asio::buffer("b", 1)}; + sender.async_send_to( + pieces, receiver.local_endpoint(), + asio::bind_allocator(counting_allocator(allocations), + [&](boost::system::error_code, std::size_t) { ++completions; })); + BOOST_TEST_EQ(allocations.live, 2U); + // Destroy the context without running the queued completion handler. + } + BOOST_TEST_EQ(completions, 0); + BOOST_TEST_EQ(allocations.live, 0U); +} +#endif +} // namespace + +int main() { + test_gather(); +#if defined(__wasip2__) || defined(__wasip3__) + test_shutdown(); +#endif + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/Jamfile new file mode 100644 index 0000000..d60779d --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/Jamfile @@ -0,0 +1,33 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project : requirements /webcpp/asio//asio ; +import webcpp ; +webcpp.targets wasip2 ; + +# Exercise the same public timer, stream and datagram contracts as WASIp3. +webcpp.run core : ../wasi_core_test.cpp : : wasip2 ; +webcpp.run contract : ../wasi_contract_test.cpp : : wasip2 ; +webcpp.run udp_gather : ../wasi_udp_gather_test.cpp : : wasip2 ; +webcpp.run coroutine : ../wasi_coroutine_test.cpp : : wasip2 ; +webcpp.run pollable : pollable_test.cpp : : wasip2 ; +webcpp.run resolver : resolver_test.cpp : : wasip2 ; +webcpp.run run_family : ../run_family_test.cpp : : wasip2 ; +webcpp.run timers : ../timers_test.cpp : : wasip2 ; +webcpp.run write_permit : write_permit_test.cpp + : -Wl,--wrap=streams_method_output_stream_check_write : wasip2 ; +webcpp.run pending_write : write_permit_test.cpp + : WEBCPP_TEST_PENDING_WRITE + -Wl,--wrap=streams_method_output_stream_check_write + -Wl,--wrap=streams_method_output_stream_subscribe : wasip2 ; +webcpp.original python3 : . ; +webcpp.drive stdio : stdio_test.cpp : /webcpp//node-test : stdio_driver.py : : wasip2 ; +webcpp.lane supplied-stream : stdio : wasip2 ; +webcpp.drive idle : idle_test.cpp : /webcpp//node-test : idle_driver.py : : wasip2 ; +webcpp.lane scheduler-idle : idle : wasip2 ; + +webcpp.headers-alone asio : ../../include : asio/wasi/*.hpp + asio/detail/wasi_pollable_descriptor.hpp : : wasip2 ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/counting_allocator.hpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/counting_allocator.hpp new file mode 100644 index 0000000..d8bec95 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/counting_allocator.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_ASIO_TEST_P2_COUNTING_ALLOCATOR_HPP +#define WEBCPP_ASIO_TEST_P2_COUNTING_ALLOCATOR_HPP +#include + +struct counts { + unsigned allocations = 0; + unsigned live = 0; +}; + +template +struct allocator { + using value_type = T; + counts* counter; + + explicit allocator(counts& value) : counter(&value) {} + + template + explicit allocator(allocator const& other) : counter(other.counter) {} + + T* allocate(std::size_t size) { + ++counter->allocations; + ++counter->live; + return std::allocator{}.allocate(size); + } + + void deallocate(T* ptr, std::size_t size) { + --counter->live; + std::allocator{}.deallocate(ptr, size); + } + + template + bool operator==(allocator const& other) const { + return counter == other.counter; + } +}; + +#endif diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/idle_driver.py b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/idle_driver.py new file mode 100644 index 0000000..e8a33ea --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/idle_driver.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +"""An external watchdog verifies idle waits without relying on a guest timer.""" +import os +import select +import subprocess +import sys + +for arguments in ([], ['reactor']): + command = [os.environ.get('WASMTIME', 'wasmtime'), 'run', '-W', 'fuel=10000000', + sys.argv[-1], *arguments] + with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as guest: + assert guest.stdout is not None + try: + assert select.select([guest.stdout], [], [], 10)[0], 'guest did not start' + line = guest.stdout.readline() + if line != b'ready\n': + _, errors = guest.communicate(timeout=5) + raise AssertionError(('guest startup', line, errors)) + try: + output, errors = guest.communicate(timeout=0.3) + except subprocess.TimeoutExpired: + pass + else: + raise AssertionError(('idle run exited', guest.returncode, output, errors)) + finally: + if guest.poll() is None: + guest.kill() + guest.wait() +print('Guard-only and reactor idle waits stayed blocked without exhausting fuel') diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/idle_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/idle_test.cpp new file mode 100644 index 0000000..5982cf1 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/idle_test.cpp @@ -0,0 +1,25 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include + +int main(int argc, char** /*argv*/) { + webcpp::asio::io_context context; + auto const guard = boost::asio::make_work_guard(context); + std::optional timer; + if (argc > 1) { + timer.emplace(context, std::chrono::milliseconds(0)); + timer->async_wait([](boost::system::error_code) {}); + } + if (std::puts("ready") < 0 || std::fflush(stdout) != 0) { + return 2; + } + context.run(); // lint-run: a live guard must wait indefinitely without trapping or spinning + return 3; +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/package-lock.json b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/package-lock.json new file mode 100644 index 0000000..61e5951 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "webcpp-asio-wasip2-tests", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "webcpp-asio-wasip2-tests", + "version": "0.0.0", + "license": "BSL-1.0" + } + } +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/package.json b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/package.json new file mode 100644 index 0000000..0588552 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/package.json @@ -0,0 +1,7 @@ +{ + "name": "webcpp-asio-wasip2-tests", + "version": "0.0.0", + "private": true, + "license": "BSL-1.0", + "description": "Local Python driver for WASIp2 supplied stream tests; no npm dependencies." +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/pollable_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/pollable_test.cpp new file mode 100644 index 0000000..1b08729 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/pollable_test.cpp @@ -0,0 +1,55 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +void check_readiness(std::uint64_t delay) { + webcpp::asio::io_context context; + auto const ready = monotonic_clock_subscribe_duration(delay); + webcpp::asio::detail::wasi_pollable_descriptor storage{}; + storage.handle = ready.__handle; + auto const fd = webcpp_asio_wasi_pollable_descriptor(&storage); + BOOST_TEST(fd >= 0); + if (fd < 0) { + poll_pollable_drop_own(ready); + return; + } + boost::asio::posix::stream_descriptor descriptor(context, fd); + webcpp::asio::steady_timer timer(context, std::chrono::milliseconds(1)); + int callbacks = 0; + bool timer_fired = false; + timer.async_wait([&](boost::system::error_code error) { + BOOST_TEST(!error); + timer_fired = true; + }); + descriptor.async_wait(boost::asio::posix::stream_descriptor::wait_read, + [&](boost::system::error_code error) { + BOOST_TEST(!error); + ++callbacks; + }); + BOOST_TEST_EQ(callbacks, 0); + context.run(); // lint-run: wait for a native pollable alongside an Asio timer + BOOST_TEST_EQ(callbacks, 1); + BOOST_TEST(timer_fired); + descriptor.close(); + BOOST_TEST(!storage.active); + poll_pollable_drop_own(ready); +} +} // namespace + +int main() { + check_readiness(0); // Ready before registration must not lose a wakeup. + check_readiness(20000000); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/resolver_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/resolver_test.cpp new file mode 100644 index 0000000..0f39374 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/resolver_test.cpp @@ -0,0 +1,155 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "counting_allocator.hpp" + +namespace { +void initiation_and_cancellation() { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + webcpp::asio::io_context context; + webcpp::asio::io_context completions; + tcp::resolver resolver(context); + int completed = 0; + auto lazy = resolver.async_resolve("localhost", "80", asio::deferred); + BOOST_TEST_EQ(context.poll(), 0U); + context.restart(); + std::move(lazy)(asio::bind_executor( + completions.get_executor(), + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST(!ec); + BOOST_TEST(!result.empty()); + for (auto const& entry : result) { + BOOST_TEST_EQ(entry.endpoint().port(), 80); + } + ++completed; + })); + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: the lookup must not invoke another executor's handler + BOOST_TEST_EQ(completed, 0); + completions.run(); // lint-run: deliver on the associated executor + BOOST_TEST_EQ(completed, 1); + + context.restart(); + resolver.async_resolve( + "localhost", "80", + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST_EQ(ec, asio::error::operation_aborted); + BOOST_TEST(result.empty()); + ++completed; + }); + resolver.cancel(); + context.run(); // lint-run: cancellation before the lookup starts + BOOST_TEST_EQ(completed, 2); + + context.restart(); + asio::cancellation_signal cancel; + resolver.async_resolve( + "localhost", "80", + asio::bind_cancellation_slot(cancel.slot(), [&](boost::system::error_code ec, + const tcp::resolver::results_type& result) { + BOOST_TEST_EQ(ec, asio::error::operation_aborted); + BOOST_TEST(result.empty()); + ++completed; + })); + cancel.emit(asio::cancellation_type::all); + context.run(); // lint-run: per-operation cancellation + BOOST_TEST_EQ(completed, 3); + + context.restart(); + resolver.async_resolve( + "127.0.0.1", "443", tcp::resolver::numeric_host, + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST(!ec); + BOOST_TEST_EQ(result.size(), 1U); + if (!result.empty()) { + BOOST_TEST_EQ(result.begin()->endpoint().port(), 443); + } + ++completed; + }); + context.run(); // lint-run: numeric addresses never require DNS + BOOST_TEST_EQ(completed, 4); +} + +void resources_and_errors() { + namespace asio = boost::asio; + using tcp = webcpp::asio::ip::tcp; + webcpp::asio::io_context context; + tcp::resolver resolver(context); + int completed = 0; + resolver.async_resolve( + "localhost", "80", + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST_EQ(ec, asio::error::operation_aborted); + BOOST_TEST(result.empty()); + ++completed; + }); + BOOST_TEST_EQ(context.poll_one(), 1U); // Start the native lookup, leave its completion queued. + resolver.cancel(); + context.run(); // lint-run: cancel after registration with the pollable reactor + BOOST_TEST_EQ(completed, 1); + + context.restart(); + resolver.async_resolve( + "localhost", "80", tcp::resolver::canonical_name, + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST_EQ(ec, asio::error::operation_not_supported); + BOOST_TEST(result.empty()); + ++completed; + }); + context.run(); // lint-run: unsupported flags fail deliberately and asynchronously + BOOST_TEST_EQ(completed, 2); + context.restart(); + counts allocations; + resolver.async_resolve( + "localhost", "80", + asio::bind_allocator( + allocator(allocations), + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST(!ec); + BOOST_TEST(!result.empty()); + BOOST_TEST(allocations.allocations >= + 2); // Operation and endpoint scratch storage. + BOOST_TEST_EQ(allocations.live, 0U); // Scratch storage is freed before the upcall. + ++completed; + })); + context.run(); // lint-run: verify associated allocation and deallocation before completion + BOOST_TEST_EQ(completed, 3); + + context.restart(); + resolver.async_resolve( + "invalid host name", "80", + [&](boost::system::error_code ec, const tcp::resolver::results_type& result) { + BOOST_TEST(ec == asio::error::invalid_argument || ec == asio::error::host_not_found); + BOOST_TEST(result.empty()); + ++completed; + }); + context.run(); // lint-run: malformed names report a value without an initiation-time failure + BOOST_TEST_EQ(completed, 4); + { + webcpp::asio::io_context abandoned; + tcp::resolver pending(abandoned); + pending.async_resolve("localhost", "80", + [&](auto, const auto&) { BOOST_ERROR("abandoned callback"); }); + BOOST_TEST_EQ(abandoned.poll_one(), 1U); + } +} + +} // namespace + +int main() { + initiation_and_cancellation(); + resources_and_errors(); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/stdio_driver.py b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/stdio_driver.py new file mode 100644 index 0000000..9a88544 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/stdio_driver.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +"""Keep the guest's input open and empty while it checks readiness cancellation.""" +import os +import subprocess +import sys +import tempfile + +command = [os.environ.get('WASMTIME', 'wasmtime'), 'run', '-W', 'timeout=15s', sys.argv[-1]] +with tempfile.TemporaryFile() as output, tempfile.TemporaryFile() as diagnostics: + with subprocess.Popen(command, + stdin=subprocess.PIPE, stdout=output, stderr=diagnostics) as guest: + try: + status = guest.wait(timeout=20) + finally: + if guest.poll() is None: + guest.kill() + guest.wait() + diagnostics.seek(0) + text = diagnostics.read().decode() + assert status == 0, (status, text) + output.seek(0) + assert output.read() == b'' + print(text, end='') +print('WASIp2 supplied stream: timer cancellation, slot, destruction, ' + 'allocator and executor passed') diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/stdio_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/stdio_test.cpp new file mode 100644 index 0000000..00e400c --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/stdio_test.cpp @@ -0,0 +1,116 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "counting_allocator.hpp" + +int main() { + namespace asio = boost::asio; + using stream_type = webcpp::asio::wasi::stdio_stream; + webcpp::asio::io_context context; + stream_type stream(context.get_executor()); + std::array data{}; + counts counter; + int completed = 0; + webcpp::asio::steady_timer timer(context, std::chrono::milliseconds(5)); + timer.async_wait([&](auto error) { + BOOST_TEST(!error); + stream.cancel(); + }); + stream.async_read_some( + asio::buffer(data), + asio::bind_allocator(allocator(counter), + [&](boost::system::error_code error, std::size_t count) { + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST_EQ(count, 0U); + BOOST_TEST(counter.allocations > 0); + BOOST_TEST_EQ(counter.live, 0U); + ++completed; + })); + BOOST_TEST_EQ(completed, 0); + context.run(); // lint-run: timer must progress while the host keeps input open and empty + BOOST_TEST_EQ(completed, 1); + + context.restart(); + asio::cancellation_signal signal; + stream.async_read_some( + asio::buffer(data), + asio::bind_cancellation_slot(signal.slot(), + [&](boost::system::error_code error, std::size_t count) { + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST_EQ(count, 0U); + ++completed; + })); + signal.emit(asio::cancellation_type::all); + context.run(); // lint-run: cancellation before initial posted work + BOOST_TEST_EQ(completed, 2); + + context.restart(); + { + stream_type temporary(context.get_executor()); + temporary.async_read_some(asio::buffer(data), + [&](boost::system::error_code error, std::size_t count) { + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST_EQ(count, 0U); + ++completed; + }); + BOOST_TEST_EQ(context.poll_one(), 1U); + } + context.run(); // lint-run: destroying the stream cancels its outstanding read safely + BOOST_TEST_EQ(completed, 3); + + context.restart(); + webcpp::asio::io_context target; + stream.async_read_some( + asio::mutable_buffer{}, + asio::bind_executor(target.get_executor(), + [&](boost::system::error_code error, std::size_t count) { + BOOST_TEST(!error); + BOOST_TEST_EQ(count, 0U); + ++completed; + })); + context.poll(); // Both contexts are single-threaded: poll one, then drive the other. + BOOST_TEST_EQ(completed, 3); + target.run(); // lint-run: deliver the zero-length read without consuming input + BOOST_TEST_EQ(completed, 4); + context.restart(); + auto deferred_read = stream.async_read_some(asio::buffer(data), asio::deferred); + stream.cancel(); // No read was initiated yet; this must not cancel the deferred operation. + bool cancelled_by_timer = false; + timer.expires_after(std::chrono::milliseconds(5)); + timer.async_wait([&](auto error) { + BOOST_TEST(!error); + cancelled_by_timer = true; + stream.cancel(); + }); + std::move(deferred_read)([&](boost::system::error_code error, std::size_t count) { + BOOST_TEST(cancelled_by_timer); + BOOST_TEST_EQ(error, asio::error::operation_aborted); + BOOST_TEST_EQ(count, 0U); + ++completed; + }); + context.run(); // lint-run: cancellation is scoped to initiated operations + BOOST_TEST_EQ(completed, 5); + { + webcpp::asio::io_context abandoned; + stream_type pending(abandoned.get_executor()); + pending.async_read_some(asio::buffer(data), + [&](auto, auto) { BOOST_ERROR("abandoned callback"); }); + BOOST_TEST_EQ(abandoned.poll_one(), 1U); + } + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/write_permit_test.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/write_permit_test.cpp new file mode 100644 index 0000000..37f70cd --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2/write_permit_test.cpp @@ -0,0 +1,95 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WEBCPP_TEST_PENDING_WRITE +namespace { +std::optional& tested_stream() { + static std::optional handle; + return handle; +} +} // namespace + +extern "C" streams_own_pollable_t real_subscribe(streams_borrow_output_stream_t stream) asm( + "__real_streams_method_output_stream_subscribe"); +#endif + +// Linker wrappers model valid host quotas at the WASI C boundary. The large +// quota case still writes real bytes to Wasmtime stdout. The pending case +// supplies a native clock pollable that will not become ready during the test. +extern "C" bool real_check_write( + streams_borrow_output_stream_t stream, uint64_t* capacity, + streams_stream_error_t* error) asm("__real_streams_method_output_stream_check_write"); +extern "C" bool wrapped_check_write( + streams_borrow_output_stream_t stream, uint64_t* capacity, + streams_stream_error_t* error) asm("__wrap_streams_method_output_stream_check_write"); + +extern "C" bool wrapped_check_write(streams_borrow_output_stream_t stream, uint64_t* capacity, + streams_stream_error_t* error) { +#ifdef WEBCPP_TEST_PENDING_WRITE + if (tested_stream() == stream.__handle) { + *capacity = 0; + return true; + } + return real_check_write(stream, capacity, error); +#else + if (!real_check_write(stream, capacity, error)) { + return false; + } + if (*capacity != 0) { + *capacity = uint64_t{1} << 32u; + } + return true; +#endif +} + +#ifdef WEBCPP_TEST_PENDING_WRITE +extern "C" streams_own_pollable_t wrapped_subscribe(streams_borrow_output_stream_t stream) asm( + "__wrap_streams_method_output_stream_subscribe"); + +extern "C" streams_own_pollable_t wrapped_subscribe(streams_borrow_output_stream_t stream) { + if (!tested_stream()) { + tested_stream() = stream.__handle; + return monotonic_clock_subscribe_instant(std::numeric_limits::max()); + } + return real_subscribe(stream); +} +#endif + +int main() { + webcpp::asio::io_context context; + webcpp::asio::wasi::stdio_stream stream(context.get_executor()); + webcpp::asio::steady_timer timer(context); + int calls = 0; +#ifdef WEBCPP_TEST_PENDING_WRITE + timer.expires_after(std::chrono::milliseconds(5)); + timer.async_wait([&](boost::system::error_code error) { + BOOST_TEST(!error); + stream.cancel(); + }); +#endif + stream.async_write_some(boost::asio::buffer("ping", 4), + [&](boost::system::error_code error, std::size_t transferred) { +#ifdef WEBCPP_TEST_PENDING_WRITE + BOOST_TEST_EQ(error, boost::asio::error::operation_aborted); + BOOST_TEST_EQ(transferred, 0U); +#else + BOOST_TEST(!error); + BOOST_TEST_EQ(transferred, 4U); +#endif + ++calls; + }); + context.run(); // lint-run: exercise host quota conversion and pending-write cancellation + BOOST_TEST_EQ(calls, 1); + return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/Jamfile b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/Jamfile new file mode 100644 index 0000000..6e19da0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/Jamfile @@ -0,0 +1,39 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project : requirements /webcpp/asio//asio /webcpp//node-test ; +import webcpp ; +webcpp.targets wasip2 ; +webcpp.run cobalt : ../cobalt_test.cpp : /webcpp/asio//cobalt : wasip2 ; +webcpp.run cobalt_network : ../cobalt_network_test.cpp : /webcpp/asio//cobalt : wasip2 ; +webcpp.run cobalt_io : ../cobalt_io_test.cpp : /webcpp/asio//cobalt : wasip2 ; +webcpp.run cobalt_accept_cancel : ../cobalt_accept_cancel_test.cpp + : /webcpp/asio//cobalt : wasip2 ; +webcpp.run cobalt_cancel : cobalt_cancel.cpp : /webcpp/asio//cobalt : wasip2 ; +webcpp.original python3 : ../wasip2 ; +webcpp.drive entropy : ../../../../tools/openssl/test/entropy.c + : /webcpp/third_party//openssl -Wl,--wrap=getentropy + : entropy_driver.py : : wasip2 ; +webcpp.drive cobalt_status : ../cobalt_status_test.cpp : /webcpp/asio//cobalt + : status_driver.py : : wasip2 ; +for local test in tls_client tls_client_embedded cobalt_tls_client cobalt_ssl_client + cobalt_ssl_state cobalt_ssl_cancel +{ + local args ; + local library = /webcpp/asio//tls ; + if $(test) = cobalt_tls_client { library += /webcpp/asio//cobalt ; } + if $(test) in cobalt_ssl_client cobalt_ssl_state cobalt_ssl_cancel + { library = /webcpp/asio//cobalt_ssl ; } + if $(test) != tls_client { args = --embedded ; } + if $(test) = cobalt_ssl_client { args += --require-sni ; } + if $(test) in cobalt_ssl_state cobalt_ssl_cancel { args = --state-test ; } + webcpp.drive $(test) : ../../../../tools/openssl/test/$(test).cpp + : $(library) 180 + ../../../../tools/openssl/test/tls.py + : tls_driver.py : $(args) : wasip2 ; +} +webcpp.lane wasip2-tls : entropy cobalt_status tls_client tls_client_embedded + cobalt_tls_client cobalt_ssl_client cobalt_ssl_state cobalt_ssl_cancel : wasip2 ; diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/cobalt_cancel.cpp b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/cobalt_cancel.cpp new file mode 100644 index 0000000..8100460 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/cobalt_cancel.cpp @@ -0,0 +1,70 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace cobalt = boost::cobalt; +namespace io = cobalt::io; +namespace asio = boost::asio; + +namespace { +cobalt::promise resolve_cancelled(io::resolver& resolver) { + const auto [error, endpoints] = co_await cobalt::as_tuple(resolver.resolve("localhost", "443")); + BOOST_TEST(error == asio::error::operation_aborted); + BOOST_TEST(endpoints.empty()); +} + +cobalt::promise timer_cancelled(io::steady_timer& timer) { + const auto [error] = co_await cobalt::as_tuple(timer.wait()); + BOOST_TEST(error == asio::error::operation_aborted); +} +} // namespace + +cobalt::main co_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + const auto exec = co_await cobalt::this_coro::executor; + asio::steady_timer watchdog(exec, std::chrono::seconds(5)); + watchdog.async_wait([](boost::system::error_code error) { + if (!error) { + std::abort(); + } + }); + io::resolver resolver(exec); + auto pending = resolve_cancelled(resolver); + BOOST_TEST(!pending.ready()); + resolver.cancel(); + co_await pending; + auto signal_cancelled = resolve_cancelled(resolver); + BOOST_TEST(!signal_cancelled.ready()); + signal_cancelled.cancel(); + co_await signal_cancelled; + + io::lookup lookup("localhost", "443", exec); + const auto [error, endpoints] = co_await cobalt::as_tuple(lookup); + BOOST_TEST(!error); + BOOST_TEST(!endpoints.empty()); + + io::steady_timer timer(std::chrono::hours(1), exec); + auto waiting = timer_cancelled(timer); + BOOST_TEST(!waiting.ready()); + waiting.cancel(); + co_await waiting; + watchdog.cancel(); + std::puts("cobalt: forward lookup, resolver cancellation and timer cancellation checked"); + co_return webcpp::test::exit_status(boost::report_errors()); +} diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/entropy_driver.py b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/entropy_driver.py new file mode 100644 index 0000000..1ca8239 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/entropy_driver.py @@ -0,0 +1,24 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Require actual host entropy, independent keys and fail-closed RNG failures.""" +import os +import subprocess +import sys + +launcher = [os.environ.get('WASMTIME', 'wasmtime'), 'run', '-W', 'timeout=15s', sys.argv[-1]] +keys = set() +for _ in range(3): + result = subprocess.run(launcher, capture_output=True, text=True, timeout=20, check=True) + print(result.stdout, end='') + assert 'PASS random, reseed, EC P-256, ECDSA, tamper rejection:' in result.stdout + key = next(line for line in result.stdout.splitlines() if line.startswith('PUBLIC_KEY=')) + assert key not in keys, 'Independent processes generated the same public key' + keys.add(key) +result = subprocess.run([*launcher, 'fail-entropy'], capture_output=True, text=True, + timeout=20, check=True) +print(result.stdout, end='') +assert 'PASS fail-closed:' in result.stdout, result.stdout + result.stderr diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/status_driver.py b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/status_driver.py new file mode 100644 index 0000000..e6c9c96 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/status_driver.py @@ -0,0 +1,18 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Require a resumed Cobalt main to return both success and failure without traps.""" +import os +import subprocess +import sys + +for status, arguments in ((7, []), (0, ['zero'])): + result = subprocess.run([os.environ.get('WASMTIME', 'wasmtime'), 'run', '-W', 'timeout=8s', + sys.argv[-1], *arguments], capture_output=True, text=True, timeout=10) + assert result.returncode == (1 if status else 0), result.stdout + result.stderr + assert result.stdout.strip() == f'cobalt: returning {status}', result.stdout + assert result.stderr == '', result.stderr + print(f'cobalt: return {status}, exact host exit status {result.returncode}') diff --git a/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/tls_driver.py b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/tls_driver.py new file mode 100644 index 0000000..f016550 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/source/test/wasip2_tls_cobalt/tls_driver.py @@ -0,0 +1,14 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Drive the shared real TLS peer against the WASIp2 public consumer.""" +from pathlib import Path +import subprocess +import sys + +script = Path(__file__).resolve().parents[4] / 'tools/openssl/test/tls.py' +subprocess.run([sys.executable, str(script), sys.argv[-1], '--wasip2', *sys.argv[1:-1]], + check=True, timeout=170) diff --git a/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0011-tools-keep-variant-link-dependencies-out-of-artifact-consumers.patch b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0011-tools-keep-variant-link-dependencies-out-of-artifact-consumers.patch new file mode 100644 index 0000000..86ca975 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0011-tools-keep-variant-link-dependencies-out-of-artifact-consumers.patch @@ -0,0 +1,137 @@ +From 35c8aa78ef8752c595b5eea8e307f3c304f2ae81 Mon Sep 17 00:00:00 2001 +From: R +Date: Wed, 14 Oct 2026 13:10:30 -0400 +Subject: [PATCH] tools: keep variant link dependencies out of artifact + consumers + +--- + AGENTS.md | 8 +++++++ + tools/test/emscripten_test.py | 39 +++++++++++++++++++++++++++++++++++ + tools/webcpp.jam | 25 +++++++++++++++++++++- + 3 files changed, 71 insertions(+), 1 deletion(-) + +diff --git a/AGENTS.md b/AGENTS.md +index 65fe5aa..a5214f7 100644 +--- a/AGENTS.md ++++ b/AGENTS.md +@@ -1677,6 +1677,14 @@ webcpp.variants shell : shell.cpp ; + webcpp.size-table shell : shell ; + ``` + ++A `webcpp.variants` executable consumes its library usage requirements at ++its own link and exports none to downstream consumers. A driver can pass ++the explicit target reference `.//shell` to `webcpp.drive`, with ++`shell.variants.json`, without linking the libraries' source ++objects again or combining the two suspension variants. The driver must ++not inherit the page program's library requirements; apply those to the ++page program itself. ++ + **WebAssembly components** (`tools/component/component.jam`). A library's + `build.jam` declares the C bindings of a world, and its test and example + Jamfiles the HTTP components that wasmtime serves: +diff --git a/tools/test/emscripten_test.py b/tools/test/emscripten_test.py +index 84e183d..4e6b582 100644 +--- a/tools/test/emscripten_test.py ++++ b/tools/test/emscripten_test.py +@@ -357,6 +357,44 @@ def test_variants_write_the_manifest_beside_the_jspi_artifact(root): + assert '-sEXPORT_ES6' in link_line(root, result, 'shell-60-d-asyncify') + + ++def test_variants_can_be_driven_without_relinking_dependencies(root): ++ # A library's source usage belongs to each linked variant, not to its consumer. ++ folder = root / 'libs/browser_demo/test/variants' ++ library = root / 'libs/browser_demo/build.jam' ++ library.write_text(library.read_text() + "\nobj support : support.cpp ;\n" ++ "alias supported : : : : support include ;\n") ++ (library.parent / 'support.cpp').write_text('int support() { return 7; }\n') ++ (folder / 'shell.cpp').write_text('#include \nint support();\n' ++ 'int main() { std::printf("support=%d\\n", support()); }\n') ++ jam = folder / 'Jamfile' ++ jam.write_text(jam.read_text().replace( ++ 'webcpp.variants shell : shell.cpp ;', ++ 'webcpp.variants shell : shell.cpp : /webcpp/browser_demo//supported ;') ++ + '\nwebcpp.targets emscripten ;\nwebcpp.original node ;\n' ++ 'webcpp.drive loads : .//shell : shell.variants.json : load.mjs ;\n' ++ 'webcpp.lane load : loads : emscripten ;\n') ++ for name in ('package.json', 'package-lock.json'): ++ (folder / name).write_bytes((folder.parent / 'driver' / name).read_bytes()) ++ (folder / 'load.mjs').write_text("""import assert from 'node:assert/strict' ++import {readFileSync} from 'node:fs' ++import {dirname, join} from 'node:path' ++import {pathToFileURL} from 'node:url' ++const manifestUrl = pathToFileURL(join(dirname(process.argv.at(-1)), 'shell.variants.json')) ++const manifest = JSON.parse(readFileSync(manifestUrl, 'utf8')) ++for (const variant of ['jspi', 'asyncify']) { ++ const lines = [] ++ const {default: factory} = await import(new URL(manifest[variant].script, manifestUrl)) ++ await factory({print: line => lines.push(line)}) ++ assert.deepEqual(lines, ['support=7']) ++} ++console.log('both linked variants loaded') ++""") ++ result = harness.run_b2(root, '-a', '-d+2', *EMSCRIPTEN, ++ 'libs/browser_demo/test/variants//load') ++ harness.expect(result, True, 'both linked variants loaded') ++ assert passed(result) == {'loads'}, (passed(result), result.stdout[-4000:]) ++ ++ + def test_variants_asked_for_with_javascript_exceptions_are_refused(root): + # b2 cannot take an optional property back from a request: the jspi variant would be linked + # with JavaScript exceptions, and the manifest and the size table would give it as jspi's. +@@ -529,6 +567,7 @@ CASES = [prepared(case) for case in ( + test_link_only_unresolved_symbol_fails, + test_artifacts_are_named_boost_s_way, + test_variants_write_the_manifest_beside_the_jspi_artifact, ++ test_variants_can_be_driven_without_relinking_dependencies, + test_variants_asked_for_with_javascript_exceptions_are_refused, + test_the_size_table_lists_every_variant, + test_variants_are_not_built_natively, +diff --git a/tools/webcpp.jam b/tools/webcpp.jam +index e4a44c9..c59d58b 100644 +--- a/tools/webcpp.jam ++++ b/tools/webcpp.jam +@@ -89,6 +89,7 @@ import project ; + import regex ; + import sequence ; + import set ; ++import targets ; + import testing ; + import toolset ; + +@@ -472,10 +473,32 @@ rule suspend-tag ( name : type ? : property-set ) + # size of its .wasm, which webcpp-asio-loader.mjs reads. Never run by + # node: no -sNODERAWFS=1. The manifest builds both variants itself, so a + # build that asks for one of them is refused (variants-request). ++# A page program is a finished executable, not a link dependency. Its ++# library usage requirements have already been consumed by its own link. ++# Exporting them would make a driver or a manifest consumer link those ++# sources again, combining objects from incompatible suspension variants. ++class variant-program : typed-target ++{ ++ import property-set ; ++ ++ rule __init__ ( name : project : sources * : requirements * ++ : default-build * : usage-requirements * ) ++ { ++ typed-target.__init__ $(name) : $(project) : EXE : $(sources) ++ : $(requirements) : $(default-build) : $(usage-requirements) ; ++ } ++ ++ rule compute-usage-requirements ( subvariant ) ++ { ++ return [ property-set.empty ] ; ++ } ++} ++ + rule variants ( name : sources + : requirements * ) + { + local only = emscripten @webcpp%filter ; +- exe $(name) : $(sources) ++ targets.create-metatarget variant-program : [ project.current ] ++ : $(name) : $(sources) + : $(requirements) $(only) $(.handler) @webcpp%suspend-tag + -sMODULARIZE -sEXPORT_ES6 ; + local found = [ where ] ; +-- +2.55.0 + diff --git a/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0012-tools-ci-asio-browser-lane-gets-pinned-Chrome.patch b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0012-tools-ci-asio-browser-lane-gets-pinned-Chrome.patch new file mode 100644 index 0000000..39ee5e0 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0012-tools-ci-asio-browser-lane-gets-pinned-Chrome.patch @@ -0,0 +1,79 @@ +From 3d069a16728cb1a86dc3070658399b0f747649bc Mon Sep 17 00:00:00 2001 +From: R +Date: Wed, 14 Oct 2026 13:19:08 -0400 +Subject: [PATCH] tools/ci: asio's browser lane gets the pinned Chrome + +--- + AGENTS.md | 3 ++- + tools/ci/matrix.py | 4 ++-- + tools/ci/matrix_test.py | 14 ++++++++++++-- + 3 files changed, 16 insertions(+), 5 deletions(-) + +diff --git a/AGENTS.md b/AGENTS.md +index a5214f7..68d09a5 100644 +--- a/AGENTS.md ++++ b/AGENTS.md +@@ -2230,7 +2230,8 @@ jobs: + kind `programs` on any other target, such as wasi's served lanes, has + none. + - An own lane whose driver meets a browser, one of `CHROME_LANES` in +- `tools/ci/matrix.py` (trystero's `interop`, natively and on emscripten), ++ `tools/ci/matrix.py` (trystero's `interop`, natively and on emscripten, ++ document's `js`, and asio's `browser`), + has its entry's `chrome`, and its job runs the `chrome` action, which + gives it `CHROME`, a pinned Chrome rather than the image's, which moves + with the image, so that a red interop lane is never a browser nobody +diff --git a/tools/ci/matrix.py b/tools/ci/matrix.py +index 5bc03a2..94ad20f 100755 +--- a/tools/ci/matrix.py ++++ b/tools/ci/matrix.py +@@ -190,8 +190,8 @@ CONTAINER_IMAGE = container_tag() + + # The own lanes whose driver meets a browser, (library, lane), which the CI's chrome action gives + # its pinned chrome-headless-shell, as CHROME: trystero's interop, natively and on emscripten, and +-# document's js, whose examples Playwright runs in Chrome. +-CHROME_LANES = {('document', 'js'), ('trystero', 'interop')} ++# document's js, whose examples Playwright runs in Chrome, and asio's browser lane. ++CHROME_LANES = {('asio', 'browser'), ('document', 'js'), ('trystero', 'interop')} + + # MSVC's lanes build 64-bit programs, embed their manifest with the linker and abbreviate b2's + # paths against Windows's MAX_PATH, as xstate-cpp's green Windows jobs did. b2 abbreviates each +diff --git a/tools/ci/matrix_test.py b/tools/ci/matrix_test.py +index eba357e..36c2fd3 100755 +--- a/tools/ci/matrix_test.py ++++ b/tools/ci/matrix_test.py +@@ -1092,12 +1092,21 @@ def test_a_container_lane_has_its_image_from_the_cache(_): + assert 'if: matrix.container\n' in steps[container[0]], steps[container[0]] + + ++def test_asio_browser_lane_receives_chrome(root): ++ # The browser driver needs Chrome when the lane is scheduled, on emscripten alone. ++ own = matrix.OwnLane('asio', 'browser', ('libs/asio/test/browser',), ++ 'emscripten', 'original') ++ entry = own_lane_entry_of(own) ++ assert entry['chrome'] is True, entry ++ ++ + def test_a_browser_lane_has_the_pinned_chrome(root): +- # An own lane whose driver meets a browser, trystero's interop and document's js ++ # An own lane whose driver meets a browser, asio's browser, trystero's interop and document's js + # (CHROME_LANES), says chrome, on every target it runs on, and its job installs the pinned + # chrome-headless-shell, which gives CHROME; no other own lane does, and no job names the + # image's Chrome. +- assert matrix.CHROME_LANES == {('document', 'js'), ('trystero', 'interop')}, matrix.CHROME_LANES ++ assert matrix.CHROME_LANES == { ++ ('asio', 'browser'), ('document', 'js'), ('trystero', 'interop')}, matrix.CHROME_LANES + boost_only(root) + external_library(root) + oracle_library(root, 'beta') +@@ -1307,6 +1316,7 @@ CASES = [ + test_whether_a_library_has_external_dependencies, + test_the_jobs_install_the_external_dependencies, + test_a_container_lane_has_its_image_from_the_cache, ++ test_asio_browser_lane_receives_chrome, + test_a_browser_lane_has_the_pinned_chrome, + test_container_apt_get_retries_transient_failures, + test_a_container_lane_runs_b2_with_no_network, +-- +2.55.0 + diff --git a/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0013-tools-select-example-and-size-table-inputs.patch b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0013-tools-select-example-and-size-table-inputs.patch new file mode 100644 index 0000000..02a0321 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0013-tools-select-example-and-size-table-inputs.patch @@ -0,0 +1,154 @@ +From 771a247c6210c4684867c686e2ba6a1e74b631c5 Mon Sep 17 00:00:00 2001 +From: R +Date: Wed, 14 Oct 2026 13:48:10 -0400 +Subject: [PATCH] tools: select example and size-table inputs independently of + linked objects + +--- + tools/test/emscripten_test.py | 50 +++++++++++++++++++++++++++++++++++ + tools/webcpp.jam | 33 +++++++++++++++++------ + 2 files changed, 75 insertions(+), 8 deletions(-) + +diff --git a/tools/test/emscripten_test.py b/tools/test/emscripten_test.py +index 4e6b582..db4cfdc 100644 +--- a/tools/test/emscripten_test.py ++++ b/tools/test/emscripten_test.py +@@ -108,6 +108,54 @@ def test_emscripten_lane_runs_under_node(root): + assert any(harness.emscripten_cache().iterdir()), harness.emscripten_cache() + + ++def add_source_dependency(root): ++ """Give the fixture a linked object like Asio's browser bridge support.""" ++ library = root / 'libs/browser_demo/build.jam' ++ library.write_text(library.read_text() + "\nobj support : support.cpp ;\n" ++ "alias supported : : : : support ;\n") ++ (library.parent / 'support.cpp').write_text('int support() { return 7; }\n') ++ ++ ++def test_example_expected_survives_source_dependencies(root): ++ # The expected file must not be confused with an appended library object. ++ add_source_dependency(root) ++ folder = root / 'libs/browser_demo/example' ++ jam = folder / 'Jamfile' ++ jam.write_text(jam.read_text().replace( ++ '/webcpp/browser_demo//browser_demo', ++ '/webcpp/browser_demo//browser_demo /webcpp/browser_demo//supported')) ++ (folder / 'hello.cpp').write_text('#include \nint support();\n' ++ 'int main() { std::printf("support=%d\\n", support()); }\n') ++ (folder / 'hello.expected').write_text('support=7\n') ++ for request in ((), ('webcpp-suspend=asyncify',)): ++ result = harness.run_b2(root, '-a', *EMSCRIPTEN, *request, ++ 'libs/browser_demo/example//hello.output') ++ harness.expect(result, True) ++ outputs = built(root, 'hello.output') ++ assert len(outputs) == 2, outputs ++ assert all(path.read_text() == 'support=7\n' for path in outputs), outputs ++ (folder / 'hello.expected').write_text('wrong output\n') ++ result = harness.run_b2(root, *EMSCRIPTEN, 'libs/browser_demo/example//hello.output') ++ harness.expect(result, False, 'wrong output') ++ ++ ++def test_size_table_ignores_linked_source_dependencies(root): ++ # A table consumes manifests, not the source objects inherited by its make target. ++ add_source_dependency(root) ++ folder = root / 'libs/browser_demo/test/variants' ++ jam = folder / 'Jamfile' ++ jam.write_text('project : requirements /webcpp/browser_demo//supported ;\n' ++ + jam.read_text()) ++ result = harness.run_b2(root, '-a', *EMSCRIPTEN, ++ 'libs/browser_demo/test/variants//shell.sizes.md') ++ harness.expect(result, True) ++ tables = built(root, 'shell.sizes.md') ++ assert len(tables) == 1, tables ++ manifest = json.loads(built(root, 'shell.variants.json')[0].read_text()) ++ assert f"{manifest['jspi']['bytes']:,}" in tables[0].read_text() ++ assert f"{manifest['asyncify']['bytes']:,}" in tables[0].read_text() ++ ++ + def test_a_launcher_is_refused_on_emscripten(root): + # b2's emscripten toolset runs a program with node itself: a launcher would make the command + # `node "node" x.js`, which fails, so it is refused by name before anything is built. +@@ -553,6 +601,8 @@ def prepared(case): + + CASES = [prepared(case) for case in ( + test_emscripten_lane_runs_under_node, ++ test_example_expected_survives_source_dependencies, ++ test_size_table_ignores_linked_source_dependencies, + test_a_launcher_is_refused_on_emscripten, + test_input_file_is_read_from_the_host, + test_programs_are_wasm32, +diff --git a/tools/webcpp.jam b/tools/webcpp.jam +index c59d58b..13d1350 100644 +--- a/tools/webcpp.jam ++++ b/tools/webcpp.jam +@@ -558,11 +558,22 @@ rule write-size-table ( targets * : sources * : properties * ) + { + PYTHON on $(targets) = $(.python) ; + SCRIPT on $(targets) = $(.variants-script) ; ++ # A project's libraries can append source objects to this make target. ++ # Only variant manifests are table inputs. ++ local manifests ; ++ for local source in $(sources) ++ { ++ if $(source:S) = .json ++ { ++ manifests += $(source) ; ++ } ++ } ++ MANIFESTS on $(targets) = $(manifests) ; + } + +-actions write-size-table ++actions write-size-table bind MANIFESTS + { +- "$(PYTHON)" "$(SCRIPT)" table --out "$(<)" "$(>)" ++ "$(PYTHON)" "$(SCRIPT)" table --out "$(<)" "$(MANIFESTS)" + } + + # A test that passes when sources compile, which builds no program. +@@ -632,10 +643,10 @@ rule example ( source : requirements * : targets * ) + } + # The program's main target can generate more than the executable, which + # it lists first: MSVC's debug link adds the .pdb after the .exe. So the +- # action reads the program as the first source and the expected output +- # as the last, never as the second, and run-and-compare finds the input +- # by its suffix. The input is a source of the output, so that editing it +- # runs the example again. ++ # action reads the program as the first source. Library source usage ++ # can also append objects, so run-and-compare finds both the expected ++ # output and the optional input by suffix, not by position. The input ++ # is a source of the output, so editing it runs the example again. + make $(name).output : $(name) $(input) $(source:S=.expected) : @webcpp%run-and-compare + : $(requirements) $(only) ; + # testing.launcher is a free feature: it plays no part in the target's +@@ -675,19 +686,25 @@ rule run-and-compare ( targets * : sources * : properties * ) + # The action binds it to its path, and its word `--input="$(INPUT)"`, + # which holds a reference to it, disappears whole when it is empty. + local input ; ++ local expected ; + for local source in $(sources) + { + if $(source:S) = .input + { + input = $(source) ; + } ++ if $(source:S) = .expected ++ { ++ expected = $(source) ; ++ } + } + INPUT on $(targets) = $(input) ; ++ EXPECTED on $(targets) = $(expected) ; + } + +-actions run-and-compare bind INPUT ++actions run-and-compare bind INPUT EXPECTED + { +- "$(PYTHON)" "$(RUNNER)" $(LAUNCHER_ARGS) --input="$(INPUT)" --expected "$(>[-1])" --output "$(<)" -- "$(>[1])" ++ "$(PYTHON)" "$(RUNNER)" $(LAUNCHER_ARGS) --input="$(INPUT)" --expected "$(EXPECTED)" --output "$(<)" -- "$(>[1])" + } + + # A test per public header of library, each a translation unit that only +-- +2.55.0 + diff --git a/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0014-tools-boost-cobalt-preserve-consumer-exception-setting.patch b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0014-tools-boost-cobalt-preserve-consumer-exception-setting.patch new file mode 100644 index 0000000..dcff6cf --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0014-tools-boost-cobalt-preserve-consumer-exception-setting.patch @@ -0,0 +1,160 @@ +From d507a93e7dd22f2a740524f8d5b4f1c5edc1c4e6 Mon Sep 17 00:00:00 2001 +From: R +Date: Wed, 14 Oct 2026 14:56:25 -0400 +Subject: [PATCH] tools/boost: let Cobalt preserve the consumer exception + setting + +--- + AGENTS.md | 8 +++- + tools/boost/Jamfile | 24 +++------- + tools/test/boost_libraries_test.py | 74 +++++++++++++++++++++++++++++- + 3 files changed, 86 insertions(+), 20 deletions(-) + +diff --git a/AGENTS.md b/AGENTS.md +index 68d09a5..39d1a5d 100644 +--- a/AGENTS.md ++++ b/AGENTS.md +@@ -2867,7 +2867,13 @@ What webcpp does not have yet, and the chapters that mention it: + - **Compiled Boost libraries.** Boost.URL, Boost.Charconv, Boost.Locale and + Boost.Cobalt are built from Boost's sources (`/webcpp//boost_url`, + `/webcpp//boost_charconv`, `/webcpp//boost_locale`, `/webcpp//boost_cobalt`). +- Boost.Locale and Boost.Cobalt have no build without exceptions, and it is not yet measured on Windows. A ++ Boost.Locale requires exceptions. Boost.Cobalt follows the consumer's exception ++ setting without a blanket refusal. This is not a guarantee that all of Cobalt ++ works without exceptions: in Boost 1.92, moving a pending task calls ++ std::make_exception_ptr, which aborts with libc++ and -fno-exceptions, even ++ when the application uses as_result. Eager promises and timer cancellation ++ handled as values are covered by tools/test/boost_libraries_test.py. ++ The compiled libraries are not yet measured on Windows. A + Boost.Test suite still compiles the framework's header-only form (chapters + 2 and 9). + - **Bundled toolchains.** Each toolchain is installed by hand and configured +diff --git a/tools/boost/Jamfile b/tools/boost/Jamfile +index f9d4bf7..113f55d 100644 +--- a/tools/boost/Jamfile ++++ b/tools/boost/Jamfile +@@ -167,25 +167,13 @@ rule cobalt-sources ( ) + return $(sources) ; + } + +-# Boost.Cobalt throws, through boost::throw_exception and +-# std::rethrow_exception, so it is refused without exceptions, as Boost.Locale +-# is; a program that uses it declares on in its own +-# requirements. +-rule cobalt-configuration ( properties * ) +-{ +- if off in $(properties) +- { +- errors.user-error "/webcpp//boost_cobalt needs exceptions: Boost.Cobalt throws, and" +- "a program that uses it declares on in its own requirements," +- "which keeps it with exceptions in a build without them (b2 ignores it as a usage" +- "requirement), or leaves Boost.Cobalt out" ; +- } +-} +- + # Boost.Cobalt, with the macros of its own build: its sources see +-# BOOST_COBALT_SOURCE=1, and its users BOOST_COBALT_NO_LIB=1. Native only in +-# practice: the programs that use it are declared native. ++# BOOST_COBALT_SOURCE=1, and its users BOOST_COBALT_NO_LIB=1. Exception handling ++# follows the consumer: result-based programs may disable it without a blanket ++# configuration refusal. This does not guarantee every Cobalt operation works ++# without exceptions: moving a pending task creates an exception_ptr in Boost ++# 1.92, which libc++ aborts on when built with -fno-exceptions. + compiled boost_cobalt : [ cobalt-sources ] + : libs/cobalt/src holds no .cpp file +- : BOOST_COBALT_SOURCE=1 @cobalt-configuration ++ : BOOST_COBALT_SOURCE=1 + : BOOST_COBALT_NO_LIB=1 ; +diff --git a/tools/test/boost_libraries_test.py b/tools/test/boost_libraries_test.py +index ee7c6ff..e964477 100755 +--- a/tools/test/boost_libraries_test.py ++++ b/tools/test/boost_libraries_test.py +@@ -14,7 +14,8 @@ library's sources each stopping the build by name, while a build that needs none + /webcpp//boost_charconv links on every target, with and without exceptions; /webcpp//boost_locale + converts, and translates from a catalog, natively, on wasip2, wasip3 and emscripten, where its + sources alone are told that pthreads are there, which no public header depends on, and is refused +-by name without exceptions. ++by name without exceptions. Boost.Cobalt follows the consumer's exception setting, ++including a result-based coroutine and timer cancellation handled as a value. + Each case builds a scratch superproject with the fixture library demo, whose path holds a space. + Run with the names of some cases to run only those.""" + +@@ -532,7 +533,78 @@ def test_boost_locale_is_refused_without_exceptions(root: Path) -> None: + result.stdout[-4000:]) + + ++COBALT_JAMFILE = ('import webcpp ;\n' ++ 'webcpp.targets native emscripten ;\n' ++ 'webcpp.run coroutines : coroutines.cpp : /webcpp//boost_cobalt ;\n') ++ ++COBALT_SOURCE = r'''#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++boost::cobalt::promise answer() { ++ co_return 42; ++} ++ ++boost::cobalt::promise exercise(boost::asio::io_context& ctx) { ++ // Eager promises provide a result without moving a pending task. ++ auto child = answer(); ++ auto result = co_await boost::cobalt::as_result(child); ++ if (!result || *result != 42) ++ co_return 1; ++ boost::asio::steady_timer timer(ctx, std::chrono::hours(1)); ++ boost::asio::post(ctx, [&timer] { timer.cancel(); }); ++ auto [error] = co_await boost::cobalt::as_tuple( ++ timer.async_wait(boost::cobalt::use_op)); ++ co_return error == boost::asio::error::operation_aborted ? 42 : 2; ++} ++ ++int main() { ++ webcpp::test::bound(std::chrono::seconds(10)); ++ boost::asio::io_context ctx; ++ boost::cobalt::this_thread::set_executor(ctx.get_executor()); ++ auto operation = exercise(ctx); ++ ctx.run(); ++ bool const ok = operation.ready() && operation.get() == 42; ++ std::puts(ok ? "result and cancellation passed" : "failed"); ++ return webcpp::test::exit_status(ok ? 0 : 1); ++} ++''' ++ ++ ++def test_boost_cobalt_preserves_exception_setting(root: Path) -> None: ++ # A blanket exception requirement would reject a valid result-based consumer. ++ # Build the real archive and execute eager promises and cancellation in each mode. ++ harness.link_emsdk(root) ++ harness.add_library(root, 'coroutines', COBALT_JAMFILE, {'coroutines.cpp': COBALT_SOURCE}) ++ wasm = (*EMSCRIPTEN, 'define=BOOST_ASIO_DISABLE_THREADS') ++ count = 0 ++ for request in ((), wasm, (*wasm, 'webcpp-suspend=asyncify')): ++ for exceptions in ('off', 'on'): ++ result = harness.run_b2(root, '-a', '-j4', '-d+2', '--verbose-test', *request, ++ f'exception-handling={exceptions}', 'libs/coroutines/test') ++ harness.expect(result, True, 'result and cancellation passed') ++ assert passed(result) == {'coroutines'}, (request, exceptions, result.stdout[-4000:]) ++ compiles = [line for line in result.stdout.splitlines() ++ if ' -c ' in line and ('coroutines.cpp' in line or '/cobalt/src/' in line)] ++ assert any('coroutines.cpp' in line for line in compiles), result.stdout[-4000:] ++ assert any('/cobalt/src/' in line for line in compiles), result.stdout[-4000:] ++ assert all(('-fno-exceptions' in line) == (exceptions == 'off') ++ for line in compiles), (request, exceptions, compiles) ++ count += 1 ++ assert len(list((root / 'bin').rglob('libboost_cobalt.a'))) == count ++ print(f'cobalt {request or ("native",)} exceptions={exceptions}: passed', flush=True) ++ ++ + CASES = [ ++ test_boost_cobalt_preserves_exception_setting, + test_boost_url_links_on_every_target, + test_boost_charconv_links_on_every_target, + test_boost_locale_on_every_target, diff --git a/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0015-tools-boost-complete-cobalt-source-and-browser-configuration.patch b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0015-tools-boost-complete-cobalt-source-and-browser-configuration.patch new file mode 100644 index 0000000..d86957f --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0015-tools-boost-complete-cobalt-source-and-browser-configuration.patch @@ -0,0 +1,350 @@ +From 8829e990d7f015be7e21b4d011c48ac754899000 Mon Sep 17 00:00:00 2001 +From: R +Date: Wed, 14 Oct 2026 22:36:06 -0400 +Subject: [PATCH] tools/boost: complete Cobalt source and browser configuration + +--- + AGENTS.md | 26 +++++++- + tools/boost/Jamfile | 48 ++++++++++++-- + tools/ci/actions/boost/action.yml | 2 +- + tools/ci/actions/boost/install.sh | 2 +- + tools/ci/actions_test.py | 6 ++ + tools/test/boost_libraries_test.py | 102 ++++++++++++++++++++++++++++- + 6 files changed, 173 insertions(+), 13 deletions(-) + +diff --git a/AGENTS.md b/AGENTS.md +index 39d1a5d..721a065 100644 +--- a/AGENTS.md ++++ b/AGENTS.md +@@ -322,6 +322,29 @@ being on the compiler's default include path, naming the `using boost` line to + add, and if it lacks the library's sources; a build that needs none never + looks. + ++**Cobalt source target.** `/webcpp//boost_cobalt` builds a static library from ++24 of Boost 1.92's 26 Cobalt sources: `src/*.cpp`, `src/detail/*.cpp` and ++`src/io/*.cpp`, excluding `src/main.cpp` and `src/io/ssl.cpp`. It supplies no ++OpenSSL integration or default `co_main` runner; the webcpp runner belongs to ++the subsequent Asio integration task. Ordinary `main` consumers can use it now. ++Its sources define `BOOST_COBALT_SOURCE=1` and `BOOST_COBALT_IO_SOURCE=1`, while ++consumers receive `BOOST_COBALT_NO_LIB=1`. On Emscripten, both sources and ++consumers define `BOOST_ASIO_DISABLE_THREADS`; native thread support is unchanged. ++Use the shared `BOOST_SOURCE` setup above, not a separate Cobalt source tree. ++ ++**Cobalt without exceptions.** A build that uses `/webcpp//boost_cobalt` with ++`exception-handling=off` emits a non-fatal configuration warning with ++https://github.com/boostorg/cobalt/issues/287 and recommends enabling exception ++handling. Boost 1.92 with libc++ can abort when a pending task is moved, including ++moves performed inside Cobalt. This warning describes a runtime risk; it does ++not claim to detect a move or prove a program safe. It appears once per distinct ++Cobalt build configuration in each b2 invocation, including dry runs, and never ++for an exceptions-enabled Cobalt configuration or an unrelated target. It does ++not change the exception setting or the build exit status. Compiler and lint ++warnings still follow their existing warnings-as-errors policies; a b2 warning ++is not a compiler diagnostic. Keep the warning until an upstream fix has been ++verified, rather than assuming a newer Boost release fixes the issue. ++ + **Machine-local setup.** `.local/` is git-ignored and holds what one machine + needs: `.local/user-config.jam`, `.local/wasi-sdk/`, `.local/mrdocs/`, + `.local/wit-bindgen/` and `.local/wasi-wit/p2` and `p3`, `.local/emsdk` (an +@@ -2868,7 +2891,8 @@ What webcpp does not have yet, and the chapters that mention it: + Boost.Cobalt are built from Boost's sources (`/webcpp//boost_url`, + `/webcpp//boost_charconv`, `/webcpp//boost_locale`, `/webcpp//boost_cobalt`). + Boost.Locale requires exceptions. Boost.Cobalt follows the consumer's exception +- setting without a blanket refusal. This is not a guarantee that all of Cobalt ++ setting with a non-fatal warning when disabled (chapter 1). This is not a ++ guarantee that all of Cobalt + works without exceptions: in Boost 1.92, moving a pending task calls + std::make_exception_ptr, which aborts with libc++ and -fno-exceptions, even + when the application uses as_result. Eager promises and timer cancellation +diff --git a/tools/boost/Jamfile b/tools/boost/Jamfile +index 113f55d..fe8f040 100644 +--- a/tools/boost/Jamfile ++++ b/tools/boost/Jamfile +@@ -9,12 +9,15 @@ + # program's own features, exception-handling=off among them, reach them. The + # sources are the Jamroot's WEBCPP_BOOST_SOURCE, whose version the Jamroot's + # alias of each library checks before anything is built: /webcpp//boost_url, +-# /webcpp//boost_charconv and /webcpp//boost_locale. They are Boost's code, ++# /webcpp//boost_charconv, /webcpp//boost_locale and /webcpp//boost_cobalt. ++# They are Boost's code, + # not webcpp's, and compile without webcpp's warnings, as Boost's headers are + # read as system ones. + import errors ; + import feature ; ++import property-set ; + import sequence ; ++import set ; + + project /webcpp/boost-libraries + : source-location $(WEBCPP_BOOST_SOURCE) +@@ -151,15 +154,15 @@ compiled boost_locale : $(.locale) + : BOOST_LOCALE_SOURCE @locale-configuration + : BOOST_LOCALE_NO_LIB=1 darwin:iconv ; + +-# Boost.Cobalt's sources without ssl.cpp, which needs OpenSSL, and which no +-# webcpp library uses yet. ++# Boost.Cobalt without its default co_main runner (main.cpp), which webcpp ++# supplies separately, and io/ssl.cpp, which needs OpenSSL. + rule cobalt-sources ( ) + { + local sources ; + for local file in [ glob libs/cobalt/src/*.cpp libs/cobalt/src/detail/*.cpp + libs/cobalt/src/io/*.cpp ] + { +- if ! [ MATCH "(^|/)ssl[.]cpp$" : $(file) ] ++ if ! [ MATCH "(^|/)(main|ssl)[.]cpp$" : $(file) ] + { + sources += $(file) ; + } +@@ -167,13 +170,44 @@ rule cobalt-sources ( ) + return $(sources) ; + } + ++# This diagnostic is a configuration warning, not a compiler warning: even ++# warnings-as-errors=on must preserve the consumer's choice. Cache the ++# base configuration so several consumers of one archive do not repeat it. ++# b2 evaluates conditionals before and after applying library requirements; ++# ignore link and warning features, which this library fixes independently. ++rule cobalt-configuration ( properties * ) ++{ ++ if off in $(properties) ++ { ++ local settings = [ property-set.create $(properties) ] ; ++ local base = [ $(settings).base ] ; ++ base = [ set.difference $(base) : shared static ++ all extra off ++ on off ] ; ++ local key = $(base:J=|) ; ++ if ! $(.cobalt-warned.$(key)) ++ { ++ .cobalt-warned.$(key) = true ; ++ ECHO "warning: webcpp: Boost.Cobalt is built with exceptions disabled;" ++ "moving a pending task can abort at runtime with libc++." ++ "Use exception-handling=on." ++ "See https://github.com/boostorg/cobalt/issues/287" ; ++ } ++ } ++} ++ + # Boost.Cobalt, with the macros of its own build: its sources see +-# BOOST_COBALT_SOURCE=1, and its users BOOST_COBALT_NO_LIB=1. Exception handling ++# BOOST_COBALT_SOURCE=1 and BOOST_COBALT_IO_SOURCE=1; users see ++# BOOST_COBALT_NO_LIB=1. Emscripten sources and users disable Asio threads ++# consistently, without changing native thread support. Exception handling + # follows the consumer: result-based programs may disable it without a blanket + # configuration refusal. This does not guarantee every Cobalt operation works + # without exceptions: moving a pending task creates an exception_ptr in Boost + # 1.92, which libc++ aborts on when built with -fno-exceptions. + compiled boost_cobalt : [ cobalt-sources ] + : libs/cobalt/src holds no .cpp file +- : BOOST_COBALT_SOURCE=1 +- : BOOST_COBALT_NO_LIB=1 ; ++ : BOOST_COBALT_SOURCE=1 BOOST_COBALT_IO_SOURCE=1 ++ emscripten:BOOST_ASIO_DISABLE_THREADS ++ @cobalt-configuration ++ : BOOST_COBALT_NO_LIB=1 ++ emscripten:BOOST_ASIO_DISABLE_THREADS ; +diff --git a/tools/ci/actions/boost/action.yml b/tools/ci/actions/boost/action.yml +index f003d82..fa1a609 100644 +--- a/tools/ci/actions/boost/action.yml ++++ b/tools/ci/actions/boost/action.yml +@@ -6,7 +6,7 @@ + + name: Boost + description: >- +- Installs Boost 1.92.0's headers, the sources of its compiled libraries and its b2 in a cached ++ Installs Boost 1.92.0's headers, compiled-library sources (including Cobalt) and b2 in a cached + prefix, from the source archive of archives.boost.io checked against its SHA-256, writes the + `using boost` line and the sources' `modules.poke` of .local/user-config.jam, and puts b2 on + PATH. On Linux, macOS and Windows. +diff --git a/tools/ci/actions/boost/install.sh b/tools/ci/actions/boost/install.sh +index 38dfb27..870f2a5 100755 +--- a/tools/ci/actions/boost/install.sh ++++ b/tools/ci/actions/boost/install.sh +@@ -23,7 +23,7 @@ + # + # The headers are installed, and beside them, in /source, the sources of Boost's compiled + # libraries, from which webcpp builds those it needs (the Jamroot's /webcpp//boost_url, +-# boost_charconv and boost_locale). ++# boost_charconv, boost_locale and boost_cobalt). + set -euo pipefail + + version=1.92.0 +diff --git a/tools/ci/actions_test.py b/tools/ci/actions_test.py +index 8883ee1..243f2bd 100755 +--- a/tools/ci/actions_test.py ++++ b/tools/ci/actions_test.py +@@ -200,6 +200,10 @@ def boost_archive(scratch: Path) -> Path: + ('libs/charconv/src/from_chars.cpp', '// charconv\n'), + ('libs/locale/src/message.cpp', '// locale\n'), + ('libs/cobalt/src/this_thread.cpp', '// cobalt\n'), ++ ('libs/cobalt/src/main.cpp', '// cobalt main\n'), ++ ('libs/cobalt/src/detail/util.cpp', '// cobalt detail\n'), ++ ('libs/cobalt/src/io/sleep.cpp', '// cobalt io\n'), ++ ('libs/cobalt/src/io/ssl.cpp', '// cobalt ssl\n'), + ('libs/url/doc/index.html', '

not kept

\n')): + (tree / path).parent.mkdir(parents=True, exist_ok=True) + (tree / path).write_text(text) +@@ -260,6 +264,8 @@ def test_boost_install_fails_when_the_prefix_is_incomplete(scratch: Path) -> Non + # tree, nothing else. + MARKER = '.webcpp-boost-source' + KEPT_SOURCES = [MARKER, 'boost/version.hpp', 'libs/charconv/src/from_chars.cpp', ++ 'libs/cobalt/src/detail/util.cpp', 'libs/cobalt/src/io/sleep.cpp', ++ 'libs/cobalt/src/io/ssl.cpp', 'libs/cobalt/src/main.cpp', + 'libs/cobalt/src/this_thread.cpp', 'libs/json/src/src.cpp', + 'libs/locale/src/message.cpp', 'libs/url/src/detail/pattern.hpp', + 'libs/url/src/url.cpp'] +diff --git a/tools/test/boost_libraries_test.py b/tools/test/boost_libraries_test.py +index e964477..aa03078 100755 +--- a/tools/test/boost_libraries_test.py ++++ b/tools/test/boost_libraries_test.py +@@ -537,9 +537,20 @@ COBALT_JAMFILE = ('import webcpp ;\n' + 'webcpp.targets native emscripten ;\n' + 'webcpp.run coroutines : coroutines.cpp : /webcpp//boost_cobalt ;\n') + +-COBALT_SOURCE = r'''#include ++COBALT_SOURCE = r'''#if defined(__EMSCRIPTEN__) && !defined(BOOST_ASIO_DISABLE_THREADS) ++#error Cobalt must configure Asio for the browser in its usage requirements ++#endif ++#if !defined(__EMSCRIPTEN__) && defined(BOOST_ASIO_DISABLE_THREADS) ++#error Native consumers must retain their normal thread configuration ++#endif ++#if defined(BOOST_COBALT_SOURCE) || defined(BOOST_COBALT_IO_SOURCE) ++#error Source-only macros must not leak into consumers ++#endif ++ ++#include + #include + #include ++#include + #include + #include + #include +@@ -559,6 +570,11 @@ boost::cobalt::promise exercise(boost::asio::io_context& ctx) { + auto result = co_await boost::cobalt::as_result(child); + if (!result || *result != 42) + co_return 1; ++ boost::cobalt::io::steady_timer cobalt_timer(std::chrono::milliseconds(1), ++ ctx.get_executor()); ++ auto [timer_error] = co_await boost::cobalt::as_tuple(cobalt_timer.wait()); ++ if (timer_error) ++ co_return 3; + boost::asio::steady_timer timer(ctx, std::chrono::hours(1)); + boost::asio::post(ctx, [&timer] { timer.cancel(); }); + auto [error] = co_await boost::cobalt::as_tuple( +@@ -579,23 +595,100 @@ int main() { + ''' + + ++def test_boost_cobalt_names_missing_or_mismatched_sources(root: Path) -> None: ++ harness.without_boost_source(root) ++ target = '/webcpp//boost_cobalt' ++ harness.expect(harness.run_b2(root, '-a', target), False, ++ "Boost's sources", '-sBOOST_SOURCE=', '.local/boost-source') ++ harness.expect(harness.run_b2(root, '-a', 'libs/demo/test//pass'), True) ++ empty = fake_sources(root / 'no cobalt sources', 109200, with_url=False) ++ harness.expect(harness.run_b2(root, '-a', f'-sBOOST_SOURCE={empty}', target), False, ++ 'libs/cobalt/src holds no .cpp file', target) ++ old = with_sources_of(fake_sources(root / 'old sources', 109100), 'cobalt') ++ harness.expect(harness.run_b2(root, '-a', f'-sBOOST_SOURCE={old}', target), False, ++ "holds Boost 1.91.0's sources", 'is 1.92.0') ++ ++ ++def test_boost_cobalt_omits_main_and_ssl_from_supplied_sources(root: Path) -> None: ++ # Poison the excluded sources: compiling either would break the application boundary. ++ sources = fake_sources(root / 'cobalt sources', 109200, with_url=False) ++ for name in ('channel.cpp', 'detail/util.cpp', 'io/sleep.cpp', 'main.cpp', 'io/ssl.cpp'): ++ source = sources / 'libs/cobalt/src' / name ++ source.parent.mkdir(parents=True, exist_ok=True) ++ text = '#error This source must not be compiled by boost_cobalt\n' ++ if name not in ('main.cpp', 'io/ssl.cpp'): ++ text = ('#if !defined(BOOST_COBALT_SOURCE) || !defined(BOOST_COBALT_IO_SOURCE)\n' ++ '#error Both source macros are required\n#endif\n') ++ text += 'int fixture_' + name.replace('/', '_').replace('.', '_') + ' = 0;\n' ++ source.write_text(text) ++ result = harness.run_b2(root, '-a', '-j4', '-d+2', f'-sBOOST_SOURCE={sources}', ++ '/webcpp//boost_cobalt') ++ harness.expect(result, True) ++ compiled = set(re.findall(r'libs/cobalt/src/([a-z/_]+[.]cpp)"', result.stdout)) ++ assert compiled == {'channel.cpp', 'detail/util.cpp', 'io/sleep.cpp'}, compiled ++ assert len(list((root / 'bin').rglob('libboost_cobalt.a'))) == 1 ++ ++ ++def test_boost_cobalt_warns_only_for_disabled_exceptions(root: Path) -> None: ++ # Missing, unconditional or repeated warnings would hide or misrepresent the risk. ++ # Dry runs exercise dependency configuration without recompiling the archive. ++ harness.add_library(root, 'coroutines', COBALT_JAMFILE, {'coroutines.cpp': COBALT_SOURCE}) ++ harness.add_library(root, 'more_coroutines', COBALT_JAMFILE, ++ {'coroutines.cpp': COBALT_SOURCE}) ++ issue = 'https://github.com/boostorg/cobalt/issues/287' ++ targets = ('libs/coroutines/test', 'libs/more_coroutines/test') ++ for exceptions, expected in (('on', 0), ('off', 1)): ++ result = harness.run_b2(root, '-a', '-n', f'exception-handling={exceptions}', *targets) ++ harness.expect(result, True) ++ assert result.stdout.count(issue) == expected, result.stdout ++ if expected: ++ assert 'warning:' in result.stdout, result.stdout ++ assert 'pending task' in result.stdout, result.stdout ++ assert 'libc++' in result.stdout, result.stdout ++ assert 'exception-handling=on' in result.stdout, result.stdout ++ unrelated = harness.run_b2(root, '-a', '-n', 'exception-handling=off', 'libs/demo/test//pass') ++ harness.expect(unrelated, True) ++ assert issue not in unrelated.stdout, unrelated.stdout ++ variants = harness.run_b2(root, '-a', '-n', 'exception-handling=off', ++ 'variant=debug,release', *targets) ++ harness.expect(variants, True) ++ assert variants.stdout.count(issue) == 2, variants.stdout ++ # A consumer may require exceptions even in an otherwise exception-free build. ++ forced = COBALT_JAMFILE.replace('/webcpp//boost_cobalt', ++ '/webcpp//boost_cobalt on') ++ (root / 'libs/coroutines/test/Jamfile').write_text(forced) ++ result = harness.run_b2(root, '-a', '-n', 'exception-handling=off', targets[0]) ++ harness.expect(result, True) ++ assert issue not in result.stdout, result.stdout ++ ++ + def test_boost_cobalt_preserves_exception_setting(root: Path) -> None: + # A blanket exception requirement would reject a valid result-based consumer. + # Build the real archive and execute eager promises and cancellation in each mode. + harness.link_emsdk(root) + harness.add_library(root, 'coroutines', COBALT_JAMFILE, {'coroutines.cpp': COBALT_SOURCE}) +- wasm = (*EMSCRIPTEN, 'define=BOOST_ASIO_DISABLE_THREADS') ++ wasm = EMSCRIPTEN + count = 0 + for request in ((), wasm, (*wasm, 'webcpp-suspend=asyncify')): + for exceptions in ('off', 'on'): + result = harness.run_b2(root, '-a', '-j4', '-d+2', '--verbose-test', *request, + f'exception-handling={exceptions}', 'libs/coroutines/test') + harness.expect(result, True, 'result and cancellation passed') ++ issue = 'https://github.com/boostorg/cobalt/issues/287' ++ assert result.stdout.count(issue) == (1 if exceptions == 'off' else 0), result.stdout + assert passed(result) == {'coroutines'}, (request, exceptions, result.stdout[-4000:]) + compiles = [line for line in result.stdout.splitlines() + if ' -c ' in line and ('coroutines.cpp' in line or '/cobalt/src/' in line)] + assert any('coroutines.cpp' in line for line in compiles), result.stdout[-4000:] +- assert any('/cobalt/src/' in line for line in compiles), result.stdout[-4000:] ++ library_compiles = [line for line in compiles if '/cobalt/src/' in line] ++ assert len(library_compiles) == 24, library_compiles ++ assert not any('/main.cpp' in line or '/io/ssl.cpp' in line ++ for line in library_compiles), library_compiles ++ for line in library_compiles: ++ assert '-DBOOST_COBALT_SOURCE=1' in line, line ++ assert '-DBOOST_COBALT_IO_SOURCE=1' in line, line ++ assert all(('-DBOOST_ASIO_DISABLE_THREADS' in line) == bool(request) ++ for line in compiles), compiles + assert all(('-fno-exceptions' in line) == (exceptions == 'off') + for line in compiles), (request, exceptions, compiles) + count += 1 +@@ -604,6 +697,9 @@ def test_boost_cobalt_preserves_exception_setting(root: Path) -> None: + + + CASES = [ ++ test_boost_cobalt_names_missing_or_mismatched_sources, ++ test_boost_cobalt_omits_main_and_ssl_from_supplied_sources, ++ test_boost_cobalt_warns_only_for_disabled_exceptions, + test_boost_cobalt_preserves_exception_setting, + test_boost_url_links_on_every_target, + test_boost_charconv_links_on_every_target, +-- +2.55.0 + diff --git a/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0016-tools-ci-asio-native-ssl-requires-openssl.patch b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0016-tools-ci-asio-native-ssl-requires-openssl.patch new file mode 100644 index 0000000..4cae504 --- /dev/null +++ b/libraries/asio/openspec/changes/genesis/reference/superproject-patches/0016-tools-ci-asio-native-ssl-requires-openssl.patch @@ -0,0 +1,44 @@ +From 063343df26066ac3fa57ef7ca894c4e311a41b14 Mon Sep 17 00:00:00 2001 +From: R +Date: Thu, 15 Oct 2026 04:02:59 -0400 +Subject: [PATCH] tools/ci: asio's native ssl requires OpenSSL + +--- + tools/ci/matrix.py | 6 +++++- + tools/ci/matrix_test.py | 2 ++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/tools/ci/matrix.py b/tools/ci/matrix.py +index 94ad20f..b2e3522 100755 +--- a/tools/ci/matrix.py ++++ b/tools/ci/matrix.py +@@ -162,7 +162,11 @@ EMSDK_JAM = ROOT / 'tools/ci/emsdk.jam' + # until webcpp builds them from third_party/ (AGENTS.md chapter 13): the CI's actions of these + # names, tools/ci/actions/, install each where the build looks, in .local/, before a lane, + # an own lane, the docs or the lint that builds such a library runs. +-EXTERNAL_DEPENDENCIES = {'trystero': ('secp256k1', 'libdatachannel', 'openssl')} ++# Asio's native ssl header requires the program to name OpenSSL. ++EXTERNAL_DEPENDENCIES = { ++ 'asio': ('openssl',), ++ 'trystero': ('secp256k1', 'libdatachannel', 'openssl'), ++} + + # The variables that name those libraries' directories, which the actions give a job, and a lane + # of such a library passes to b2 as -s=: a library's build.jam reads them from b2's +diff --git a/tools/ci/matrix_test.py b/tools/ci/matrix_test.py +index 36c2fd3..9ecba8f 100755 +--- a/tools/ci/matrix_test.py ++++ b/tools/ci/matrix_test.py +@@ -945,7 +945,9 @@ def test_a_lane_of_a_library_with_external_dependencies_says_so(root): + # the CI's actions of their names, on a lane or an own lane that builds trystero: its entry + # says external, and no other does. + assert matrix.EXTERNAL_DEPENDENCIES == { ++ 'asio': ('openssl',), + 'trystero': ('secp256k1', 'libdatachannel', 'openssl')}, matrix.EXTERNAL_DEPENDENCIES ++ assert matrix.needs_external('asio') + for dependencies in matrix.EXTERNAL_DEPENDENCIES.values(): + for dependency in dependencies: + assert (matrix.ROOT / 'tools/ci/actions' / dependency / 'action.yml').is_file(), ( +-- +2.55.0 + diff --git a/libraries/asio/openspec/changes/genesis/specs/asio/spec.md b/libraries/asio/openspec/changes/genesis/specs/asio/spec.md index 4678f9b..3291726 100644 --- a/libraries/asio/openspec/changes/genesis/specs/asio/spec.md +++ b/libraries/asio/openspec/changes/genesis/specs/asio/spec.md @@ -1,33 +1,50 @@ ## Purpose -webcpp::asio is a header-only C++20 wrapper over Boost.Asio, for native and Emscripten targets. -Natively it is Boost.Asio itself; compiled with Emscripten it is still Boost's own `io_context`, -whose `run` suspends into the browser's event loop, and it adds only what Boost lacks there: the -configuration Asio needs to build, a reactor made at construction, a limit on the handlers one -turn runs so that the page keeps rendering, and a bridge through which browser events post. -These requirements are the structured form of `reference/spec.md` and `reference/plan.md`. The -areas Library, Build (the suspension feature, names, manifest, size table and test support -included), Names, Options, Reactor, Run, Detection, Bridge, Exceptions, Stack and Testing -describe the code of `reference/source/` and the superproject commits of tasks 2 and 3 as they -are, but for the lane `browser` and the lanes of the later tasks; the areas Timers, Allocation, -Loader, Browser, Docs, Cobalt, Promise, Event, Socket, Resolver, Ssl and Release describe what the -plan's tasks 10 to 23 require and are not built. +webcpp::asio provides Boost-style C++20 asynchronous programming on native, +Emscripten and WASIp2/P3. Native upstream-equivalent types are actual Boost types; +Wasm uses a version-pinned implementation shipped under WebCPP paths. Its browser +context suspends into the event loop with a configurable handler-count budget. +WASI uses pollable/waitable reactors. Native upstream limitations remain explicit. + +Owner approval on 2026-11-06 supersedes the earlier derived-native-context, +Boost-namespace-in-Wasm and consumer-overlay architecture. References below to +Boost algorithms or semantics describe the selected backend; Wasm applications +use `webcpp::asio` operations and traits consistently, not mixed Boost executors. +Cobalt's implementation is independently owned by `webcpp::cobalt`. Status and +exact evidence are in `reference/STATUS.md`; requirements are not test results. ## ADDED Requirements ### Requirement: Library: Header-only library in its namespace -The library SHALL be header-only C++20 in namespace `webcpp::asio`, with public headers under ``, internals in `webcpp::asio::detail`, the browser's types in `webcpp::asio::browser`, macros prefixed `WEBCPP_ASIO_` and include guards `WEBCPP_ASIO__HPP`, except for the two translation units under `src/` that the build compiles for a program: `src/browser_src.cpp` (the JavaScript of the yield and of the bridge, linked on Emscripten) and, from the plan's task 16, `src/cobalt_main.cpp`. +The library SHALL provide C++20 headers under `` with explicit +WebCPP namespaces and configuration. Its browser/P2/P3 support units MUST ship +under `src/`, be enumerated by `sources.json`, and be usable by B2 and independent +compiler/CMake consumers. Native upstream-equivalent types MUST forward to Boost. +Wasm implementation paths MUST not shadow installed Boost headers. Cobalt runner, +core and SSL sources MUST belong to the independent Cobalt library; old Asio names +remain compatibility aliases. Consumer builds MUST NOT run maintainer patch tools. #### Scenario: A header is the only include of its translation unit - **WHEN** each of `asio.hpp`, `asio/config.hpp`, `asio/io_context.hpp`, `asio/steady_timer.hpp`, `asio/system_timer.hpp` and `asio/basic_waitable_timer.hpp` is compiled alone with `-std=c++20` and Boost 1.92's headers - **THEN** each compiles (`-fsyntax-only` exit 0), and `test/Jamfile` declares `webcpp.headers-alone` for them on both targets and for `asio/browser/*.hpp` and `asio/detail/*.hpp` on Emscripten alone -### Requirement: Library: Targets are native and Emscripten, with no WASI backend -The library SHALL declare native and Emscripten as its targets (`webcpp.targets native emscripten`) and MUST NOT declare wasm32-wasip2 or wasm32-wasip3, because Boost.Asio 1.92 does not compile for them with wasi-sdk 34; a library built on webcpp::asio declares native and Emscripten at most. +### Requirement: Library: Native, Emscripten and WASI targets +The library SHALL declare `webcpp.targets native emscripten wasip2 wasip3`. Its WASIp3 backend SHALL use checked, version-pinned shipped sources for timers, TCP and UDP. Its WASIp2 core SHALL support timers, TCP, UDP and pollable-based asynchronous forward DNS in the single-thread profile with exceptions on or off. P2 SHALL also support the shared source-built OpenSSL, embedded/replacement CAs, Cobalt and its SSL wrapper in both exception modes. Unsupported P2 thread build targets SHALL be rejected explicitly. Libraries using Asio's socket reactor MUST follow these targets; portable messages and host APIs without that reactor may support additional targets independently. -#### Scenario: The test Jamfile names two targets -- **WHEN** `test/Jamfile` and `example/Jamfile` are read -- **THEN** each calls `webcpp.targets native emscripten`, and no lane of asio names a WASI toolset +#### Scenario: The target declarations match the backend +- **WHEN** the test and example Jamfiles are read +- **THEN** their supported target declarations include native, Emscripten, WASIp2 and WASIp3, with P2 limited to its verified single-thread feature profile + +### Requirement: WASIp3: Networking, TLS and threading profiles +WASIp3 SHALL support timer waits, TCP accept/connect/read/write, UDP send/receive and cancellation using the host's permitted network. Optional source-built OpenSSL SHALL provide guest TLS, embedded or replacement CA trust, peer verification and explicit per-connection hostname/SNI configuration. Single-thread profiles SHALL support exceptions on and off. Cooperative-thread profiles SHALL require the matching SDK sysroot; a request for exceptions without a supplied C++ exception runtime MUST fail by name instead of silently disabling exceptions. + +#### Scenario: Real network and encrypted operations +- **WHEN** loopback TCP/UDP and TLS tests run on single-thread profiles and the supported cooperative profile +- **THEN** real peers exchange data, cancellation completes with the documented errors, untrusted peers fail verification, and entropy failure prevents key generation + +#### Scenario: Unsupported cooperative exception runtime +- **WHEN** a WASIp3 multi-thread build requests exceptions using an SDK whose cooperative sysroot has no C++ exception runtime +- **THEN** configuration stops with an actionable diagnostic naming that profile limitation ### Requirement: Library: Convenience header `include/webcpp/asio.hpp` SHALL include `config.hpp`, `basic_waitable_timer.hpp`, `io_context.hpp`, `steady_timer.hpp` and `system_timer.hpp` and, on Emscripten alone, `browser/bridge.hpp`; it MUST leave out ``, which natively brings OpenSSL. @@ -37,11 +54,11 @@ The library SHALL declare native and Emscripten as its targets (`webcpp.targets - **THEN** it compiles natively, and on Emscripten `webcpp::asio::browser::bridge` is also declared ### Requirement: Library: Configuration header and the no-exceptions macro -``, which every public header includes first, SHALL include `` and define `WEBCPP_ASIO_NO_EXCEPTIONS` exactly when `BOOST_NO_EXCEPTIONS` is defined, and MUST keep it when a developer defines it in a build that has exceptions; an API of asio that throws sits behind `#ifndef WEBCPP_ASIO_NO_EXCEPTIONS`. +``, which every public header includes first, SHALL include `` first and define `WEBCPP_ASIO_NO_EXCEPTIONS` when `WEBCPP_NO_EXCEPTIONS` or `BOOST_NO_EXCEPTIONS` is defined, and MUST keep it when a developer defines it in a build that has exceptions; an API of asio that throws sits behind `#ifndef WEBCPP_ASIO_NO_EXCEPTIONS`. #### Scenario: The macro follows the build - **WHEN** `config_test.cpp` is compiled with exceptions, without exceptions (`-fno-exceptions`), and with `-DWEBCPP_ASIO_NO_EXCEPTIONS -DWEBCPP_TEST_ASIO_DEVELOPER_DEFINED` -- **THEN** each compiles: the macro is defined exactly when `BOOST_NO_EXCEPTIONS` is, and the developer's definition is kept +- **THEN** each compiles: the macro follows the compiler or global WebCPP exception setting, and the developer's definition is kept #### Scenario: The test lane builds the configuration twice - **WHEN** `test/Jamfile` is read @@ -54,8 +71,12 @@ The library SHALL declare native and Emscripten as its targets (`webcpp.targets - **WHEN** `asyncify_stack_size_test.cpp` is built with `asyncify 4096` - **THEN** it does not compile (`asyncify_stack_size_refused`, a `compile-fail`), while the same source with `8192` compiles (`asyncify_stack_size_control`) +#### Scenario: Global configuration reaches Asio +- **WHEN** `WEBCPP_NO_EXCEPTIONS` is defined before including an Asio header +- **THEN** Asio's no-exceptions setting is active, and its B2 target propagates the config library dependency + ### Requirement: Library: Repository files of a webcpp library -The repository SHALL hold `build.jam`, `meta/libraries.json` (key `asio`, `"port-of": null`, categories `["Concurrent", "IO"]`, `cxxstd` `20`, maintainer `R `), `README.md`, `AGENTS.md` (only what is specific to asio), `LICENSE_1_0.txt`, `.gitignore` (at least `doc/html/`), `.gitattributes`, `.github/workflows/ci.yml` calling the superproject's reusable `library.yml` with `library: asio`, `doc/`, `test/` and `example/`. +The repository SHALL hold `build.jam`, `meta/libraries.json` (key `asio`, `"port-of": null`, categories `["Concurrent", "IO"]`, `cxxstd` `20`, maintainer `R `), `README.md`, `AGENTS.md` (only what is specific to asio), `LICENSE_1_0.txt`, `.gitignore` (at least `doc/html/`), `.gitattributes`, `.github/workflows/ci.yml` calling the superproject's reusable `library.yml` with `library: asio`, `doc/` including a maintained `doc/changelog.adoc` as the last page appendix, `test/` and `example/`. #### Scenario: The metadata names no port - **WHEN** `meta/libraries.json` is read @@ -69,18 +90,18 @@ Every source file SHALL open with the notice "Copyright (c) 2026 WebCpp.org" and - **THEN** its calls of `boost::asio::io_context::run_one()` carry `// lint-run: step 4, the one wait` and `// lint-run: step 4 alone`, and its `using` declarations of Boost's `run`, `run_for` and `run_one` carry `// lint-run: Boost's own, natively` ### Requirement: Build: One target gives a program everything on every target -`build.jam` SHALL declare `project /webcpp/asio` and an alias `asio` whose usage requirements are `include` and `/boost//headers` on every target and, on Emscripten, `BOOST_ASIO_DISABLE_THREADS`, `-lembind`, `browser-src`, the link flags of the program's suspension variant, the conditional `asyncify-stack` and `@webcpp%suspend-tag`; a program MUST reach the library through `/webcpp/asio//asio`. +`build.jam` SHALL declare `project /webcpp/asio` and an alias `asio` whose usage requirements are `include` and `/boost//headers` on every target and, on single-thread Emscripten, `BOOST_ASIO_DISABLE_THREADS`, `-lembind`, `browser-src`, the link flags of the program's suspension variant, the conditional `asyncify-stack` and `@webcpp%suspend-tag`; a program MUST reach the library through `/webcpp/asio//asio`. #### Scenario: A program names one target - **WHEN** a Jamfile writes `exe app : app.cpp /webcpp/asio//asio ;` and is built with `toolset=emscripten` - **THEN** the program compiles with `BOOST_ASIO_DISABLE_THREADS`, links embind and `browser-src`, and its name carries the variant -### Requirement: Build: Boost.Asio is built without threads on Emscripten -On Emscripten the usage requirements SHALL define `BOOST_ASIO_DISABLE_THREADS`, because without it Asio decides it has threads under any `__GNUC__` outside Linux and `` stops at "Only Windows and POSIX are supported!"; since Asio's inline namespace differs with and without threads, a translation unit that missed the define MUST fail at link and never silently. +### Requirement: Build: Emscripten thread profiles agree +Single-thread Emscripten usage requirements SHALL define `BOOST_ASIO_DISABLE_THREADS`. Explicit pthread builds SHALL retain Boost thread support and the selected suspension mechanism. The application and all compiled dependencies MUST use the same thread profile; the build MUST NOT silently replace a multi-thread request with single-thread execution. #### Scenario: Every translation unit of a program shares the define - **WHEN** `build.jam`'s `alias asio` and `obj browser-src` are read -- **THEN** both carry `emscripten:BOOST_ASIO_DISABLE_THREADS` +- **THEN** both carry the same single-thread conditional `BOOST_ASIO_DISABLE_THREADS` requirement ### Requirement: Build: The browser's JavaScript is compiled once and linked into every program `build.jam` SHALL declare the explicit object `browser-src` from `src/browser_src.cpp`, whose only content is `#include `, and the usage requirements MUST link it into every program on Emscripten, so that the JavaScript functions asio calls and the export the bridge delivers through exist exactly once; a program built otherwise includes `browser/src.hpp` in exactly one source file. @@ -142,58 +163,51 @@ The superproject SHALL give every `webcpp.run`, `webcpp.run-fail` and `webcpp.ex - **WHEN** `emscripten_test.py`'s `test_every_test_and_example_links_the_support` runs - **THEN** a program built by `webcpp.run` links the pre-js on Emscripten and finds `` on every target -### Requirement: Names: The io_context is a class derived from Boost's -`webcpp::asio::io_context` SHALL derive from `boost::asio::io_context` on both targets, convert to `boost::asio::io_context&` and share its executor type, so that code written against either interoperates. +### Requirement: Names: Native identity and explicit Wasm backend -#### Scenario: The static assertions of names_test hold -- **WHEN** `names_test.cpp` is compiled -- **THEN** `std::is_base_of_v`, `std::is_convertible_v` and `std::is_same_v` all hold +Native `webcpp::asio::io_context`, timers, sockets, executors and completion tokens +SHALL be the corresponding Boost types. Wasm SHALL use the coherently selected +shipped backend; source compatibility MUST NOT imply cross-backend type or ABI +identity. Algorithms and customization points MUST be available through WebCPP. -#### Scenario: A posted handler runs -- **WHEN** one handler is posted to a `webcpp::asio::io_context` and `run()` is called -- **THEN** `run()` returns 1 and the handler ran once +#### Scenario: Native identity +- **WHEN** direct native consumers include Boost and WebCPP in either order +- **THEN** type-identity assertions hold and timer, post and cancellation witnesses use the same backend -### Requirement: Names: The timers are Boost's own -`webcpp::asio::steady_timer`, `system_timer` and `basic_waitable_timer` (with Boost's default arguments) SHALL be aliases of the Boost.Asio types of the same names, in ``, `system_timer.hpp` and `basic_waitable_timer.hpp`, so that their interface, any completion token, the per-operation cancellation slot and the allocator associations are Boost's unchanged; on Emscripten they sit in the reactor's timer queue, which `run` waits on. - -#### Scenario: The aliases are the same types -- **WHEN** `names_test.cpp` is compiled -- **THEN** `std::is_same_v`, `std::is_same_v` and `std::is_same_v, boost::asio::basic_waitable_timer>` hold - -### Requirement: Names: Every other name of Boost.Asio keeps being Boost's -A program SHALL keep naming `post`, `dispatch`, `co_spawn`, `use_awaitable`, `bind_executor`, executors and completion tokens directly from `boost::asio::`, and webcpp::asio MUST NOT alias them; the only aliases and classes of asio are the io_context, the three timer names and, from the plan's tasks 19 to 21, `ip::tcp`, `ip::udp`, the socket, acceptor and resolver templates and `ssl`. - -#### Scenario: Boost's operations run on asio's context -- **WHEN** a program calls `boost::asio::post(io, handler)` and `boost::asio::dispatch` on a `webcpp::asio::io_context` -- **THEN** they behave as on Boost's context (`names_test`: `a_posted_handler_runs`) +#### Scenario: Wasm customization +- **WHEN** a source-archive consumer uses WebCPP custom tokens, associated executors and multiple translation units +- **THEN** operations use the shipped backend without resolving replacement Boost headers or a checkout cache ### Requirement: Options: The io_context's options and their default -`webcpp::asio::io_context_options` SHALL be a struct with one member, `std::size_t max_handlers_per_turn`, defaulting to 1000, which bounds the handlers one turn of the run family runs on Emscripten before it yields to the browser; a value of 0 MUST be taken as 1. +On Wasm, `webcpp::asio::io_context_options` SHALL be a struct with one member, `std::size_t max_handlers_per_turn`, defaulting to `WEBCPP_ASIO_DEFAULT_MAX_HANDLERS_PER_TURN` (100 unless defined by the application before including config), which bounds the handlers one turn of the run family runs on Emscripten before it yields to the browser; a value of 0 MUST be taken as 1. #### Scenario: The default, a given value and zero - **WHEN** `names_test`'s `options_are_kept` constructs a default context, a context with `io_context_options{.max_handlers_per_turn = 64}` and one with `{.max_handlers_per_turn = 0}` -- **THEN** `max_handlers_per_turn()` is 1000, 64 and 1 +- **THEN** `max_handlers_per_turn()` is 100, 64 and 1 ### Requirement: Options: The option can be read and changed later -`io_context` SHALL provide `std::size_t max_handlers_per_turn() const noexcept` and `void max_handlers_per_turn(std::size_t n) noexcept`, where 0 is taken as 1, on both targets. +`io_context` SHALL provide `std::size_t max_handlers_per_turn() const noexcept` and `void max_handlers_per_turn(std::size_t n) noexcept`, where 0 is taken as 1, on Wasm; the limit affects browser scheduling only. #### Scenario: Setting 250 and then 0 - **WHEN** a default context is given `max_handlers_per_turn(250)` and then `max_handlers_per_turn(0)` - **THEN** the getter returns 250 and then 1 ### Requirement: Options: The constructors take the options last -`io_context` SHALL provide `io_context()`, `explicit io_context(io_context_options)`, `io_context(std::allocator_arg_t, const Allocator&, io_context_options = {})`, `explicit io_context(int concurrency_hint, io_context_options = {})` and `io_context(std::allocator_arg_t, const Allocator&, int concurrency_hint, io_context_options = {})`, the allocator forms passing the allocator to Boost's constructor, which allocates the context's services and its I/O objects' state with it, and the hint forms forwarding Boost's concurrency hint, so that Boost's idiom `io_context io{1}` compiles unchanged (departure 2 of the plan: the spec lists three constructors). +The Wasm `io_context` SHALL provide `io_context()`, `explicit io_context(io_context_options)`, `io_context(std::allocator_arg_t, const Allocator&, io_context_options = {})`, `explicit io_context(int concurrency_hint, io_context_options = {})` and `io_context(std::allocator_arg_t, const Allocator&, int concurrency_hint, io_context_options = {})`, the allocator forms passing the allocator to Boost's constructor, which allocates the context's services and its I/O objects' state with it, and the hint forms forwarding Boost's concurrency hint, so that Boost's idiom `io_context io{1}` compiles unchanged (departure 2 of the plan: the spec lists three constructors). #### Scenario: Boost's idiom and a hint with options - **WHEN** `names_test`'s `a_concurrency_hint_is_boost_s` constructs `webcpp::asio::io_context io{1}` and one with `BOOST_ASIO_CONCURRENCY_HINT_1` and `.max_handlers_per_turn = 8` -- **THEN** the first reports 1000 and the second 8, and a posted handler runs once under `run()` +- **THEN** the first reports 100 and the second 8, and a posted handler runs once under `run()` + +### Requirement: Options: Native construction remains Boost's -### Requirement: Options: Natively the options change nothing and the run family is Boost's -Natively `io_context` SHALL bring Boost's `run`, `run_for`, `run_one`, `run_one_for`, `run_one_until` and `run_until` into its scope with `using` declarations and MUST accept the options without effect, since no page waits on a native loop. +Native `io_context` MUST expose Boost's constructors and members exactly. Browser +turn options MUST NOT be accepted silently by a native facade. Portable code that +selects a browser turn limit SHALL use an explicit target conditional. -#### Scenario: The native twin of the run family keeps Boost's meaning -- **WHEN** `run_family_test.cpp` runs natively (`run_family_native`) -- **THEN** it passes: `run` returns the handlers run, `run_one` runs one, a timer is waited for, the timed forms return at their deadline, `stop` and `restart` work, a passed deadline runs nothing, and a limit of 0 still runs +#### Scenario: Native construction +- **WHEN** an application constructs the native context with Boost's concurrency hint or allocator constructor +- **THEN** its type and execution behavior are Boost's, without a derived WebCPP context ### Requirement: Reactor: The reactor exists from construction On Emscripten the io_context SHALL hold one unarmed `boost::asio::steady_timer` member, made through public API, so that the reactor is the scheduler's task from construction, and a `run` that has work and no timer of the program's own waits in `select`, which a post wakes, and never in `null_event::do_wait`'s `::pause()`, which nothing wakes. @@ -237,7 +251,7 @@ On Emscripten the six members SHALL hide Boost's (which are not virtual) and `ru #### Scenario: The yield count of a self-posting handler - **WHEN** `turn_limit_test`'s `run_yields_every_turn` runs a handler that posts itself 5000 times under `run()` with the default limit -- **THEN** `run()` returns 5000, the longest run of handlers between two yields is 1000 and the yield counter reads 4 +- **THEN** `run()` returns 5000, the longest run of handlers between two yields is 100 and the yield counter reads 49 #### Scenario: run_for yields the same way - **WHEN** `run_for_yields_every_turn` sets the limit to 250 and runs 5000 self-posts under `run_for(10s)` @@ -251,7 +265,7 @@ The yield SHALL be the `EM_ASYNC_JS` import `webcpp_asio_yield`, which awaits a - **THEN** the first handler that sees the timeout run is the first handler of a turn (`seen_since` is 1), at least one yield has happened and no turn exceeded 250 handlers ### Requirement: Run: A turn is bounded, and the bound between two yields is stated -The run family SHALL run at most `max_handlers_per_turn` handlers in one turn; step 4's single handler belongs to no turn, so that up to `k + 1 + max_handlers_per_turn` handlers, fewer than twice the limit and one, can run between two yields when a short turn of `k` handlers is followed by a wait that ends at once; the default of 1000 was measured with Emscripten 6.0.11 (a `setTimeout(0)` ran after 1,000 handlers under JSPI and 999 under Asyncify, against 300,000 without the limit). +The run family SHALL run at most `max_handlers_per_turn` handlers in one turn; step 4's single handler belongs to no turn, so that up to `k + 1 + max_handlers_per_turn` handlers, fewer than twice the limit and one, can run between two yields when a short turn of `k` handlers is followed by a wait that ends at once; the owner selected the default of 100 after the 2026-10-15 yield-cost measurements. The guide SHALL retain the measured costs, methodology and responsiveness limits; a handler is never preempted by the turn limit. #### Scenario: Boost's own run has no limit - **WHEN** `boost_s_own_run_never_yields` runs 5000 self-posts through a `boost::asio::io_context&` reference to the context @@ -494,7 +508,7 @@ Every browser test (`reactor`, `run_family`, `turn_limit`, `bridge`, `bridge_abo `-sASYNCIFY_STACK_SIZE` SHALL be 8192 unless a program raises it, which is twice 4096, the smallest power of two with which every test passed in every build b2 links (measured 2026-10-11 with Emscripten 6.0.11: the deepest suspension, in a release build compiled with `-O3` and linked without optimization as b2's emscripten toolset links it, wrote 3,540 bytes, against 1,272 in a debug build; Emscripten's default of 4096 left it 556 bytes and 2048 trapped), so that half of the stack is left to the program's own frames. #### Scenario: Every suspension leaves half the stack -- **WHEN** `asyncify_stack_test` measures `run`, `run_one`, `run_for`, `run_until`, `run_one_for` and `run_one_until` at the reactor's wait, `run` and `run_for` at the yield, and `run` inside a `try` and inside a `catch` block (with exceptions) +- **WHEN** `asyncify_stack_test` measures `run`, `run_one`, `run_for`, `run_until`, `run_one_for` and `run_one_until` at the reactor's wait, `run`, `run_for` and `run_until` at the yield, and `run` inside a `try` and inside a `catch` block (with exceptions) - **THEN** each reading finds at least one unwind and more than 0 bytes, and twice the deepest is at most the stack size; hand-built at `-O0` with `-sASYNCIFY_STACK_SIZE=8192` on 2026-10-13 the deepest were 1,104 bytes (`run_for`, the reactor's wait) and 324 (`run`, the yield) ### Requirement: Stack: The measurement is exact and covers every build @@ -504,6 +518,10 @@ The bytes each unwind wrote SHALL be read from Asyncify's own data when the unwi - **WHEN** `test/Jamfile` is read - **THEN** `asyncify_stack_debug_exceptions_on`, `_off`, `asyncify_stack_release_...` and `asyncify_stack_optimized_link_...` are declared, the last with `release -O3`, and they join the lane `asyncify` +#### Scenario: A delayed entry still measures the blocking wait +- **WHEN** a reactor-wait case schedules a JavaScript macrotask, keeps outstanding Asio work, and delays entry to the run family by 25 ms +- **THEN** the macrotask posts the handler that releases the work, and the measurement observes a nonzero-timeout poll as well as an unwind; the initial nonblocking poll alone cannot satisfy the case + ### Requirement: Stack: An overflow traps and a program may ask for more A suspension that does not fit SHALL trap with `RuntimeError: unreachable` when the unwind stops, and nothing of the program runs afterwards; a program that calls `run` deep in its code asks for more with `` or `asyncify-stack-size=` on b2's command line, a value being a power of two from 8192 to 1048576. @@ -617,30 +635,21 @@ A program that runs a self-posting handler for one second on a `webcpp::asio::io - **WHEN** `asio_turn_limit` runs with `io_context_options{.max_handlers_per_turn = 250}` and 5,000 self-posts - **THEN** it prints `max_handlers_per_turn: 250` and `handlers run: 5000` -### Requirement: Cobalt: Boost.Cobalt's sources are compiled but main.cpp and io/ssl.cpp -The superproject SHALL provide the static target `/webcpp//boost_cobalt`, every `.cpp` of Boost.Cobalt's `src/`, `src/detail/` and `src/io/` but `main.cpp` (whose `run_main` webcpp defines) and `io/ssl.cpp` (departure 3: it needs OpenSSL), with `BOOST_COBALT_SOURCE`, `BOOST_COBALT_IO_SOURCE` and, on Emscripten, `BOOST_ASIO_DISABLE_THREADS`, from `-sBOOST_COBALT_SOURCE=` or `.local/boost-cobalt` (never the environment); a build that uses it and finds neither MUST stop, naming both places. - -#### Scenario: Sources found and left out -- **WHEN** `jamroot_test.py` builds `/webcpp//boost_cobalt` with a directory holding `channel.cpp`, `main.cpp`, `detail/util.cpp`, `io/sleep.cpp` and `io/ssl.cpp` -- **THEN** exactly `channel.cpp`, `detail/util.cpp` and `io/sleep.cpp` are compiled, and for Boost 1.92 that is 24 sources per toolset - -### Requirement: Cobalt: A co_main program changes nothing and gets the turn limit -`src/cobalt_main.cpp` SHALL define `boost::cobalt::detail::main_promise::run_main(::boost::cobalt::main)` and `final_suspend` with the same steps as Cobalt's (the executor, the signal set of `SIGINT` and `SIGTERM`, the post that resumes the coroutine) over a `webcpp::asio::io_context{BOOST_ASIO_CONCURRENCY_HINT_1}` and its run family, `/webcpp/asio//cobalt` MUST link `asio`, `cobalt-main` and `/webcpp//boost_cobalt`, and under Asyncify (`emscripten_has_asyncify() == 1`) `run_main` MUST end the program with `std::exit(res)` so that the `co_return` value is the exit status. - -#### Scenario: The unchanged co_main -- **WHEN** `cobalt_test` runs a `co_main` of 5,000 `co_await post(exec, use_op)`, a 50 ms Cobalt timer wait and a 20 ms Asio timer wait, natively and on both variants -- **THEN** it passes, and on Emscripten the page's `setTimeout(0)` ran within 1,000 posts +### Requirement: Cobalt: Forwarding compatibility targets -#### Scenario: The co_return value is the status -- **WHEN** `cobalt_status_test`'s `co_main` waits 20 ms and does `co_return 7;` -- **THEN** as a `run-fail` test its `.output` says `EXIT STATUS: 7` natively and on both variants, and with the `std::exit` removed in a scratch copy under Asyncify it says `EXIT STATUS: 1` +`/webcpp/asio//cobalt` and `cobalt_ssl`, and the root `boost_cobalt` and +`boost_cobalt_io_ssl` names, MUST forward to independently owned Cobalt targets. +Cobalt SHALL preserve the browser default of 100 handlers and independently test +its runner and task helper. Native core/runner MUST remain upstream; the corrected +SSL wrapper is the owner-approved exception specified by Cobalt's genesis. -### Requirement: Cobalt: The definition is kept honest and has a fallback -The definition reads `main_promise`'s members (`result`, `exec`, `exec_`, `signal_set`, `signal`), which are Boost's implementation, so compiling it against the pinned Boost on every lane MUST be the probe that fails when Boost changes them; if it cannot be kept, Cobalt's own `co_main` is the fallback, unchanged and without the turn limit; a program that uses `boost::cobalt::io::ssl_stream` does not link with it until Cobalt's TLS sources are built against the program's OpenSSL. +#### Scenario: Mixed aliases +- **WHEN** an application links old and canonical Cobalt targets together +- **THEN** one matching core, selected runner and optional TLS provider are linked -#### Scenario: Cobalt's own co_main works unchanged -- **WHEN** the probe `cobalt_main.cpp` of the review is built with Cobalt's own `main.cpp` -- **THEN** its `co_main` sleeps 150 ms on a timer and returns (JSPI), without the limit +#### Scenario: Plain Asio +- **WHEN** a source archive consumer selects only the Asio core +- **THEN** neither Cobalt sources nor OpenSSL are required ### Requirement: Promise: A JavaScript promise is an Asio operation `webcpp::asio::browser::async_await(const boost::asio::any_io_executor&, emscripten::val promise, CompletionToken&&)` SHALL initiate through `boost::asio::async_initiate` with the completion signature `void(boost::system::error_code, emscripten::val)`, so that every completion token works (a callback, `deferred`, `use_awaitable`, Cobalt's `use_op`), delivering through the bridge: the settlement posts the handler, never inline; a value that is no promise completes with itself. @@ -771,26 +780,108 @@ Reverse resolution (`resolve(endpoint, ec)`, `async_resolve(endpoint, ...)`) SHA - **THEN** the error is `operation_not_supported` ### Requirement: Ssl: Boost's ssl natively and a record on Emscripten -``, which the convenience header leaves out, SHALL define `namespace ssl = boost::asio::ssl;` in `webcpp::asio` natively (needing OpenSSL 3) and on Emscripten a record of the program's TLS settings (`context`, `stream_base`, `verify_*`, `host_name_verification`) that links no library and that only webcpp::beast's browser streams read; without `WEBCPP_ASIO_HAS_OPENSSL` natively the header MUST stop with a message telling the program to add `/webcpp/asio//openssl` beside `/webcpp/asio//asio`. +``, which the convenience header leaves out, SHALL define `namespace ssl = boost::asio::ssl;` in `webcpp::asio` natively and on WASIp2/P3 (needing source-built OpenSSL 3) and on Emscripten a record of the program's TLS settings (`context`, `stream_base`, `verify_*`, `host_name_verification`) that links no library and that only webcpp::beast's browser streams read; without `WEBCPP_ASIO_HAS_OPENSSL` on those guest TLS targets the header MUST stop with a message telling the program to add `/webcpp/asio//openssl` beside `/webcpp/asio//asio`. #### Scenario: Natively without OpenSSL - **WHEN** a native program includes `` without naming `/webcpp/asio//openssl` (`ssl_without_openssl_test`) - **THEN** the compile stops with the instruction -### Requirement: Ssl: OpenSSL is named by the program for native builds alone -`/webcpp/asio//openssl` SHALL link OpenSSL 3's `libssl` and `libcrypto`, found by `webcpp.external` and linked as the system's (shared), with `WEBCPP_ASIO_HAS_OPENSSL=1`, and a program that names it on a machine that lacks it stops the build with a message naming asio, OpenSSL, every place looked and `-sOPENSSL_ROOT=`; named in a build for Emscripten it MUST stop the compile through the forced include `src/openssl_on_webassembly.hpp` with a message naming what to write, the form for a program built for both targets being a `@native-openssl` in the project's requirements; `/webcpp/asio//openssl-tests` is the same for asio's own tests, left out on a machine that lacks OpenSSL. +### Requirement: Ssl: OpenSSL is an explicit source-built dependency +`/webcpp/asio//openssl` SHALL select `/webcpp/third_party//openssl`, built from the pinned unmodified upstream source for native or WASIp3, with matching generated headers and archives for the requested compiler, optimization, runtime and threading profile. It MUST NOT silently fall back to system OpenSSL. Emscripten MUST refuse a guest OpenSSL target by name because browser streams use host-managed TLS. `/webcpp/asio//tls` SHALL add the verified embedded CA snapshot and support an explicit replacement trust set without combining it with implicit system roots. + +#### Scenario: Native and WASIp3 source builds +- **WHEN** a program names `/webcpp/asio//openssl` or `/webcpp/asio//tls` on native or WASIp3 +- **THEN** its OpenSSL headers and binaries come from the same B2 variant and pinned source, without requiring a system OpenSSL installation + +#### Scenario: Guest OpenSSL requested in the browser +- **WHEN** a program names `/webcpp/asio//openssl` for Emscripten +- **THEN** its compile fails with the instruction to use the browser settings adapter + +#### Scenario: Cobalt's optional SSL wrapper +- **WHEN** a program names `/webcpp/asio//cobalt_ssl` on native or WASIp3 +- **THEN** the shipped corrected Cobalt SSL wrapper and source-built OpenSSL are linked, and TLS state, encrypted transfers, cancellation and shutdown are covered by real-peer tests + +### Requirement: Release: The rulebook, index, documentation and gates +Task 22 SHALL reconcile CODING-GUIDELINES chapters 15/16 and AGENTS with the actual targets, compiled dependencies and named compatibility departures. The page SHALL retain the owner's Diataxis organization and generated MrDocs reference, followed by the changelog. Task 23 SHALL review the complete library and superproject integration, correct important findings with failing regressions first, and verify the exact candidate tree in CI before final integration. G1 records repository creation, G2 the superproject submodule, and G3 publication plus successful library and superproject CI. Existing owner-authorized publication is recorded as history, not repeated or hidden. No subagent pushes, creates a repository or changes a GitHub setting. + +#### Scenario: Validation covers the actual target variants +- **WHEN** the CI plan and declared own lanes are inspected +- **THEN** they include native, Emscripten and WASIp3, JSPI/Asyncify, browser runtime checks and the supported networking/TLS/threading variants; unsupported profiles are refused and documented explicitly + +### Requirement: WASIp2 pollable readiness and cancellation + +The P2 backend SHALL combine socket, timer and forward-DNS readiness through the +executor without resolver worker threads or fixed-interval lookup polling. It +SHALL preserve deferred initiation, associated executors and allocators, and +resolver-wide and per-operation cancellation. Unsupported resolver policies +SHALL complete with explicit error values. Any private libc ABI bridge SHALL +verify its SDK/libc revision and copied declaration hashes before building. + +#### Scenario: A pending CLI read is cancelled by a timer + +- **GIVEN** a P2 CLI input stream that remains open without input +- **WHEN** an Asio timer cancels its pending asynchronous read +- **THEN** the read completes once with operation_aborted, with no dependency on EOF +- **AND** this guarantee excludes a host import that blocks inside the host itself + +#### Scenario: A deferred operation has not been initiated + +- **GIVEN** a deferred asynchronous operation and an intervening cancellation +- **WHEN** the application later initiates that operation +- **THEN** the earlier cancellation does not cancel the newly initiated operation + + +### Requirement: WASI datagram sequences and asynchronous forward lookup +WASIp2/P3 SHALL preserve one datagram per connected or unconnected send and receive +for scalar and multiple-buffer sequences. Gather/scatter scratch SHALL use the +context allocator synchronously and the associated handler allocator asynchronously, +and SHALL be released before completion. Truncation and cancellation SHALL retain +normal datagram behavior. P3 SHALL use native asynchronous lookup and waitables in +both supported thread profiles without blocking initiation or polling DNS on timers. + +#### Scenario: Pending lookup leaves timer progress available +- **WHEN** a P3 host lookup remains pending while an unrelated timer expires +- **THEN** the timer completes before the lookup and cancellation releases the pending host resources through the normal completion channel + +#### Scenario: Connected UDP uses the complete buffer sequence +- **WHEN** a WASI UDP socket sends several buffers on an established peer association +- **THEN** exactly one datagram contains the concatenated bytes and scatter receive preserves ordering and truncation + +### Requirement: Target capability diagnostics +The library SHALL expose read-only numeric capability macros from `config.hpp`. +It SHALL distinguish platform availability from optional dependency selection. +Explicit `WEBCPP_ASIO_REQUIRE_*` requirements and feature-header target guards SHALL +reject known-invalid compilation with a useful alternative. Runtime-only host +permissions and transport selection SHALL retain runtime errors and documentation. + +#### Scenario: An application requires raw sockets in a browser +- **WHEN** it sets `WEBCPP_ASIO_REQUIRE_SOCKET_BACKEND=1` before the first library include on Emscripten +- **THEN** compilation explains that a browser transport or native/WASI target is required + +#### Scenario: A consumer attempts to forge a capability +- **WHEN** it predefines a derived `WEBCPP_ASIO_HAS_*` capability +- **THEN** config.hpp rejects the override instead of advertising unverified support + +#### Scenario: Runtime permissions are absent +- **WHEN** a supported WASI backend is compiled but the host denies a required network permission +- **THEN** the operation reports a runtime error and the capability macro does not falsely guarantee access + -#### Scenario: Named on WebAssembly -- **WHEN** a program names `/webcpp/asio//openssl` in a build for Emscripten (`openssl_on_webassembly_test`) -- **THEN** every source fails to compile with the instruction +### Requirement: Explicit browser pthread execution +The Emscripten target SHALL support explicit pthread builds with JSPI or Asyncify +and either exception setting when the pinned host supports that profile. A browser +io_context SHALL run only on its constructing thread and SHALL accept cross-thread +posting. A main-thread executor SHALL deliver nonsuspending DOM callbacks and +preserve context/handler allocation and safe queued-operation cleanup. -#### Scenario: One program for both targets -- **WHEN** `example/tls/asio_tls.cpp` is built natively and with `toolset=emscripten` under the lane `tls` -- **THEN** it builds and prints the same line on both +#### Scenario: A worker timer completes on the DOM thread +- **WHEN** a worker timer uses the main-thread executor as its associated executor +- **THEN** completion runs on the actual browser main thread and can post ordinary C++ data back to wake the worker -### Requirement: Release: The rulebook, the index and the gates -Task 22 SHALL write the superproject's `AGENTS.md` chapter 13 items (every variant tested in three levels of the CI, the compiled Boost libraries naming Cobalt first, the levels item recording that the Asyncify lanes run on every push until the levels exist, and the OpenSSL item recording that `/webcpp/asio//openssl` moves onto `/third_party//openssl` with webcpp::crypto) and the library's row, and the repository MUST NOT be published before the whole-branch review is fixed and the owner has taken the three gates: G1 he creates `webcpporg/asio` (public, BSL-1.0), G2 he adds the submodule `libs/asio` (`git submodule add ../asio.git libs/asio`) and the superproject commits it, G3 the library is pushed first and the superproject second; no subagent ever pushes, creates a repository or changes a GitHub setting. +#### Scenario: A page cannot provide isolated shared memory +- **WHEN** the deployment lacks the browser's required isolation or shared-memory support +- **THEN** documentation identifies the hosting requirement without claiming that a compiler macro proves it -#### Scenario: The matrix names asio's lanes -- **WHEN** `python3 tools/ci/matrix.py plan --library asio` and `own-lanes --library asio` run after task 22 -- **THEN** the lanes of every native compiler and Emscripten appear, and the own lanes `emscripten.asio.asyncify`, `emscripten.asio.browser` (with `chrome` true), `native.asio.tls` and `emscripten.asio.tls` (with `external` true) +#### Scenario: A queued callback destroys its main-thread context +- **WHEN** a running main-thread callback destroys its context while other callbacks remain queued +- **THEN** remaining callbacks are discarded without accessing the destroyed context or invoking user functions diff --git a/libraries/asio/openspec/changes/genesis/tasks.md b/libraries/asio/openspec/changes/genesis/tasks.md index 91fecb1..93777f8 100644 --- a/libraries/asio/openspec/changes/genesis/tasks.md +++ b/libraries/asio/openspec/changes/genesis/tasks.md @@ -105,130 +105,159 @@ All of them are of 2026-10-11, as `R`. - [x] 9.3 Measure the stack size (Step 3): 8192, twice 4096, measured as the bytes each unwind wrote - [x] 9.4 Run every lane (Step 4) - [x] 9.5 Commit (Step 5): `27aa662`; fix round 1 `7cfd449` (the stack measured in every link, `asyncify-stack-size`, the bridge enters nothing after an abort) -- [ ] 9.6 The scoped re-review of fix round 1, stopped on 2026-10-11 when the owner asked to review every task one by one (open; not part of the plan's steps) +- [x] 9.6 The scoped re-review of fix round 1, completed on 2026-10-14 with deterministic blocking-wait measurements, the run_until yield case and corrected ABORT comments (local library ad6367b; evidence in reference/STATUS.md) ## 10. Timers: Boost's, Beast's (plan: Task 10) -- [ ] 10.1 Write the page's section `doc/timers.adoc` (plan: Task 10, Step 1) -- [ ] 10.2 Write the failing `test/timers_test.cpp`: order 20, 40, 60 ms, a `system_timer`, cancellation, per-operation cancellation, Beast's WebSocket handshake timeout (Step 2) -- [ ] 10.3 Run `timers` on each lane and see it can fail (Step 3) -- [ ] 10.4 Commit (Step 4) +- [x] 10.1 Write the page's section `doc/timers.adoc` (plan: Task 10, Step 1) +- [x] 10.2 Write the failing `test/timers_test.cpp`: order 20, 40, 60 ms, a `system_timer`, cancellation, per-operation cancellation, Beast's WebSocket handshake timeout (Step 2) +- [x] 10.3 Run `timers` on each lane and see it can fail (Step 3) +- [x] 10.4 Commit (Step 4): local library `ded30cb`; native 14 and WebAssembly 70 passing markers, wrong-order negative controls on JSPI and Asyncify, six clang-tidy configurations and rendered documentation validated locally (reference/STATUS.md) ## 11. Allocation (plan: Task 11) -- [ ] 11.1 Write the page's section `doc/allocation.adoc` (plan: Task 11, Step 1) -- [ ] 11.2 Write the failing `test/allocation_test.cpp`: `operator new`, the C library and the aligned allocations counted, the runtime's own allocations kept out by name (Step 2) -- [ ] 11.3 Run it with the allocator removed and see it fail, restore, run every lane (Step 3) -- [ ] 11.4 Commit (Step 4) +- [x] 11.1 Write the page's section `doc/allocation.adoc` (plan: Task 11, Step 1) +- [x] 11.2 Write the failing `test/allocation_test.cpp`: `operator new`, the C library and the aligned allocations counted, the runtime's own allocations kept out by name (Step 2) +- [x] 11.3 Run it with the allocator removed and see it fail, restore, run every lane (Step 3) +- [x] 11.4 Commit (Step 4): local library `a179adc`; native 15 and WebAssembly 74 passing markers, five scratch negative controls, six clang-tidy configurations and rendered documentation validated locally (reference/STATUS.md) ## 12. The loader (plan: Task 12) -- [ ] 12.1 Write the page's part of `doc/building.adoc` (plan: Task 12, Step 1) -- [ ] 12.2 Write the driven test's files in `test/browser/` (Step 2) -- [ ] 12.3 Run the browser lane and see it fail (Step 3) -- [ ] 12.4 Implement `include/webcpp/asio/webcpp-asio-loader.mjs` (Step 4) -- [ ] 12.5 Run the browser lane and the lint (Step 5) -- [ ] 12.6 Commit (Step 6) +- [x] 12.1 Write the page's part of `doc/building.adoc` (plan: Task 12, Step 1) +- [x] 12.2 Write the driven test's files in `test/browser/` (Step 2) +- [x] 12.3 Run the browser lane and see it fail (Step 3) +- [x] 12.4 Implement `include/webcpp/asio/webcpp-asio-loader.mjs` (Step 4) +- [x] 12.5 Run the browser lane and the lint (Step 5) +- [x] 12.6 Commit (Step 6) ## 13. The browser lane in headless Chrome (plan: Task 13) -- [ ] 13.1 Superproject: `('asio', 'browser')` in `CHROME_LANES`, test first (plan: Task 13, Step 1) -- [ ] 13.2 Write the idle, render and unlimited-render programs (Step 2) -- [ ] 13.3 Write `page.html` (Step 3) -- [ ] 13.4 Write the driver `run.mjs` with its three modes (Step 4) -- [ ] 13.5 Declare the drives in the Jamfile (Step 5) -- [ ] 13.6 Run the lane before and after the driver exists (Step 6) -- [ ] 13.7 Record the turn measurement three times, under the stop rule (Step 7) -- [ ] 13.8 Commit (Step 8) +- [x] 13.1 Superproject: `('asio', 'browser')` in `CHROME_LANES`, test first (plan: Task 13, Step 1) +- [x] 13.2 Write the idle, render and unlimited-render programs (Step 2) +- [x] 13.3 Write `page.html` (Step 3) +- [x] 13.4 Write the driver `run.mjs` with its three modes (Step 4) +- [x] 13.5 Declare the drives in the Jamfile (Step 5) +- [x] 13.6 Run the lane before and after the driver exists (Step 6) +- [x] 13.7 Record the turn measurement three times, under the stop rule (Step 7) +- [x] 13.8 Commit (Step 8) ## 14. The guide's examples and the size table (plan: Task 14) -- [ ] 14.1 Write `doc/guarantees.adoc`, nine numbered guarantees (plan: Task 14, Step 1) -- [ ] 14.2 Write the three examples with their `.expected` and the size table (Step 2) -- [ ] 14.3 Run the native and emscripten lanes before and after the `.expected` files (Step 3) -- [ ] 14.4 Write the quick start and include the examples (Step 4) -- [ ] 14.5 Commit (Step 5) +- [x] 14.1 Write `doc/guarantees.adoc`, nine numbered guarantees (plan: Task 14, Step 1) +- [x] 14.2 Write the three examples with their `.expected` and the size table (Step 2) +- [x] 14.3 Run the native and emscripten lanes before and after the `.expected` files (Step 3) +- [x] 14.4 Write the quick start and include the examples (Step 4) +- [x] 14.5 Commit (Step 5) ## 15. Boost.Cobalt's sources (superproject; plan: Task 15) -- [ ] 15.1 Failing tests in `tools/test/jamroot_test.py` and `tools/ci/actions_test.py` (plan: Task 15, Step 1) -- [ ] 15.2 Implement `/webcpp//boost_cobalt` and the Boost action (Step 2) -- [ ] 15.3 Run the tests and build the target for native, JSPI and Asyncify (Step 3) -- [ ] 15.4 Document it in AGENTS.md (Step 4) -- [ ] 15.5 Commit (Step 5) +- [x] 15.1 Failing tests in `tools/test/boost_libraries_test.py` and installer coverage in `tools/ci/actions_test.py` (plan: Task 15, Step 1) +- [x] 15.2 Implement `/webcpp//boost_cobalt` and the Boost action (Step 2) +- [x] 15.3 Run the tests and build the target for native, JSPI and Asyncify (Step 3) +- [x] 15.4 Document it in AGENTS.md (Step 4) +- [x] 15.5 Commit (Step 5) ## 16. Boost.Cobalt's `co_main` with the turn limit (plan: Task 16) -- [ ] 16.1 Write the page's section `doc/cobalt.adoc` (plan: Task 16, Step 1) -- [ ] 16.2 Write the failing `cobalt_test.cpp` and `cobalt_status_test.cpp` (Step 2) -- [ ] 16.3 Implement `src/cobalt_main.cpp` and the targets `cobalt-main` and `cobalt` (Step 3) -- [ ] 16.4 Run every lane (Step 4) -- [ ] 16.5 Measure Asyncify's stack again with the Cobalt tests (Step 5) -- [ ] 16.6 Write the twin example `asio_cobalt.cpp` (Step 6) -- [ ] 16.7 Commit (Step 7) +- [x] 16.1 Write the page's section `doc/cobalt.adoc` (plan: Task 16, Step 1) +- [x] 16.2 Write the failing `cobalt_test.cpp` and `cobalt_status_test.cpp` (Step 2) +- [x] 16.3 Implement `src/cobalt_main.cpp` and the targets `cobalt-main` and `cobalt` (Step 3) +- [x] 16.4 Run every lane (Step 4) +- [x] 16.5 Measure Asyncify's stack again with the Cobalt tests (Step 5) +- [x] 16.6 Write the twin example `asio_cobalt.cpp` (Step 6) +- [x] 16.7 Commit (Step 7) ## 17. Promises as operations (plan: Task 17) -- [ ] 17.1 Write the page's section `doc/promises.adoc` with guarantees 10 and 11 (plan: Task 17, Step 1) -- [ ] 17.2 Write the failing `promise_test.cpp` and `promise_cobalt_test.cpp` (Step 2) -- [ ] 17.3 See them fail (Step 3) -- [ ] 17.4 Implement `browser/error.hpp` and `browser/async_await.hpp` (Step 4) -- [ ] 17.5 Run every lane and the lint (Step 5) -- [ ] 17.6 Write the example `asio_promise.cpp` (Step 6) -- [ ] 17.7 Commit (Step 7) +- [x] 17.1 Write the page's section `doc/promises.adoc` with guarantees 10 and 11 (plan: Task 17, Step 1) +- [x] 17.2 Write the failing `promise_test.cpp` and `promise_cobalt_test.cpp` (Step 2) +- [x] 17.3 See them fail (Step 3) +- [x] 17.4 Implement `browser/error.hpp` and `browser/async_await.hpp` (Step 4) +- [x] 17.5 Run every lane and the lint (Step 5) +- [x] 17.6 Write the example `asio_promise.cpp` (Step 6) +- [x] 17.7 Commit (Step 7) ## 18. Events as operations (plan: Task 18) -- [ ] 18.1 Write the failing `event_test.cpp` (plan: Task 18, Step 1) -- [ ] 18.2 See it fail (Step 2) -- [ ] 18.3 Implement `browser/async_wait_event.hpp` (Step 3) -- [ ] 18.4 Run every lane and the lint (Step 4) -- [ ] 18.5 Write the example `asio_event.cpp` (Step 5) -- [ ] 18.6 Commit (Step 6) +- [x] 18.1 Write the failing `event_test.cpp` (plan: Task 18, Step 1) +- [x] 18.2 See it fail (Step 2) +- [x] 18.3 Implement `browser/async_wait_event.hpp` (Step 3) +- [x] 18.4 Run every lane and the lint (Step 4) +- [x] 18.5 Write the example `asio_event.cpp` (Step 5) +- [x] 18.6 Commit (Step 6) ## 19. Sockets and the transport point (plan: Task 19) -- [ ] 19.1 Write the page's section `doc/sockets.adoc` with guarantee 12 (plan: Task 19, Step 1) -- [ ] 19.2 Write the failing `sockets_test.cpp` and `transport_test.cpp` (Step 2) -- [ ] 19.3 See them fail (Step 3) -- [ ] 19.4 Implement `ip/tcp.hpp`, `ip/udp.hpp`, the three socket templates and `browser/transport.hpp` (Step 4) -- [ ] 19.5 Run every lane and the lint (Step 5) -- [ ] 19.6 Write the example `asio_sockets.cpp` (Step 6) -- [ ] 19.7 Commit (Step 7) +- [x] 19.1 Write the page's section `doc/sockets.adoc` with guarantee 12 (plan: Task 19, Step 1) +- [x] 19.2 Write the failing `sockets_test.cpp` and `transport_test.cpp` (Step 2) +- [x] 19.3 See them fail (Step 3) +- [x] 19.4 Implement `ip/tcp.hpp`, `ip/udp.hpp`, the three socket templates and `browser/transport.hpp` (Step 4) +- [x] 19.5 Run every lane and the lint (Step 5) +- [x] 19.6 Write the example `asio_sockets.cpp` (Step 6) +- [x] 19.7 Commit (Step 7) ## 20. The resolver, option A (plan: Task 20) -- [ ] 20.1 Write the page's part of `doc/sockets.adoc` with guarantee 13 (plan: Task 20, Step 1) -- [ ] 20.2 Write the failing `resolver_test.cpp` with the services table (Step 2) -- [ ] 20.3 See it fail (Step 3) -- [ ] 20.4 Implement `ip/basic_resolver.hpp` (Step 4) -- [ ] 20.5 Run every lane and the lint (Step 5) -- [ ] 20.6 Write the example `asio_resolver.cpp` (Step 6) -- [ ] 20.7 Commit (Step 7) +- [x] 20.1 Write the page's part of `doc/sockets.adoc` with guarantee 13 (plan: Task 20, Step 1) +- [x] 20.2 Write the failing `resolver_test.cpp` with the services table (Step 2) +- [x] 20.3 See it fail (Step 3) +- [x] 20.4 Implement `ip/basic_resolver.hpp` (Step 4) +- [x] 20.5 Run every lane and the lint (Step 5) +- [x] 20.6 Write the example `asio_resolver.cpp` (Step 6) +- [x] 20.7 Commit (Step 7) ## 21. The `ssl` names, and OpenSSL named by the program (plan: Task 21) -- [ ] 21.1 Write the failing tests `ssl_test.cpp`, `ssl_without_openssl_test.cpp`, `openssl_on_webassembly_test.cpp`, `openssl_named_test.cpp` (plan: Task 21, Step 1) -- [ ] 21.2 Implement `ssl.hpp`, `src/openssl_on_webassembly.hpp` and the `openssl` targets in `build.jam` (Step 2) -- [ ] 21.3 Run every lane, `matrix_test.py` and the lint (Step 3) -- [ ] 21.4 The form a program built for both targets writes, built by an example in `example/tls/` (Step 4) -- [ ] 21.5 Write the page's parts (Step 5) -- [ ] 21.6 Commit (Step 6) +- [x] 21.1 Write the failing tests `ssl_test.cpp`, `ssl_without_openssl_test.cpp`, `openssl_on_webassembly_test.cpp`, `openssl_named_test.cpp` (plan: Task 21, Step 1) +- [x] 21.2 Implement `ssl.hpp`, `src/openssl_on_webassembly.hpp` and the `openssl` targets in `build.jam` (Step 2) +- [x] 21.3 Run every lane, `matrix_test.py` and the lint (Step 3) +- [x] 21.4 The form a program built for both targets writes, built by an example in `example/tls/` (Step 4) +- [x] 21.5 Write the page's parts (Step 5) +- [x] 21.6 Commit (Step 6) ## 22. The rulebook, the index and the page whole (plan: Task 22) -- [ ] 22.1 Write chapter 13's items of the superproject's AGENTS.md (plan: Task 22, Step 1) -- [ ] 22.2 Write the rows of the table of libraries (Step 2) -- [ ] 22.3 Order the page (Step 3) -- [ ] 22.4 Check the text for the banned characters (Step 4) -- [ ] 22.5 Commit both repositories (Step 5) +- [x] 22.1 Reconcile CODING-GUIDELINES chapters 15/16/19 and AGENTS with the approved WASIp3/TLS scope (supersedes the old chapter 13 references) +- [x] 22.2 Write the rows of the table of libraries (Step 2) +- [x] 22.3 Keep the owner-approved Diataxis page order, generated MrDocs reference and final changelog appendix (supersedes the older overview-first order) +- [x] 22.4 Check the text for the banned characters (Step 4) +- [x] 22.5 Commit both repositories (Step 5) ## 23. Green, review and the gates (plan: Task 23) - [ ] 23.1 Run the definition of green, each lane from scratch (plan: Task 23, Step 1) -- [ ] 23.2 Dispatch the whole-branch review (Step 2) -- [ ] 23.3 Fix what it finds, each with a failing test first (Step 3) -- [ ] 23.4 Record the owner's approvals of the five departures in the ledger (Step 3a) -- [ ] 23.5 Gate G1: the owner creates `webcpporg/asio` (Step 4) -- [ ] 23.6 Gate G2: the owner adds the submodule (Step 5) +- [x] 23.2 Dispatch the whole-branch review (Step 2) +- [x] 23.3 Fix what it finds, each with a failing test first (Step 3) +- [x] 23.4 Record the owner's five approvals of 2026-10-11, already present in reference/plan.md; later amendments supersede only the explicitly changed departures +- [x] 23.5 Gate G1: `webcpporg/asio` was created with owner authorization on 2026-11-03 (UTC) +- [x] 23.6 Gate G2: the owner-authorized submodule integration is recorded by superproject commit `2ba5116` - [ ] 23.7 Gate G3: push the library, then the superproject, and watch both CIs (Step 6) + +## Approved WASIp2 follow-up, 2026-11-03 + +- [x] P2.1 Implement the single-thread pollable core for timers and TCP/UDP; explicitly + reject unsupported multi-thread targets. The initial Cobalt/guest TLS exclusions + are superseded by the capability-completion extension below. +- [x] P2.2 Implement deferred forward async DNS with pollables, cancellation and handler + associations; pin and verify the private wasi-libc descriptor ABI. +- [x] P2.3 Implement supplied CLI streams with partial I/O, readiness, cancellation, + associated allocation/execution and explicit host-blocking boundaries. +- [x] P2.4 Reproduce and fix idle empty-poll trapping and write-permit narrowing; add + readiness-at-registration and pending-write cancellation consumers. +- [x] P2.5 Commit local native/P3/P2 regressions, focused lint and rendered documentation; + export the exact committed reference tree. See reference/STATUS.md for scope and counts. +- [ ] P2.6 Complete fresh remote CI and the existing integration gates for the current tree. + + +## Approved capability completion, 2026-11-03 + +- [x] C1 Complete WASI connected UDP gather and scatter receive, native P3 asynchronous + DNS, and cancellation/resource-lifetime regressions. +- [x] C2 Enable the shared source-built OpenSSL/CAs and Cobalt/SSL targets on P2 with + both exception profiles; retain the pinned SDK thread restriction. +- [x] C3 Enable explicit browser pthread execution and main-thread handoff, test both + suspension mechanisms and document dependency-only counterexamples. +- [x] C4 Centralize derived capability macros and explicit requirement/header guards, + update Diataxis/AsciiDoc/MrDocs documentation and the target/variant matrix. +- [x] C5 Complete local reviews/checks and commit/export the exact candidate. Publication + gates remain separate; this extension does not claim new remote CI or a merge. diff --git a/libraries/beast/openspec/changes/genesis/.openspec.yaml b/libraries/beast/openspec/changes/genesis/.openspec.yaml index e08ead5..be092b9 100644 --- a/libraries/beast/openspec/changes/genesis/.openspec.yaml +++ b/libraries/beast/openspec/changes/genesis/.openspec.yaml @@ -2,10 +2,10 @@ schema: spec-driven created: 2026-10-10 webcpp: library: beast - title: "beast: Boost.Beast natively, the browser's WebSocket and fetch on Emscripten" + title: "beast: existing Boost.Beast applications on WASIp2, WASIp3 and Emscripten" kind: wrapper port_of: null - status: draft + status: implementing release: null - implementation: null - decided: null + implementation: https://github.com/webcpporg/beast + decided: 2026-11-06 diff --git a/libraries/beast/openspec/changes/genesis/design.md b/libraries/beast/openspec/changes/genesis/design.md index e63c622..386a2ef 100644 --- a/libraries/beast/openspec/changes/genesis/design.md +++ b/libraries/beast/openspec/changes/genesis/design.md @@ -1,13 +1,23 @@ ## Context -webcpp::beast is a wrapper of webcpp, not a port. Natively it is Boost.Beast. Compiled with +The primary goal is to compile existing Boost.Beast programs to WebAssembly, on WASIp2, +WASIp3 and Emscripten, with minimal source changes. Native Boost.Beast is the reference. +webcpp::beast is a compatibility facade with environment-specific implementations. +Use the platform's HTTP/WebSocket services where they exist; do not require an upstream +Beast protocol engine merely because the application uses its programming interface. Compiled with Emscripten, the same names and interfaces drive the browser's `WebSocket` and `fetch`: the layers the browser does not expose (resolve, connect, the TLS handshake) record what the browser needs, and the last one (the WebSocket handshake, or an HTTP request) opens the connection. -The design is `reference/spec.md` (a draft of 2026-10-10, with four decisions of the owner of -that date). It rests on a review of Boost.Beast 1.92 and Emscripten 6.0.11 whose probes are -cited there; this change has not re-run them. The library builds on webcpp::asio +The historical baseline is `reference/spec.md` (2026-10-10). The owner expanded the scope +on 2026-11-02 to all upstream example applications and explicitly included WASIp2 and +WASIp3. On 2026-11-03 the owner confirmed that guest sockets/TLS follow Asio's targets: +initially native and WASIp3. Later that day the owner approved a single-thread Asio +WASIp2 core and asynchronous supplied-channel WebSocket. Portable HTTP and host HTTP +remain independent of the reactor; the full P2 guest-socket corpus needs its own validation. This design and `specs/beast/spec.md` are the current proposal; +the historical baseline is not rewritten. The committed implementation has native, WASI and actual browser +measurements; `reference/STATUS.md` identifies the exact source snapshot, evidence and +remaining acceptance gates. The library builds on webcpp::asio (`libraries/asio`, change `genesis`): the io_context, the bridge that posts the browser's events to it, Boost's timers, the `ip::tcp` types with the resolver of its decision 5, and the `ssl` record of the program's TLS settings. @@ -15,8 +25,8 @@ events to it, Boost's timers, the `ip::tcp` types with the resolver of its decis Constraints every decision below works within, from the superproject's rulebook: - header-only C++20, namespace `webcpp::beast`, macros `WEBCPP_BEAST_*`; -- targets native and Emscripten only, because Boost.Asio 1.92 does not compile for the WASI - targets with wasi-sdk 34 and webcpp::asio therefore has none; +- targets native, WASIp2, WASIp3 and Emscripten; WASI host-HTTP and stream/socket backends + are separate. The newly approved Asio P2 core makes sockets possible, while the Beast P2 guest-socket corpus remains an integration/validation task; - errors as values; exceptions optional through `WEBCPP_BEAST_NO_EXCEPTIONS`; - allocation through allocators the program gives; Boost and std before custom code; outside interfaces wrapped; fixed-width types; @@ -26,18 +36,21 @@ Constraints every decision below works within, from the superproject's rulebook: **Goals:** -- Beast's three client examples (`websocket_client_async`, `websocket_client_async_ssl`, - `http_client_async`) run in a browser with the changes the specification names, and print the - same natively and in the browser. +- Account for all 53 executable targets in the pinned Beast examples, plus their support + files and documentation snippets. Run every application whose required facilities the + target exposes, and provide useful host-service or stream counterparts for applications + whose original OS transport is absent. Keep both results visible. +- Preserve the original programming model and protocol behaviour. Every source adaptation + has an inspectable diff; a counterpart with a different model is reported separately. - Natively, no cost and no difference: Beast's own types, one derived class, two functions. - In the browser, every Beast setting classified: honoured, unsupported, or ignored with a reason; a program learns at the operation what the browser cannot do. -- Bounded memory in the browser: a send bound and a receive queue, both options. +- Bound the library-owned receive queue and pending writes in the browser; browser-internal + memory is outside the C++ allocator and cannot be bounded by this wrapper. - A defined cancellation, destructor and allocation contract, proven by a counting test. **Non-Goals:** -- A WASI target (waits for a WASI backend of webcpp::asio). - `WebSocketStream` (increment 3: Chromium only, doubles the surface behind one interface). - A resolver of webcpp::beast's own (rejected, decision D4). - Server-side WebSocket or HTTP in the browser; the browser has no listening socket. @@ -50,16 +63,24 @@ Constraints every decision below works within, from the superproject's rulebook: ### D1. A library of its own on webcpp::asio; WebSocket first, then the HTTP client Owner's decision 1. Beast is a library on Asio, so webcpp::beast is a library on webcpp::asio, -not a part of it. Increment 1 is the WebSocket client on both targets; increment 2 is the HTTP -client in the browser. This change covers both; increments 3 and 4 are later changes. +not a part of it. Increment 1 is WebSocket across the target workstreams; increment 2 adds HTTP browser +transport and completes HTTP example coverage. WASI prerequisites can advance independently. +All upstream examples are covered by this change; WebSocketStream and trystero migration +remain later changes. -### D2. Natively it is Boost.Beast; the browser classes exist only on Emscripten +### D2. Preserve the interface while selecting the platform implementation -Every name that touches no network (buffers, `http` messages, parsers, serializers, `websocket` -close reasons and errors) is Beast's own on both targets. Natively `tcp_stream` and -`ssl_stream` are Beast's, and `websocket::stream` is a class derived from Beast's, adding the -allocator constructor, so that the two targets have one constructor set. A static-assertion test -proves the aliases are Beast's types. +Native uses upstream Beast. Wasm HTTP can translate Beast-shaped requests, responses and +completion tokens directly to host HTTP services; browser WebSocket uses the browser object. +Application compatibility does not require that the implementation be Boost.Beast. A raw +stream/socket backend can retain upstream protocol algorithms where useful and supported. + +The owner-approved 2026-11-06 architecture makes native type identity literal. +Wasm protocol/data adaptations ship under explicit WebCPP paths and share Asio's +selected backend with Cobalt. Browser host APIs remain independent of the guest +protocol engine. Source archive consumers declare their bindings, provider and +compiler requirements, without consumer-time patches or replacement Boost include +paths. Native and Wasm types do not promise binary interoperability. ### D3. What the browser cannot honour fails as a value, by default @@ -90,41 +111,55 @@ browser has one call that does resolution, connection, TLS and the upgrade toget ### D6. The browser WebSocket is selected by the next layer's type `websocket::stream` over the browser `tcp_stream` or `ssl_stream` is webcpp's -browser WebSocket; over any other next layer (a relay socket, a WebRTC channel's byte stream) it -is Beast's, as natively. `teardown` and `async_teardown` for webcpp::asio's sockets are declared +browser WebSocket. A supported explicit byte-stream next layer (a relay socket, a WebRTC +channel's byte stream) needs a guest protocol engine. Upstream Beast is the proposed engine +for that opt-in path, subject to O6; it is not a prerequisite for browser-native WebSocket. +Where Beast is reused, `teardown` and `async_teardown` for webcpp::asio's sockets are declared in the sockets' namespace so that argument-dependent lookup finds them, as Beast's `websocket/teardown.hpp` asks of a user-defined socket. ### D7. Back-pressure is a queue in the library, not the browser's -`send` never blocks and never refuses; the library bounds `bufferedAmount` (default 4 MiB, an -option) and fails a write past it with `error::send_limit`. Messages arrive whether a read is +Browser `send` does not synchronously wait for delivery, but can reject an invalid state or +close when it cannot buffer. The library checks OPEN before sending, maps failures to error +values, bounds `bufferedAmount` (default 4 MiB, an option), and fails a write past it with +`browser_errc::send_limit`. Successful completion means accepted for sending, not peer delivery. Messages arrive whether a read is pending or not and wait in a bounded queue in the stream's allocator; past the bound the stream -closes and the next read completes with `error::receive_limit`. A queued message does not keep +closes and the next read completes with `browser_errc::receive_limit`. A queued message does not keep `run` alive. `WebSocketStream`, which would pause receiving while C++ does not read, is a later increment. -### D8. The HTTP client reuses Beast's algorithms by being a byte stream +### D8. HTTP host backends translate messages directly + +The default browser HTTP backend maps request/response operations to fetch. The WASI host-HTTP +backend maps them to wasi:http, with separate P2/P3 ABI adapters. Facade overloads or dispatch +for HTTP operations are allowed; the old rule forbidding all overloads is removed. Do not +require serialize-parse-serialize round trips just to reuse upstream algorithms over an +imaginary socket. Message/body/serializer incremental interfaces still need explicit coverage; +this is not permission to drop them or ignore body limits, back-pressure or allocators. -The browser `tcp_stream` accepts the bytes Beast's serializer writes, parses them back with -Beast's `request_parser`, makes one `fetch` per whole request, and serializes the response with -Beast's serializer into the bytes the reads yield (chunked, with `Content-Length` and -`Content-Encoding` left out). webcpp::beast overloads no HTTP algorithm. The cost is one parse -and one serialization per message, for Beast's code unchanged. +A byte-oriented compatibility adapter remains available when an application explicitly needs +parser/serializer stream APIs or a supplied stream. Its cost and changed framing are recorded; +wire parsers are not claims about the host's real HTTP framing. HEAD/204/304 responses have no +synthetic body or chunk terminator. Direct and byte-adapter paths must agree on application +status, exposed headers, body and cancellation outcomes. -### D9. Configuration is read once, in one header, and cannot silently disagree +### D9. Configuration is propagated once, with distinct browser types `` reads `WEBCPP_BEAST_UNSUPPORTED_ERROR`, `WEBCPP_BEAST_UNSUPPORTED_IGNORE` and `WEBCPP_BEAST_NO_EXCEPTIONS`; both unsupported macros defined is an `#error`. A b2 feature drives the setting from the usage requirements. The browser classes live in an inline namespace named after the setting, as Asio tags its own, so -translation units that disagree name different types and fail at link. +translation units that disagree name different types. A test passes a configured stream +across translation units and requires a link failure for a mismatch. This does not claim +that unrelated functions using different configurations always produce a linker error. ### D10. Errors with no counterpart have a category of their own The browser's `error` event carries no cause, and a failed connection closes with 1006, so refusal, DNS, TLS and a blocked port are one error. Seven values in the category -`webcpp.beast` are fixed and never reused; every other outcome maps to an existing Beast or Asio +`webcpp.beast` are fixed and never reused and are named by `browser_errc`, preserving +Boost.Beast's existing `error` enum and its category; every other outcome maps to an existing Beast or Asio code (`websocket::error::closed`, `connection_reset`, `beast::error::timeout`, `websocket::error::message_too_big`, `operation_not_supported`). @@ -135,7 +170,7 @@ per operation and per cancellation type, what happens. The destructor completes operation with `operation_aborted` (posted, so no pending work keeps `run` alive), closes the browser socket without a code, and removes its registrations from webcpp::asio's bridge. -### D12. An allocator constructor on both targets +### D12. An allocator constructor on every target Operation state uses the handler's associated allocator, as Beast's does. The stream's own state (the receive queue, the registrations, the buffered fragments) uses the allocator given to @@ -146,7 +181,167 @@ without it. Natively Beast's own state uses Beast's allocation, which the docume Beast's SSL examples set SNI through `SSL_set_tlsext_host_name(native_handle(), host)`; there is no OpenSSL handle in the browser. Boost 1.92 has no SNI helper, so `set_server_name` is new on -both targets and a program changes that line once. +every target and a program changes that line once. Exact-version TLS context methods are a separate +restriction: `tlsv12_client` fixes both minimum and maximum to TLS 1.2 upstream. Browser +strict mode rejects it; a documented `tls_client` counterpart delegates version negotiation +to the browser. Ignoring a version restriction is never reported as enforcing it. +For host-service backends, record the requested SNI hostname and validate it against the +eventual URL authority. The host controls SNI; a differing requested name follows the +unsupported-setting policy. Only guest-owned socket TLS calls OpenSSL. + +### D14. Target profiles and ownership of the WASI prerequisites + +Use the target's own service first for that protocol, selected explicitly by backend type or +build configuration; do not silently fall back to a different trust/transport policy after an +error. WASI host-HTTP uses webcpp::wasi and the component ABI. Its completion scheduling may +need Asio executor integration, but not TCP, a socket reactor, DNS workers or guest OpenSSL. +For a socket backend, keep socket/reactor/resolver fixes in Asio or wasi-libc and TLS changes +in the shared build. Guest sockets follow Asio's declared targets: native, WASIp2 single +and WASIp3. Guest TLS is currently validated only for native and WASIp3. These are distinct dependency chains +and are tested independently. + +| Profile | Threading | Exceptions | Current dependency position | +| --- | --- | --- | --- | +| Native | single or OS threads | on/off | reference, with example-specific dependencies | +| WASIp2 host HTTP | host invocations; guest threads separately probed | on/off independently verified | independent Beast bridge and application counterparts measured | +| WASIp2 supplied streams | single; guest threads separately probed | on/off independently verified | HTTP counterparts and asynchronous WebSocket client/server counterparts measured | +| WASIp2 sockets/TLS | single for Asio core | on/off for Asio core | Asio core is available; Beast guest-socket applications and guest TLS remain unvalidated/not integrated | +| WASIp3 host HTTP | host invocations; guest threads separately probed | on/off independently verified | independent Beast bridge and application counterparts measured | +| WASIp3 sockets, single | disabled | on/off | Asio/TLS integrated; async DNS unsupported | +| WASIp3 sockets, multi | cooperative, not CPU-parallel | off | Asio/TLS integrated | +| WASIp3 sockets, multi | cooperative | on | blocked by the tested SDK 34 exception runtime | +| Emscripten JSPI | single | on/off | browser Asio integration available | +| Emscripten Asyncify | single | on/off | browser Asio integration available | + +B2 must reject unsupported configurations with a specific reason, rather than silently +switching targets, enabling exceptions or turning off threads. Browser pthread support is +not implied by Emscripten supporting pthreads generally; the current Asio backend disables +threads. Unsupported thread profiles still appear in the matrix. WASIp2 threading and EH +are investigated independently; do not copy WASIp3's cooperative-thread result into them. +The existing Asio evidence is pinned to superproject `2ba5116` and Asio `3611a6e`; +`libs/asio/doc/capabilities.adoc` and `feature-matrix.adoc` are the dependency references. + +### D15. Compatibility is demonstrated by the upstream applications + +The owner's acceptance corpus is the entire example catalogue, not a hand-picked tutorial. +Pin Boost tag `boost-1.92.0`, Beast commit `7c1e061f91e2ef542217b76286c314d006c0c8fc`. +The source audit found 53 `exe` declarations under `example/**/Jamfile` and 53 entry-point +sources. Keep a future machine-readable manifest with one row per executable, all source +and fixture paths, target/profile, exact adaptations, upstream dependencies, build command, +runtime command, expected exchange, result and evidence. Reconcile it with upstream Jamfiles +and CMake definitions on upgrades. A missing row is a coverage failure. + +The native upstream build is the oracle. Maintain an adapted webcpp twin with a small, +reviewable diff: includes/namespaces, the portable SNI helper, target build configuration and +explicit platform adaptations. Do not replace `spawn` with `co_await`, `system_executor` with +an event loop, or synchronous code with callbacks and then label the original compatible. +Such counterparts can be useful and are built too, but the original's blocked status remains. +Retain upstream notices. Common certificate headers are fixtures, not a production trust store. + +### D16. Execution, scheduling and TLS remain faithful to the target + +- WASI HTTP applications use host request/response resources by default. Applications that + need real TCP/HTTP wire control or WebSocket framing can explicitly select a socket/stream + backend. Host HTTP is not evidence of a WebSocket upgrade/tunnel API; probe such a + facility independently before exposing it. +- On WASIp3 single, the existing async resolver's unsupported result is a required negative + test. A pre-resolved endpoint (or synchronous resolution before running the context) is an + explicit example adaptation. The program's URL hostname is still used for Host, SNI and + certificate identity. Do not claim this establishes asynchronous DNS compatibility. +- Guest-owned TLS in native/WASIp3 socket backends uses existing OpenSSL and CA targets. + Asio also provides WASIp2 guest TLS, but Beast's P2 guest-socket and guest-TLS + applications remain pending integration and validation. WASI host HTTP and browser services use the + host's TLS and trust policy where provided; guest CAs do not automatically affect it. + Never disable verification or silently switch backends to make an example pass. +- Browser synchronous client methods need a suspending facade over the asynchronous transport. + Probe this before promising compatibility: JSPI/Asyncify must resume the original call and + allow a browser heartbeat to run while it waits. No busy waits or nested `io_context::run` + inside a running handler. The initial supported entry is the application's outer main; + nested/reentrant synchronous use must be diagnosed and documented. It stays blocked until + the probe and example tests pass, rather than silently converting the program to async. +- `coro` examples and `websocket-server-fast` use stackful Boost.Coroutine/Context. Test the + upstream backend, unwinding and EH requirements independently. JSPI, Asyncify and C++20 + coroutines are not evidence for that backend. `stackless` examples use Asio's state-machine + coroutine and are a different dependency class. +- Server examples that start threads or install signals need separate original and adapted + results. A one-runner, explicitly stopped counterpart can work without those facilities; + it does not prove parallelism, signals or the original threading model. + +### D17. Controlled peers and honest browser results + +Use bounded local fixtures instead of the examples' public hosts. Supply deterministic files, +JSON, method responses and crawler URLs; keep the crawler's algorithm and exercise multiple +hosts/paths without crawling the public internet. Grant only the WASI network/filesystem +capabilities the fixture requires. A host driver starts peers, waits for readiness, drives the +application, checks the response, imposes a deadline and reaps every process. + +Run clients against native and supported WASI servers, WASI servers against a host client, +and browser clients against those servers. The chat example includes its HTML client and +multiple simultaneous participants. A browser client talking to a WASI server is a working +cross-target application, not evidence that the server runs inside the browser. Browser TCP +listeners, Unix-domain sockets and raw TCP echo remain unavailable without another transport; +provide the requested stream or host-service counterparts, labelled as such. A network +proxy or a different application protocol is a separate design, not an implicit dependency. + +For HTTP compare status, exposed application headers and decoded payloads, using a documented +normalization of framing and browser-controlled fields. Do not erase meaningful errors, body +bytes or redirect outcomes. Raw output remains available. For WebSocket compare text/binary +mode, payloads and observable close outcomes. Test TLS trust failures, hostname mismatches, +timeouts, mid-transfer cancellation, peer close and cleanup. Servers have an explicit bounded +shutdown path. Compilation and execution are separate matrix fields: a fallback `main` that +prints 'not supported', a no-op build or Node-only execution cannot count as browser success. + +### D18. Documentation and acceptance are driven by the matrix + +Write tutorials, how-to guides, reference and explanations in AsciiDoc following Diataxis; +MrDocs supplies API reference from headers. Include compiled example regions and observed +output. Publish one feature matrix and one example matrix, with target, JSPI/Asyncify where +applicable, threads, EH, tool versions, flags and commands. Label results as planned, passed, +failed, blocked or platform-unavailable. Unsupported-policy IGNORE never changes a blocked +backend into a supported one. All promised runnable rows must pass. A documented host-service/stream counterpart can +fulfil application portability even when the original OS transport is unavailable; it does +not establish exact source/transport parity. Unresolved implementation blockers still remain +visible for their promised backend. Do not reduce the denominator to the examples that happen to build. + +### D19. Adapt WASI HTTP servers at the host entrypoint + +The owner explicitly wants WASI's HTTP infrastructure reused for Beast HTTP servers. Keep +request-handling logic and message operations, replacing transport bootstrap with a component +entry adapter. In P2 the host calls incoming-handler with a request and response-outparam; +in P3 it calls the versioned async handler. The host owns bind/listen, physical connections, +HTTP version and potentially TLS. An HTTP handler is not a physical TCP accept event. + +Offer the host-adapted application alongside the raw-socket example. The diff identifies the +entrypoint and listener/session plumbing replaced by the adapter. It must not fake socket +options, peer identity, pipelined physical connection identity, keep-alive ownership, TLS +inspection or WebSocket upgrades. Request routing and response construction remain the +application's. A library entry adapter may standardize this bootstrap, but cannot infer an +arbitrary program's application handler from its main function. + +Reuse webcpp::wasi's component/B2 machinery. Its current helper exposes method/target and a +response containing status, content type and a whole body; that is evidence of an existing +entrypoint, not a complete Beast bridge. Extend its reusable request/header/body/trailer, +streaming and lifetime interfaces in that library. Exactly one response is committed per +request; cancellation after commitment fails the remaining body rather than sending a second +response. P2 response-outparam and P3 async-resource lifetimes have independent tests. + +### D20. Pair-of-streams counterparts for local-socket examples + +Treat an input stream plus an output stream as one already-connected byte channel when the +host wires them to a peer. stdin/stdout are possible endpoints, not an implicit Unix socket. +The adapter implements synchronous/asynchronous read/write, partial progress, EOF, +back-pressure, cancellation and ownership to the extent the specific host streams provide. +A regular file, terminal and pipe can have different readiness/closure behaviour; test the +provided endpoints rather than infer capabilities from an integer descriptor. + +Run the original HTTP or WebSocket application exchange over this explicit stream transport +where the protocol engine supports it. stdin/stdout carry protocol bytes only; diagnostics go +to stderr. The test driver wires both directions, drains output concurrently, injects partial +reads/writes, closes endpoints and enforces a deadline. One input/output pair is one peer; +multiple connections require additional host-supplied resources, not invented accept calls. +No pathname bind/connect, descriptor passing, Unix peer credentials or socket-only options +are promised. These are successful adapted applications when their stated exchanges pass, +while the original Unix-domain transport row remains unavailable on that profile. ## Risks / Trade-offs @@ -157,15 +352,21 @@ both targets and a program changes that line once. DNS, TLS, a blocked port and CORS-like failures. Accepted: the Web APIs offer no more. - **Node enforces neither CORS nor mixed content** (measured by the review), so those failures are only seen in the headless-browser lane. -- **One parse and one serialization per HTTP message** in the browser. Accepted for Beast's code - unchanged; a direct path is a later optimisation if measured necessary. +- **Synthetic HTTP framing costs and differences.** The explicit byte-stream adapter may + parse/serialize messages and change framing. Measure and document that optional path; + direct request/response mapping to host services is the default architecture. - **The `ERROR` default makes some of Beast's examples fail as written** (`User-Agent`, added roots); the specification lists, per example, what changes under each setting. The trade-off is honesty over compatibility. - **Idle-timeout activity** is messages and close frames only, because the browser answers the peer's pings itself and shows none; stated in the table of differences. -- **Dependence on a draft of webcpp::asio.** Its decisions (resolver, bridge, `ssl` record) are - settled by the owner but unimplemented. +- **Backend gaps are not Beast features.** The integrated Asio already has browser and WASIp3 + support and now a single-thread WASIp2 core with asynchronous forward DNS. Its WASIp3 single-thread async resolver reports + `operation_not_supported`; cooperative threads currently require exceptions off. Keep + those constraints in the matrix and fix common transport issues in Asio/libc, not Beast. +- **Stackful coroutines and operating-system facilities.** Boost.Context, Unix sockets, + signal handlers and CPU-parallel thread pools cannot be inferred from a working TCP test. + Each example is checked for these dependencies before a profile can be called supported. ## Migration Plan @@ -176,16 +377,167 @@ lists. Trystero moves onto the library in a later change. ## Open Questions -- **O1. Header layout.** The public headers and the convenience header are not fixed by the - specification (the plan will fix them). webcpp::asio's convenience header leaves `ssl` out - natively because it brings OpenSSL; whether `` does the same is to decide. -- **O2. The defaults of the receive queue bound** (the send bound is 4 MiB) and the names of the - two options. To measure and decide in the plan. -- **O3. How a decorator is called** on an empty `websocket::request_type`: whether any other - field can be told apart from `User-Agent` by name alone, or every non-subprotocol field is - unsupported (the specification says the latter: confirm with a test). +- **O1. Header layout, initial decision.** The convenience header contains portable data. + Byte-stream algorithms, sockets and TLS have explicit headers and dependencies. Host-entry + headers are also explicit. This keeps message-only WASIp2 builds free of a reactor. +- **O2. Queue defaults, implemented decision.** `websocket::queue_limits` exposes `send` and + `receive`, both defaulting to 4 MiB. The send bound includes browser `bufferedAmount` + and unsent application fragments. The receive bound includes retained payload capacity + and message records, including arrivals before executor dispatch and partially consumed + records. Empty messages consume record budget. Ingress is charged before retention and + uses one allocator-bound notification for a batch; a paused executor cannot accumulate + an unbounded queue of notifications. `test/browser/browser_test.cpp` and + `test/browser/lifecycle_test.cpp` exercise limits with real native Beast peers, including + paused empty/payload bursts. Browser-internal memory remains outside this bound. +- **O3. Decorator shape and classification, implemented decision.** The browser calls the + decorator on an empty `websocket::request_type` with PMR fields backed by the stream's + allocator. Only `Sec-WebSocket-Protocol` is representable, including comma-separated + protocol tokens. Every other field, including `User-Agent`, is unsupported: ERROR + rejects the dependent handshake and IGNORE omits the field. Actual Chrome and Node + JSPI/Asyncify tests exercise both policies; the allocation witness covers long field + values and allocator-owned decorator state. Guest protocol decorators remain a separate + explicit adapter and do not relax the browser host restriction. - **O4. Streaming request bodies.** The specification buffers a request body whole before the `fetch`; whether a streaming upload (Chromium only) is wanted is open, and belongs to a later change. +- **O6. Upstream header/type dependency, implementation decision.** Following the authorized + recommendation, reuse upstream data types. Browser and WASI host operations still map + directly to environment services; they need not execute the upstream protocol engine. - **O5. The Boost proposal** (specification section 10) is made when both libraries have run in real programs, trystero first; no work in this change. + +## Upstream executable inventory: original transport/programming model + +Source: [Boost.Beast 1.92 examples](https://github.com/boostorg/beast/tree/7c1e061f91e2ef542217b76286c314d006c0c8fc/example), +read on 2026-11-02. This is a source audit, not build or runtime evidence. + +`T`: intended direct twin after common include/namespace/SNI changes; `A`: an explicit +platform adaptation is also expected; `B`: dependency or implementation probe blocks a +compatibility claim; `U`: required platform facility is unavailable in the selected backend. +All cells are prospective. This table describes the original transport/model, not the +complete application result: the measured manifest must add host-HTTP and pair-of-streams +counterparts for each applicable executable. An original `U` does not exclude those +counterparts from the deliverable. Native denotes an OS/EH/thread configuration that supplies the +example's dependencies; every single-thread and EH-off variant is tested and reported +separately. WASIp2 socket cells are `B` until integrated and tested against the newly +approved Asio P2 core. Unix-domain and system-executor requirements remain `U`. Host HTTP and supplied-stream results remain +separate from these original socket cells. Browser columns +must expand to both JSPI/Asyncify and EH modes in the measured matrix. + +Notes: `DNS` = async DNS gap on WASIp3 single; `CTX` = stackful coroutine backend; +`LOCAL` = Unix-domain socket; `EXEC` = system executor/thread pool; `SYNC` = browser suspension +facade; `RUN` = thread/signal/server-lifetime adaptation; `TLS` = trust/SNI adaptation; +`FIX` = controlled fixture input; `STREAM` = raw Asio stream needs browser Beast transport. +A `U` is documented and negatively tested, never counted as a passed application. + +| Upstream path under example/ | Executable | Native | WASIp2 sockets | WASIp3 single | WASIp3 cooperative | Browser | Notes | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `advanced/server` | `advanced-server` | A | B | A | A | U | RUN | +| `advanced/server-flex` | `advanced-server-flex` | A | B | A | A | U | RUN, TLS | +| `advanced/server-flex-awaitable` | `advanced-server-flex-awaitable` | A | B | A | A | U | RUN, TLS | +| `doc/ssl` | `doc-ssl-client` | A | B | A | A | A | TLS, STREAM | +| `doc/ssl` | `doc-ssl-server` | A | B | A | A | U | TLS, STREAM | +| `echo-op` | `echo-op` | T | B | A | A | U | Common migration | +| `http/client/async` | `http-client-async` | T | B | A | T | A | DNS | +| `http/client/async-local` | `http-client-async-local` | T | U | U | U | U | LOCAL | +| `http/client/async-ssl` | `http-client-async-ssl` | A | B | A | A | A | DNS, TLS | +| `http/client/async-ssl-system-executor` | `http-client-async-ssl-system-executor` | A | U | B | A | B | DNS, EXEC, TLS | +| `http/client/awaitable` | `http-client-awaitable` | T | B | A | T | A | DNS | +| `http/client/awaitable-ssl` | `http-client-awaitable-ssl` | A | B | A | A | A | DNS, TLS | +| `http/client/body` | `json_client` | A | B | T | T | B | SYNC, FIX | +| `http/client/coro` | `http-client-coro` | T | B | B | B | B | DNS, CTX | +| `http/client/coro-ssl` | `http-client-coro-ssl` | A | B | B | B | B | DNS, CTX, TLS | +| `http/client/crawl` | `http-crawl` | A | B | A | A | A | DNS, RUN, FIX | +| `http/client/methods` | `http-client-methods` | A | B | T | T | B | SYNC, FIX | +| `http/client/sync` | `http-client-sync` | A | B | T | T | B | SYNC | +| `http/client/sync-ssl` | `http-client-sync-ssl` | A | B | A | A | B | SYNC, TLS | +| `http/server/async` | `http-server-async` | A | B | A | A | U | RUN | +| `http/server/async-local` | `http-server-async-local` | A | U | U | U | U | LOCAL, RUN | +| `http/server/async-ssl` | `http-server-async-ssl` | A | B | A | A | U | RUN, TLS | +| `http/server/awaitable` | `http-server-awaitable` | A | B | A | A | U | RUN | +| `http/server/coro` | `http-server-coro` | A | B | B | B | U | CTX, RUN | +| `http/server/coro-ssl` | `http-server-coro-ssl` | A | B | B | B | U | CTX, RUN, TLS | +| `http/server/fast` | `http-server-fast` | T | B | A | A | U | Common migration | +| `http/server/flex` | `http-server-flex` | A | B | A | A | U | RUN, TLS | +| `http/server/small` | `http-server-small` | T | B | A | A | U | Common migration | +| `http/server/stackless` | `http-server-stackless` | A | B | A | A | U | RUN | +| `http/server/stackless-ssl` | `http-server-stackless-ssl` | A | B | A | A | U | RUN, TLS | +| `http/server/sync` | `http-server-sync` | A | B | A | A | U | RUN, SYNC | +| `http/server/sync-ssl` | `http-server-sync-ssl` | A | B | A | A | U | RUN, SYNC, TLS | +| `websocket/client/async` | `websocket-client-async` | T | B | A | T | A | DNS | +| `websocket/client/async-local` | `websocket-client-async-local` | T | U | U | U | U | LOCAL | +| `websocket/client/async-ssl` | `websocket-client-async-ssl` | A | B | A | A | A | DNS, TLS | +| `websocket/client/async-ssl-system-executor` | `websocket-client-async-ssl-system-executor` | A | U | B | A | B | DNS, EXEC, TLS | +| `websocket/client/awaitable` | `websocket-client-awaitable` | T | B | A | T | A | DNS | +| `websocket/client/coro` | `websocket-client-coro` | T | B | B | B | B | DNS, CTX | +| `websocket/client/coro-ssl` | `websocket-client-coro-ssl` | A | B | B | B | B | DNS, CTX, TLS | +| `websocket/client/sync` | `websocket-client-sync` | A | B | T | T | B | SYNC | +| `websocket/client/sync-ssl` | `websocket-client-sync-ssl` | A | B | A | A | B | SYNC, TLS | +| `websocket/server/async` | `websocket-server-async` | A | B | A | A | U | RUN | +| `websocket/server/async-local` | `websocket-server-async-local` | A | U | U | U | U | LOCAL, RUN | +| `websocket/server/async-ssl` | `websocket-server-async-ssl` | A | B | A | A | U | RUN, TLS | +| `websocket/server/awaitable` | `websocket-server-awaitable` | A | B | A | A | U | RUN | +| `websocket/server/chat-multi` | `websocket-chat-multi` | A | B | A | A | U | RUN, FIX | +| `websocket/server/coro` | `websocket-server-coro` | A | B | B | B | U | CTX, RUN | +| `websocket/server/coro-ssl` | `websocket-server-coro-ssl` | A | B | B | B | U | CTX, RUN, TLS | +| `websocket/server/fast` | `websocket-server-fast` | A | B | B | B | U | CTX, RUN | +| `websocket/server/stackless` | `websocket-server-stackless` | A | B | A | A | U | RUN | +| `websocket/server/stackless-ssl` | `websocket-server-stackless-ssl` | A | B | A | A | U | RUN, TLS | +| `websocket/server/sync` | `websocket-server-sync` | A | B | A | A | U | RUN, SYNC | +| `websocket/server/sync-ssl` | `websocket-server-sync-ssl` | A | B | A | A | U | RUN, SYNC, TLS | + +The catalogue also includes `common/root_certificates.hpp`, `common/server_certificate.hpp`, +`doc/http_examples.hpp`, `http/client/body/json_body.hpp`, crawler input sources, +`http/server/fast/fields_alloc.hpp`, the multi-file chat implementation and `chat_client.html`. +They remain attached to their examples, with dedicated compile/runtime harnesses for the +standalone documentation snippets. They are not silently counted as additional applications. + + +## Draft review corrections, 2026-11-02 + +The builder check identified three contradictions in the historical browser contract, corrected +in this draft: use `browser_errc` for browser-only errors so upstream `beast::error::timeout` +keeps its identity; reject fixed-version TLS methods such as `tlsv12_client` in strict browser +mode; and emit no synthetic chunk framing for HEAD/204/304 responses. These corrections follow +source inspection, not an implementation measurement. The plan must include their regression +scenarios. Primary references: + +- [Beast core error enum](https://github.com/boostorg/beast/blob/7c1e061f91e2ef542217b76286c314d006c0c8fc/include/boost/beast/core/error.hpp) +- [Asio TLS context methods](https://github.com/boostorg/asio/blob/boost-1.92.0/include/boost/asio/ssl/impl/context.ipp) +- [Beast HTTP parser](https://github.com/boostorg/beast/blob/7c1e061f91e2ef542217b76286c314d006c0c8fc/include/boost/beast/http/impl/basic_parser.ipp) +- [Browser WebSocket interface](https://websockets.spec.whatwg.org/) +- [Fetch transport and response model](https://fetch.spec.whatwg.org/) + +The environment-backend review additionally removed universal WASI socket/OpenSSL +prerequisites and mandatory HTTP serialization in the browser. Host HTTP and supplied-stream +counterparts now count as application portability with their original transport limitations +retained. SNI intent is validated against the host URL rather than silently discarded. + +Sources inspected for this revision include webcpp::wasi's `http/entrypoint.hpp`, +`http/response.hpp`, `example/http_hello.cpp`, `build.jam` and the HTTP P2/P3 WIT worlds. +The current helper accepts method/target and returns status/content-type/whole-body; it +does not yet provide the complete request/body/trailer bridge described in D19. The pinned +interfaces are `wasi:http@0.2.12` (incoming-handler/response-outparam) and `@0.3.0` +(async handler). P2 CLI stdio uses input/output resources; P3 uses asynchronous streams and +completion futures. Source inspection establishes available interfaces, not passing Beast +tests. Further references: + +- [WASI HTTP host interface rationale](https://github.com/WebAssembly/wasi-http) +- [WASI stream abstraction](https://github.com/WebAssembly/wasi-io) +- [Wasmtime P2 HTTP embedding](https://docs.wasmtime.dev/api/wasmtime_wasi_http/p2/index.html) +- [Wasmtime P3 HTTP embedding](https://docs.wasmtime.dev/api/wasmtime_wasi_http/p3/index.html) + +### Later P2 core and supplied-WebSocket approval, 2026-11-03 + +The owner subsequently approved Asio P2 core and the four supplied-stream +WebSocket combinations. This supersedes the earlier explanation that no Asio P2 +target exists. The current P2 WebSocket counterparts retain asynchronous +operations via Asio pollables and preserve host channel ownership. Their client +and server exchanges pass with exceptions on/off, including 128 KiB binary +frames, ping/pong and close. Other supplied counterparts remain synchronous. +The new Asio capability does not establish the separate Beast guest-socket +application corpus. Asio's later capability completion also provides P2 guest +OpenSSL and Cobalt; Beast's P2 guest-socket and guest-TLS application cells remain +blocked integration work, +not an inherent WASI platform impossibility. The generated matrix now has 571 +measured passing cells, 216 blocked cells and 432 platform-unavailable cells. diff --git a/libraries/beast/openspec/changes/genesis/proposal.md b/libraries/beast/openspec/changes/genesis/proposal.md index 76a9cf6..a12dca3 100644 --- a/libraries/beast/openspec/changes/genesis/proposal.md +++ b/libraries/beast/openspec/changes/genesis/proposal.md @@ -1,78 +1,107 @@ ## Why -Code written against Boost.Beast (resolve, connect, the TLS handshake, the WebSocket handshake, -then reads and writes) cannot run in a browser: the browser has no sockets, only `WebSocket` and -`fetch`. A C++ program that talks WebSocket or HTTP, and that must run natively and on -Emscripten, therefore has two code paths today, or a custom abstraction over both. webcpp wants -one: Beast's own layered code, unchanged, driving the browser's `WebSocket` and `fetch` when -compiled with Emscripten, and Boost.Beast itself natively. It is to webcpp::asio what Boost.Beast -is to Boost.Asio, and it is what trystero's relays (WebSocket signalling) need to stop polling -the browser from event handlers. With webcpp::asio it is also the prototype of a later proposal to -Boost. +The primary purpose of webcpp::beast is to take existing Boost.Beast applications to +WebAssembly: WASIp2, WASIp3 and Emscripten in a real browser. Native Boost.Beast is the +behavioural reference. Keeping the original operations, types and control flow with minimal, +reviewable source changes matters more than providing a new HTTP or WebSocket interface. +The implementation should use the target's own facilities: browser fetch/WebSocket and WASI +HTTP/streams, rather than requiring Boost.Beast's transport/protocol implementation everywhere. -The library is specified (draft of 2026-10-10, with four decisions of the owner) and has no plan -and no code yet. This change records the specification as a proposal, so that the plan and the -reference code are the first work and everything after them is traceable to a requirement. +The owner's scope clarification of 2026-11-02 includes every application in Boost.Beast's +examples. The pinned Boost 1.92 catalogue contains 53 executable targets, including clients, +servers, TLS, synchronous, asynchronous, stackful and C++20 coroutine examples. Every target +must be accounted for; a rewritten application, a compile-only result and a working port are +not interchangeable. Browsers expose WebSocket and fetch instead of raw listening sockets, +so compatibility has to state the platform boundaries rather than promise impossible parity. + +The original specification of 2026-10-10 is preserved in `reference/spec.md`. This revision +supersedes its native/Emscripten-only scope and its three-example acceptance criterion. +The owner authorized the coordinated Asio/Cobalt/Beast implementation contract on +2026-11-06. Status is `implementing`, with no release or publication claim. The committed +implementation and measured backend/application results are recorded in `reference/STATUS.md`; +remaining prerequisites and acceptance gates stay explicit in `tasks.md`. ## What Changes -- **New library `webcpp::beast`**, a wrapper (not a port) over Boost.Beast and webcpp::asio, - header-only C++20, on native and Emscripten (webcpp::asio has no WASI target, so neither has - this library until a WASI backend exists). -- **Natively** it is Boost.Beast: aliases of Beast's types, a `websocket::stream` derived from - Beast's that adds an allocator constructor, `set_server_name` (the one line of Beast's SSL - examples that cannot compile in a browser), and `teardown` / `async_teardown` for - webcpp::asio's sockets. -- **On Emscripten** the same names drive the browser: `tcp_stream` and `ssl_stream` - are browser streams that record what the layers say (resolver entry, endpoint, TLS settings) - and `websocket::stream` over them opens `new WebSocket(...)` at the handshake, with reads, - writes, close, timeouts, back-pressure queues, cancellation and a destructor contract. -- **What the browser cannot honour fails as a value** (`boost::asio::error::operation_not_supported`) - by default, `WEBCPP_BEAST_UNSUPPORTED_ERROR`; a program may define - `WEBCPP_BEAST_UNSUPPORTED_IGNORE` to have it ignored. A b2 feature, - `webcpp-beast-unsupported=error|ignore`, drives it for a whole program, and the browser classes - live in an inline namespace named after the setting so that disagreeing translation units fail - at link. -- **Errors by name:** failures with no counterpart in Beast or Asio are in the category - `webcpp.beast` (`invalid_url`, `blocked`, `connection_failed`, `send_limit`, `receive_limit`, - `fetch_failed`, `no_host`), with fixed values never reused. -- **The HTTP client in the browser (second increment):** the browser `tcp_stream` is a byte - stream, so `http::async_write` and `http::async_read` run unchanged over it; each whole request - becomes one `fetch`, and the response is serialized back into the bytes the reads yield. -- **The rules hold from the first commit:** exceptions on and off, both Emscripten suspension - variants, allocators, Boost first, outside interfaces wrapped, fixed-width types. -- Tests: native lanes, Emscripten lanes under node on both variants, a headless-browser lane, - native Beast echo servers (plain and TLS), and a twin of each guide example that prints the - same natively and in the browser. -- Out of this change (later increments, later proposals): `WebSocketStream` where the browser has - it, and trystero's relays on webcpp::beast. +- **WebAssembly is the main deliverable.** Native is the reference; WASIp2, WASIp3 and + Emscripten are required target workstreams through their declared backends. Guest sockets + follow Asio's declared targets and each Beast backend needs independent validation. + Asio now offers a single-thread WASIp2 core; Beast's P2 raw-socket application corpus + remains blocked integration work and guest TLS remains unsupported there. P2 portable + HTTP, host `wasi:http` and supplied stdin/stdout have independent supported paths. + P2 supplied WebSocket uses the new pollable executor; host HTTP does not require it. +- **A separate library `webcpp::beast`**, a C++20 wrapper over Boost.Beast and webcpp::asio, + presenting Beast-compatible operations and data interfaces while selecting an environment + backend. Native retains upstream Beast. Wasm data interfaces reuse upstream types while + host-service protocol execution maps directly to the environment. + The first increment remains WebSocket, followed by HTTP. +- **WASI HTTP uses the host's HTTP interfaces.** Adapt client requests and server handlers to + `wasi:http` on P2/P3, reusing and extending webcpp::wasi. The host owns transport and may + own TLS; this path does not require the raw-socket Asio port or guest OpenSSL. Keep a + separate stream/socket backend for applications that need wire-level control, with shared + Asio/OpenSSL dependencies where available. +- **Stream counterparts preserve useful applications.** For Unix-domain socket examples, + add a pair-of-streams counterpart, including host-wired stdin/stdout, keeping the exchange + logic. Document startup and endpoint changes; do not pretend to implement Unix-domain + addressing, ancillary data or peer credentials. Similar applications are part of the + requested deliverable, not merely rejected examples. +- **Emscripten uses browser transports.** The layered connection calls record URL and TLS + intent; the final handshake or request uses WebSocket or fetch. Add synchronous client + coverage through suspending adapters as well as the asynchronous interface. Run both + JSPI and Asyncify in the browser. +- **All 53 upstream executables are the acceptance inventory**, with their original paths, + dependency restrictions, source differences and per-profile build and runtime evidence. + Supporting sources, certificate fixtures, the chat HTML and documentation snippets are + included. The detailed initial inventory is in `design.md`. +- **A capability matrix** separates target, suspension mechanism, threading and exception + mode. It distinguishes tested parity, documented adaptation, implementation blockers and + platform-unavailable operations. No silent skips or trivial replacement programs count. +- **Browser differences stay explicit.** The default unsupported-setting policy reports + errors as values; the optional ignore policy cannot create a listening socket, Unix-domain + socket or unsupported execution backend. An explicit host-service/stream adaptation can + nevertheless provide the application with a supported execution path. Raw servers run on native/WASI and serve the + browser clients; they are not advertised as browser server ports. +- **Validation uses real exchanges.** Test each runnable example with local controlled peers, + compare application payloads and outcomes against native Boost.Beast, and exercise failure, + timeout, cancellation and TLS trust behaviour. Compilation alone is a separate result. +- **Documentation** follows Diataxis in AsciiDoc, with MrDocs reference and compiled examples. + It publishes the capability and example matrices and reproducible commands. ## Capabilities ### New Capabilities -- `beast`: webcpp::beast, Boost.Beast's names and layered interfaces natively, and over the - browser's `WebSocket` and `fetch` on Emscripten, with its unsupported-setting policy, error - category, back-pressure, cancellation, allocation, configuration, tests and documentation. +- `beast`: source-compatible migration of Boost.Beast programs to WebAssembly, its native + reference, browser stream adaptations, WASI transport integration, unsupported-setting + policy, allocation and lifetime contracts, exhaustive example inventory and evidence. ### Modified Capabilities -None. +None in this OpenSpec root. Extensions to webcpp::wasi for complete HTTP requests/responses +and stream I/O, shared TLS/B2 changes for Asio's declared socket targets and any +Boost.Context work belong to their owning components and must have linked changes and tests; +this proposal does not declare those dependencies implemented. ## Impact -- **Kind:** a wrapper (`port_of: null`): webcpp's interface over Boost.Beast and, in the - browser, over the Web APIs. Repository `webcpporg/beast` (not created), checked out as the - submodule `libs/beast`, BSL-1.0, "Copyright (c) 2026 WebCpp.org". -- **Implementation:** not started. There is no reference code: `reference/` holds the - specification alone, and a plan and the reference code are required before the proposal is - accepted. They are the first tasks (`tasks.md`, group 0). -- **Dependencies:** webcpp::asio (the proposal `libraries/asio`, change `genesis`: the - io_context, the bridge that posts the browser's events, the `ip::tcp` types and resolver, the - `ssl` record); Boost.Beast 1.92 and Boost.Asio, Boost.System; OpenSSL natively (through - Boost.Asio's `ssl`); webcpp::config; Emscripten 6.0.11 with its two suspension variants; node - 26 and headless Chrome for the lanes. -- **Status:** draft; no release. Targets are native and Emscripten only. -- **Other proposals:** depends on webcpp::asio's genesis (its Emscripten resolver of decision 4, - its bridge and its `ssl` record must exist first). The later trystero change that moves its - relays onto webcpp::beast depends on this one. +- **Kind:** wrapper (`port_of: null`), BSL-1.0; repository + [webcpporg/beast](https://github.com/webcpporg/beast), registered as `libs/beast` in the + superproject candidate. Retain upstream copyright and licence on adapted code. +- **Implementation:** committed browser, WASI host HTTP, supplied-stream and native/WASIp3 + socket backends, with the full 53-application inventory and explicit adaptations. + The P2 supplied-channel WebSocket backend now also passes its four role/EH cells. + `reference/source/` records the exact committed tree named in `reference/STATUS.md`; + the new local commits still need publication and fresh CI. WASIp2 raw-socket application + integration is blocked and guest TLS is unsupported. All classifications remain explicit + in the complete matrix. +- **Dependencies:** pinned Boost.Beast 1.92, webcpp::asio, Boost.System and webcpp::config; + webcpp::wasi for host HTTP/streams; shared OpenSSL and CA targets only for guest-owned + TLS in native/WASI socket backends; wasi-sdk and Wasmtime for WASI; + Emscripten, Node and a real browser for JSPI/Asyncify. Stackful examples additionally + require a proven Boost.Coroutine/Context backend; replacing them with C++20 coroutines + does not establish compatibility of the original examples. +- **Status:** proposed; no acceptance decision or release. Intended targets: native, wasip2, + wasip3, emscripten, by backend. Asio declares native, wasip3 and emscripten; Beast guest + sockets use native/WASIp3, while WASIp2 uses portable HTTP, host HTTP and supplied streams. +- **Other proposals:** build on the published Asio integration and record extensions in its + proposal. Trystero's later relay migration and an upstream Boost proposal remain separate. diff --git a/libraries/beast/openspec/changes/genesis/reference/STATUS.md b/libraries/beast/openspec/changes/genesis/reference/STATUS.md index f4c23a6..7f05e46 100644 --- a/libraries/beast/openspec/changes/genesis/reference/STATUS.md +++ b/libraries/beast/openspec/changes/genesis/reference/STATUS.md @@ -1,4 +1,349 @@ -# webcpp::beast: where the work stands, and how to resume +# webcpp::beast: implementation status + +## Coordinated publication in progress, 2026-11-07 + +The owner authorized publication and remote CI for the reviewed migration. +The immutable library candidates are Asio `e7cf267b4ab43437a09ce68f40a3994ca63b9054`, +Cobalt `36b9f2475aab1171e0898ab87d5b9630a8e04d71`, and Beast +`6c53f854070a4eebd844f21c29692e938181f8f6`. Superproject commit +`c411965` records those three revisions and the new public Cobalt submodule. +All three candidate branches are published. No main integration is claimed. + +CI environment preparation is running at +https://github.com/webcpporg/webcpp/actions/runs/42370588658 . The complete +combined CI and library CI remain pending. The preceding local validation +records remain evidence for their stated scope, not remote-CI certification. +No release or proposal archival is part of this publication step. The release +packaging check still rejects the prepared 0.1.0 freeze together with these +libraries' Unreleased entries; reconcile that state in the release procedure. + +## Current local migration, 2026-11-07 + +The owner-approved 2026-11-06 distribution contract is now implemented locally in +the coordinated Asio/Cobalt/Beast candidate. Native equivalents are actual Boost +types; Wasm selects explicitly shipped sources, without consumer patches or Boost +include overlays. Cobalt's corrected native SSL wrapper is the approved exception. +Direct compiler/CMake consumers passed from an extracted source archive, including +custom executor/PMR settings, multiple translation units and optional TLS. + +This candidate remains uncommitted. The starting revisions are superproject +`d3a67959cbe52e6d972ef575be8870cc79da1312`, Asio +`db4f7fc6afc516fdef057614cc971cdc39484099`, Beast +`31af69150d61776e7699cb89125f79d103e11ac8`, and local Cobalt +`58701c7dd22777c84c17ac9bbeea6d517c0c7f38`. These hashes identify bases, not the +edited tree. Dated evidence includes source snapshots and artifact hashes. +Historical remote CI below does not certify this local candidate. No new remote +CI, push, merge, repository publication or release is claimed. + +The 53 pinned applications cover 1,855 cells across 35 profiles: +843 passes, 816 platform-unavailable and 196 explicitly blocked, with zero +planned or failed cells. Controlled native upstream peers and namespace +counterparts both passed all 53 applications; these are endpoint adaptations, +not claims of unchanged external services. Real page/worker browser coverage +includes 256 successful observations. P2 supplied-stream WebSocket and P2/P3 +guest socket/TLS contracts retain separate evidence from host HTTP. +See `libs/beast/doc/application-matrix.adoc` and the shared application evidence +under `libs/cobalt/test/applications/results/2026-11-07/`. The shared Release +HTTP parser workload measures in-memory parsing, not network/TLS throughput. + +Documentation and proposal records have been reconciled with the shipped-source +contract. All three strict MrDocs/AsciiDoc builds passed again. A fresh independent +whole-candidate review, followed by focused reviews of every correction, has no +open findings. Local closure items 4 and 5 are complete: the lint covered 831 +translation units and 1,528 compilation commands. The complete run found two +final style issues; both were corrected and their exact checks passed again. +Its original exit status and diagnostics are retained, alongside the successful +follow-ups, in `closure-lint-reconciled.json`. All other lint rules and the tooling +regression suites passed. SDK 34 P2 pthread/P3 cooperative EH limits, versioned P3 +LTO diagnostics, Boost.Context restrictions and native Boost +defects remain explicit, not passing support cells. The local execution ledger is +`.superpowers/sdd/2026-11-06-portable-network-libraries/progress.md` in the +superproject. New implementation boxes remain unchecked until coordinated commits; +publication/CI is a separate step. No proposal is archived or marked implemented. + +## Historical records + +The following snapshots and task states describe their dates, not the migration above. + + +Updated 2026-11-04. The owner approved submission with status `proposed`, with +no formal acceptance date, release or tag. The source is integrated in the +superproject. The original 53-application inventory remains in scope. + +## Current committed snapshot + +- Repository: [webcpporg/beast](https://github.com/webcpporg/beast). +- Published commit: `31af69150d61776e7699cb89125f79d103e11ac8`. +- `source/` is an exact `git archive` of that commit: 774 tracked files, with + every Git blob identity and executable mode checked against the commit. +- Integrated superproject: `80a48ff989bfa301917936af5945de0149bffa08`, merged by + [superproject PR 7](https://github.com/webcpporg/webcpp/pull/7). +- Full [CI 41803777144](https://github.com/webcpporg/webcpp/actions/runs/41803777144) + passed for candidate `44a2ee02a4adf70112270ddb4b3fe5f5cbe93176`: every test and + example built in 78 lanes, tools, lint, documentation and site. The merge has + exactly the same tree. This does not change the 571/216/432 compatibility matrix. +- Beast `main` now points at the published library commit and is the default branch. + Its first [main CI 41815132710](https://github.com/webcpporg/beast/actions/runs/41815132710) + and [root main CI 41814889451](https://github.com/webcpporg/webcpp/actions/runs/41814889451) + are in progress. The historical checkpoints below do not supersede this state. + +## Publication checks, 2026-11-03 + +Asio commit `9455076` supplies WASIp2 guest OpenSSL and Cobalt, along with the +completed WASIp3 asynchronous resolver. Those Asio results do not establish +Beast's separate P2 guest-socket application corpus or remove the existing +WASIp3 fixture-resolver adaptations. The generated matrix preserves 571 passed, +216 blocked and 432 platform-unavailable cells. The correction passed ten +inventory tests and a fresh Beast MrDocs/rendered-documentation build. + +The owner authorized publishing and integration after green CI. The first new +root run, [41675267321](https://github.com/webcpporg/webcpp/actions/runs/41675267321), +failed during checkout because a pinned Trystero commit had not been pushed. +The missing Trystero and WASI dependency commits are now published. Asio's +library CI still selects the superproject's old main, which lacks the new P2 +build project. Current-candidate root CI and the post-integration library CI +remain required. These failures are not passing validation evidence. + +The completed root run +[41686583077](https://github.com/webcpporg/webcpp/actions/runs/41686583077), on the +earlier root `d7a6614`, failed. It found stale build fixtures, a Windows Asio +test expectation, Windows runner portability failures, empty WASIp3 TLS fixture +executables, lint timeouts, five global P2 workload interrupts and one native +Trystero multiroom interop failure. Local corrections passed for every group. +Trystero now preserves bounded native frames until a receiver is installed. The provider +split preserves exactly the same compilation database and passed native upstream +and P2/P3 TLS tests. All five unchanged P2 document workloads passed with the +corrected finite launcher budget. These results do not establish a green final +candidate. The 571/216/432 matrix remains unchanged. + +## Final local candidate, 2026-11-04 + +The host TLS test driver still called the removed `serve.KEEPER` helper after +the portable process-runner change. The actual P2 lane reproduced that error. +The driver now uses `process_tree.start_tree` and the existing shared cleanup. +Fresh P2/P3 builds passed 28 driver executions and 88 TLS cases with exceptions +on/off, including mutual TLS. Their XML report, focused Pyright and independent +review passed. The local TLS peer used Python with OpenSSL, matching CI; +Apple Python's LibreSSL emits a different missing-client-certificate alert. +The assertions were not weakened for that exploratory environment. + +The last full local lint found three Trystero test-fixture style defects and +the obsolete Beast helper. All four findings have focused passing checks; +Pyright passed over all 135 repository Python sources. The final candidate still +requires a new complete remote lint and CI verdict. Full local documentation, +the site with 21 pages and 11 libraries, and the prepared 0.1.0 release check +passed. No release tag or main integration is claimed. + +## Current CI follow-up, 2026-11-04 + +The corrected parent candidate is being validated by +[CI 41803777144](https://github.com/webcpporg/webcpp/actions/runs/41803777144). +No green verdict or merge is claimed for that candidate yet. + +Root run [41793433211](https://github.com/webcpporg/webcpp/actions/runs/41793433211) +found a stale OpenSSL header-stage test assertion and a missing libdatachannel +header variant during lint. Both corrections passed their focused tests and independent review. The header +preparation also isolates the full-build OpenSSL proof and MSVC PDB dependencies. +Complete remote checks must pass on the new candidate. +Its downloaded XML reports also found two WASIp3 flex-awaitable server failures: +cold Wasmtime compilation consumed the listener readiness allowance. A real Linux +component reproduced the timeout under a constrained CPU budget; that experimental +budget is not asserted to be the historical runner's quota. + +Beast commit `31af691` separates compilation into a bounded 60-second phase, then +retains the 15-second guest readiness and five-second protocol deadlines. Only the +artifact created in the current private temporary directory is loaded, with the +same engine features and epoch instrumentation for compilation and execution. +Fresh B2 runs passed eight targets across cooperative WASIp3, ordinary WASIp3 and +native control lanes; the actual Linux component passed under the same constrained +CPU budget. Driver regressions, inventory checks, focused lint, documentation and +independent review passed. This fixes the test harness without changing application +or library code. Complete remote CI on the integrated candidate remains required. + +The final report of all 78 downloaded lanes identified eight failed executions: +the two Beast cases above, four Windows TLS-driver argument failures and two +Trystero allocation-test failures. The Windows driver now quotes its diagnostic +label for cmd.exe. Trystero checks queued payload allocation by address instead +of mistaking a deque map allocation for a frame. These corrections passed focused +regressions and independent reviews. Root `44a2ee0` includes all corrections and +passed the prepared release check and Pyright over all 136 repository Python files. +A new full remote run must validate this exact candidate before integration. + +## Earlier WASIp2 follow-up, 2026-11-03 + +The following subsection records the earlier core-only increment. Its TLS, +Cobalt and publication limitations are superseded by the current snapshot above. + +The final documentation-only root commit is `15e2f44d2bdff0602b8e761a5a9c89b98c3a5d97`; implementation +remains root `e80ffab`, Asio `dad1aef` and Beast `ab95e84`. A later fresh Emscripten +Release regression passed 271 B2 test targets, covering the default suites and +Asio Asyncify/Cobalt lanes with EH on/off. This is Node-based execution, not a +fresh complete browser run. Full lint compilation-database preparation passed +with 1,419 commands, including P2 aggregate EH twins. The focused clang-tidy scope +remains the 20 configurations below; database generation is not a full tidy run. + +The owner approved both the Asio pollable core and supplied-stream WebSocket work. +The local implementation commits are Asio `dad1aef`, Beast `ab95e84` and superproject +`e80ffab`. Each library's `reference/source/` is exported from its exact committed +tree, with every Git blob and executable mode verified. These new commits have not +been pushed or tested by remote CI. The older green root run does not validate them. + +Fresh Release builds passed 138 native, 131 WASIp3 and 68 WASIp2 B2 test targets, +including compile/header and runtime targets, with exceptions on/off. The selected +scope covers the default suites and supplied-stream lanes; it is not a new complete +all-platform CI run. Focused clang-tidy passed 20 translation-unit configurations. +Formatting, text rules, Pyright, Asio/Beast MrDocs and rendered-guide checks passed. +Build tests verify the public P2 target, explicit multi-thread/Cobalt/TLS rejection, +pinned SDK/private-ABI refusal and unchanged P3 profile selection. Root +`b2 check-release` passed after the implementation commits. + +One independent review found two defects, each reproduced before its correction: +guard-only idle trapped on an empty poll list, and a valid 64-bit host write permit +could narrow to zero on wasm32. Idle now waits on a clock pollable; the permit is +clamped before narrowing. Added consumers cover readiness at registration and +pending-write cancellation. A controlled ABI fixture supplies the large/zero +permit; it does not claim every host's stdout import is nonblocking or preemptible. + +P2 core supports timers, TCP/UDP, forward asynchronous DNS and the supplied CLI +stream in a single thread. DNS preserves deferred initiation and handler +associations. P2 guest TLS, Cobalt and multiple threads remain explicitly rejected. +Both supplied WebSocket roles pass with EH on/off. Their actual exchanges cover +upgrade, text/binary frames, fragmentation, ping/pong, close, truncated input, +consumer pause/resume and pending-read cancellation. The application matrix records +571 passed, 216 blocked and 432 platform-unavailable cells. P2 raw-socket Beast +application integration remains blocked despite the now-working Asio core. + +## Earlier integration evidence + +The following records explain fixes already present in the published baseline. +They are historical evidence, not a rerun of the current local candidate. + +- Run [41588828531](https://github.com/webcpporg/webcpp/actions/runs/41588828531) + exposed a response-before-observation race in the HTTP test peer. The fix records + each complete request before transmitting its response. A deterministic real-TCP + regression failed for GET, HEAD and POST with the old ordering and passes with the + correction. The follow-up passed 56 P2/P3 host-client executions across both exception + modes and four native protocol checks. The new CI also explicitly expands browser + contracts across both exception modes and ERROR/IGNORE policies: 56 test executions + plus eight tutorial executions. All 39 CI planner tests passed. +- Run [41590629467](https://github.com/webcpporg/webcpp/actions/runs/41590629467) + exposed nine WASIp3 TLS client timeouts under the old eight-second total wall limit. + Six affected clients reproduced that timeout locally under cold-cache CPU contention, + before accepting any TCP connection. The fixture now separates at most 15 seconds + of process startup from five seconds of protocol and process completion, starting + at real TCP acceptance before TLS. The same six contended clients passed with + startup times of 9.98-14.61 seconds and protocol times of 0.055-0.104 seconds. + Nineteen additional exception-off, cooperative, HTTP-method and native executions + passed. Six real-process/socket regression methods cover slow startup, stalled + protocol and TLS handshake, missing connections, early exit and supervisor + descheduling. Independent review reproduced and verified the acceptance timestamp + boundary correction; all six methods and ten inventory tests pass. The final source + also passed two actual Wasmtime TLS checks. The previous full run remains available + for its complete diagnostics; only the new candidate can establish the merge gate. + + +- The same earlier full run exposed 13 failures on each MSVC version. The shared + include ordering selected the original Boost headers before the checked Asio/Cobalt + overlays. Quoting only the external path restores the overlays' precedence while + retaining external warning suppression for the same Boost root. A real no-exceptions + compile using the emitted search order fails with the old ordering and passes with + the correction, including paths with spaces and compiled Cobalt sources. Additional + corrections protect the TLS factory from Windows' `max` macro, use upstream's static + Context export definition for MASM, enable extended COFF sections for Beast tests, + and suppress CRT deprecation diagnostics only in controlled application fixtures. + Seven affected native tests passed a fresh `b2 -a` run; all three Context assembly + sources failed without the definition and passed LLVM MASM with it. The Beast socket + and documentation-snippet tests, build regressions, generator inventory, static + analysis and independent review passed. The later full baseline CI passed; fresh Windows results for the current local candidate remain pending. + +The reference snapshot will be refreshed if further reviewed implementation commits land. +This status does not turn publication of source into formal proposal acceptance or release. + +## Implemented and measured + +The committed [verification guide](source/doc/verification.adoc), +[application matrix](source/doc/application-matrix.adoc), and +[browser differences](source/doc/browser-differences.adoc) contain the reproduction +commands, adaptations and backend boundaries. Local evidence was collected with Boost +1.92, native Clang 21 on macOS ARM64, wasi-sdk 34, Wasmtime 50.0.1, Emscripten 6.0.11, +Node 26 and actual full Chrome. It does not imply Windows or Linux execution. + +| Workstream | Committed implementation and observed evidence | +| --- | --- | +| Portable/native interfaces | Upstream messages, parsers, serializers and buffers; explicit native/WASIp3 socket and TLS layers; real HTTP/WebSocket exchanges, constructor conversions and error-policy checks. Portable data builds cover native, WASIp2/P3 and Emscripten, with exceptions on/off. | +| Browser transport | Browser WebSocket/fetch, synchronous suspension and completion-token APIs; URL/TLS intent, ERROR/IGNORE, deadlines, cancellation, destruction, response reuse and separate guest byte-stream adapters. Actual Chrome and Node exercise JSPI and Asyncify; Node is not a browser-policy substitute. | +| Browser environment | All eight actual Chrome JSPI/Asyncify, ERROR/IGNORE and EH on/off combinations pass the HTTPS/WSS suspension probe: at least three timer and animation callbacks while the native peer withholds bytes, nested-entry rejection followed by successful outer operations, and mixed-content rejection with an HTTP-origin positive control. | +| Browser ownership | Caller/associated allocator witnesses, queued-event generation checks, bounded ingress before executor dispatch, same-object reuse and cancelled-open regressions. O2 and O3 are settled in `../design.md`. | +| WASI host HTTP | Independent P2/P3 worlds; reusable request/response/header/body/trailer ownership in webcpp::wasi; Beast client/server adapters, readiness-driven completion tokens, cancellation and failure after response commitment. Real hosted tests transfer 256 KiB messages and trailers. | +| Supplied streams | Portable callback channels and explicit WASI/POSIX stdin/stdout counterparts with partial I/O, EOF, deadlines, cancellation and SIGPIPE handling. They do not claim Unix-domain addressing. P2 WebSocket counterparts now use asynchronous readiness-driven streams. | +| Guest TLS | Real native/WASIp3 HTTP and WebSocket TLS scenarios: trust/hostname failures, cancellation, close, truncated shutdown and deadlines. Eight scenarios across TLS 1.2/1.3 and the supported thread/EH profiles produce 112 recorded scenario executions. | +| Host TLS | Private process/profile CAs with normal verification. Six WASI HTTPS application counterparts plus the shared body/trailer contract produce 35 driver executions and 125 TLS attempts; trusted localhost succeeds and unknown issuers/wrong hostnames fail. The documentation client also exercises mutual TLS. Full Chrome uses disposable profile trust and explicit untrusted/wrong-host controls. | +| Application corpus | Every upstream Jamfile/CMake executable is reconciled at Beast commit `7c1e061f91e2ef542217b76286c314d006c0c8fc`. Immutable upstream hashes, generated adaptations, observable native oracle comparisons, crawler report/concurrency/failure tests, chat and documentation snippets remain inspectable. | +| Documentation | Diataxis AsciiDoc, compiled examples and MrDocs API comments. The final local Beast documentation build passed source checks, reference extraction and rendered HTML checks, updating 13 targets. | + +The application matrix retains **53 applications across 23 profiles**, or 1,219 +compile/run cells: **571 passed, 216 blocked and 432 platform-unavailable**. +All four P2 supplied-stream WebSocket cells now have runtime evidence. The P06/P07 +raw-socket profiles retain 98 blocked cells because the Asio P2 core is now available +but the Beast raw-socket application corpus is not integrated. The eight Unix-domain +cells in those profiles remain unavailable. No cell is discarded from the denominator. + +The other 118 blocked cells comprise 53 WASIp3 cooperative EH-on cells without an SDK +exception runtime, 27 WASIp3 socket cells without a verified Boost.Context backend, +18 native EH-off cells requiring stack unwinding, 16 browser cells without a +Boost.Context backend, and four browser documentation clients unable to select the +upstream mutual-TLS identity. These are application/profile outcomes, not a count of +unchanged-source ports or CI jobs. Native oracle normalization compares observable +payload/status/mode results while excluding fixture addresses and elapsed time. +Each adaptation and the host-blocking boundary remain explicit. + +## Remaining acceptance work + +- **0.5:** the owner-approved submission metadata and reference source are committed + as `proposed`. Acceptance remains a separate decision; `decided` and `release` are null. +- Former **0A.3 and 0A.4** were removed by an earlier approved scope decision. The + subsequent P2 approval adds Asio core and supplied WebSocket support. Raw-socket + Beast guest-socket and guest-TLS applications remain blocked integration work, + even though Asio now supplies P2 guest OpenSSL and Cobalt. +- **8.3:** complete final-candidate CI and release steps remain pending. Local checks + and published source do not close the gate. No tag or release publication is authorized. + +Other classified limitations remain visible even where the inventory/accounting task is +complete: Boost.Context lacks a verified Wasm backend; WASIp3 cooperative EH-on lacks the +SDK exception runtime; some original application DNS paths still use explicitly labelled local +endpoint counterparts; Asio P2 forward async DNS now has its own pollable backend; host HTTP has no WebSocket upgrade stream; browsers have no raw +listeners or Unix namespace; and standard-descriptor adaptation requires WASI or POSIX. +No unbounded host write can be preempted by a guest cancellation callback. + +The final committed follow-up also distinguishes normal WebSocket closure in exception-off +sync/SSL server counterparts: clean closure is recorded and the server continues accepting, +while genuine read/accept/write failures retain the explicit failure path. The targeted +normal-close and marker-evidence regressions passed. The complete final WASIp3 application +rerun passed all 120 cases with an explicit successful exit. The final native application +rerun passed all 247 cases with exit 0: 53 upstream oracle, 53 threaded port, 44 threaded +exception-off, 53 single-thread exception-on and 44 single-thread exception-off executions. +All eight exception-off synchronous WebSocket server cases observed normal closure inside +the engine. Independent review of the frozen candidate reported no remaining findings; +the earlier full CI subsequently passed. The new local candidate still needs fresh CI. + + +## How to resume current work + +1. Read this record, `../tasks.md`, the current `../specs/beast/spec.md`, and the + committed verification/matrix documents under `source/doc/`. +2. Review and commit any acceptance follow-up, then refresh `source/` with `git archive` + of that exact committed Beast tree and verify its blob identities. Check only + tasks whose full criterion is satisfied by committed work and measured evidence. +3. Push the new candidate, run fresh superproject CI for pull request 7 and record + its exact commit and result. Fix any failed declared lane before claiming the gate complete. +4. Keep the formal proposal decision and release/tag separate. Do not mark the proposal + `implemented`, archive it, or invent a release before those actions happen. +5. Regenerate the proposal README, run proposal checks/tests, and run strict OpenSpec + validation. The historical intake below and `spec.md` remain unchanged. + +The historical intake below describes what was known on 2026-10-13, not this snapshot. + +## Historical intake record, 2026-10-13 Written 2026-10-13, when this proposal took beast in as a specified library with nothing built. `spec.md` is the specification; `../tasks.md` is the checklist; `../design.md` the decisions. diff --git a/libraries/beast/openspec/changes/genesis/reference/plan.md b/libraries/beast/openspec/changes/genesis/reference/plan.md new file mode 100644 index 0000000..1f0e61d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/plan.md @@ -0,0 +1,141 @@ +# Beast implementation plan + +> **For agentic workers:** Use superpowers:executing-plans for the Beast work and superpowers:systematic-debugging for existing failures. Track independently verified increments; do not report the complete 53-example matrix from an initial working backend. + +**Goal:** Compile Beast-shaped applications to native, WASIp2, WASIp3 and browser WebAssembly, using host services where available. + +**Architecture:** Reuse upstream Beast's data types and native/socket protocol implementations. Keep browser WebSocket/fetch and WASI HTTP adapters separate from guest socket/TLS dependencies. Host-entry and supplied-stream examples preserve application behaviour with explicit transport changes. + +**Tech Stack:** C++20, Boost 1.92, B2, wasi-sdk 34, Wasmtime, Emscripten 6.0.11, JavaScript WebSocket/fetch, WASI HTTP 0.2.12/0.3.0. + +**Spec:** `../design.md` and `../specs/beast/spec.md`. + +## Global constraints + +- Public namespace `webcpp::beast`; macros `WEBCPP_BEAST_*`; public configuration includes webcpp config first. +- Errors as values; exceptions on/off; caller allocators and associated completion executors. +- Native remains the oracle. Keep all 53 original executable entries and report adapted applications separately. +- No claim of browser support from Node execution alone; no claim of runtime support from compilation alone. +- Tests use bounded controlled peers, deterministic payloads, explicit trust and cleanup. +- English files, BSL-1.0 source notices, no em dash, no hand edits of generated artifacts or CHANGELOG.md files. +- Current closeout follows the committed implementation and published candidate. Formal proposal + acceptance and release remain separate gates; current CI state is in `STATUS.md`. + +## Decisions at implementation start + +- The user authorized implementation after the recommendation to reuse upstream data types. Keep those types; remove O6 as a blocker. This does not require executing upstream protocol code for host HTTP/WebSocket. +- The convenience header exposes portable data interfaces. Optional socket/TLS and host-entry headers are included explicitly, so message-only WASIp2 code does not import the missing socket reactor. +- Begin with a verified native/WASIp3 socket baseline and portable messages, then implement host backends. This is an implementation order, not a reduction of the required target matrix. +- The organization repository now exists and the superproject candidate references its published + commit. `STATUS.md` identifies the current snapshot; the initial local-only record below is history. +- Browser `websocket::queue_limits` uses 4 MiB for both send and receive; receive accounting + includes payload and record storage before executor dispatch. The decorator receives a + stream-allocator-backed PMR request and only subprotocol fields are representable (O2/O3). + +## Review focus + +1. A message-only component must not acquire raw-socket or OpenSSL dependencies. +2. A connection that stalls must terminate by the declared deadline, including asynchronous shutdown. +3. A split or binary payload must survive buffering, framing and target conversions unchanged. +4. Cancellation/destruction must complete once without a late callback reaching freed memory. +5. Compilation variants must use matching dependency headers, exception mode and thread runtime. + +## Task 1: Restore the existing build contract + +**Files:** `tools/openssl/`, `tools/webcpp-openssl.jam`, `tools/test/openssl_test.py`, `tools/lint/`, `tools/boost/cobalt-wasip3/`, `tools/ci/`, affected Asio documentation and Cobalt usage requirements. + +**Interfaces:** Preserve `/webcpp/third_party//openssl`, `/webcpp//boost_cobalt`, and CI matrix output contracts. Reproduce run 41563713062 from its recorded commands and artifacts. + +- [x] Reproduce OpenSSL symlinked compiler/source-integrity failure; add regression and fix compiler selection/diagnostic ordering. +- [x] Implement MSVC/nmake recipe with correct archives, runtime variants and tool environment; test commands locally and identify Windows-only validation still needed. +- [x] Reproduce bare-throw fixture and Cobalt lint compilation failures; correct the fixture/commands without disabling the real checks. +- [x] Fix WASIp3 launch capabilities, Cobalt consumer header/library mismatch, missing container tools, and site title; add focused regressions. +- [x] Run affected complete tool suites and local native/WASIp3 application tests; record exact commands and results. +- [x] Commit reviewed corrections separately from the Beast library. + +## Task 2: Portable data interfaces and native/WASIp3 socket baseline + +**Files:** `libs/beast/build.jam`, `include/webcpp/beast.hpp`, `include/webcpp/beast/{config,core,http,websocket,ssl}.hpp`, `test/Jamfile`, `test/{config_test,message_test,socket_test}.cpp`, metadata and library instructions. + +**Interfaces:** `webcpp::beast::http` exposes upstream message/parser/serializer types; `flat_buffer` retains upstream identity. Explicit socket headers expose `tcp_stream` and `websocket::stream`; the latter accepts `std::allocator_arg_t` while retaining the documented native upstream allocation behaviour. TLS exposes `ssl_stream` and `set_server_name(stream, host) -> boost::system::result` only when its dependency is selected. + +- [x] Write config/message tests, including type identity, parser limits, binary content, and malformed messages; run before headers exist to observe the missing API. +- [x] Add minimal configuration and data aliases; run B2 on native, WASIp2, WASIp3 and Emscripten, exceptions on/off. +- [x] Write a bounded loopback HTTP request/response and WebSocket echo/close test using the proposed public socket interface; observe the missing socket API. +- [x] Implement native/WASIp3 aliases and wrapper; run real loopback exchanges in both exception modes and available threading profiles. +- [x] Add optional TLS helper with valid/error hostname checks; verify host-service/message builds have no OpenSSL dependency. +- [x] Add executable example and record its actual output, commands and initial feature matrix. Commit local library independently. + +## Task 3: Browser WebSocket transport + +**Files:** `include/webcpp/beast/browser/`, `src/browser_src.cpp`, browser tests/driver and the corresponding B2 targets. + +**Interfaces:** Browser `tcp_stream` records resolver results, executor and timeout; TLS records policy; `websocket::stream` supplies Beast-shaped async operations, backed by JavaScript WebSocket and webcpp::asio's event bridge. + +- [x] Pin default queue sizes in the design with measured boundary tests; implement URL/TLS/unsupported-setting validation and category values 1 through 7. +- [x] Implement connect/handshake, message read/write, binary/text, close, queue limits, cancellation and destructor completion, one contract at a time with a failing test first. +- [x] Use controlled local WebSocket peers and a real browser; run JSPI/Asyncify and EH on/off, allocator counting, invalid URL, rejected handshake, timeout and late-event tests. +- [x] Port the applicable upstream client examples and retain browser-unavailable server facilities in the manifest. + +## Task 4: Host HTTP and supplied streams + +**Files:** reusable WASI request/response/stream extensions in `libs/wasi`, Beast host adapters and example counterparts; browser fetch adapter and tests. + +**Interfaces:** Preserve Beast request/response operations; map directly to fetch or pinned WASI outgoing interfaces. Server entry adapters invoke the application handler once per host request, commit one response, and retain body/resource ownership until completion. + +- [x] Extend reusable WASI interfaces beyond method/target/content-type/whole-body; test P2 resource ownership and P3 stream/future completion independently. +- [x] Implement host client and server adapters without Asio raw sockets or guest OpenSSL; test headers, request bodies, response bodies, trailers, cancellation and failure after commitment. +- [x] Implement browser fetch request/response mapping and optional byte adapter; test HEAD/204/304, CORS, unsupported fields, redirects, limits and cancellation. +- [x] Implement host-supplied input/output channel and stdin/stdout application counterpart; test partial I/O, EOF, bounded buffering and cancellation with concurrent draining. + +## Task 5: Complete application coverage and documentation + +**Files:** checked upstream executable manifest, adapted examples/drivers, feature/results matrix, AsciiDoc guide, MrDocs configuration and public API comments. + +- [x] Reconcile all 53 executable targets, support sources and snippet harnesses against the pinned upstream source. +- [x] Build/run native oracle and every promised target/variant/backend counterpart with exact adaptation diffs and evidence. +- [ ] Resolve stackful coroutine prerequisites in their owning libraries; never hide blocked rows. WASIp2 sockets/TLS are platform-unavailable because guest sockets follow Asio's declared targets. +- [x] Publish the Diataxis guide with compiled examples and observed outputs, plus independent feature and application matrices. +- [x] Run local documented validation, perform independent review and fix regressions. Report any runtime/platform still unverified before publication. + +## Current acceptance gates + +The implementation and application accounting above are committed. Unverified stackful Wasm +backends, formal proposal acceptance and the final CI/release gate remain open. The owner's +2026-11-03 scope decision removes a WASIp2 socket/TLS port as a requirement while retaining +portable HTTP, host HTTP and supplied stdin/stdout. The submission state is `proposed`; +`../tasks.md` and `STATUS.md` retain the exact pending items. +The verification and initial implementation sections below preserve the earlier intake +chronology; `source/` is refreshed to the current commit named in `STATUS.md`. + +## Verification observed for the initial increment + +- Native Clang 21 Release: data/socket/SNI tests and example, EH on/off, threading single/multi. +- SDK 34 WASIp2 Release: data tests/example, EH on/off; no guest networking claim. +- SDK 34 WASIp3 Release: data/socket/SNI tests/example, single EH on/off and cooperative multi EH off. Wasmtime 49.0.3 ran the cooperative binaries; 47.0.3 rejected their component encoding. +- Emscripten 6.0.11 Release: data tests/example under Node, EH on/off; no browser transport claim. +- Independent review found missing default/converting WebSocket constructors and facade rebinding. Real construction, conversion and move regressions now pass. +- OpenSSL integration suite: nine cases passed, including real native source builds and consumers. Source-integrity suite: seven passed. Windows orchestration suite: four passed. Windows compilation/execution remains unverified. +- Lint framework suite: all 59 cases passed, including the new clean-checkout Cobalt overlay case and the bare-throw fixture. Actual combined-tree lint is a separate check. +- CI matrix/actions/report/site assembler suites passed locally. Six previously failing WASIp3 runtime tests passed with the CI-pinned Wasmtime 47.0.3 and corrected capabilities. +- The document Cobalt example passed with matching headers and compiled library. A Linux amd64 container built OpenSSL from source without network access. Source and rendered Asio title validation passed. +- No new CI run, merge, push or release was performed. Run 41563713062 remains the old failed remote result until a later run verifies the fixes. + +## Initial implementation record + +The first local Beast commit is `c7dfe2bffb16559aa4f5a6e3bece633e6999b0b4` on +`work/beast-and-wasmtime-50`. `source/` is an exact archive of its tracked tree. The +organization repository and superproject gitlink remain pending. This records the +initial increment, not completion of the browser, host-HTTP or 53-application work. + +The owner's subsequent project-wide upgrade selected Wasmtime 50.0.1. Fresh P2/P3 +data, socket, SNI, example and cooperative runs passed with that runtime; the +47.0.3/49.0.3 comparisons above remain historical evidence. The superproject's +`docs/superpowers/plans/2026-11-02-wasmtime-50.md` records the broader validation. +Combined lint checked 897 commands over 406 translation units, and affected +documentation was regenerated with MrDocs and passed source/rendered checks. + +The superproject corrections and Wasmtime upgrade are recorded in local commit +`684c4feed137af2e1912fecff75119bad8c509c8`, separate from the Beast repository. +The broad P2/P3 logs retain the initial Lexical/Config failures; fresh focused +runs of every corrected target passed. No remote CI run or push followed. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/.gitattributes b/libraries/beast/openspec/changes/genesis/reference/source/.gitattributes new file mode 100644 index 0000000..efdba87 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.sh text eol=lf diff --git a/libraries/beast/openspec/changes/genesis/reference/source/.github/workflows/ci.yml b/libraries/beast/openspec/changes/genesis/reference/source/.github/workflows/ci.yml new file mode 100644 index 0000000..30b3093 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# beast's CI: the superproject's reusable workflow, which builds this commit inside a checkout of +# webcpp, on every lane beast declares, with its page, the lint and the test matrix. +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + # As the superproject's: a run on main is the record of main, and is never cut short by the + # next; a pull request's newer push replaces its older run. + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + ci: + name: CI + uses: webcpporg/webcpp/.github/workflows/library.yml@main + with: + library: beast diff --git a/libraries/beast/openspec/changes/genesis/reference/source/.gitignore b/libraries/beast/openspec/changes/genesis/reference/source/.gitignore new file mode 100644 index 0000000..c9e2452 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/.gitignore @@ -0,0 +1,6 @@ +doc/html/ +node_modules +.node-modules/ +__pycache__/ +*.pyc +test/applications/host-tls/target/ diff --git a/libraries/beast/openspec/changes/genesis/reference/source/AGENTS.md b/libraries/beast/openspec/changes/genesis/reference/source/AGENTS.md new file mode 100644 index 0000000..31da392 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/AGENTS.md @@ -0,0 +1,41 @@ +# Working on beast + +Read the superproject's [AGENTS.md](../../AGENTS.md) and +[CODING-GUIDELINES.md](../../CODING-GUIDELINES.md) first. + +- This is a compatibility wrapper, with Boost 1.92 as its reference. Its complete + proposal is in `proposals/libraries/beast/openspec/changes/genesis` in the organization. +- Portable message headers must not include a socket reactor. `http.hpp` contains + data, parsers and serializers; `http/read.hpp` and `http/write.hpp` are explicit + byte-stream operations and browser message overloads. WASI host APIs live in + `wasi/http.hpp` and depend on independent host bindings. +- `/webcpp/beast//beast` supplies portable headers. `//sockets` selects native or + WASIp3 guest transport; `//tls` selects source-built OpenSSL explicitly. + Asio P2 core is now available, but the Beast guest-socket application corpus + remains a separate integration task; do not mark it passed from Asio tests. +- `/webcpp/beast//browser`, `//wasi-http` and `//wasi-streams` select independent + environment adapters. Their runtime tests are separate from the socket tests. + Keep source compatibility, application counterparts and unavailable facilities + explicit in the matrix; compilation alone never establishes runtime parity. +- Socket tests use real loopback peers and five-second outer deadlines. WASIp3 + execution uses the shared network-capable launcher, never a mocked socket. +- Test both exception modes. The native/WASIp3 allocator constructor preserves + upstream stream-state allocation; it must not claim custom stream allocation. +- The example's expected output is captured from its upstream compile, selecting + `WEBCPP_TEST_UPSTREAM_BEAST`; do not hand-edit that output. +- Browser-native WebSocket and fetch must remain independent of guest protocol + engines. Host-managed TLS never inherits guest OpenSSL or CA settings silently. +- Preserve `example/upstream` exactly at its pinned commit. The inventory checks + every file hash before lint exempts that corpus's upstream style and notices. + Change generated application adaptations through their generator, never by + editing its outputs. Both the adapted sources and their generator are linted. +- TLS shutdown cancellation tests synchronize on the peer's observed close_notify. + Cancelling a lowest layer between two internal socket operations is not proof + that a pending shutdown read was cancelled. WebSocket close already tears down + TLS and its underlying socket; do not call TLS shutdown again afterwards. + +The owner approved the P2 supplied-stream WebSocket port on 2026-11-03. Its +client/server examples use `webcpp::asio::wasi::stdio_stream` with real asynchronous +operations, without guest network grants. Keep the explicit flush and the actual +128 KiB binary/ping/close regression. Host-import blocking limits still apply. +Regenerate the application matrix from measured logs, never from inferred parity. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/LICENSE_1_0.txt b/libraries/beast/openspec/changes/genesis/reference/source/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/README.md b/libraries/beast/openspec/changes/genesis/reference/source/README.md new file mode 100644 index 0000000..914be98 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/README.md @@ -0,0 +1,33 @@ +# webcpp::beast + +Beast-compatible HTTP and WebSocket interfaces for native and WebAssembly applications. +The facade reuses Boost.Beast 1.92's data types and native/WASIp3 socket algorithms. +Browser WebSocket/fetch and WASI host HTTP are separate adapters: the environment +owns their transport and TLS policy. The guide distinguishes source-compatible +programs from explicit application counterparts and records their verification. + +Use this repository inside the WebCPP superproject at `libs/beast`. + +```sh +unset CPATH CPLUS_INCLUDE_PATH C_INCLUDE_PATH +b2 -a libs/beast/test libs/beast/example +b2 -a toolset=clang-wasip2 testing.launcher=wasmtime libs/beast/test libs/beast/example +b2 -a toolset=clang-wasip3 testing.launcher=tools/boost/asio-wasip3/run.sh libs/beast/test libs/beast/example +b2 -a toolset=emscripten libs/beast/test libs/beast/example +``` + +Host HTTP and real-browser tests have dedicated lanes. Data tests under Node do +not establish browser transport behaviour. Native/WASIp3 socket tests use real +loopback peers; TLS tests use source-built OpenSSL and fresh local certificates. + +Build dependencies are explicit: `/webcpp/beast//beast` for messages, +`/webcpp/beast//sockets` for guest networking and `/webcpp/beast//tls` for guest TLS. +Select `/webcpp/beast//browser` for browser-owned transport, +`/webcpp/beast//wasi-http` for host HTTP, or `/webcpp/beast//wasi-streams` for +explicit supplied-stream counterparts. `beast.hpp` omits optional transport/TLS +headers so constructing an HTTP message never brings in a socket reactor. + +See [the guide](doc/beast.adoc) for the feature matrix and commands. API reference +comes from the public headers through MrDocs. Build locally with `b2 -a libs/beast/doc`. + +Distributed under the [Boost Software License 1.0](LICENSE_1_0.txt). diff --git a/libraries/beast/openspec/changes/genesis/reference/source/build.jam b/libraries/beast/openspec/changes/genesis/reference/source/build.jam new file mode 100644 index 0000000..50bc063 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/build.jam @@ -0,0 +1,38 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project /webcpp/beast ; + +import feature ; +import webcpp ; +use-project /webcpp/asio-wasip3 : ../../tools/boost/asio-wasip3 ; + +# The hash-verified upstream Jamfiles belong to the reference corpus only. +webcpp.source-only example/upstream ; + +feature.feature webcpp-beast-unsupported : error ignore : propagated ; + +# Data interfaces do not require a socket reactor or guest TLS library. +alias beast : : : : include /webcpp/config//config + error:WEBCPP_BEAST_UNSUPPORTED_ERROR + ignore:WEBCPP_BEAST_UNSUPPORTED_IGNORE ; + +# Only a program using guest-owned sockets acquires the Asio dependency. +alias sockets : : : : beast /webcpp/asio//asio ; + +# Source-built OpenSSL is optional and belongs only to guest-owned TLS. +alias tls : : : : sockets /webcpp/asio//openssl ; + +# Browser APIs own the network connection and TLS; no guest OpenSSL is linked. +alias browser : : : : beast /webcpp/asio//asio ; + +# Host HTTP bindings are independent of guest sockets and guest TLS. +alias wasi-http : : : : beast /webcpp/wasi//host-http + clang-wasip2:/webcpp/asio-wasip3//host-headers + clang-wasip3:/webcpp/asio-wasip3//headers ; + +# Supplied CLI streams use the portable WASI resource layer, not guest sockets. +alias wasi-streams : : : : beast /webcpp/wasi//wasi ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/doc/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/doc/Jamfile new file mode 100644 index 0000000..474e347 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/doc/Jamfile @@ -0,0 +1,19 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +import webcpp ; + +webcpp.doc beast : beast.adoc ; +# Browser headers need Emscripten's data model. Independent WASI bindings +# expose host API contracts in the same parse, without a guest reactor. +webcpp.reference beast : /webcpp//emscripten-reference + /webcpp/asio//asio /webcpp/wasi//wasi + /webcpp/wasi//host-http-bindings-p2-headers + WEBCPP_WASI_HTTP_P2 BOOST_ASIO_DISABLE_THREADS + : /webcpp//emscripten-reference + /webcpp/asio//asio /webcpp/wasi//wasi + /webcpp/wasi//host-http-bindings-p3-headers + WEBCPP_WASI_HTTP_P3 BOOST_ASIO_DISABLE_THREADS ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/doc/application-matrix.adoc b/libraries/beast/openspec/changes/genesis/reference/source/doc/application-matrix.adoc new file mode 100644 index 0000000..722b68f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/doc/application-matrix.adoc @@ -0,0 +1,308 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by test/applications/matrix.py. Do not edit. + +[[application-profile-matrix]] +=== Application profile evidence + +All 53 upstream executables remain in every profile. Each cell gives the compile/run result independently. P = measured pass, F = measured failure, B = blocked, U = unavailable, N = no measured result. + +A passing counterpart preserves the measured application operations. It does not establish unchanged source, scheduling, DNS, TLS policy or failure semantics. Native oracle comparison covers payloads/status/modes, excluding fixture addresses and elapsed time. Local native measurements use macOS ARM64; other operating systems require their CI runs. Raw results and commands are retained by the drivers. + +[cols="1,5",options="header"] +|=== +|Profile |Configuration +|P01 |`native-original-threads-eh-on` +|P02 |`native-port-threads-eh-on` +|P03 |`native-port-single-eh-on` +|P04 |`native-port-single-eh-off` +|P05 |`native-port-threads-eh-off` +|P06 |`wasip2-socket-eh-on` +|P07 |`wasip2-socket-eh-off` +|P08 |`wasip3-socket-single-eh-on` +|P09 |`wasip3-socket-single-eh-off` +|P10 |`wasip3-socket-cooperative-eh-on` +|P11 |`wasip3-socket-cooperative-eh-off` +|P12 |`wasip2-host-http-eh-on` +|P13 |`wasip2-host-http-eh-off` +|P14 |`wasip3-host-http-eh-on` +|P15 |`wasip3-host-http-eh-off` +|P16 |`wasip2-supplied-stream-eh-on` +|P17 |`wasip2-supplied-stream-eh-off` +|P18 |`wasip3-supplied-stream-eh-on` +|P19 |`wasip3-supplied-stream-eh-off` +|P20 |`browser-jspi-eh-on` +|P21 |`browser-jspi-eh-off` +|P22 |`browser-asyncify-eh-on` +|P23 |`browser-asyncify-eh-off` +|=== + +[cols="4,1,1,1,1,1,1",options="header"] +|=== +|Application |P01 C/R |P02 C/R |P03 C/R |P04 C/R |P05 C/R |P06 C/R +|`advanced-server` |P/P |P/P |P/P |P/P |P/P |B/B +|`advanced-server-flex` |P/P |P/P |P/P |P/P |P/P |B/B +|`advanced-server-flex-awaitable` |P/P |P/P |P/P |P/P |P/P |B/B +|`doc-ssl-client` |P/P |P/P |P/P |P/P |P/P |B/B +|`doc-ssl-server` |P/P |P/P |P/P |P/P |P/P |B/B +|`echo-op` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-async` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-async-local` |P/P |P/P |P/P |P/P |P/P |U/U +|`http-client-async-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-async-ssl-system-executor` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-awaitable` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-awaitable-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`json_client` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-coro` |P/P |P/P |P/P |B/B |B/B |B/B +|`http-client-coro-ssl` |P/P |P/P |P/P |B/B |B/B |B/B +|`http-crawl` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-methods` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-sync` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-client-sync-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-async` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-async-local` |P/P |P/P |P/P |P/P |P/P |U/U +|`http-server-async-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-awaitable` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-coro` |P/P |P/P |P/P |B/B |B/B |B/B +|`http-server-coro-ssl` |P/P |P/P |P/P |B/B |B/B |B/B +|`http-server-fast` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-flex` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-small` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-stackless` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-stackless-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-sync` |P/P |P/P |P/P |P/P |P/P |B/B +|`http-server-sync-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-client-async` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-client-async-local` |P/P |P/P |P/P |P/P |P/P |U/U +|`websocket-client-async-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-client-async-ssl-system-executor` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-client-awaitable` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-client-coro` |P/P |P/P |P/P |B/B |B/B |B/B +|`websocket-client-coro-ssl` |P/P |P/P |P/P |B/B |B/B |B/B +|`websocket-client-sync` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-client-sync-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-async` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-async-local` |P/P |P/P |P/P |P/P |P/P |U/U +|`websocket-server-async-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-awaitable` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-chat-multi` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-coro` |P/P |P/P |P/P |B/B |B/B |B/B +|`websocket-server-coro-ssl` |P/P |P/P |P/P |B/B |B/B |B/B +|`websocket-server-fast` |P/P |P/P |P/P |B/B |B/B |B/B +|`websocket-server-stackless` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-stackless-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-sync` |P/P |P/P |P/P |P/P |P/P |B/B +|`websocket-server-sync-ssl` |P/P |P/P |P/P |P/P |P/P |B/B +|=== + +[cols="4,1,1,1,1,1,1",options="header"] +|=== +|Application |P07 C/R |P08 C/R |P09 C/R |P10 C/R |P11 C/R |P12 C/R +|`advanced-server` |B/B |P/P |P/P |B/B |P/P |P/P +|`advanced-server-flex` |B/B |P/P |P/P |B/B |P/P |P/P +|`advanced-server-flex-awaitable` |B/B |P/P |P/P |B/B |P/P |P/P +|`doc-ssl-client` |B/B |P/P |P/P |B/B |P/P |P/P +|`doc-ssl-server` |B/B |P/P |P/P |B/B |P/P |P/P +|`echo-op` |B/B |P/P |P/P |B/B |P/P |U/U +|`http-client-async` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-async-local` |U/U |U/U |U/U |B/B |U/U |P/P +|`http-client-async-ssl` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-async-ssl-system-executor` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-awaitable` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-awaitable-ssl` |B/B |P/P |P/P |B/B |P/P |P/P +|`json_client` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-coro` |B/B |B/B |B/B |B/B |B/B |P/P +|`http-client-coro-ssl` |B/B |B/B |B/B |B/B |B/B |P/P +|`http-crawl` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-methods` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-sync` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-client-sync-ssl` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-async` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-async-local` |U/U |U/U |U/U |B/B |U/U |P/P +|`http-server-async-ssl` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-awaitable` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-coro` |B/B |B/B |B/B |B/B |B/B |P/P +|`http-server-coro-ssl` |B/B |B/B |B/B |B/B |B/B |P/P +|`http-server-fast` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-flex` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-small` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-stackless` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-stackless-ssl` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-sync` |B/B |P/P |P/P |B/B |P/P |P/P +|`http-server-sync-ssl` |B/B |P/P |P/P |B/B |P/P |P/P +|`websocket-client-async` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-client-async-local` |U/U |U/U |U/U |B/B |U/U |U/U +|`websocket-client-async-ssl` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-client-async-ssl-system-executor` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-client-awaitable` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-client-coro` |B/B |B/B |B/B |B/B |B/B |U/U +|`websocket-client-coro-ssl` |B/B |B/B |B/B |B/B |B/B |U/U +|`websocket-client-sync` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-client-sync-ssl` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-async` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-async-local` |U/U |U/U |U/U |B/B |U/U |U/U +|`websocket-server-async-ssl` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-awaitable` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-chat-multi` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-coro` |B/B |B/B |B/B |B/B |B/B |U/U +|`websocket-server-coro-ssl` |B/B |B/B |B/B |B/B |B/B |U/U +|`websocket-server-fast` |B/B |B/B |B/B |B/B |B/B |U/U +|`websocket-server-stackless` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-stackless-ssl` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-sync` |B/B |P/P |P/P |B/B |P/P |U/U +|`websocket-server-sync-ssl` |B/B |P/P |P/P |B/B |P/P |U/U +|=== + +[cols="4,1,1,1,1,1,1",options="header"] +|=== +|Application |P13 C/R |P14 C/R |P15 C/R |P16 C/R |P17 C/R |P18 C/R +|`advanced-server` |P/P |P/P |P/P |U/U |U/U |U/U +|`advanced-server-flex` |P/P |P/P |P/P |U/U |U/U |U/U +|`advanced-server-flex-awaitable` |P/P |P/P |P/P |U/U |U/U |U/U +|`doc-ssl-client` |P/P |P/P |P/P |U/U |U/U |U/U +|`doc-ssl-server` |P/P |P/P |P/P |U/U |U/U |U/U +|`echo-op` |U/U |U/U |U/U |U/U |U/U |U/U +|`http-client-async` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-async-local` |P/P |P/P |P/P |P/P |P/P |P/P +|`http-client-async-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-async-ssl-system-executor` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-awaitable` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-awaitable-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`json_client` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-coro` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-coro-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-crawl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-methods` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-sync` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-client-sync-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-async` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-async-local` |P/P |P/P |P/P |P/P |P/P |P/P +|`http-server-async-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-awaitable` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-coro` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-coro-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-fast` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-flex` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-small` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-stackless` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-stackless-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-sync` |P/P |P/P |P/P |U/U |U/U |U/U +|`http-server-sync-ssl` |P/P |P/P |P/P |U/U |U/U |U/U +|`websocket-client-async` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-async-local` |U/U |U/U |U/U |P/P |P/P |P/P +|`websocket-client-async-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-async-ssl-system-executor` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-awaitable` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-coro` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-coro-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-sync` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-client-sync-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-async` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-async-local` |U/U |U/U |U/U |P/P |P/P |P/P +|`websocket-server-async-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-awaitable` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-chat-multi` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-coro` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-coro-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-fast` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-stackless` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-stackless-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-sync` |U/U |U/U |U/U |U/U |U/U |U/U +|`websocket-server-sync-ssl` |U/U |U/U |U/U |U/U |U/U |U/U +|=== + +[cols="4,1,1,1,1,1",options="header"] +|=== +|Application |P19 C/R |P20 C/R |P21 C/R |P22 C/R |P23 C/R +|`advanced-server` |U/U |U/U |U/U |U/U |U/U +|`advanced-server-flex` |U/U |U/U |U/U |U/U |U/U +|`advanced-server-flex-awaitable` |U/U |U/U |U/U |U/U |U/U +|`doc-ssl-client` |U/U |B/B |B/B |B/B |B/B +|`doc-ssl-server` |U/U |U/U |U/U |U/U |U/U +|`echo-op` |U/U |U/U |U/U |U/U |U/U +|`http-client-async` |U/U |P/P |P/P |P/P |P/P +|`http-client-async-local` |P/P |U/U |U/U |U/U |U/U +|`http-client-async-ssl` |U/U |P/P |P/P |P/P |P/P +|`http-client-async-ssl-system-executor` |U/U |P/P |P/P |P/P |P/P +|`http-client-awaitable` |U/U |P/P |P/P |P/P |P/P +|`http-client-awaitable-ssl` |U/U |P/P |P/P |P/P |P/P +|`json_client` |U/U |P/P |P/P |P/P |P/P +|`http-client-coro` |U/U |B/B |B/B |B/B |B/B +|`http-client-coro-ssl` |U/U |B/B |B/B |B/B |B/B +|`http-crawl` |U/U |P/P |P/P |P/P |P/P +|`http-client-methods` |U/U |P/P |P/P |P/P |P/P +|`http-client-sync` |U/U |P/P |P/P |P/P |P/P +|`http-client-sync-ssl` |U/U |P/P |P/P |P/P |P/P +|`http-server-async` |U/U |U/U |U/U |U/U |U/U +|`http-server-async-local` |P/P |U/U |U/U |U/U |U/U +|`http-server-async-ssl` |U/U |U/U |U/U |U/U |U/U +|`http-server-awaitable` |U/U |U/U |U/U |U/U |U/U +|`http-server-coro` |U/U |U/U |U/U |U/U |U/U +|`http-server-coro-ssl` |U/U |U/U |U/U |U/U |U/U +|`http-server-fast` |U/U |U/U |U/U |U/U |U/U +|`http-server-flex` |U/U |U/U |U/U |U/U |U/U +|`http-server-small` |U/U |U/U |U/U |U/U |U/U +|`http-server-stackless` |U/U |U/U |U/U |U/U |U/U +|`http-server-stackless-ssl` |U/U |U/U |U/U |U/U |U/U +|`http-server-sync` |U/U |U/U |U/U |U/U |U/U +|`http-server-sync-ssl` |U/U |U/U |U/U |U/U |U/U +|`websocket-client-async` |U/U |P/P |P/P |P/P |P/P +|`websocket-client-async-local` |P/P |U/U |U/U |U/U |U/U +|`websocket-client-async-ssl` |U/U |P/P |P/P |P/P |P/P +|`websocket-client-async-ssl-system-executor` |U/U |P/P |P/P |P/P |P/P +|`websocket-client-awaitable` |U/U |P/P |P/P |P/P |P/P +|`websocket-client-coro` |U/U |B/B |B/B |B/B |B/B +|`websocket-client-coro-ssl` |U/U |B/B |B/B |B/B |B/B +|`websocket-client-sync` |U/U |P/P |P/P |P/P |P/P +|`websocket-client-sync-ssl` |U/U |P/P |P/P |P/P |P/P +|`websocket-server-async` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-async-local` |P/P |U/U |U/U |U/U |U/U +|`websocket-server-async-ssl` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-awaitable` |U/U |U/U |U/U |U/U |U/U +|`websocket-chat-multi` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-coro` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-coro-ssl` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-fast` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-stackless` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-stackless-ssl` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-sync` |U/U |U/U |U/U |U/U |U/U +|`websocket-server-sync-ssl` |U/U |U/U |U/U |U/U |U/U +|=== + +==== Adaptations and limits + +* WASIp3 uses a fixture resolver posting the known local endpoint. DNS worker threads remain unverified. Worker/system executors use an explicit event loop. +* Host HTTP preserves file handlers or request/body operations. Host listeners, framing and TLS are distinct from guest sockets. Six HTTPS client counterparts run through a configured Wasmtime host with an isolated CA, rejecting unknown issuers and trusted certificates for the wrong hostname. The documentation client additionally measures host-owned mutual TLS and missing-identity rejection. The documentation server measures a host mutual-TLS frontend. +* The host crawler retains upstream report aggregation and two asynchronous workers over bounded authority/path inputs. Its fixture uses two peers, six paths, four response statuses, and a truncated-response failure followed by continued work. Host HTTP combines transport phases: failures count as Read; separate DNS/connect/write/timer phase counts are unmeasured. +* Supplied streams replace Unix-domain addressing with caller-provided stdio. P2 WebSocket counterparts retain asynchronous partial operations through Asio pollables; the other supplied counterparts use synchronous partial operations. +* Browser fetch/WebSocket own DNS, framing and TLS. Guest CA lists, protocol pinning and handshake User-Agent are removed explicitly. HTTPS fixtures install an ephemeral CA in an isolated Chrome profile. A fresh untrusted profile rejects the certificate; the trusted profile rejects its incorrect IP hostname. No certificate-error bypass or system trust-store modification is used. +* Exception-off counterparts retain error-code paths and successful operations; formerly throwing paths report failure and abort. Stackful Context remains blocked. +* Asio P2 provides sockets and guest TLS, but the Beast guest-socket and guest-TLS application corpus still needs P2 integration and validation. Browser listeners and WASI Unix-domain socket addressing remain unavailable. WASIp3 cooperative EH-on lacks the toolchain exception runtime. + +==== Reproduction + +[source,bash] +---- +python3 libs/beast/test/applications/inventory.py --check +python3 libs/beast/example/applications/tools/prepare.py --clang-format clang-format +b2 libs/beast/test/applications//applications +b2 toolset=clang-wasip3 libs/beast/test/applications/wasip3//applications-p3 +b2 toolset=emscripten libs/beast/test/applications/browser//applications-browser +b2 toolset=clang-wasip2 libs/beast/test/applications/host//applications-host +b2 toolset=clang-wasip2 libs/beast/test/applications/host-clients//applications-host-clients +cargo build --locked --manifest-path libs/beast/test/applications/host-tls/Cargo.toml --target-dir .local/host-tls +export PATH="$PWD/.local/host-tls/debug:$PATH" +b2 toolset=clang-wasip2 libs/beast/test/applications/host-tls//applications-host-tls +b2 libs/beast/test/applications/noexcept//applications-noexcept +b2 toolset=clang-wasip3 libs/beast/test/applications/noexcept//applications-single-noexcept +b2 toolset=emscripten libs/beast/test/applications/browser-noexcept//applications-browser +b2 toolset=clang-wasip3 libs/beast/test/applications/streams//applications-streams +b2 toolset=clang-wasip3 libs/beast/test/applications/streams//applications-websocket-streams +b2 libs/beast/test/applications/chat//applications-chat +---- + +Configure pinned toolchains with the standard B2 user configuration. Clear CPATH/C_INCLUDE_PATH/CPLUS_INCLUDE_PATH. Runtime peers bind loopback ports, wait for readiness, enforce deadlines, and reap every process. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/doc/beast.adoc b/libraries/beast/openspec/changes/genesis/reference/source/doc/beast.adoc new file mode 100644 index 0000000..094ab98 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/doc/beast.adoc @@ -0,0 +1,272 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + += beast: HTTP and WebSocket for WebAssembly +:toc: left +:toclevels: 2 +:idprefix: +:sectanchors: +:attribute-missing: warn + +`webcpp::beast` is a {cpp}20 compatibility facade for Boost.Beast applications. +It preserves Boost.Beast's messages, buffers and parsers while selecting a +transport appropriate to the program's environment. Native and WASIp3 socket +programs use the guest protocol engine. Browser clients use WebSocket and fetch; +WASI host HTTP programs use the host's request and response resources. +The application matrix distinguishes direct source compatibility from explicit +counterparts, since a browser client and a host HTTP handler do not own a TCP +listener. + +[#beast-tutorial] +== Tutorial: construct a response + +Use the library at `libs/beast` in the WebCPP superproject, with Boost 1.92 and B2 +configured. This first example handles an in-memory request; it opens no connection. + +[source,cpp] +---- +include::{examples}/http_message.cpp[tag=handler,indent=0] +include::{examples}/http_message.cpp[tag=program,indent=0] +---- + +From the superproject root, run: + +[source,bash] +---- +unset CPATH CPLUS_INCLUDE_PATH C_INCLUDE_PATH +b2 -a libs/beast/example//http_message.output +---- + +The expected output is captured from the same example compiled against upstream Beast: + +[listing] +---- +include::{examples}/http_message.expected[] +---- + +The successful finish is a matched `.output` target. Compiling the executable alone +does not check its result. + +[#beast-browser-tutorial] +=== Exchange a message in the browser + +Configure Emscripten and the project's pinned Chrome. The browser driver serves +controlled local peers and the compiled page, runs JSPI and Asyncify, and checks +the page's result. It does not substitute Node for the browser. + +[source,bash] +---- +b2 -a toolset=emscripten variant=release libs/beast/example/browser//browser +---- + +The example resolves the local test peer and records its authority. These +operations then exchange a text message through the browser's WebSocket: + +[source,cpp] +---- +include::{examples}/browser/client.cpp[tag=browser-websocket-client,indent=0] +---- + +The synchronous interface suspends the {cpp} stack while the browser handles the +operation. Use the Asio suspension configuration supplied by the B2 dependency; +blocking the browser thread would prevent the event that completes the wait. + +The same example sends an HTTP message through fetch and validates the response: + +[source,cpp] +---- +include::{examples}/browser/client.cpp[tag=browser-fetch-client,indent=0] +---- + +A successful page prints `browser tutorial: ok`; the driver requires that result +for both suspension variants. The controlled peer uses loopback HTTP. Production +HTTPS/WSS connections use the browser's certificate validation and trust store. + +[#beast-host-tutorial] +=== Handle a host HTTP request + +The WASI example receives an HTTP request from the host and returns a Beast +response. The host owns the listener, connection and any HTTPS termination: + +[source,cpp] +---- +include::{examples}/wasi/http_echo.cpp[] +---- + +[source,bash] +---- +b2 -a toolset=clang-wasip2 variant=release libs/beast/example/wasi//http +b2 -a toolset=clang-wasip3 variant=release libs/beast/example/wasi//http +---- + +The served test checks the health response and echoed request body against the +example's recorded request transcript. A failed response, timeout or mismatch +fails the test. Supplying a guest TCP acceptor is unnecessary for this backend. + +[#beast-how-to] +== How-to: select a dependency and target + +[cols="1,2",options="header"] +|=== +|B2 dependency |Purpose +|`/webcpp/beast//beast` |Portable buffers, HTTP messages, parsers and serializers. +|`/webcpp/beast//sockets` |Native/WASIp3 guest socket algorithms and Asio configuration. +|`/webcpp/beast//tls` |Guest-owned TLS with source-built OpenSSL. +|`/webcpp/beast//browser` |Browser-owned WebSocket, fetch and TLS policy. +|`/webcpp/beast//wasi-http` |WASIp2/P3 host HTTP resources, without guest sockets or OpenSSL. +|`/webcpp/beast//wasi-streams` |Explicit supplied-stream counterparts, including WASI CLI input/output. +|=== + +Include `` and `` explicitly +for byte-stream operations, and `` or +`` for the socket types. The convenience header omits +these transport headers and ``. + +Select the dependency for the transport the application actually uses. A WASI +host HTTP handler does not need the guest socket or TLS dependency. Combining +backends is explicit, for example a WASIp3 service that accepts host HTTP requests +and separately contacts a TCP service. + +[source,bash] +---- +b2 -a variant=release exception-handling=on,off libs/beast/test libs/beast/example +b2 -a toolset=clang-wasip2 testing.launcher=wasmtime exception-handling=on,off libs/beast/test libs/beast/example +b2 -a toolset=clang-wasip3 testing.launcher=tools/boost/asio-wasip3/run.sh exception-handling=on,off libs/beast/test libs/beast/example +b2 -a toolset=emscripten exception-handling=on,off libs/beast/test libs/beast/example +---- + +WASIp3 socket tests require the launcher's loopback networking capabilities. Production +hosts should grant only the capabilities their application needs. + +[#beast-configuration] +=== Configure error policy + +`webcpp-beast-unsupported=error` is the default; `ignore` is the alternative intended +for documented host-adapter restrictions. It does not make an unavailable transport +work. The B2 feature defines exactly one of `WEBCPP_BEAST_UNSUPPORTED_ERROR` and +`WEBCPP_BEAST_UNSUPPORTED_IGNORE`. Defining both fails compilation. + +`WEBCPP_BEAST_NO_EXCEPTIONS` follows `` and can also be defined by +the application. `WEBCPP_NO_EXCEPTIONS` applies to all WebCPP libraries. These macros +do not change the compiler configuration or remove upstream Boost overloads; use +`exception-handling=off` for a complete build without exception handling. Prefer +upstream error-code overloads when recovery is required. + +[#beast-explanation] +== Explanation: separate messages from transport + +Boost.Beast's general headers include stream algorithms that reach Asio sockets. +A message-only application does not need those dependencies, even though the +Asio port now offers a WASIp2 socket reactor. This facade exposes data headers separately, +retaining upstream type identity and parsing behaviour without a guest reactor. + +The socket backend executes upstream Beast over the existing Asio port. Host +adapters map operations to browser WebSocket/fetch and `wasi:http`, preserving +application-visible messages with documented differences in connection ownership, +headers, framing and TLS. A host HTTP handler does not imply a TCP acceptor. + +For a server counterpart, keep the application's HTTP request processing and +replace its accept loop with the host handler entry. For a local-stream +counterpart, explicitly supply the two stream directions; stdin and stdout do +not provide Unix socket names, descriptor passing or peer credentials. + +Browser security remains the browser's: CORS, forbidden request headers, +certificate validation, redirects and WebSocket control frames cannot be +implemented as arbitrary raw-socket options. Host TLS never uses guest OpenSSL +settings. Prefer explicit errors to silently claiming that the host accepted an +unavailable setting. + +The native/WASI WebSocket allocator constructor accepts the portable constructor +syntax, but upstream Beast still controls its internal stream-state allocation. +Associated completion-handler allocators retain upstream semantics. Data containers +use their upstream allocator template parameters. + +`set_server_name` configures SNI only. It copies a non-terminated string view into a +bounded buffer and rejects empty, overlong or embedded-NUL hostnames. Certificate and +hostname verification remain separate TLS settings. Guest OpenSSL settings must never +be represented as changing browser or WASI host trust policy. + +[#beast-matrix] +== Feature matrix + +Capabilities belong to a backend, not only a compiler target. The runtime record +below and the application matrix state which variants were actually exercised. +An application counterpart preserves a stated use case; it does not imply every +API or transport detail of the original program is available. + +[cols="2,1,1,1,1",options="header"] +|=== +|Feature |Native |WASIp2 |WASIp3 |Emscripten +|HTTP message/parser/serializer interfaces |Implemented |Implemented |Implemented |Implemented +|Guest HTTP/WebSocket socket engine |Asio sockets |Asio core available; guest-socket facade/application integration pending |Asio socket port |Explicit supplied byte stream only +|Browser WebSocket and fetch |Not applicable |Not applicable |Not applicable |JSPI and Asyncify +|Guest TLS, identity verification and shutdown |Source-built OpenSSL |No guest TLS backend |Source-built OpenSSL |Browser owns TLS +|Host HTTP entry/client |Not applicable |wasi:http |wasi:http |fetch client only +|Unix socket namespace and peer identity |Operating-system sockets |Unavailable |Unavailable |Unavailable +|Explicit supplied-stream counterpart |Borrowed descriptors |CLI input/output; asynchronous WebSocket via pollables |CLI input/output |Caller-supplied channel +|Raw TCP HTTP/WebSocket listener |Available |Use host HTTP entry |Available |Unavailable +|Host HTTP WebSocket upgrade |Not applicable |Not provided by host adapter |Use guest socket backend |Browser WebSocket client only +|Native CPU-parallel threads |Available |Unavailable |Cooperative WASI threads only |Not implied by this backend +|=== + +Exception and thread variants are reported separately in the verification record. +Emscripten data tests run under Node; transport tests run in the pinned Chrome. +Cooperative WASIp3 threads are not CPU-parallel threads, and their SDK 34 runtime +currently requires exceptions off. + +include::browser-differences.adoc[] + +[#beast-stream-cancellation] +=== Cancellation of host-supplied streams + +The WASIp2 WebSocket counterparts use Asio's pollable-driven CLI adapter and +retain asynchronous read/write operations. Their actual client/server exchanges +pass with both exception profiles. The P2 Asio supplied-stream lane checks a +pending read with open, empty input, timer cancellation, cancellation slots, +stream destruction, deferred initiation and handler allocator/executor associations. +Other supplied counterparts retain their explicit synchronous partial operations. + +Supplied-stream cancellation is checked between host calls and while waiting on +supported readiness operations. It cannot preempt a host import that blocks the +calling thread. In the tested Wasmtime 50 CLI, WASIp2 stdout can block when its +operating-system pipe fills even after `check-write` grants permission. A paused +consumer must resume draining before that import returns and the component can +observe cancellation. Keep the consumer draining or select a host/channel with +nonblocking write behaviour when a strict cancellation deadline is required. + +This is separate from a guest socket's cancellation semantics. Standard input +and output also do not acquire Unix socket addressing or peer credentials merely +because they are exposed through file descriptors. + +include::verification.adoc[] + +include::application-matrix.adoc[] + +[#beast-guarantees] +== Guarantees and evidence + +* `message_test.cpp` checks upstream type identity, embedded-NUL payloads, parser body + limits and malformed fields on every declared data target. +* `socket_test.cpp` exchanges real HTTP and binary WebSocket payloads, completes both + sides of a close handshake, and verifies a stalled peer reaches the stream timeout. + Each case has a five-second outer deadline. +* `ssl_test.cpp` checks SNI copying and rejection without replacing an existing valid + name. It does not claim that an SNI setting authenticates the peer. +* `config_test.cpp` checks compiler/global/library exception configuration, both + unsupported-operation policies and rejection of conflicting definitions. +* `test/tls/protocol.cpp` checks actual TLS HTTP and WebSocket exchanges, + authentication failures, transfer cancellation and TLS shutdown outcomes. +* `test/browser/browser_test.cpp` runs the browser contracts in Chrome. Its local + server controls delayed headers and bodies, redirects, WebSocket closure and CORS. +* `test/applications/inventory.py` verifies all 53 pinned upstream executables and + their source hashes; application drivers compare explicit local exchanges. + +[#reference] +== Reference + +include::{reference}[leveloffset=+1] + +include::changelog.adoc[] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/doc/browser-differences.adoc b/libraries/beast/openspec/changes/genesis/reference/source/doc/browser-differences.adoc new file mode 100644 index 0000000..e5dde2f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/doc/browser-differences.adoc @@ -0,0 +1,110 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#beast-browser-differences] +=== Browser settings and observable differences + +This table describes the browser-owned WebSocket and fetch backends. It does not +change native or WASIp3 guest socket semantics. `ERROR` rejects an unsupported +setting with `operation_not_supported` when the dependent operation starts. +`IGNORE` discards that setting; it does not add a missing browser capability or +disable browser security. Configuration is part of the browser types' namespace; +translation units using different policies cannot exchange those types silently. + +The browser-owned WebSocket's `websocket::request_type` uses +`http::basic_fields>`. Its handshake fields +therefore use the stream's memory resource, including long decorator values. +Use that alias, or a generic callable, when declaring a request decorator rather +than requiring Boost's default field allocator. Native and WASIp3 socket streams +retain the upstream request type. The explicit guest WebSocket adapter accepts +typed WebCPP request and response decorators for client and server handshakes; +it converts their fields when calling the upstream protocol implementation. + +The test harness configures an ephemeral CA in a disposable full-Chrome profile. +The protocol contract peer's certificate covers `localhost` and `127.0.0.1`; +an untrusted profile rejects its WSS connection before the trusted contracts run. +Application HTTPS fixtures use a separate localhost-only certificate to prove +that a trusted certificate is still rejected for the wrong hostname. These +fixture settings belong to the host harness and do not add guest TLS controls. + +[cols="2,2,3",options="header"] +|=== +|Setting or operation |Outcome |Meaning for the application +|SNI and `host_name_verification` matching the URL authority +|Accepted |The browser performs its own certificate and hostname validation. +|`verify_peer`, default verification paths, `tls_client` and `sslv23_client` +|Accepted |The browser chooses its enabled protocol versions and trust store. +|Fixed TLS version, `verify_none`, arbitrary verification callback +|Unsupported |The application cannot change browser TLS validation or negotiation. +|Client certificate/key, additional roots, verification path or file +|Unsupported |Guest certificate material does not configure the browser's TLS stack. +|SNI, verification hostname or handshake Host differing from the URL authority +|Unsupported |The browser connects and authenticates the URL authority. +|WebSocket decorator's `Sec-WebSocket-Protocol` +|Accepted |Its values become the browser constructor's subprotocol list. +|Other WebSocket decorator fields, including `User-Agent` +|Unsupported |The browser constructs the handshake headers. +|`expires_after`, `expires_at`, `expires_never`, handshake timeout +|Accepted |An expired operation returns `beast::error::timeout` and closes the connection. +|Idle timeout without keep-alive pings +|Accepted |Visible messages and closure determine activity; incoming ping frames are hidden. +|Idle timeout with keep-alive pings; explicit ping and pong +|Unsupported |The browser cannot send application-requested control frames. +|`control_callback` +|Close notifications only |Ping and pong frames are not exposed by the browser API. +|`permessage_deflate`, `auto_fragment`, `write_buffer_bytes` +|Ignored under both policies |The browser controls compression and frame boundaries. +|Close code 1000 or 3000 through 4999 +|Accepted |The reason uses Beast's bounded UTF-8 reason string. +|Other close codes, including 1001 +|Unsupported |Under `IGNORE`, the adapter closes with 1000 instead. +|`read_message_max` +|Enforced |An oversized message reports `message_too_big` and closes the connection. +|`queue_limits` +|Enforced |Queued receives and browser-buffered sends have separate bounds. Exceeding +one closes the connection with `receive_limit` or `send_limit`. +|HTTP Host equal to URL host or host:port +|Accepted |The browser generates the corresponding Host field. +|HTTP `Content-Length` and `Transfer-Encoding` +|Message framing accepted |The adapter sends decoded body bytes; fetch chooses wire framing. +|HTTP `Connection` and `Keep-Alive` +|Ignored under both policies |Connection ownership and reuse belong to the browser. +|HTTP `User-Agent` and browser-forbidden request headers +|Unsupported |The browser may reject, replace or omit these headers. +|HTTP methods or bodies fetch cannot send, including CONNECT +|Unsupported |`IGNORE` cannot make the browser issue a forbidden request. +|Redirected HTTP response +|Policy dependent |`ERROR` reports `operation_not_supported`; `IGNORE` returns the final response. +The redirect has already been followed by fetch when this is reported. +|CORS rejection, mixed-content rejection or another fetch failure +|`browser_errc::fetch_failed` |The browser does not reliably expose a more specific cause. +|Browser socket facade's shutdown, close and cancel +|Facade lifecycle operations |These stop pending facade work; they do not expose a TCP descriptor. +|=== + +A successful WebSocket write means the browser accepted the message, not that the +peer received it. Partial writes are accumulated into one message, and their +bytes count toward the send bound. A cancelled read leaves the next message +available to a later read. Destruction aborts pending operations through posted +completion and unregisters event callbacks before late events can reach them. +Both queue bounds default to 4 MiB. The default maximum WebSocket message is +16 MiB; a smaller receive-queue bound still applies independently. +The receive bound charges each retained payload and its message record, including +empty messages. Partial reads release that charge only when the complete message +is consumed and its storage is released. Container bookkeeping and allocator +overhead are additional implementation costs; the bound is not a total heap quota. + +The default HTTP path maps messages directly to fetch. Its response body limit +defaults to 8 MiB. `http::async_read_header` and `http::read_header` accept response +messages and complete when metadata is available, before the body is consumed; +a subsequent full read consumes the body. The separate +`http_byte_stream` compatibility adapter synthesizes HTTP/1.1 bytes for programs +using Beast parsers, buffering the full fetch response before parsing. Fetch has +already decoded the response body, so synthetic +responses omit original `Content-Encoding` and `Content-Length`; responses with +a body use chunked framing. HEAD, 204 and 304 responses have no synthetic body +or chunk terminator. HEAD parser users retain `skip(true)`. These representation +differences do not imply byte-for-byte equality with the original wire response. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/doc/changelog.adoc b/libraries/beast/openspec/changes/genesis/reference/source/doc/changelog.adoc new file mode 100644 index 0000000..c891622 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/doc/changelog.adoc @@ -0,0 +1,31 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[appendix] +[#beast-changelog] +== Changelog + +Changes to the unreleased Beast facade. + +[#beast-changelog-unreleased] +=== Unreleased + +// tag::unreleased[] +// end::unreleased[] + +[#beast-changelog-0-1-0] +=== webcpp 0.1.0 + +// tag::0.1.0[] +* Added portable HTTP data interfaces and native/WASIp3 socket operations. +* Added optional guest TLS SNI configuration with hostname validation. +* Added browser WebSocket and fetch adapters with explicit capability policies. +* Added WASI host HTTP and supplied-stream application counterparts. +* Fixed WebSocket executor conversion when per-message compression is disabled. +* Fixed host completion storage lifetime and support for PMR operation allocators. +* Fixed supplied-stream HTTP reads with small bounded buffers. +* Added executable examples, API reference and a verified target matrix. +// end::0.1.0[] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/doc/verification.adoc b/libraries/beast/openspec/changes/genesis/reference/source/doc/verification.adoc new file mode 100644 index 0000000..670e36d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/doc/verification.adoc @@ -0,0 +1,161 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +[#beast-verification] +== Verification and reproduction + +The local evidence below was collected on macOS ARM64 on 2026-11-02 and 2026-11-03 with Boost +1.92, native Clang 21, wasi-sdk 34, Emscripten 6.0.11 and Wasmtime 50.0.1. +Core and guest TLS runs use Release builds. Browser contract runs use Debug, +and the standalone upstream oracle compiles with `-O0`; these are correctness +checks, not performance or binary-size measurements. A local pass does not +establish Windows or Linux coverage; the remote CI report supplies those +independent results. + +[cols="2,2,3",options="header"] +|=== +|Suite |Profiles exercised |What passed +|Portable core and socket facade +|Native single/multi, exceptions on/off; WASIp2/P3 single, exceptions on/off; +Emscripten single, exceptions on/off +|Public-header compilation, upstream type identity, binary HTTP bodies, parser +limits, error policy, constructor conversion and applicable socket/SNI exchanges. +|Guest TLS protocol +|Native single/multi, exceptions on/off; WASIp3 single, exceptions on/off; +WASIp3 cooperative, exceptions off +|Eight scenarios with TLS 1.2 and again with TLS 1.3 in each profile: 112 scenario +executions. HTTP and binary WebSocket transfer, normal close, wrong hostname, +untrusted CA, cancelled body read, truncated TLS shutdown, cancelled shutdown +and handshake timeout. +|Browser and Node contract, plus browser tutorial +|JSPI/Asyncify, exceptions on/off, ERROR/IGNORE +|Real Chrome and Node 26 WebSocket/fetch exchanges, queue and body limits, timeout, +cancellation, destruction, allocator alignment, reconnection and response reuse. +Direct header reads complete while the server still withholds the body. +The allocation counter distinguishes stream, handler and context resources and +requires zero escaped global allocations and zero retained blocks after cleanup. +|WASI host HTTP and supplied streams +|WASIp2/P3 single, exceptions on/off; applicable WASIp3 cooperative tests +|Bounded 256 KiB exchanges, request/response trailers, malformed requests, +resource cleanup, cancellation and explicit CLI stream counterparts. +|WASI host HTTPS +|WASIp2/P3 single, exceptions on/off; WASIp3 cooperative, exceptions off +|Six application counterparts and the shared sync/async body-and-trailer contract: +35 driver executions containing 125 TLS attempts. Trusted localhost succeeds; +unknown CA and trusted wrong hostname fail. The documentation SSL client also +proves mutual TLS and rejection without a client identity. +|Upstream application inventory +|Per-application and per-profile results below +|All 53 executable definitions are cross-checked against upstream Jamfiles, +CMake definitions and entry points. Source hashes protect the original corpus. +|=== + +The TLS fixture synchronizes shutdown cancellation with the peer receiving +`close_notify`; it does not rely on an arbitrary sleep or callback ordering. +WebSocket close already tears down TLS and TCP, so its test verifies that result +without starting a second TLS shutdown. Each protocol scenario has an outer +five-second deadline, and the driver also bounds the whole process. + +Guest-socket applications compile their Wasm component once with Wasmtime before +the execution deadlines start. Compilation has a separate 60-second limit and +records its command, duration and exit status. The driver runs only the artifact +it produced in its private temporary directory, with matching engine features and +epoch interruption enabled. Guest readiness retains its 15-second bound and +protocol I/O retains its five-second bound. The WASIp3 driven-test envelope is +90 seconds: the compilation allowance plus the existing 30-second driver bound. +Compilation failures report stdout and stderr without starting the guest. + +The native WebSocket constructor regression checks same-type move and conversion +from a concrete executor to `any_io_executor`, including `deflateSupported=false`. +The configuration tests include a deliberately failing cross-translation-unit +link with different browser policies and a matching-policy success control. +An expected compile/link failure is a passing negative test only when B2 reports +`failed-as-expected` and its success control also passes. + +[#beast-reproduce] +=== Reproduce a suite + +Configure the project's pinned SDKs and native Boost 1.92 in a B2 user config. +Select Wasmtime 50.0.1 explicitly through `PATH`. Emscripten 6 requires Python +3.10 or newer; set `EMSDK_PYTHON` when the system's default Python is older. +The commands assume `.local/user-config.jam` and run from the superproject root. +`-a` forces compilation and execution; separate build directories preserve logs +and outputs across targets. + +[source,bash] +---- +unset CPATH CPLUS_INCLUDE_PATH C_INCLUDE_PATH +b2 --user-config=.local/user-config.jam -a variant=release \ + exception-handling=on,off threading=single,multi \ + libs/beast/test libs/beast/example libs/beast/test/tls//tls +b2 --user-config=.local/user-config.jam -a toolset=clang-wasip2 \ + variant=release exception-handling=on,off testing.launcher=wasmtime \ + libs/beast/test libs/beast/example libs/beast/test/wasi//http +b2 --user-config=.local/user-config.jam -a toolset=clang-wasip3 \ + variant=release exception-handling=on,off \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/beast/test libs/beast/example libs/beast/test/tls//tls +b2 --user-config=.local/user-config.jam -a toolset=clang-wasip3 \ + variant=release threading=multi exception-handling=off \ + testing.launcher=tools/boost/asio-wasip3/run.sh \ + libs/beast/test libs/beast/example libs/beast/test/tls//tls +b2 --user-config=.local/user-config.jam \ + libs/beast/test/browser/peer//native_peer-program threading=multi +b2 --user-config=.local/user-config.jam -a toolset=emscripten \ + variant=release exception-handling=on,off \ + libs/beast/test/browser//browser libs/beast/example/browser//browser +---- + +The native peer built above is shared by the browser and Node contract suites. +Run the Node contracts separately: + +[source,bash] +---- +b2 --user-config=.local/user-config.jam -a toolset=emscripten \ + exception-handling=on,off libs/beast/test/browser//browser-node +---- + +Repeat both contract commands with `webcpp-beast-unsupported=ignore` to exercise the +second policy. The browser lane installs and runs pinned full Chrome. The Node lane +executes the same Wasm programs in Node 26, using its WebSocket and fetch APIs; +it does not replace the separate browser CORS and mixed-content checks. +Host HTTP drivers start +Wasmtime with a loopback listener and bounded request transcripts. Production +network capabilities remain the embedding application's responsibility. + +HTTPS/WSS fixtures use temporary CAs. The protocol contract peer has a leaf +valid for both `localhost` and `127.0.0.1`, preserving its existing loopback +request URLs. Its fresh untrusted Chrome profile must reject WSS with an +authority error before the trusted contract exchange runs. The application +fixture uses a separate leaf valid only for `localhost`; its trusted profile +must reject that certificate when addressed as `127.0.0.1`. +Full Chrome receives each CA in a disposable profile, and Node receives the +contract CA through `NODE_EXTRA_CA_CERTS`. The system trust store is unchanged, +and neither fixture disables certificate verification. Production browser +trust remains browser-owned. + +The WASI HTTPS fixture embeds exactly Wasmtime 50.0.1 and supplies a private +test root through its supported host hook. Rustls performs normal chain and +hostname verification. This isolates the CA from the machine and avoids claiming +that a guest OpenSSL test establishes host HTTPS behavior. The stock Wasmtime +CLI uses its own public roots and does not expose a custom-CA command-line option. + +[source,bash] +---- +cargo +1.97.1 build --locked \ + --manifest-path libs/beast/test/applications/host-tls/Cargo.toml \ + --target-dir .local/beast-host-tls +export WEBCPP_WASI_TLS_FIXTURE="$PWD/.local/beast-host-tls/debug/webcpp-beast-host-tls-fixture" +b2 --user-config=.local/user-config.jam \ + toolset=clang-wasip2,clang-wasip3 exception-handling=on,off \ + libs/beast/test/applications/host-tls//applications-host-tls +---- + +The 53 upstream applications and their adaptations have separate targets. Their +matrix records compilation and execution separately, including unavailable +programming models rather than selecting an empty fallback program. In particular, +stackful Boost.Context coroutines, native threads and asynchronous DNS are not +inferred from a successful {cpp}20 coroutine or pre-resolved-address counterpart. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/.clang-tidy b/libraries/beast/openspec/changes/genesis/reference/source/example/.clang-tidy new file mode 100644 index 0000000..a625662 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/.clang-tidy @@ -0,0 +1,7 @@ +# Examples let an allocation or operation error terminate their main, as +# Boost's examples do. Other exception-escape checks remain enabled. +--- +InheritParentConfig: true +CheckOptions: + - key: bugprone-exception-escape.CheckMain + value: 'false' diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/Jamfile new file mode 100644 index 0000000..45ff668 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/Jamfile @@ -0,0 +1,15 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project : requirements /webcpp/beast//beast ; + +import webcpp ; + +webcpp.targets native wasip2 wasip3 emscripten ; +webcpp.example http_message.cpp ; + +build-project browser ; +build-project wasi ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/adaptations.patch b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/adaptations.patch new file mode 100644 index 0000000..26b308f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/adaptations.patch @@ -0,0 +1,32086 @@ +--- upstream/advanced/server/advanced_server.cpp ++++ port/advanced/server/advanced_server.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,17 +30,14 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include +-#include ++#include + #include + #include + #include + #include ++#include + #include + #include +-#include + #include + #include + #include +@@ -32,70 +46,87 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -107,15 +138,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -126,9 +152,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -139,9 +163,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -152,19 +174,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -173,19 +193,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -195,10 +214,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -209,106 +226,71 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class websocket_session : public std::enable_shared_from_this +-{ ++class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- websocket_session(tcp::socket&& socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation +- template +- void +- do_accept(http::request> req) +- { ++ template ++ void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " advanced-server"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); ++ })); + + // Accept the websocket handshake + ws_.async_accept( +- req, +- beast::bind_front_handler( +- &websocket_session::on_accept, +- shared_from_this())); ++ req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + + private: +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + return; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &websocket_session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, ++ shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -322,13 +304,12 @@ + //------------------------------------------------------------------------------ + + // Handles an HTTP server connection +-class http_session : public std::enable_shared_from_this +-{ ++class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + +- static constexpr std::size_t queue_limit = 8; // max responses ++ static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can +@@ -337,35 +318,23 @@ + + public: + // Take ownership of the socket +- http_session( +- tcp::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- static_assert(queue_limit > 0, +- "queue limit must be positive"); ++ http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) { ++ static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- stream_.get_executor(), +- beast::bind_front_handler( +- &http_session::do_read, +- this->shared_from_this())); ++ net::dispatch(stream_.get_executor(), ++ beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + + private: +- void +- do_read() +- { ++ void do_read() { + // Construct a new parser for each message + parser_.emplace(); + +@@ -377,34 +346,26 @@ + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface +- http::async_read( +- stream_, +- buffer_, +- *parser_, +- beast::bind_front_handler( +- &http_session::on_read, +- shared_from_this())); +- } +- +- void +- on_read(beast::error_code ec, std::size_t bytes_transferred) +- { ++ http::async_read(stream_, buffer_, *parser_, ++ beast::bind_front_handler(&http_session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade +- if(websocket::is_upgrade(parser_->get())) +- { ++ if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. +- std::make_shared( +- stream_.release_socket())->do_accept(parser_->release()); ++ std::make_shared(stream_.release_socket()) ++ ->do_accept(parser_->release()); + return; + } + +@@ -416,9 +377,7 @@ + do_read(); + } + +- void +- queue_write(http::message_generator response) +- { ++ void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + +@@ -429,43 +388,30 @@ + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. +- void +- do_write() +- { +- if(! response_queue_.empty()) +- { ++ void do_write() { ++ if (!response_queue_.empty()) { + bool keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( +- stream_, +- std::move(response_queue_.front()), +- beast::bind_front_handler( +- &http_session::on_write, +- shared_from_this(), +- keep_alive)); +- } +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(response_queue_.front()), ++ beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); ++ } ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); + } + + // Resume the read if it has been paused +- if(response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) + do_read(); + + response_queue_.pop(); +@@ -473,9 +419,7 @@ + do_write(); + } + +- void +- do_close() +- { ++ void do_close() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -487,97 +431,69 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- acceptor_.get_executor(), +- beast::bind_front_handler( +- &listener::do_accept, +- this->shared_from_this())); ++ net::dispatch(acceptor_.get_executor(), ++ beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the http session and run it +- std::make_shared( +- std::move(socket), +- doc_root_)->run(); ++ std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection +@@ -587,15 +503,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: advanced-server
\n" << +- "Example:\n" << +- " advanced-server 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: advanced-server
\n" ++ << "Example:\n" ++ << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -604,40 +517,33 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port +- std::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); +- signals.async_wait( +- [&](beast::error_code const&, int) +- { +- // Stop the `io_context`. This will cause `run()` +- // to return immediately, eventually destroying the +- // `io_context` and all of the sockets in it. +- ioc.stop(); +- }); ++ signals.async_wait([&](beast::error_code const&, int) { ++ // Stop the `io_context`. This will cause `run()` ++ // to return immediately, eventually destroying the ++ // `io_context` and all of the sockets in it. ++ ioc.stop(); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for(auto& t : v) ++ for (auto& t : v) + t.join(); + + return EXIT_SUCCESS; +--- upstream/advanced/server-flex/advanced_server_flex.cpp ++++ port/advanced/server-flex/advanced_server_flex.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,21 +31,18 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include + #include + #include ++#include ++#include + #include + #include +-#include + #include + #include + #include +@@ -35,71 +50,88 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -110,16 +142,11 @@ + // + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. +-template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++template ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -130,9 +157,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -143,9 +168,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -156,19 +179,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -177,19 +198,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -199,10 +219,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -213,9 +231,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -233,7 +249,7 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +@@ -244,100 +260,69 @@ + // Echoes back all received WebSocket messages. + // This uses the Curiously Recurring Template Pattern so that + // the same code works with both SSL streams and regular sockets. +-template +-class websocket_session +-{ ++template ++class websocket_session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. +- Derived& +- derived() +- { +- return static_cast(*this); +- } ++ Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation +- template +- void +- do_accept(http::request> req) +- { ++ template ++ void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( +- websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { ++ websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " advanced-server-flex"); ++ std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake +- derived().ws().async_accept( +- req, +- beast::bind_front_handler( +- &websocket_session::on_accept, +- derived().shared_from_this())); ++ derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, ++ derived().shared_from_this())); + } + + private: +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- derived().ws().async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- derived().shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, ++ derived().shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + return; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), +- beast::bind_front_handler( +- &websocket_session::on_write, +- derived().shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -349,10 +334,8 @@ + + public: + // Start the asynchronous operation +- template +- void +- run(http::request> req) +- { ++ template ++ void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } +@@ -361,74 +344,46 @@ + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection +-class plain_websocket_session +- : public websocket_session +- , public std::enable_shared_from_this +-{ ++class plain_websocket_session : public websocket_session, ++ public std::enable_shared_from_this { + websocket::stream ws_; + + public: + // Create the session +- explicit +- plain_websocket_session( +- beast::tcp_stream&& stream) +- : ws_(std::move(stream)) +- { +- } ++ explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class +- websocket::stream& +- ws() +- { +- return ws_; +- } ++ websocket::stream& ws() { return ws_; } + }; + + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection +-class ssl_websocket_session +- : public websocket_session +- , public std::enable_shared_from_this +-{ ++class ssl_websocket_session : public websocket_session, ++ public std::enable_shared_from_this { + websocket::stream> ws_; + + public: + // Create the ssl_websocket_session +- explicit +- ssl_websocket_session(ssl::stream&& stream) +- : ws_(std::move(stream)) +- { +- } ++ explicit ssl_websocket_session(ssl::stream&& stream) ++ : ws_(std::move(stream)) {} + + // Called by the base class +- websocket::stream>& +- ws() +- { +- return ws_; +- } ++ websocket::stream>& ws() { return ws_; } + }; + + //------------------------------------------------------------------------------ + +-template +-void +-make_websocket_session( +- beast::tcp_stream stream, +- http::request> req) +-{ +- std::make_shared( +- std::move(stream))->run(std::move(req)); ++template ++void make_websocket_session(beast::tcp_stream stream, ++ http::request> req) { ++ std::make_shared(std::move(stream))->run(std::move(req)); + } + +-template +-void +-make_websocket_session( +- ssl::stream stream, +- http::request> req) +-{ +- std::make_shared( +- std::move(stream))->run(std::move(req)); ++template ++void make_websocket_session(ssl::stream stream, ++ http::request> req) { ++ std::make_shared(std::move(stream))->run(std::move(req)); + } + + //------------------------------------------------------------------------------ +@@ -436,20 +391,15 @@ + // Handles an HTTP server connection. + // This uses the Curiously Recurring Template Pattern so that + // the same code works with both SSL streams and regular sockets. +-template +-class http_session +-{ ++template ++class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. +- Derived& +- derived() +- { +- return static_cast(*this); +- } +- +- static constexpr std::size_t queue_limit = 8; // max responses ++ Derived& derived() { return static_cast(*this); } ++ ++ static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can +@@ -461,17 +411,10 @@ + + public: + // Construct the session +- http_session( +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : doc_root_(doc_root) +- , buffer_(std::move(buffer)) +- { +- } +- +- void +- do_read() +- { ++ http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) ++ : doc_root_(doc_root), buffer_(std::move(buffer)) {} ++ ++ void do_read() { + // Construct a new parser for each message + parser_.emplace(); + +@@ -480,43 +423,33 @@ + parser_->body_limit(10000); + + // Set the timeout. +- beast::get_lowest_layer( +- derived().stream()).expires_after(std::chrono::seconds(30)); ++ beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), +- buffer_, +- *parser_, +- beast::bind_front_handler( +- &http_session::on_read, +- derived().shared_from_this())); +- } +- +- void +- on_read(beast::error_code ec, std::size_t bytes_transferred) +- { ++ derived().stream(), buffer_, *parser_, ++ beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return derived().do_eof(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade +- if(websocket::is_upgrade(parser_->get())) +- { ++ if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. +- return make_websocket_session( +- derived().release_stream(), +- parser_->release()); ++ return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response +@@ -527,9 +460,7 @@ + do_read(); + } + +- void +- queue_write(http::message_generator response) +- { ++ void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + +@@ -540,43 +471,30 @@ + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. +- void +- do_write() +- { +- if(! response_queue_.empty()) +- { ++ void do_write() { ++ if (!response_queue_.empty()) { + bool keep_alive = response_queue_.front().keep_alive(); + +- beast::async_write( +- derived().stream(), +- std::move(response_queue_.front()), +- beast::bind_front_handler( +- &http_session::on_write, +- derived().shared_from_this(), +- keep_alive)); +- } +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::async_write(derived().stream(), std::move(response_queue_.front()), ++ beast::bind_front_handler(&http_session::on_write, ++ derived().shared_from_this(), keep_alive)); ++ } ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused +- if(response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) + do_read(); + + response_queue_.pop(); +@@ -588,50 +506,28 @@ + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection +-class plain_http_session +- : public http_session +- , public std::enable_shared_from_this +-{ ++class plain_http_session : public http_session, ++ public std::enable_shared_from_this { + beast::tcp_stream stream_; + + public: + // Create the session +- plain_http_session( +- beast::tcp_stream&& stream, +- beast::flat_buffer&& buffer, +- std::shared_ptr const& doc_root) +- : http_session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(stream)) +- { +- } ++ plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, ++ std::shared_ptr const& doc_root) ++ : http_session(std::move(buffer), doc_root), ++ stream_(std::move(stream)) {} + + // Start the session +- void +- run() +- { +- this->do_read(); +- } ++ void run() { this->do_read(); } + + // Called by the base class +- beast::tcp_stream& +- stream() +- { +- return stream_; +- } ++ beast::tcp_stream& stream() { return stream_; } + + // Called by the base class +- beast::tcp_stream +- release_stream() +- { +- return std::move(stream_); +- } ++ beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class +- void +- do_eof() +- { ++ void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -643,78 +539,48 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection +-class ssl_http_session +- : public http_session +- , public std::enable_shared_from_this +-{ ++class ssl_http_session : public http_session, ++ public std::enable_shared_from_this { + ssl::stream stream_; + + public: + // Create the http_session +- ssl_http_session( +- beast::tcp_stream&& stream, +- ssl::context& ctx, +- beast::flat_buffer&& buffer, +- std::shared_ptr const& doc_root) +- : http_session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(stream), ctx) +- { +- } ++ ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, ++ std::shared_ptr const& doc_root) ++ : http_session(std::move(buffer), doc_root), ++ stream_(std::move(stream), ctx) {} + + // Start the session +- void +- run() +- { ++ void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, +- buffer_.data(), +- beast::bind_front_handler( +- &ssl_http_session::on_handshake, +- shared_from_this())); ++ ssl::stream_base::server, buffer_.data(), ++ beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class +- ssl::stream& +- stream() +- { +- return stream_; +- } ++ ssl::stream& stream() { return stream_; } + + // Called by the base class +- ssl::stream +- release_stream() +- { +- return std::move(stream_); +- } ++ ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class +- void +- do_eof() +- { ++ void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( +- beast::bind_front_handler( +- &ssl_http_session::on_shutdown, +- shared_from_this())); ++ beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + + private: +- void +- on_handshake( +- beast::error_code ec, +- std::size_t bytes_used) +- { +- if(ec) ++ void on_handshake(beast::error_code ec, std::size_t bytes_used) { ++ if (ec) + return fail(ec, "handshake"); + + // Consume the portion of the buffer used by the handshake +@@ -723,10 +589,8 @@ + do_read(); + } + +- void +- on_shutdown(beast::error_code ec) +- { +- if(ec) ++ void on_shutdown(beast::error_code ec) { ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -736,167 +600,112 @@ + //------------------------------------------------------------------------------ + + // Detects SSL handshakes +-class detect_session : public std::enable_shared_from_this +-{ ++class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + + public: +- explicit +- detect_session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , ctx_(ctx) +- , doc_root_(doc_root) +- { +- } ++ explicit detect_session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- stream_.get_executor(), +- beast::bind_front_handler( +- &detect_session::on_run, +- this->shared_from_this())); +- } +- +- void +- on_run() +- { ++ net::dispatch(stream_.get_executor(), ++ beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); ++ } ++ ++ void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( +- stream_, +- buffer_, +- beast::bind_front_handler( +- &detect_session::on_detect, +- this->shared_from_this())); +- } +- +- void +- on_detect(beast::error_code ec, bool result) +- { +- if(ec) ++ stream_, buffer_, ++ beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); ++ } ++ ++ void on_detect(beast::error_code ec, bool result) { ++ if (ec) + return fail(ec, "detect"); + +- if(result) +- { ++ if (result) { + // Launch SSL session +- std::make_shared( +- std::move(stream_), +- ctx_, +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(std::move(stream_), ctx_, std::move(buffer_), ++ doc_root_) ++ ->run(); + return; + } + + // Launch plain session +- std::make_shared( +- std::move(stream_), +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) ++ ->run(); + } + }; + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the detector http_session and run it +- std::make_shared( +- std::move(socket), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection +@@ -906,15 +715,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: advanced-server-flex
\n" << +- "Example:\n" << +- " advanced-server-flex 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: advanced-server-flex
\n" ++ << "Example:\n" ++ << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -923,7 +729,7 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -932,38 +738,30 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); +- signals.async_wait( +- [&](beast::error_code const&, int) +- { +- // Stop the `io_context`. This will cause `run()` +- // to return immediately, eventually destroying the +- // `io_context` and all of the sockets in it. +- ioc.stop(); +- }); ++ signals.async_wait([&](beast::error_code const&, int) { ++ // Stop the `io_context`. This will cause `run()` ++ // to return immediately, eventually destroying the ++ // `io_context` and all of the sockets in it. ++ ioc.stop(); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for(auto& t : v) ++ for (auto& t : v) + t.join(); + + return EXIT_SUCCESS; +--- upstream/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // Copyright (c) 2024 Mohammad Nejati +@@ -14,12 +32,12 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" ++#include "common/server_certificate.hpp" + + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -31,73 +49,88 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; +-namespace ssl = boost::asio::ssl; +- +-using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = typename net::ip::tcp::acceptor::rebind_executor::other; ++namespace net = boost::asio; ++namespace ssl = boost::asio::ssl; ++ ++using executor_type = net::strand; ++using stream_type = typename beast::tcp_stream::rebind_executor::other; ++using acceptor_type = ++ typename webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -108,16 +141,11 @@ + // + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. +-template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++template ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -128,9 +156,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -141,9 +167,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -154,19 +178,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -175,19 +197,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -197,10 +218,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -211,70 +230,53 @@ + /** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. + */ +-class task_group +-{ ++class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + + public: + task_group(net::any_io_executor exec) +- : cv_{ std::move(exec), net::steady_timer::time_point::max() } +- { +- } ++ : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +- task_group(task_group&&) = delete; ++ task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + +- @note @p completion_token must have an associated executor that matches +- the one the child task runs on (e.g. via @c net::bind_executor). This is +- because @c emit() can run on a different thread than the task, and +- @c co_spawn dispatches the cancellation to the handler's associated ++ ote `completion_token` must have an associated executor that matches ++ the one the child task runs on (e.g. via `net::bind_executor`). This is ++ because `emit`() can run on a different thread than the task, and ++ `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety +- @e Distinct @e objects: Safe.@n +- @e Shared @e objects: Safe. ++ `Distinct` `objects:` Safe. ++ `Shared` `objects:` Safe. + */ +- template +- auto +- adapt(CompletionToken&& completion_token) +- { +- auto lg = std::lock_guard{ mtx_ }; ++ template ++ auto adapt(CompletionToken&& completion_token) { ++ auto lg = std::lock_guard{mtx_}; + auto cs = css_.emplace(css_.end()); + +- class remover +- { ++ class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: +- remover( +- task_group* tg, +- decltype(css_)::iterator cs) +- : tg_{ tg } +- , cs_{ cs } +- { +- } ++ remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept +- : tg_{ std::exchange(other.tg_, nullptr) } +- , cs_{ other.cs_ } +- { +- } +- +- ~remover() +- { +- if(tg_) +- { +- auto lg = std::lock_guard{ tg_->mtx_ }; +- if(tg_->css_.erase(cs_) == tg_->css_.end()) ++ : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} ++ ++ ~remover() { ++ if (tg_) { ++ auto lg = std::lock_guard{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) + tg_->cv_.cancel(); + } + } +@@ -282,9 +284,7 @@ + + return net::bind_cancellation_slot( + cs->slot(), +- net::consign( +- std::forward(completion_token), +- remover{ this, cs })); ++ net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's +@@ -293,14 +293,12 @@ + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety +- @e Distinct @e objects: Safe.@n +- @e Shared @e objects: Safe. ++ `Distinct` `objects:` Safe. ++ `Shared` `objects:` Safe. + */ +- void +- emit(net::cancellation_type type) +- { +- auto lg = std::lock_guard{ mtx_ }; +- for(auto& cs : css_) ++ void emit(net::cancellation_type type) { ++ auto lg = std::lock_guard{mtx_}; ++ for (auto& cs : css_) + cs.emit(type); + } + +@@ -308,8 +306,8 @@ + + The completion handler will be called when: + +- @li All the child tasks completed. +- @li The operation was cancelled. ++ - All the child tasks completed. ++ - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion +@@ -321,86 +319,66 @@ + @endcode + + @par Thread Safety +- @e Distinct @e objects: Safe.@n +- @e Shared @e objects: Safe. ++ `Distinct` `objects:` Safe. ++ `Shared` `objects:` Safe. + */ +- template< +- typename CompletionToken = +- net::default_completion_token_t> +- auto +- async_wait( +- CompletionToken&& completion_token = +- net::default_completion_token_t{}) +- { +- return net:: +- async_compose( +- [this, scheduled = false]( +- auto&& self, boost::system::error_code ec = {}) mutable ++ template > ++ auto async_wait(CompletionToken&& completion_token = ++ net::default_completion_token_t{}) { ++ return net::async_compose( ++ [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { ++ if (!scheduled) ++ self.reset_cancellation_state(net::enable_total_cancellation()); ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) ++ ec = {}; ++ + { +- if(!scheduled) +- self.reset_cancellation_state( +- net::enable_total_cancellation()); +- +- if(!self.cancelled() && ec == net::error::operation_aborted) +- ec = {}; +- +- { +- auto lg = std::lock_guard{ mtx_ }; +- +- if(!css_.empty() && !ec) +- { +- scheduled = true; +- return cv_.async_wait(std::move(self)); +- } ++ auto lg = std::lock_guard{mtx_}; ++ ++ if (!css_.empty() && !ec) { ++ scheduled = true; ++ return cv_.async_wait(std::move(self)); + } +- +- if(!std::exchange(scheduled, true)) +- return net::post(net::append(std::move(self), ec)); +- +- self.complete(ec); +- }, +- completion_token, +- cv_); ++ } ++ ++ if (!std::exchange(scheduled, true)) ++ return net::post(net::append(std::move(self), ec)); ++ ++ self.complete(ec); ++ }, ++ completion_token, cv_); + } + }; + +-template +-net::awaitable +-run_websocket_session( +- Stream& stream, +- beast::flat_buffer& buffer, +- http::request req) +-{ ++template ++net::awaitable run_websocket_session(Stream& stream, ++ beast::flat_buffer& buffer, ++ http::request req) { + auto cs = co_await net::this_coro::cancellation_state; +- auto ws = websocket::stream{ stream }; ++ auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set( +- http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " advanced-server-flex"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); ++ })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + +- while(!cs.cancelled()) +- { ++ while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if(ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) + co_return; + +- if(ec) +- throw boost::system::system_error{ ec }; ++ if (ec) ++ throw boost::system::system_error{ec}; + + // Echo the message back + ws.text(ws.got_text()); +@@ -411,47 +389,37 @@ + } + + // A cancellation has been requested, gracefully close the session. +- auto [ec] = co_await ws.async_close( +- websocket::close_code::service_restart, net::as_tuple); +- +- if(ec && ec != ssl::error::stream_truncated) +- throw boost::system::system_error{ ec }; +-} +- +-template +-net::awaitable +-run_session( +- Stream& stream, +- beast::flat_buffer& buffer, +- beast::string_view doc_root) +-{ ++ auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); ++ ++ if (ec && ec != ssl::error::stream_truncated) ++ throw boost::system::system_error{ec}; ++} ++ ++template ++net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, ++ beast::string_view doc_root) { + auto cs = co_await net::this_coro::cancellation_state; + +- while(!cs.cancelled()) +- { ++ while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + +- auto [ec, _] = +- co_await http::async_read(stream, buffer, parser, net::as_tuple); +- +- if(ec == http::error::end_of_stream) ++ auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); ++ ++ if (ec == http::error::end_of_stream) + co_return; + +- if(websocket::is_upgrade(parser.get())) +- { ++ if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + +- co_await run_websocket_session( +- stream, buffer, parser.release()); ++ co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); +- if(!res.keep_alive()) +- { ++ if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } +@@ -460,19 +428,15 @@ + } + } + +-net::awaitable +-detect_session( +- stream_type stream, +- ssl::context& ctx, +- beast::string_view doc_root) +-{ ++net::awaitable detect_session(stream_type stream, ssl::context& ctx, ++ beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. +- co_await net::this_coro::reset_cancellation_state( +- net::enable_total_cancellation(), net::enable_terminal_cancellation()); ++ co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), ++ net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be +@@ -481,104 +445,82 @@ + + stream.expires_after(std::chrono::seconds(30)); + +- if(co_await beast::async_detect_ssl(stream, buffer)) +- { +- ssl::stream ssl_stream{ std::move(stream), ctx }; +- +- auto bytes_transferred = co_await ssl_stream.async_handshake( +- ssl::stream_base::server, buffer.data()); ++ if (co_await beast::async_detect_ssl(stream, buffer)) { ++ ssl::stream ssl_stream{std::move(stream), ctx}; ++ ++ auto bytes_transferred = ++ co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if(!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) + co_return; + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) +- throw boost::system::system_error{ ec }; +- } +- else +- { ++ if (ec && ec != ssl::error::stream_truncated) ++ throw boost::system::system_error{ec}; ++ } else { + co_await run_session(stream, buffer, doc_root); + +- if(!stream.socket().is_open()) ++ if (!stream.socket().is_open()) + co_return; + +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); +- } +-} +- +-net::awaitable +-listen( +- task_group& task_group, +- ssl::context& ctx, +- net::ip::tcp::endpoint endpoint, +- beast::string_view doc_root) +-{ +- auto cs = co_await net::this_coro::cancellation_state; ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); ++ } ++} ++ ++net::awaitable listen(task_group& task_group, ssl::context& ctx, ++ webcpp::asio::ip::tcp::endpoint endpoint, ++ beast::string_view doc_root) { ++ auto cs = co_await net::this_coro::cancellation_state; + auto executor = co_await net::this_coro::executor; +- auto acceptor = acceptor_type{ executor, endpoint }; ++ auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. +- co_await net::this_coro::reset_cancellation_state( +- net::enable_total_cancellation()); +- +- while(!cs.cancelled()) +- { ++ co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); ++ ++ while (!cs.cancelled()) { + auto socket_executor = net::make_strand(executor.get_inner_executor()); +- auto [ec, socket] = +- co_await acceptor.async_accept(socket_executor, net::as_tuple); +- +- if(ec == net::error::operation_aborted) ++ auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); ++ ++ if (ec == net::error::operation_aborted) + co_return; + +- if(ec) +- throw boost::system::system_error{ ec }; ++ if (ec) ++ throw boost::system::system_error{ec}; + + net::co_spawn( +- socket_executor, +- detect_session(stream_type{ std::move(socket) }, ctx, doc_root), +- net::bind_executor( +- socket_executor, +- task_group.adapt( +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception& e) +- { +- std::cerr << "Error in session: " << e.what() << "\n"; +- } +- } +- }))); +- } +-} +- +-net::awaitable +-handle_signals(task_group& task_group) +-{ +- auto executor = co_await net::this_coro::executor; +- auto signal_set = net::signal_set{ executor, SIGINT, SIGTERM }; ++ socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception& e) { ++ std::cerr << "Error in session: " << e.what() << "\n"; ++ } ++ } ++ }))); ++ } ++} ++ ++net::awaitable handle_signals(task_group& task_group) { ++ auto executor = co_await net::this_coro::executor; ++ auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + + auto sig = co_await signal_set.async_wait(); + +- if(sig == SIGINT) +- { ++ if (sig == SIGINT) { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( +- net::as_tuple(net::cancel_after(std::chrono::seconds{ 10 }))); +- +- if(ec == net::error::operation_aborted) // Timeout occurred ++ net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); ++ ++ if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); +@@ -586,80 +528,64 @@ + } + + std::cout << "Child tasks completed.\n"; +- } +- else // SIGTERM ++ } else // SIGTERM + { +- net::query( +- executor.get_inner_executor(), +- net::execution::context).stop(); +- } +-} +- +-int +-main(int argc, char* argv[]) +-{ ++ net::query(executor.get_inner_executor(), net::execution::context).stop(); ++ } ++} ++ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if(argc != 5) +- { ++ if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } +- auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const endpoint = net::ip::tcp::endpoint{ address, port }; +- auto const doc_root = beast::string_view{ argv[3] }; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(std::atoi(argv[2])); ++ auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; ++ auto const doc_root = beast::string_view{argv[3]}; ++ auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{ threads }; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ ssl::context::tlsv12 }; ++ ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines +- task_group task_group{ ioc.get_executor() }; ++ task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto listener_executor = net::make_strand(ioc); +- net::co_spawn( +- listener_executor, +- listen(task_group, ctx, endpoint, doc_root), +- net::bind_executor( +- listener_executor, +- task_group.adapt( +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception& e) +- { +- std::cerr << "Error in listener: " << e.what() << "\n"; +- } +- } +- }))); ++ net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception& e) { ++ std::cerr << "Error in listener: " << e.what() << "\n"; ++ } ++ } ++ }))); + + // Create and launch a signal handler coroutine +- net::co_spawn( +- net::make_strand(ioc), handle_signals(task_group), net::detached); ++ net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back([&ioc] { ioc.run(); }); +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back( ++ [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations ++ ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit +- for(auto& t : v) ++ for (auto& t : v) + t.join(); + + return EXIT_SUCCESS; +@@ -667,9 +593,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/common/root_certificates.hpp ++++ port/common/root_certificates.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -38,251 +55,253 @@ + tl;dr: root_certificates.hpp should not be used in production code + */ + +-namespace ssl = boost::asio::ssl; // from ++namespace ssl = boost::asio::ssl; // from + + namespace detail { + +-inline +-void +-load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) +-{ ++inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { ++ if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { ++ ctx.load_verify_file(path, ec); ++ return; ++ } ++ + std::string cert = + "# ACCVRAIZ1\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" +- "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" +- "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwO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LrTQfv6MooqtyuGC2mDOL7Nii4LcK2N\n" ++ "JpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW+YJF1DngoABd15jm\n" ++ "fZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7Ixjp\n" ++ "6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp\n" ++ "1txyM/1d8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B\n" ++ "9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok\n" ++ "RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" ++ "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# Actalis Authentication Root CA\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" +- "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" +- "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" +- "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" +- "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" +- "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB\n" +- "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv\n" +- "UTufClrJwk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7bAEzlgqqI0JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDz\n" ++ "WochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKxK3JCaKygvU5a2hi/a5iB0P2avl4V\n" ++ "SM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+Xlff1ANATIGk0k9j\n" ++ "pwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX\n" ++ "X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok\n" ++ "fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R\n" ++ "K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU\n" ++ "ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU\n" ++ "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" ++ "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# AffirmTrust Commercial\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" +- "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" +- "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" +- "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" +- "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhk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ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" ++ "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# AffirmTrust Networking\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" +- "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" +- "dCBOZXR3b3JraW5nMB4XDTEwMDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDEL\n" +- "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" +- "cm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +- "AQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SEHi3y\n" +- "YJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbua\n" +- "kCNrmreIdIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRL\n" +- "QESxG9fhwoXA3hA/Pe24/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp\n" +- "6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG\n" +- "yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i\n" +- "QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" +- "KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2np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VGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG\n" ++ "yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i\n" ++ "QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" ++ "KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfO\n" ++ "tDIuUFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzu\n" ++ "QY0x2+c06lkh1QF612S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZ\n" ++ "Lgo/bNjR9eUJtGxUAArgFU2HdW23WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4u\n" ++ "olu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9/ZFvgrG+CJPbFEfxojfHRZ48\n" ++ "x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# AffirmTrust Premium\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE\n" +- "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVz\n" +- "dCBQcmVtaXVtMB4XDTEwMDEyOTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkG\n" +- "A1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1U\n" +- "cnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxBLf\n" +- "qV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb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 "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# Amazon Root CA 1\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" +- "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" +- "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" +- "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" +- "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" +- "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" +- "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" +- "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" +- "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" +- "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" +- "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" +- "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" +- "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" +- "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" +- "N+gDS63pYaACbvXy8MWy7V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YzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" ++ "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" ++ "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" ++ "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" ++ "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" ++ "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" ++ "rqXRfboQnoZsG4q5WTP468SQvvG5\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" +@@ -3933,30 +3952,23 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority( +- boost::asio::buffer(cert.data(), cert.size()), ec); +- if(ec) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); ++ if (ec) + return; + } + +-} // detail ++} // namespace detail + + // Load the root certificates into an ssl::context + +-inline +-void +-load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) +-{ ++inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); + } + +-inline +-void +-load_root_certificates(ssl::context& ctx) +-{ ++inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if(ec) ++ if (ec) + throw boost::system::system_error{ec}; + } + +--- upstream/common/server_certificate.hpp ++++ port/common/server_certificate.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -24,15 +41,20 @@ + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. + */ +-inline +-void +-load_server_certificate(boost::asio::ssl::context& ctx) +-{ ++inline void load_server_certificate(boost::asio::ssl::context& ctx) { ++ if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { ++ ctx.use_certificate_chain_file(path); ++ ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), ++ boost::asio::ssl::context::pem); ++ return; ++ } ++ + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 +- openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" ++ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj ++ "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = +@@ -98,28 +120,19 @@ + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; +- ++ + ctx.set_password_callback( +- [](std::size_t, +- boost::asio::ssl::context_base::password_purpose) +- { +- return "test"; +- }); ++ [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + +- ctx.set_options( +- boost::asio::ssl::context::default_workarounds | +- boost::asio::ssl::context::no_sslv2 | +- boost::asio::ssl::context::single_dh_use); ++ ctx.set_options(boost::asio::ssl::context::default_workarounds | ++ boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + +- ctx.use_certificate_chain( +- boost::asio::buffer(cert.data(), cert.size())); ++ ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + +- ctx.use_private_key( +- boost::asio::buffer(key.data(), key.size()), +- boost::asio::ssl::context::file_format::pem); ++ ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), ++ boost::asio::ssl::context::file_format::pem); + +- ctx.use_tmp_dh( +- boost::asio::buffer(dh.data(), dh.size())); ++ ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); + } + + #endif +--- upstream/doc/http_examples.hpp ++++ port/doc/http_examples.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,8 +23,8 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include + #include ++#include + + /* This file contains the functions and classes found in the documentation + +@@ -17,7 +33,7 @@ + building a network application. + */ + +-// The documentation assumes the boost::beast::http namespace ++// The documentation assumes the webcpp::beast::http namespace + namespace boost { + namespace beast { + namespace http { +@@ -48,23 +64,13 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class SyncStream, +- class DynamicBuffer, +- class Body, class Allocator> +-void +-send_expect_100_continue( +- SyncStream& stream, +- DynamicBuffer& buffer, +- request>& req, +- error_code& ec) +-{ +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++template ++void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, ++ request>& req, error_code& ec) { ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); +@@ -74,7 +80,7 @@ + + // Send just the header + write_header(stream, sr, ec); +- if(ec) ++ if (ec) + return; + + // Read the response from the server. +@@ -82,10 +88,9 @@ + { + response res; + read(stream, buffer, res, ec); +- if(ec) +- return; +- if(res.result() != status::continue_) +- { ++ if (ec) ++ return; ++ if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; +@@ -112,40 +117,30 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class SyncStream, +- class DynamicBuffer> +-void +-receive_expect_100_continue( +- SyncStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++template ++void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); +- if(ec) ++ if (ec) + return; + + // Check for the Expect field value +- if(beast::iequals(parser.get()[field::expect], "100-continue")) +- { ++ if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); +- if(ec) ++ if (ec) + return; + } + +@@ -166,7 +161,7 @@ + + /** Send the output of a child process as an HTTP response. + +- The output of the child process comes from a @b SyncReadStream. Data ++ The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. +@@ -177,20 +172,13 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class SyncReadStream, +- class SyncWriteStream> +-void +-send_cgi_response( +- SyncReadStream& input, +- SyncWriteStream& output, +- error_code& ec) +-{ ++template ++void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, +- "SyncReadStream requirements not met"); ++ "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, +- "SyncWriteStream requirements not met"); ++ "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. +@@ -213,20 +201,17 @@ + + // Send the header immediately. + write_header(output, sr, ec); +- if(ec) ++ if (ec) + return; + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. +- do +- { ++ do { + // Read a buffer from the child process + char buffer[2048]; +- auto bytes_transferred = input.read_some( +- boost::asio::buffer(buffer, sizeof(buffer)), ec); +- if(ec == boost::asio::error::eof) +- { ++ auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); ++ if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer +@@ -234,10 +219,8 @@ + + // `false` means no more data is coming + res.body().more = false; +- } +- else +- { +- if(ec) ++ } else { ++ if (ec) + return; + + // Point to our buffer with the bytes that +@@ -247,22 +230,20 @@ + res.body().size = bytes_transferred; + res.body().more = true; + } +- ++ + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. +- if(ec == error::need_buffer) +- { ++ if (ec == error::need_buffer) { + ec = {}; + continue; + } +- if(ec) +- return; +- } +- while(! sr.is_done()); ++ if (ec) ++ return; ++ } while (!sr.is_done()); + } + + //] +@@ -276,21 +257,12 @@ + //[example_http_do_head_response + + /** Handle a HEAD request for a resource. +-*/ +-template< +- class SyncStream, +- class DynamicBuffer +-> +-void do_server_head( +- SyncStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++ */ ++template ++void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; +@@ -298,7 +270,7 @@ + // Read the request + request req; + read(stream, buffer, req, ec); +- if(ec) ++ if (ec) + return; + + // Set up the response, starting with the common fields +@@ -307,43 +279,39 @@ + res.set(field::server, "test"); + + // Now handle request-specific fields +- switch(req.method()) +- { +- case verb::head: +- case verb::get: +- { +- // A HEAD request is handled by delivering the same +- // set of headers that would be sent for a GET request, +- // including the Content-Length, except for the body. +- res.result(status::ok); +- res.content_length(payload.size()); +- +- // For GET requests, we include the body +- if(req.method() == verb::get) +- { +- // We deliver the same payload for GET requests +- // regardless of the target. A real server might +- // deliver a file based on the target. +- res.body() = payload; +- } +- break; +- } +- +- default: +- { +- // We return responses indicating an error if +- // we do not recognize the request method. +- res.result(status::bad_request); +- res.set(field::content_type, "text/plain"); +- res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; +- res.prepare_payload(); +- break; +- } ++ switch (req.method()) { ++ case verb::head: ++ case verb::get: { ++ // A HEAD request is handled by delivering the same ++ // set of headers that would be sent for a GET request, ++ // including the Content-Length, except for the body. ++ res.result(status::ok); ++ res.content_length(payload.size()); ++ ++ // For GET requests, we include the body ++ if (req.method() == verb::get) { ++ // We deliver the same payload for GET requests ++ // regardless of the target. A real server might ++ // deliver a file based on the target. ++ res.body() = payload; ++ } ++ break; ++ } ++ ++ default: { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ res.result(status::bad_request); ++ res.set(field::content_type, "text/plain"); ++ res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; ++ res.prepare_payload(); ++ break; ++ } + } + + // Send the response + write(stream, res, ec); +- if(ec) ++ if (ec) + return; + } + +@@ -368,27 +336,17 @@ + + @throws std::invalid_argument if target is empty. + */ +-template< +- class SyncStream, +- class DynamicBuffer +-> +-response +-do_head_request( +- SyncStream& stream, +- DynamicBuffer& buffer, +- string_view target, +- error_code& ec) +-{ ++template ++response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, ++ error_code& ec) { + // Do some type checking to be a good citizen +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. +- if(target.empty()) ++ if (target.empty()) + throw std::invalid_argument("target may not be empty"); + + // Build the HEAD request for the target +@@ -404,7 +362,7 @@ + + // Now send it + write(stream, req, ec); +- if(ec) ++ if (ec) + return {}; + + // Create a parser to read the response. +@@ -420,7 +378,7 @@ + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); +- if(ec) ++ if (ec) + return {}; + + // Transfer ownership of the response to the caller. +@@ -467,25 +425,15 @@ + + @tparam Fields The type of fields to use for the message. + */ +-template< +- bool isRequest, +- class SyncWriteStream, +- class SyncReadStream, +- class DynamicBuffer, +- class Transform> +-void +-relay( +- SyncWriteStream& output, +- SyncReadStream& input, +- DynamicBuffer& buffer, +- error_code& ec, +- Transform&& transform) +-{ ++template ++void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, ++ Transform&& transform) { + static_assert(is_sync_write_stream::value, +- "SyncWriteStream requirements not met"); ++ "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, +- "SyncReadStream requirements not met"); ++ "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + char buf[2048]; +@@ -498,24 +446,22 @@ + + // Read just the header from the input + read_header(input, buffer, p, ec); +- if(ec) ++ if (ec) + return; + + // Apply the caller's header transformation + transform(p.get(), ec); +- if(ec) ++ if (ec) + return; + + // Send the transformed message to the output + write_header(output, sr, ec); +- if(ec) ++ if (ec) + return; + + // Loop over the input and transfer it to the output +- do +- { +- if(! p.is_done()) +- { ++ do { ++ if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf; + p.get().body().size = sizeof(buf); +@@ -524,19 +470,17 @@ + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer +- if(ec == error::need_buffer) ++ if (ec == error::need_buffer) + ec = {}; +- if(ec) ++ if (ec) + return; + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = sizeof(buf) - p.get().body().size; + p.get().body().data = buf; +- p.get().body().more = ! p.is_done(); +- } +- else +- { ++ p.get().body().more = !p.is_done(); ++ } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } +@@ -545,12 +489,11 @@ + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer +- if(ec == error::need_buffer) ++ if (ec == error::need_buffer) + ec = {}; +- if(ec) +- return; +- } +- while(! p.is_done() && ! sr.is_done()); ++ if (ec) ++ return; ++ } while (!p.is_done() && !sr.is_done()); + } + + //] +@@ -568,24 +511,17 @@ + + // This helper is needed for C++11. + // When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +-template +-class write_ostream_helper +-{ ++template ++class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + + public: +- write_ostream_helper(Serializer& sr, std::ostream& os) +- : sr_(sr) +- , os_(os) +- { +- } ++ write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer +- template +- void +- operator()(error_code& ec, ConstBufferSequence const& buffers) const +- { ++ template ++ void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + +@@ -593,20 +529,16 @@ + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence +- for(auto it = boost::asio::buffer_sequence_begin(buffers); +- it != boost::asio::buffer_sequence_end(buffers); ++it) +- { ++ for (auto it = boost::asio::buffer_sequence_begin(buffers); ++ it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream +- os_.write( +- reinterpret_cast(buffer.data()), +- buffer.size()); ++ os_.write(reinterpret_cast(buffer.data()), buffer.size()); + + // If the std::ostream fails, convert it to an error code +- if(os_.fail()) +- { ++ if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } +@@ -620,7 +552,7 @@ + } + }; + +-} // detail ++} // namespace detail + + /** Write a message to a `std::ostream`. + +@@ -633,31 +565,21 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- bool isRequest, +- class Body, +- class Fields> +-void +-write_ostream( +- std::ostream& os, +- message& msg, +- error_code& ec) +-{ ++template ++void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; +- do +- { ++ do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); +- if(ec) +- return; +- } +- while(! sr.is_done()); ++ if (ec) ++ return; ++ } while (!sr.is_done()); + } + + //] +@@ -682,17 +604,9 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class Allocator, +- bool isRequest, +- class Body> +-void +-read_istream( +- std::istream& is, +- basic_flat_buffer& buffer, +- message& msg, +- error_code& ec) +-{ ++template ++void read_istream(std::istream& is, basic_flat_buffer& buffer, ++ message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are +@@ -702,25 +616,19 @@ + // + parser p{std::move(msg)}; + +- do +- { ++ do { + // Extract whatever characters are presently available in the istream +- if(is.rdbuf()->in_avail() > 0) +- { ++ if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing +- auto const b = buffer.prepare( +- static_cast(is.rdbuf()->in_avail())); ++ auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream +- buffer.commit(static_cast(is.readsome( +- reinterpret_cast(b.data()), b.size()))); +- } +- else if(buffer.size() == 0) +- { +- // Our buffer is empty and we need more characters, ++ buffer.commit( ++ static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); ++ } else if (buffer.size() == 0) { ++ // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream +- if(! is.eof()) +- { ++ if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + +@@ -728,8 +636,7 @@ + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. +- if(is.fail() && ! is.eof()) +- { ++ if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; +@@ -737,12 +644,10 @@ + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); +- } +- else +- { ++ } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); +- if(ec) ++ if (ec) + return; + break; + } +@@ -752,15 +657,14 @@ + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. +- if(ec == error::need_more) ++ if (ec == error::need_more) + ec = {}; +- if(ec) ++ if (ec) + return; + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); +- } +- while(! p.is_done()); ++ } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +@@ -798,16 +702,8 @@ + + @throws system_error Thrown on failure. + */ +-template< +- class SyncReadStream, +- class DynamicBuffer, +- class Handler> +-void +-do_form_request( +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- Handler&& handler) +-{ ++template ++void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + +@@ -816,45 +712,42 @@ + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb +- switch(req0.get().method()) +- { +- case verb::post: +- { +- // If this is not a form upload then use a string_body +- if( req0.get()[field::content_type] != "application/x-www-form-urlencoded" && +- req0.get()[field::content_type] != "multipart/form-data") +- goto do_dynamic_body; +- +- // Commit to string_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } +- +- do_dynamic_body: +- default: +- { +- // Commit to dynamic_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } ++ switch (req0.get().method()) { ++ case verb::post: { ++ // If this is not a form upload then use a string_body ++ if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && ++ req0.get()[field::content_type] != "multipart/form-data") ++ goto do_dynamic_body; ++ ++ // Commit to string_body as the body type. ++ // As long as there are no body octets in the parser ++ // we are constructing from, no exception is thrown. ++ request_parser req{std::move(req0)}; ++ ++ // Finish reading the message ++ read(stream, buffer, req); ++ ++ // Call the handler. It can take ownership ++ // if desired, since we are calling release() ++ handler(req.release()); ++ break; ++ } ++ ++ do_dynamic_body: ++ default: { ++ // Commit to dynamic_body as the body type. ++ // As long as there are no body octets in the parser ++ // we are constructing from, no exception is thrown. ++ request_parser req{std::move(req0)}; ++ ++ // Finish reading the message ++ read(stream, buffer, req); ++ ++ // Call the handler. It can take ownership ++ // if desired, since we are calling release() ++ handler(req.release()); ++ break; ++ } + } + } + +@@ -871,30 +764,21 @@ + /* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. + */ +-template< +- bool isRequest, +- class SyncReadStream, +- class DynamicBuffer> +-void +-read_and_print_body( +- std::ostream& os, +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ ++template ++void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, ++ error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); +- if(ec) ++ if (ec) + return; +- while(! p.is_done()) +- { ++ while (!p.is_done()) { + char buf[512]; + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + read(stream, buffer, p, ec); +- if(ec == error::need_buffer) ++ if (ec == error::need_buffer) + ec = {}; +- if(ec) ++ if (ec) + return; + os.write(buf, sizeof(buf) - p.get().body().size); + } +@@ -904,7 +788,7 @@ + + //------------------------------------------------------------------------------ + // +-// Example: Read large response body ++// Example: Read large response body + // + //------------------------------------------------------------------------------ + +@@ -914,24 +798,15 @@ + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. + */ +-template< +- class SyncReadStream, +- class DynamicBuffer, +- bool isRequest, class Body, class Allocator> +-std::size_t +-read_large_response_body( +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- message>& msg, +- std::size_t body_limit, +- error_code& ec) +-{ ++template ++std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, ++ message>& msg, ++ std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); +- auto const bytes_transferred = +- http::read(stream, buffer, p, ec); +- if(ec) ++ auto const bytes_transferred = http::read(stream, buffer, p, ec); ++ if (ec) + return bytes_transferred; + msg = p.release(); + return bytes_transferred; +@@ -948,25 +823,17 @@ + //[example_chunk_parsing + + /** Read a message with a chunked body and print the chunks and extensions +-*/ +-template< +- bool isRequest, +- class SyncReadStream, +- class DynamicBuffer> +-void +-print_chunked_body( +- std::ostream& os, +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ ++ */ ++template ++void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, ++ error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); +- if(ec) ++ if (ec) + return; + + // This container will hold the extensions for each chunk +@@ -978,18 +845,17 @@ + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = +- [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk +- string_view extensions, // The raw chunk-extensions string. Already validated. +- error_code& ev) // We can set this to indicate an error ++ [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk ++ string_view extensions, // The raw chunk-extensions string. Already validated. ++ error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); +- if(ev) ++ if (ev) + return; + + // See if the chunk is too big +- if(size > (std::numeric_limits::max)()) +- { ++ if (size > (std::numeric_limits::max)()) { + ev = error::body_limit; + return; + } +@@ -1006,15 +872,14 @@ + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. +- auto body_cb = +- [&](std::uint64_t remain, // The number of bytes left in this chunk +- string_view body, // A buffer holding chunk body data +- error_code& ec) // We can set this to indicate an error ++ auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk ++ string_view body, // A buffer holding chunk body data ++ error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. +- if(remain == body.size()) ++ if (remain == body.size()) + ec = error::end_of_chunk; + + // Append this piece to our container +@@ -1026,23 +891,21 @@ + }; + p.on_chunk_body(body_cb); + +- while(! p.is_done()) +- { ++ while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); +- if(! ec) ++ if (!ec) + continue; +- else if(ec != error::end_of_chunk) ++ else if (ec != error::end_of_chunk) + return; + else + ec = {}; + + // We got a whole chunk, print the extensions: +- for(auto const& extension : ce) +- { ++ for (auto const& extension : ce) { + os << "Extension: " << extension.first; +- if(! extension.second.empty()) ++ if (!extension.second.empty()) + os << " = " << extension.second << std::endl; + else + os << std::endl; +@@ -1056,12 +919,10 @@ + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it +- for(auto const& name : token_list{msg[field::trailer]}) +- { ++ for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); +- if(it == msg.end()) +- { ++ if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << std::endl; + continue; +@@ -1072,6 +933,6 @@ + + //] + +-} // http +-} // beast +-} // boost ++} // namespace http ++} // namespace beast ++} // namespace boost +--- upstream/doc/ssl/client.cpp ++++ port/doc/ssl/client.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2025 Mohammad Nejati + // +@@ -9,50 +26,41 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = net::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = net::ssl; + +-void +-print_exception(std::exception_ptr eptr) +-{ +- if(eptr) +- { +- try +- { ++void print_exception(std::exception_ptr eptr) { ++ if (eptr) { ++ try { + std::rethrow_exception(eptr); +- } +- catch(std::exception& e) +- { ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + } + +-net::awaitable +-request(ssl::context& ctx) +-{ ++net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{ {}, 8080 }; +- ssl::stream stream{ executor, ctx }; ++ webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; ++ ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) +- if(!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set a callback to verify that the hostname in the server +@@ -63,7 +71,7 @@ + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request +- http::request req{ http::verb::get, "/", 11 }; ++ http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); +@@ -78,26 +86,22 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error(ec); + } + +-int +-main() +-{ +- try +- { ++int main() { ++ try { + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data +- ssl::context ctx{ ssl::context::sslv23 }; ++ ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ +- ctx.set_options( +- ssl::context::no_sslv2 | ssl::context::default_workarounds | +- ssl::context::single_dh_use); ++ ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | ++ ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful +@@ -117,19 +121,15 @@ + + net::co_spawn(ioc, request(ctx), print_exception); + +- ioc.run(); +- } +- catch(std::exception& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/doc/ssl/server.cpp ++++ port/doc/ssl/server.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2025 Mohammad Nejati + // +@@ -9,37 +26,29 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = net::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = net::ssl; + +-void +-print_exception(std::exception_ptr eptr) +-{ +- if(eptr) +- { +- try +- { ++void print_exception(std::exception_ptr eptr) { ++ if (eptr) { ++ try { + std::rethrow_exception(eptr); +- } +- catch(std::exception& e) +- { ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + } + +-net::awaitable +-handle_session(ssl::stream stream) +-{ ++net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + +@@ -55,46 +64,37 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error(ec); + } + +-net::awaitable +-acceptor(ssl::context& ctx) +-{ ++net::awaitable acceptor(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{ {}, 8080 }; +- net::ip::tcp::acceptor acceptor{ executor, endpoint }; ++ webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; ++ webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + +- for(;;) +- { +- net::co_spawn( +- executor, +- handle_session({ co_await acceptor.async_accept(), ctx }), +- print_exception); ++ for (;;) { ++ net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), ++ print_exception); + } + } + +-int +-main() +-{ +- try +- { ++int main() { ++ try { + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data +- ssl::context ctx{ ssl::context::sslv23 }; ++ ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ +- ctx.set_options( +- ssl::context::no_sslv2 | ssl::context::default_workarounds | +- ssl::context::single_dh_use); ++ ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | ++ ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. +- ctx.set_verify_mode( +- ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); ++ ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. +@@ -113,19 +113,15 @@ + + net::co_spawn(ioc, acceptor(ctx), print_exception); + +- ioc.run(); +- } +- catch(std::exception& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/echo-op/echo_op.cpp ++++ port/echo-op/echo_op.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,30 +23,24 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include + #include + #include + #include + #include + #include ++#include + + namespace net = boost::asio; +-namespace beast = boost::beast; ++namespace beast = webcpp::beast; + + //[example_core_echo_op_1 + +-template< +- class AsyncStream, +- class DynamicBuffer, +- class CompletionToken> +-auto +-async_echo (AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) +- +-//] +- -> +- typename net::async_result< +- typename std::decay::type, +- void(beast::error_code)>::return_type; ++template ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ ++ //] ++ -> typename net::async_result::type, ++ void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -39,15 +49,15 @@ + /** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending +- in a newline (`"\n"`) from the stream, and then write ++ in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + +- @li A line was read in and written back on the stream +- +- @li An error occurs. ++ - A line was read in and written back on the stream ++ ++ - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` +@@ -61,7 +71,7 @@ + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the +- requirements of AsyncReadStream and @AsyncWriteStream ++ requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is +@@ -82,24 +92,20 @@ + of the handler will be performed in a manner equivalent to using + `net::post`. + */ +-template< +- class AsyncStream, +- class DynamicBuffer, +- class CompletionToken> +-auto +-async_echo ( ++template ++auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> +- typename net::async_result< /*< `async_result` deduces the return type from the completion handler >*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) -> typename net:: ++ async_result*/ ++ typename std::decay::type, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 + +-template ++template + class echo_op; + + // This example uses the Asio's stackless "fauxroutines", implemented +@@ -109,27 +115,18 @@ + + // Read a line and echo it back + // +-template< +- class AsyncStream, +- class DynamicBuffer, +- class CompletionToken> +-auto +-async_echo( +- AsyncStream& stream, +- DynamicBuffer& buffer, +- CompletionToken&& token) -> +- typename net::async_result< +- typename std::decay::type, +- void(beast::error_code)>::return_type /*< The completion handler signature goes here >*/ ++template ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> ++ typename net::async_result::type, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +- static_assert( +- beast::is_async_stream::value, +- "AsyncStream type requirements not met"); +- static_assert( +- net::is_dynamic_buffer::value, +- "DynamicBuffer type requirements not met"); ++ static_assert(beast::is_async_stream::value, ++ "AsyncStream type requirements not met"); ++ static_assert(net::is_dynamic_buffer::value, ++ "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, +@@ -156,29 +153,27 @@ + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ +- beast::executor_type /*< The type of executor used by the stream to dispatch asynchronous operations >*/ +- >; ++ beast::executor_type /*< The type of executor used by the stream to dispatch ++ asynchronous operations >*/ ++ >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + +- struct echo_op : base_type, boost::asio::coroutine +- { ++ struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream_; + DynamicBuffer& buffer_; + +- echo_op( +- AsyncStream& stream, +- DynamicBuffer& buffer, +- handler_type&& handler) ++ echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +- std::move(handler), /*< The `async_base` helper takes ownership of the handler, >*/ +- stream.get_executor()) /*< and also needs to know which executor to use. >*/ +- , stream_(stream) +- , buffer_(buffer) +- { ++ std::move( ++ handler), /*< The `async_base` helper takes ownership of the handler, >*/ ++ stream.get_executor()) /*< and also needs to know which executor to use. >*/ ++ , ++ stream_(stream), ++ buffer_(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -190,21 +185,19 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t +- find_newline(typename DynamicBuffer::const_buffers_type const& buffers) +- { ++ std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = net::buffers_iterator< +- typename DynamicBuffer::const_buffers_type>::begin(buffers); +- auto end = net::buffers_iterator< +- typename DynamicBuffer::const_buffers_type>::end(buffers); ++ auto begin = ++ net::buffers_iterator::begin(buffers); ++ auto end = ++ net::buffers_iterator::end(buffers); + auto result = std::find(begin, end, '\n'); + +- if(result == end) +- return 0; // not found ++ if (result == end) ++ return 0; // not found + + return result + 1 - begin; + } +@@ -212,38 +205,33 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + +- void +- operator()( +- beast::error_code ec, +- std::size_t bytes_transferred = 0, ++ void operator()( ++ beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + +- reenter(*this) +- { +- for(;;) +- { ++ reenter(*this) { ++ for (;;) { + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer_.data()); + + // If we don't have the newline, then read more +- if(pos == 0) +- { ++ if (pos == 0) { + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( +- std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), +- std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); ++ std::max(512, // under 512 is too little, ++ buffer_.capacity() - buffer_.size()), ++ std::min(65536, // and over 65536 is too much. ++ buffer_.max_size() - buffer_.size())); + + // Read some data into our dynamic buffer_. We transfer + // ownership of the composed operation by using the +@@ -251,8 +239,8 @@ + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some( +- buffer_.prepare(bytes_to_read), std::move(*this)); ++ yield stream_.async_read_some(buffer_.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -263,7 +251,7 @@ + buffer_.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if(ec) ++ if (ec) + break; + + // Keep looping until we get the newline +@@ -274,8 +262,8 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, +- beast::buffers_prefix(pos, buffer_.data()), std::move(*this)); ++ yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, +@@ -330,27 +318,22 @@ + + //] + +-struct move_only_handler +-{ ++struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + +- void operator()(beast::error_code ec) +- { +- if(ec) ++ void operator()(beast::error_code ec) { ++ if (ec) + std::cerr << ": " << ec.message() << std::endl; + } + }; + +-int main(int argc, char** argv) +-{ +- if(argc != 3) +- { +- std::cerr +- << "Usage: echo-op
\n" +- << "Example:\n" +- << " echo-op 0.0.0.0 8080\n"; ++int main(int argc, char** argv) { ++ if (argc != 3) { ++ std::cerr << "Usage: echo-op
\n" ++ << "Example:\n" ++ << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + +@@ -358,12 +341,12 @@ + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + +- using endpoint_type = net::ip::tcp::endpoint; ++ using endpoint_type = webcpp::asio::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. +- net::io_context ioc; +- net::ip::tcp::acceptor acceptor{ioc}; ++ webcpp::asio::io_context ioc; ++ webcpp::asio::ip::tcp::acceptor acceptor{ioc}; + endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); +@@ -372,6 +355,6 @@ + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; + } +--- upstream/http/client/async/http_client_async.cpp ++++ port/http/client/async/http_client_async.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,57 +29,44 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + beast::tcp_stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- explicit +- session(net::io_context& ioc) +- : resolver_(net::make_strand(ioc)) +- , stream_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) ++ : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); +@@ -73,36 +76,23 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ stream_.async_connect(results, ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -110,36 +100,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -149,7 +127,7 @@ + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -158,16 +136,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async []\n" << +- "Example:\n" << +- " http-client-async www.example.com 80 /\n" << +- " http-client-async www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async []\n" ++ << "Example:\n" ++ << " http-client-async www.example.com 80 /\n" ++ << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -176,14 +152,14 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/async-local/http_client_async_local.cpp ++++ port/http/client/async-local/http_client_async_local.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -15,9 +31,9 @@ + //------------------------------------------------------------------------------ + + #include +-#include +-#include + #include ++#include ++#include + + #include + #include +@@ -26,49 +42,34 @@ + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- beast::basic_stream< +- stream_protocol, +- net::any_io_executor, +- beast::unlimited_rate_policy> stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++class session : public std::enable_shared_from_this { ++ beast::basic_stream ++ stream_; ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- explicit +- session(net::io_context& ioc) +- : stream_(ioc) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation +- void +- run( +- char const* path, +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* path, char const* host, char const* port, char const* target, ++ int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); +@@ -77,17 +78,12 @@ + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- stream_protocol::endpoint{path}, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ stream_.async_connect(stream_protocol::endpoint{path}, ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec) +- { +- if(ec) ++ void on_connect(beast::error_code ec) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -95,36 +91,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -134,7 +118,7 @@ + stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -143,16 +127,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 5 && argc != 6) +- { +- std::cerr << +- "Usage: http-client-async-local []\n" << +- "Example:\n" << +- " http-client-async-local /tmp/http.sock localhost 80 /\n" << +- " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; ++ if (argc != 5 && argc != 6) { ++ std::cerr << "Usage: http-client-async-local []\n" ++ << "Example:\n" ++ << " http-client-async-local /tmp/http.sock localhost 80 /\n" ++ << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; +@@ -162,26 +144,23 @@ + int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ +-std::cerr << +- "Local sockets not available on this platform" << std::endl; +-return EXIT_FAILURE; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; ++ return EXIT_FAILURE; + } + + #endif +--- upstream/http/client/async-ssl/http_client_async_ssl.cpp ++++ port/http/client/async-ssl/http_client_async_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,65 +30,48 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: +- explicit +- session( +- net::any_io_executor ex, +- ssl::context& ctx) +- : resolver_(ex) +- , stream_(ex, ctx) +- { +- } ++ explicit session(net::any_io_executor ex, ssl::context& ctx) ++ : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -88,19 +88,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -108,30 +100,21 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation +@@ -139,36 +122,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -179,14 +150,10 @@ + + // Gracefully close the stream + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -204,23 +171,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async-ssl []\n" << +- "Example:\n" << +- " http-client-async-ssl www.example.com 443 /\n" << +- " http-client-async-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async-ssl []\n" ++ << "Example:\n" ++ << " http-client-async-ssl www.example.com 443 /\n" ++ << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -229,7 +194,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -243,14 +208,11 @@ + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. +- std::make_shared( +- net::make_strand(ioc), +- ctx +- )->run(host, port, target, version); ++ std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,73 +30,55 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) +- : resolver_(strand) +- , stream_(strand, ctx) +- { +- } ++ : resolver_(strand), stream_(strand, ctx) {} + + public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. +- explicit +- session(ssl::context& ctx) +- : session(net::make_strand(net::system_executor()), ctx) +- { +- } ++ explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor()), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -96,19 +95,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -116,30 +107,21 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation +@@ -147,36 +129,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -187,14 +157,10 @@ + + // Gracefully close the stream + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -212,23 +178,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async-ssl-system-executor []\n" << +- "Example:\n" << +- " http-client-async-ssl-system-executor www.example.com 443 /\n" << +- " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async-ssl-system-executor []\n" ++ << "Example:\n" ++ << " http-client-async-ssl-system-executor www.example.com 443 /\n" ++ << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -248,7 +212,6 @@ + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, target, version); + +- + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. +--- upstream/http/client/awaitable/http_client_awaitable.cpp ++++ port/http/client/awaitable/http_client_awaitable.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -16,9 +32,9 @@ + #include + #include + #include +-#include +-#include + #include ++#include ++#include + + #include + #include +@@ -26,17 +42,16 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; + + // Performs an HTTP GET and prints the response +-net::awaitable +-do_session(std::string host, std::string port, std::string target, int version) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string target, ++ int version) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = beast::tcp_stream{ executor }; ++ auto resolver = webcpp::asio::ip::tcp::resolver{executor}; ++ auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); +@@ -48,7 +63,7 @@ + co_await stream.async_connect(results); + + // Set up an HTTP GET request message +- http::request req{ http::verb::get, target, version }; ++ http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + +@@ -72,12 +87,12 @@ + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec); ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw boost::system::system_error(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -85,48 +100,39 @@ + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << "Usage: http-client-awaitable []\n" ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; ++ auto const host = argv[1]; ++ auto const port = argv[2]; + auto const target = argv[3]; +- auto const version = +- argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, target, version), +- // If the awaitable exists with an exception, it gets delivered here +- // as `e`. This can happen for regular errors, such as connection +- // drops. +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, target, version), ++ // If the awaitable exists with an exception, it gets delivered here ++ // as `e`. This can happen for regular errors, such as connection ++ // drops. ++ [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -135,9 +141,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -18,11 +35,11 @@ + #include + #include + #include +-#include +-#include + #include ++#include ++#include + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + + #include + #include +@@ -30,32 +47,24 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = boost::asio::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = boost::asio::ssl; + + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response +-net::awaitable +-do_session( +- std::string host, +- std::string port, +- std::string target, +- int version, +- ssl::context& ctx) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string target, int version, ++ ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = ssl::stream{ executor, ctx }; ++ auto resolver = webcpp::asio::ip::tcp::resolver{executor}; ++ auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification +@@ -77,7 +86,7 @@ + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message +- http::request req{ http::verb::get, target, version }; ++ http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + +@@ -122,38 +131,33 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) + throw boost::system::system_error(ec, "shutdown"); + } + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr +- << "Usage: http-client-awaitable []\n" +- << "Example:\n" +- << " http-client-awaitable www.example.com 443 /\n" +- << " http-client-awaitable www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-awaitable []\n" ++ << "Example:\n" ++ << " http-client-awaitable www.example.com 443 /\n" ++ << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; ++ auto const host = argv[1]; ++ auto const port = argv[2]; + auto const target = argv[3]; +- auto const version = +- argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ ssl::context::tlsv12_client }; ++ ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); +@@ -162,24 +166,19 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, target, version, ctx), +- // If the awaitable exists with an exception, it gets delivered here +- // as `e`. This can happen for regular errors, such as connection +- // drops. +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, target, version, ctx), ++ // If the awaitable exists with an exception, it gets delivered here ++ // as `e`. This can happen for regular errors, such as connection ++ // drops. ++ [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -188,9 +187,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/http/client/body/json_body.hpp ++++ port/http/client/body/json_body.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -16,90 +32,68 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include ++#include + #include +-#include +-#include +-#include ++#include + + namespace json = boost::json; + +-struct json_body +-{ ++struct json_body { + using value_type = json::value; + +- struct writer +- { ++ struct writer { + using const_buffers_type = boost::asio::const_buffer; +- template +- writer( +- boost::beast::http::header const&, +- value_type const& body) +- { ++ ++ template ++ writer(webcpp::beast::http::header const&, value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer.reset(&body); + } + +- void +- init(boost::system::error_code& ec) +- { ++ void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } +- +- boost::optional> +- get(boost::system::error_code& ec) +- { ++ ++ boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer.read(buffer, sizeof(buffer)); +- return std::make_pair( +- boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), ++ !serializer.done()); + } +- private: ++ ++ private: + json::serializer serializer; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ char buffer[32768]; + }; + +- struct reader +- { +- template +- reader( +- boost::beast::http::header&, +- value_type& body) +- : body(body) +- { +- } +- void +- init( +- boost::optional const& content_length, +- boost::system::error_code& ec) +- { +- +- // If we know the content-length, we can allocate a monotonic resource to increase the parsing speed. +- // We're using it rather then a static_resource, so a consumer can modify the resulting value. +- // It is also only assumption that the parsed json will be smaller than the serialize one, +- // it might not always be the case. ++ struct reader { ++ template ++ reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ ++ void init(boost::optional const& content_length, ++ boost::system::error_code& ec) { ++ // If we know the content-length, we can allocate a monotonic resource to increase the ++ // parsing speed. We're using it rather then a static_resource, so a consumer can modify ++ // the resulting value. It is also only assumption that the parsed json will be smaller ++ // than the serialize one, it might not always be the case. + if (content_length) + parser.reset(json::make_shared_resource(*content_length)); + ec = {}; + } + +- template +- std::size_t +- put(ConstBufferSequence const& buffers, boost::system::error_code& ec) +- { ++ template ++ std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some( +- static_cast(buffers.data()), buffers.size(), ec); ++ return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + +- void +- finish(boost::system::error_code& ec) +- { ++ void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser.done()) +@@ -108,11 +102,10 @@ + ec = boost::json::error::incomplete; + } + +- private: ++ private: + json::stream_parser parser; + value_type& body; + }; + }; + +- + #endif--- upstream/http/client/body/json_client.cpp ++++ port/http/client/body/json_client.cpp +@@ -1,31 +1,46 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + #include "json_body.hpp" +-#include + +-#include +-#include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char **) +-{ ++int main(int, char**) { + // Our test endpoint for testing the json +- const auto host = "postman-echo.com"; ++ const auto host = webcpp_fixture::host(); + const auto target = "/post"; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +- auto const results = resolver.resolve(host, "80"); ++ auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); +@@ -39,7 +54,7 @@ + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); +- ++ + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + +@@ -56,6 +71,5 @@ + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + +- + return 0; + } +--- upstream/http/client/coro/http_client_coro.cpp ++++ port/http/client/coro/http_client_coro.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,39 +29,30 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-void +-do_session( +- std::string const& host, +- std::string const& port, +- std::string const& target, +- int version, +- net::io_context& ioc, +- net::yield_context yield) +-{ ++void do_session(std::string const& host, std::string const& port, std::string const& target, ++ int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +@@ -54,7 +61,7 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout. +@@ -62,7 +69,7 @@ + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Set up an HTTP GET request message +@@ -75,7 +82,7 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted +@@ -86,7 +93,7 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -98,7 +105,7 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -106,16 +113,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-coro []\n" << +- "Example:\n" << +- " http-client-coro www.example.com 80 /\n" << +- " http-client-coro www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-coro []\n" ++ << "Example:\n" ++ << " http-client-coro www.example.com 80 /\n" ++ << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -124,32 +129,28 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(target), +- version, +- std::ref(ioc), +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, ++ std::ref(ioc), std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ port/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,44 +30,35 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include ++#include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-void +-do_session( +- std::string const& host, +- std::string const& port, +- std::string const& target, +- int version, +- net::io_context& ioc, +- ssl::context& ctx, +- net::yield_context yield) +-{ ++void do_session(std::string const& host, std::string const& port, std::string const& target, ++ int version, webcpp::asio::io_context& ioc, ssl::context& ctx, ++ net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +@@ -58,8 +66,7 @@ + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) +- { ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; +@@ -70,7 +77,7 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout. +@@ -78,7 +85,7 @@ + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Set the timeout. +@@ -86,7 +93,7 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Set up an HTTP GET request message +@@ -99,7 +106,7 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted +@@ -110,7 +117,7 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -139,22 +146,20 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-coro-ssl []\n" << +- "Example:\n" << +- " http-client-coro-ssl www.example.com 443 /\n" << +- " http-client-coro-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-coro-ssl []\n" ++ << "Example:\n" ++ << " http-client-coro-ssl www.example.com 443 /\n" ++ << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -163,7 +168,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -175,30 +180,25 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(target), +- version, +- std::ref(ioc), +- std::ref(ctx), +- std::placeholders::_1), ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, ++ std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { ++ [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/crawl/http_crawl.cpp ++++ port/http/client/crawl/http_crawl.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,78 +31,63 @@ + + #include "urls_large_data.hpp" + +-#include +-#include +-#include ++#include + #include + #include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include + #include ++#include + #include + #include + #include + #include +-#include +- +-namespace chrono = std::chrono; // from +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++#include ++#include ++ ++namespace chrono = std::chrono; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites +-class crawl_report +-{ +- net::strand< +- net::io_context::executor_type> strand_; ++class crawl_report { ++ net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + + public: +- crawl_report(net::io_context& ioc) +- : strand_(ioc.get_executor()) +- , index_(0) +- , hosts_(urls_large_data()) +- { +- } ++ crawl_report(webcpp::asio::io_context& ioc) ++ : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. +- template +- void +- aggregate(F const& f) +- { +- net::post( +- strand_, +- [&, f] +- { +- f(*this); +- if(count_ % 100 == 0) +- { +- std::cerr << +- "Progress: " << count_ << " of " << hosts_.size() << "\n"; +- //std::cerr << *this; +- } +- ++count_; +- }); ++ template ++ void aggregate(F const& f) { ++ net::post(strand_, [&, f] { ++ f(*this); ++ if (count_ % 100 == 0) { ++ std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; ++ // std::cerr << *this; ++ } ++ ++count_; ++ }); + } + + // Returns the next host to check +- char const* +- get_host() +- { ++ char const* get_host() { + auto const n = index_++; +- if(n >= hosts_.size()) ++ if (n >= hosts_.size()) + return nullptr; + return hosts_[n]; + } +@@ -113,25 +114,20 @@ + std::map status_codes; + }; + +-std::ostream& +-operator<<(std::ostream& os, crawl_report const& report) +-{ ++std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report +- os << +- "Crawl report\n" << +- " Failure counts\n" << +- " Timer : " << report.timer_failures << "\n" << +- " Resolve : " << report.resolve_failures << "\n" << +- " Connect : " << report.connect_failures << "\n" << +- " Write : " << report.write_failures << "\n" << +- " Read : " << report.read_failures << "\n" << +- " Success : " << report.success << "\n" << +- " Status codes\n" +- ; +- for(auto const& result : report.status_codes) +- os << +- " " << std::setw(3) << result.first << ": " << result.second << +- " (" << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ os << "Crawl report\n" ++ << " Failure counts\n" ++ << " Timer : " << report.timer_failures << "\n" ++ << " Resolve : " << report.resolve_failures << "\n" ++ << " Connect : " << report.connect_failures << "\n" ++ << " Write : " << report.write_failures << "\n" ++ << " Read : " << report.read_failures << "\n" ++ << " Success : " << report.success << "\n" ++ << " Status codes\n"; ++ for (auto const& result : report.status_codes) ++ os << " " << std::setw(3) << result.first << ": " << result.second << " (" ++ << http::obsolete_reason(static_cast(result.first)) << ")\n"; + os.flush(); + return os; + } +@@ -139,19 +135,17 @@ + //------------------------------------------------------------------------------ + + // Performs HTTP GET requests and aggregates the results into a report +-class worker : public std::enable_shared_from_this +-{ +- enum +- { ++class worker : public std::enable_shared_from_this { ++ enum { + // Use a small timeout to keep things lively + timeout = 5 + }; + + crawl_report& report_; +- net::strand ex_; ++ net::strand ex_; + tcp::resolver resolver_; + beast::tcp_stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +@@ -159,14 +153,8 @@ + worker(worker&&) = default; + + // Resolver and socket require an io_context +- worker( +- crawl_report& report, +- net::io_context& ioc) +- : report_(report) +- , ex_(net::make_strand(ioc.get_executor())) +- , resolver_(ex_) +- , stream_(ex_) +- { ++ worker(crawl_report& report, webcpp::asio::io_context& ioc) ++ : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); +@@ -175,20 +163,14 @@ + } + + // Start the asynchronous operation +- void +- run() +- { +- do_get_host(); +- } +- +- void +- do_get_host() +- { ++ void run() { do_get_host(); } ++ ++ void do_get_host() { + // Grab another host + auto const host = report_.get_host(); + + // nullptr means no more work +- if(! host) ++ if (!host) + return; + + // The Host HTTP field is required +@@ -196,26 +178,13 @@ + + // Set up an HTTP GET request message + // Look up the domain name +- resolver_.async_resolve( +- host, +- "http", +- beast::bind_front_handler( +- &worker::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.resolve_failures; +- }); ++ resolver_.async_resolve(host, webcpp_fixture::port(), ++ beast::bind_front_handler(&worker::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + return do_get_host(); + } + +@@ -223,23 +192,13 @@ + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- results, +- beast::bind_front_handler( +- &worker::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.connect_failures; +- }); ++ stream_.async_connect(results, ++ beast::bind_front_handler(&worker::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + return do_get_host(); + } + +@@ -247,63 +206,34 @@ + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host +- http::async_write( +- stream_, +- req_, +- beast::bind_front_handler( +- &worker::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ http::async_write(stream_, req_, ++ beast::bind_front_handler(&worker::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.write_failures; +- }); ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + return do_get_host(); + } + + // Receive the HTTP response + res_ = {}; +- http::async_read( +- stream_, +- buffer_, +- res_, +- beast::bind_front_handler( +- &worker::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ http::async_read(stream_, buffer_, res_, ++ beast::bind_front_handler(&worker::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.read_failures; +- }); ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + return do_get_host(); + } + + auto const code = res_.result_int(); +- report_.aggregate( +- [code](crawl_report& rep) +- { ++ report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); +@@ -318,8 +248,7 @@ + } + }; + +-class timer +-{ ++class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; +@@ -327,33 +256,21 @@ + public: + using duration = clock_type::duration; + +- timer() +- : when_(clock_type::now()) +- { +- } +- +- duration +- elapsed() const +- { +- return clock_type::now() - when_; +- } ++ timer() : when_(clock_type::now()) {} ++ ++ duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 2) +- { +- std::cerr << +- "Usage: http-crawl \n" << +- "Example:\n" << +- " http-crawl 100\n"; ++ if (argc != 2) { ++ std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + auto const threads = std::max(1, std::atoi(argv[1])); + + // The io_context is used to aggregate the statistics +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; +@@ -363,42 +280,37 @@ + // Create and launch the worker threads. + std::vector workers; + workers.reserve(threads + 1); +- for(int i = 0; i < threads; ++i) +- { ++ for (int i = 0; i < threads; ++i) { + // Each worker will eventually add some data to the aggregated + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. +- auto reporting_work = net::require( +- ioc.get_executor(), +- net::execution::outstanding_work.tracked); +- +- workers.emplace_back( +- [&report, reporting_work] { +- // We use a separate io_context for each worker because +- // the asio resolver simulates asynchronous operation using +- // a dedicated worker thread per io_context, and we want to +- // do a lot of name resolutions in parallel. +- net::io_context ioc; +- std::make_shared(report, ioc)->run(); +- ioc.run(); +- }); ++ auto reporting_work = ++ net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); ++ ++ workers.emplace_back([&report, reporting_work] { ++ // We use a separate io_context for each worker because ++ // the asio resolver simulates asynchronous operation using ++ // a dedicated worker thread per io_context, and we want to ++ // do a lot of name resolutions in parallel. ++ webcpp::asio::io_context ioc; ++ std::make_shared(report, ioc)->run(); ++ ioc.run(); // lint-run: drives the application's network operations ++ }); + } + + // Add another thread to run the main io_context which + // is used to aggregate the statistics +- workers.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ workers.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); + + // Now block until all threads exit +- for(std::size_t i = 0; i < workers.size(); ++i) ++ for (std::size_t i = 0; i < workers.size(); ++i) + workers[i].join(); + +- std::cout << +- "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() << " seconds\n"; ++ std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() ++ << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +--- upstream/http/client/crawl/urls_large_data.cpp ++++ port/http/client/crawl/urls_large_data.cpp +@@ -1,10021 +1,23 @@ ++// Copyright (c) 2026 WebCpp.org + // +-// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) + // +-// Distributed under the Boost Software License, Version 1.0. (See accompanying +-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-// +-// Official repository: https://github.com/boostorg/beast +-// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. + + #include "urls_large_data.hpp" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + +-// Data from Alexa top 1 million sites +-// http://s3.amazonaws.com/alexa-static/top-1m.csv.zip +-// +-std::vector const& +-urls_large_data() +-{ +- static std::vector const urls ({ +- "google.com", +- "facebook.com", +- "youtube.com", +- "yahoo.com", +- "baidu.com", +- "wikipedia.org", +- "qq.com", +- "linkedin.com", +- "taobao.com", +- "twitter.com", +- "live.com", +- "amazon.com", +- "sina.com.cn", +- "google.co.in", +- "hao123.com", +- "blogspot.com", +- "weibo.com", +- "wordpress.com", +- "yandex.ru", +- "yahoo.co.jp", +- "tmall.com", +- "bing.com", +- "vk.com", +- "ebay.com", +- "360.cn", +- "google.de", +- "sohu.com", +- "pinterest.com", +- "google.co.uk", +- "ask.com", +- "google.fr", +- "msn.com", +- "163.com", +- "soso.com", +- "tumblr.com", +- "google.co.jp", +- "instagram.com", +- "mail.ru", +- "google.com.br", +- "microsoft.com", +- "paypal.com", +- "google.ru", +- "xvideos.com", +- "google.es", +- "imdb.com", +- "apple.com", +- "google.it", +- "adcash.com", +- "craigslist.org", +- "stackoverflow.com", +- "amazon.co.jp", +- "neobux.com", +- "google.com.hk", +- "imgur.com", +- "ifeng.com", +- "cnn.com", +- "google.com.mx", +- "xhamster.com", +- "xinhuanet.com", +- "gmw.cn", +- "reddit.com", +- "bbc.co.uk", +- "blogger.com", +- "google.ca", +- "fc2.com", +- "vube.com", +- "go.com", +- "akamaihd.net", +- "alipay.com", +- "about.com", +- "people.com.cn", +- "t.co", +- "googleusercontent.com", +- "wordpress.org", +- "odnoklassniki.ru", +- "alibaba.com", +- "google.com.tr", +- "aliexpress.com", +- "youku.com", +- "conduit.com", +- "huffingtonpost.com", +- "godaddy.com", +- "flickr.com", +- "pornhub.com", +- "google.com.au", +- "amazon.de", +- "blogspot.in", +- "kickass.to", +- "ebay.de", +- "netflix.com", +- "google.pl", +- "thepiratebay.se", +- "bp.blogspot.com", +- "adobe.com", +- "dailymotion.com", +- "china.com", +- "vimeo.com", +- "dailymail.co.uk", +- "cnet.com", +- "rakuten.co.jp", +- "espn.go.com", +- "ku6.com", +- "ebay.co.uk", +- "themeforest.net", +- "xnxx.com", +- "livejasmin.com", +- "indiatimes.com", +- "aol.com", +- "redtube.com", +- "dropbox.com", +- "amazonaws.com", +- "uol.com.br", +- "weather.com", +- "m2newmedia.com", +- "amazon.co.uk", +- "google.com.ar", +- "google.com.sa", +- "pixnet.net", +- "nytimes.com", +- "slideshare.net", +- "youporn.com", +- "google.com.eg", +- "buzzfeed.com", +- "wikimedia.org", +- "booking.com", +- "livejournal.com", +- "globo.com", +- "fiverr.com", +- "adf.ly", +- "secureserver.net", +- "mozilla.org", +- "google.com.pk", +- "google.com.tw", +- "google.nl", +- "yelp.com", +- "sogou.com", +- "ameblo.jp", +- "directrev.com", +- "clkmon.com", +- "hootsuite.com", +- "deviantart.com", +- "blogfa.com", +- "wikia.com", +- "outbrain.com", +- "flipkart.com", +- "wikihow.com", +- "etsy.com", +- "google.co.th", +- "soundcloud.com", +- "google.co.za", +- "avg.com", +- "w3schools.com", +- "theguardian.com", +- "stumbleupon.com", +- "espncricinfo.com", +- "livedoor.com", +- "forbes.com", +- "archive.org", +- "4shared.com", +- "foxnews.com", +- "files.wordpress.com", +- "answers.com", +- "bankofamerica.com", +- "chase.com", +- "google.co.ve", +- "mediafire.com", +- "torrentz.eu", +- "badoo.com", +- "salesforce.com", +- "aweber.com", +- "sourceforge.net", +- "bbc.com", +- "addthis.com", +- "liveinternet.ru", +- "china.com.cn", +- "indeed.com", +- "reference.com", +- "github.com", +- "skype.com", +- "hostgator.com", +- "google.gr", +- "bet365.com", +- "spiegel.de", +- "ask.fm", +- "so.com", +- "statcounter.com", +- "gameforge.com", +- "onet.pl", +- "naver.com", +- "google.com.co", +- "developunit.info", +- "google.com.vn", +- "google.co.id", +- "nicovideo.jp", +- "shutterstock.com", +- "walmart.com", +- "google.be", +- "mailchimp.com", +- "softonic.com", +- "stackexchange.com", +- "google.com.ng", +- "google.com.ua", +- "popads.net", +- "allegro.pl", +- "gamer.com.tw", +- "wordreference.com", +- "wellsfargo.com", +- "loading-delivery1.com", +- "zillow.com", +- "tripadvisor.com", +- "quikr.com", +- "pandora.com", +- "wsj.com", +- "goo.ne.jp", +- "bild.de", +- "tube8.com", +- "wix.com", +- "google.se", +- "coccoc.com", +- "google.ro", +- "suning.com", +- "photobucket.com", +- "weebly.com", +- "tianya.cn", +- "warriorforum.com", +- "telegraph.co.uk", +- "google.dz", +- "naver.jp", +- "php.net", +- "ups.com", +- "rambler.ru", +- "zedo.com", +- "reuters.com", +- "google.at", +- "media.tumblr.com", +- "taringa.net", +- "google.com.ph", +- "chinaz.com", +- "mashable.com", +- "blogspot.com.es", +- "hurriyet.com.tr", +- "google.com.pe", +- "bleacherreport.com", +- "gmx.net", +- "wp.pl", +- "goodreads.com", +- "leboncoin.fr", +- "rutracker.org", +- "lenta.ru", +- "babylon.com", +- "domaintools.com", +- "sharelive.net", +- "rediff.com", +- "google.ch", +- "comcast.net", +- "twitch.tv", +- "avito.ru", +- "kaskus.co.id", +- "nbcnews.com", +- "onclickads.net", +- "businessinsider.com", +- "ikea.com", +- "codecanyon.net", +- "ndtv.com", +- "usps.com", +- "google.cl", +- "doublepimp.com", +- "moz.com", +- "google.com.sg", +- "usatoday.com", +- "dmm.co.jp", +- "amazon.fr", +- "google.pt", +- "ucoz.ru", +- "rt.com", +- "milliyet.com.tr", +- "xuite.net", +- "samsung.com", +- "fedex.com", +- "uploaded.net", +- "pcpop.com", +- "google.com.bd", +- "bitly.com", +- "goodgamestudios.com", +- "ettoday.net", +- "baomihua.com", +- "39.net", +- "web.de", +- "rbc.ru", +- "9gag.com", +- "disqus.com", +- "snapdeal.com", +- "xcar.com.cn", +- "washingtonpost.com", +- "bloomberg.com", +- "scribd.com", +- "hp.com", +- "constantcontact.com", +- "4dsply.com", +- "gsmarena.com", +- "intuit.com", +- "meetup.com", +- "nih.gov", +- "americanexpress.com", +- "ehow.com", +- "infusionsoft.com", +- "google.cz", +- "mercadolivre.com.br", +- "myntra.com", +- "varzesh3.com", +- "mobile01.com", +- "hardsextube.com", +- "goal.com", +- "thefreecamsecret.com", +- "thefreedictionary.com", +- "douban.com", +- "iqiyi.com", +- "it168.com", +- "mama.cn", +- "tmz.com", +- "time.com", +- "olx.in", +- "microsoftonline.com", +- "hulu.com", +- "enet.com.cn", +- "speedtest.net", +- "orange.fr", +- "free.fr", +- "detik.com", +- "bluehost.com", +- "libero.it", +- "histats.com", +- "webmd.com", +- "eazel.com", +- "hudong.com", +- "extratorrent.cc", +- "google.co.kr", +- "chaturbate.com", +- "huanqiu.com", +- "cnzz.com", +- "daum.net", +- "xing.com", +- "force.com", +- "jrj.com.cn", +- "pchome.net", +- "cj.com", +- "youjizz.com", +- "delta-search.com", +- "techcrunch.com", +- "motherless.com", +- "tinyurl.com", +- "beeg.com", +- "kooora.com", +- "google.cn", +- "clickbank.com", +- "yandex.ua", +- "ad6media.fr", +- "google.no", +- "amazon.cn", +- "zippyshare.com", +- "acesse.com", +- "google.co.hu", +- "google.ae", +- "hdfcbank.com", +- "nba.com", +- "zendesk.com", +- "blogspot.co.uk", +- "bestbuy.com", +- "accuweather.com", +- "getresponse.com", +- "repubblica.it", +- "xywy.com", +- "ci123.com", +- "ebay.in", +- "in.com", +- "ign.com", +- "groupon.com", +- "yesky.com", +- "elpais.com", +- "marca.com", +- "kwejk.pl", +- "caijing.com.cn", +- "google.ie", +- "cloudfront.net", +- "intoday.in", +- "wideinfo.org", +- "pof.com", +- "kakaku.com", +- "bitauto.com", +- "life.com.tw", +- "xe.com", +- "goo.gl", +- "google.az", +- "feedly.com", +- "tagged.com", +- "amazon.in", +- "list-manage.com", +- "w3.org", +- "quora.com", +- "ixxx.com", +- "mysearchdial.com", +- "dell.com", +- "seznam.cz", +- "t-online.de", +- "plugrush.com", +- "nydailynews.com", +- "okcupid.com", +- "istockphoto.com", +- "snapdo.com", +- "abcnews.go.com", +- "target.com", +- "latimes.com", +- "mywebsearch.com", +- "joomla.org", +- "odesk.com", +- "surveymonkey.com", +- "elmundo.es", +- "siteadvisor.com", +- "aili.com", +- "uimserv.net", +- "ebay.com.au", +- "doubleclick.com", +- "zeobit.com", +- "google.co.il", +- "fbcdn.net", +- "ero-advertising.com", +- "issuu.com", +- "naukri.com", +- "gazeta.pl", +- "ck101.com", +- "udn.com", +- "google.dk", +- "ce.cn", +- "capitalone.com", +- "att.com", +- "drudgereport.com", +- "blackhatworld.com", +- "adrotator.se", +- "retailmenot.com", +- "justdial.com", +- "icicibank.com", +- "likes.com", +- "elance.com", +- "cntv.cn", +- "ameba.jp", +- "java.com", +- "lifehacker.com", +- "jabong.com", +- "gizmodo.com", +- "ebay.it", +- "lenovo.com", +- "hypergames.net", +- "google.fi", +- "doorblog.jp", +- "blogspot.de", +- "jimdo.com", +- "probux.com", +- "blogspot.it", +- "habrahabr.ru", +- "webmoney.ru", +- "irctc.co.in", +- "sahibinden.com", +- "github.io", +- "informer.com", +- "mysearchresults.com", +- "upworthy.com", +- "pch.com", +- "eyny.com", +- "canadaalltax.com", +- "b5m.com", +- "freelancer.com", +- "match.com", +- "searchfun.in", +- "adnxs.com", +- "sberbank.ru", +- "ig.com.br", +- "trulia.com", +- "subscene.com", +- "corriere.it", +- "livescore.com", +- "irs.gov", +- "twoo.com", +- "clixsense.com", +- "4399.com", +- "xda-developers.com", +- "iminent.com", +- "google.com.my", +- "onlinesbi.com", +- "empowernetwork.com", +- "zing.vn", +- "youdao.com", +- "systweak.com", +- "flipora.com", +- "ning.com", +- "engadget.com", +- "abril.com.br", +- "exoclick.com", +- "semrush.com", +- "commentcamarche.net", +- "shareasale.com", +- "vnexpress.net", +- "battle.net", +- "youm7.com", +- "digg.com", +- "rapidgator.net", +- "expedia.com", +- "twimg.com", +- "newegg.com", +- "lady8844.com", +- "xgo.com.cn", +- "pcgames.com.cn", +- "fotolia.com", +- "rednet.cn", +- "inspsearch.com", +- "lemonde.fr", +- "adultfriendfinder.com", +- "typepad.com", +- "mercadolibre.com.ar", +- "homedepot.com", +- "chip.de", +- "lefigaro.fr", +- "swagbucks.com", +- "taleo.net", +- "kinopoisk.ru", +- "oracle.com", +- "who.is", +- "2ch.net", +- "qtrax.com", +- "eonline.com", +- "sochi2014.com", +- "myfreecams.com", +- "pcbaby.com.cn", +- "gome.com.cn", +- "amazon.it", +- "timeanddate.com", +- "bestusefuldownloads.com", +- "foursquare.com", +- "telexfree.com", +- "gc.ca", +- "58.com", +- "hubspot.com", +- "backpage.com", +- "examiner.com", +- "ria.ru", +- "google.sk", +- "opensiteexplorer.org", +- "awesomehp.com", +- "sexlog.com", +- "gutefrage.net", +- "steampowered.com", +- "slate.com", +- "marketwatch.com", +- "beva.com", +- "shaadi.com", +- "v1.cn", +- "teensdigest.com", +- "blogspot.ru", +- "taboola.com", +- "citrixonline.com", +- "hatena.ne.jp", +- "seesaa.net", +- "houzz.com", +- "bodybuilding.com", +- "webs.com", +- "chexun.com", +- "ya.ru", +- "citibank.com", +- "viralnova.com", +- "2345.com", +- "ashleyrnadison.com", +- "verizonwireless.com", +- "55bbs.com", +- "theblaze.com", +- "123rf.com", +- "gotomeeting.com", +- "kijiji.ca", +- "linkbucks.com", +- "haber7.com", +- "pravda.com.ua", +- "altervista.org", +- "mihanblog.com", +- "terra.com.br", +- "soku.com", +- "urbandictionary.com", +- "mercadolibre.com.mx", +- "pixiv.net", +- "oneindia.in", +- "yellowpages.com", +- "hotels.com", +- "drtuber.com", +- "scoop.it", +- "blogspot.jp", +- "cbslocal.com", +- "movie4k.to", +- "cpmterra.com", +- "hubpages.com", +- "mobile.de", +- "yaolan.com", +- "etao.com", +- "hidemyass.com", +- "ca.gov", +- "dreamstime.com", +- "firedrive.com", +- "searchengines.ru", +- "m-w.com", +- "ebay.fr", +- "templatemonster.com", +- "evernote.com", +- "fastdailyfind.com", +- "amazon.es", +- "gateable.com", +- "hupu.com", +- "y8.com", +- "blogspot.com.tr", +- "tokobagus.com", +- "azlyrics.com", +- "website-unavailable.com", +- "r10.net", +- "wiktionary.org", +- "bongacams.com", +- "focus.de", +- "linksynergy.com", +- "steamcommunity.com", +- "vk.me", +- "sakura.ne.jp", +- "foxsports.com", +- "optmd.com", +- "tabelog.com", +- "narod.ru", +- "glassdoor.com", +- "outlook.com", +- "europa.eu", +- "viadeo.com", +- "leadpages.net", +- "ouedkniss.com", +- "facenama.com", +- "lpcloudsvr302.com", +- "agoda.com", +- "qvo6.com", +- "majesticseo.com", +- "mirror.co.uk", +- "google.com.kw", +- "filehippo.com", +- "moneycontrol.com", +- "duckduckgo.com", +- "npr.org", +- "coupons.com", +- "mynet.com", +- "allrecipes.com", +- "priceline.com", +- "liveleak.com", +- "jqw.com", +- "slickdeals.net", +- "webcrawler.com", +- "babytree.com", +- "amung.us", +- "tomshardware.com", +- "openadserving.com", +- "independent.co.uk", +- "kompas.com", +- "turbobit.net", +- "google.kz", +- "leo.org", +- "yandex.com.tr", +- "mp3skull.com", +- "nordstrom.com", +- "news.com.au", +- "traidnt.net", +- "wunderground.com", +- "cnbc.com", +- "jquery.com", +- "dict.cc", +- "persianblog.ir", +- "clarin.com", +- "all-free-download.com", +- "fhserve.com", +- "sape.ru", +- "asos.com", +- "addmefast.com", +- "lequipe.fr", +- "lapatilla.com", +- "ancestry.com", +- "stockstar.com", +- "monster.com", +- "people.com", +- "gawker.com", +- "howstuffworks.com", +- "tradedoubler.com", +- "over-blog.com", +- "cbc.ca", +- "fishcod.com", +- "yoka.com", +- "macys.com", +- "gazeta.ru", +- "free-tv-video-online.me", +- "google.bg", +- "google.lk", +- "southwest.com", +- "realtor.com", +- "custhelp.com", +- "bhaskar.com", +- "softpedia.com", +- "farsnews.com", +- "cy-pr.com", +- "theverge.com", +- "tudou.com", +- "youboy.com", +- "porn.com", +- "wetransfer.com", +- "virgilio.it", +- "mega.co.nz", +- "sfgate.com", +- "delta-homes.com", +- "squarespace.com", +- "watchseries.lt", +- "overstock.com", +- "nifty.com", +- "jvzoo.com", +- "lanacion.com.ar", +- "prntscr.com", +- "vesti.ru", +- "zimbio.com", +- "adscale.de", +- "google.co.nz", +- "yac.mx", +- "tickld.com", +- "kayak.com", +- "youth.cn", +- "jd.com", +- "shopclues.com", +- "allocine.fr", +- "cracked.com", +- "eventbrite.com", +- "behance.net", +- "youtube-mp3.org", +- "bankmellat.ir", +- "echo.msk.ru", +- "autohome.com.cn", +- "yandex.kz", +- "sex.com", +- "smh.com.au", +- "digikala.com", +- "mackolik.com", +- "rottentomatoes.com", +- "renren.com", +- "wired.com", +- "imageshack.us", +- "interia.pl", +- "zanox.com", +- "eastday.com", +- "fool.com", +- "chinabyte.com", +- "haberturk.com", +- "hespress.com", +- "wow.com", +- "jobrapido.com", +- "idnes.cz", +- "qinbei.com", +- "pr-cy.ru", +- "klikbca.com", +- "17ok.com", +- "gamefaqs.com", +- "immobilienscout24.de", +- "biblegateway.com", +- "espnfc.com", +- "ehowenespanol.com", +- "tabnak.ir", +- "avazutracking.net", +- "sapo.pt", +- "welt.de", +- "google.com.ec", +- "sears.com", +- "pcmag.com", +- "nownews.com", +- "kickstarter.com", +- "pixlr.com", +- "hongkiat.com", +- "chinatimes.com", +- "zoho.com", +- "reverso.net", +- "indianrail.gov.in", +- "privatehomeclips.com", +- "cbssports.com", +- "entrepreneur.com", +- "sporx.com", +- "bhphotovideo.com", +- "fatakat.com", +- "xunlei.com", +- "nikkei.com", +- "chron.com", +- "24h.com.vn", +- "basecamp.com", +- "airtel.in", +- "dealshark.com", +- "shopify.com", +- "babycenter.com", +- "letitbit.net", +- "nuvid.com", +- "yts.re", +- "aparat.com", +- "r2games.com", +- "prestashop.com", +- "alarabiya.net", +- "india.com", +- "magentocommerce.com", +- "heise.de", +- "sulekha.com", +- "mpnrs.com", +- "ibm.com", +- "cbsnews.com", +- "searchengineland.com", +- "mapquest.com", +- "ccb.com", +- "zappos.com", +- "rightmove.co.uk", +- "sahadan.com", +- "milanuncios.com", +- "wenku.baidu.com/user/reg", +- "ovh.net", +- "screencast.com", +- "ahrefs.com", +- "6.cn", +- "businessweek.com", +- "linternaute.com", +- "dafont.com", +- "bestblackhatforum.com", +- "streamcloud.eu", +- "as.com", +- "gtmetrix.com", +- "wmmail.ru", +- "spankwire.com", +- "google.com.do", +- "jeuxvideo.com", +- "digitalpoint.com", +- "amazon.ca", +- "mlb.com", +- "weheartit.com", +- "list.ru", +- "leagueoflegends.com", +- "56.com", +- "bloglovin.com", +- "payoneer.com", +- "nokia.com", +- "aizhan.com", +- "novinky.cz", +- "ustream.tv", +- "getbootstrap.com", +- "seekingalpha.com", +- "codwide.com", +- "vice.com", +- "usmagazine.com", +- "primewire.ag", +- "cam4.com", +- "thehindu.com", +- "deezer.com", +- "graphicriver.net", +- "dmm.com", +- "biglobe.ne.jp", +- "google.rs", +- "z5x.net", +- "tutsplus.com", +- "icicibank.co.in", +- "indiamart.com", +- "gap.com", +- "ensonhaber.com", +- "sitepoint.com", +- "rutor.org", +- "chinanews.com", +- "brainyquote.com", +- "keepvid.com", +- "censor.net.ua", +- "subito.it", +- "tablica.pl", +- "onlylady.com", +- "zulily.com", +- "squidoo.com", +- "change.org", +- "sh.st", +- "webhostingtalk.com", +- "9gag.tv", +- "nairaland.com", +- "gulfup.com", +- "staples.com", +- "gamespot.com", +- "woorank.com", +- "box.com", +- "infobae.com", +- "elegantthemes.com", +- "104.com.tw", +- "aftonbladet.se", +- "google.hr", +- "myegy.com", +- "noticias24.com", +- "eastmoney.com", +- "lowes.com", +- "xtube.com", +- "worldstarhiphop.com", +- "glispa.com", +- "verizon.com", +- "united.com", +- "linkwithin.com", +- "google.com.ly", +- "whitepages.com", +- "games.la", +- "dmoz.org", +- "imagebam.com", +- "careerbuilder.com", +- "sky.com", +- "instructables.com", +- "mercadolibre.com.ve", +- "makemytrip.com", +- "pinimg.com", +- "pingdom.com", +- "foodnetwork.com", +- "orf.at", +- "android.com", +- "wiocha.pl", +- "csdn.net", +- "appledaily.com.tw", +- "nike.com", +- "eluniversal.com.mx", +- "delta.com", +- "ezinearticles.com", +- "sueddeutsche.de", +- "woothemes.com", +- "comcast.com", +- "gismeteo.ru", +- "lotour.com", +- "nfl.com", +- "xbox.com", +- "almanar.com.lb", +- "disney.go.com", +- "ctrip.com", +- "forexfactory.com", +- "clicksvenue.com", +- "nhl.com", +- "ted.com", +- "gstatic.com", +- "forobeta.com", +- "ovh.com", +- "mystart.com", +- "maktoob.com", +- "nouvelobs.com", +- "hindustantimes.com", +- "billdesk.com", +- "1und1.de", +- "zhaopin.com", +- "weather.gov", +- "kioskea.net", +- "myspace.com", +- "firstpost.com", +- "picmonkey.com", +- "grooveshark.com", +- "exblog.jp", +- "pantip.com", +- "earthlink.net", +- "styletv.com.cn", +- "icloud.com", +- "manta.com", +- "google.by", +- "mediaset.it", +- "searchenginewatch.com", +- "japanpost.jp", +- "postimg.org", +- "mbc.net", +- "cheezburger.com", +- "workercn.cn", +- "directadvert.ru", +- "nationzoom.com", +- "caixa.gov.br", +- "gumtree.com", +- "51job.com", +- "viooz.co", +- "usbank.com", +- "wmtransfer.com", +- "fidelity.com", +- "gogetlinks.net", +- "office365.com", +- "pchome.com.tw", +- "feedburner.com", +- "mp3truck.net", +- "sfr.fr", +- "junglee.com", +- "keezmovies.com", +- "binarysystem4u.com", +- "way2sms.com", +- "oyunskor.com", +- "peyvandha.ir", +- "ticketmaster.com", +- "lacaixa.es", +- "video-one.com", +- "yomiuri.co.jp", +- "popcash.net", +- "nypost.com", +- "dubizzle.com", +- "wpmudev.org", +- "mgid.com", +- "google.lt", +- "zazzle.com", +- "nbcolympics.com", +- "battlefield.com", +- "avast.com", +- "jsfiddle.net", +- "namecheap.com", +- "css-tricks.com", +- "friv.com", +- "6park.com", +- "xhamstercams.com", +- "mysql.com", +- "dx.com", +- "thechive.com", +- "vsuch.com", +- "souq.com", +- "anyoption.com", +- "dantri.com.vn", +- "ebay.es", +- "abc.es", +- "whatsapp.com", +- "bitshare.com", +- "savefrom.net", +- "beytoote.com", +- "xiaomi.com", +- "prweb.com", +- "prothom-alo.com", +- "pagesjaunes.fr", +- "bbb.org", +- "eenadu.net", +- "tinypic.com", +- "whois.com", +- "sourtimes.org", +- "adk2.com", +- "criteo.com", +- "tistory.com", +- "ilyke.net", +- "ruten.com.tw", +- "skysports.com", +- "makeuseof.com", +- "p5w.net", +- "hh.ru", +- "nationalgeographic.com", +- "pornmd.com", +- "rakuten.ne.jp", +- "idealo.de", +- "telegraaf.nl", +- "barnesandnoble.com", +- "mynavi.jp", +- "4chan.org", +- "media-fire.org", +- "crunchbase.com", +- "bravotube.net", +- "myfitnesspal.com", +- "today.com", +- "mit.edu", +- "cnmo.com", +- "nu.nl", +- "tripadvisor.co.uk", +- "spotify.com", +- "homeway.com.cn", +- "dianping.com", +- "costco.com", +- "pastebin.com", +- "dhgate.com", +- "windowsphone.com", +- "stagram.com", +- "investopedia.com", +- "ninemsn.com.au", +- "excite.co.jp", +- "22find.com", +- "google.iq", +- "hi5.com", +- "ad4game.com", +- "kohls.com", +- "online.sh.cn", +- "geocities.jp", +- "investing.com", +- "haberler.com", +- "ft.com", +- "weblio.jp", +- "google.tn", +- "list-manage1.com", +- "hsbc.co.uk", +- "ppstream.com", +- "cloob.com", +- "korrespondent.net", +- "ucoz.com", +- "1and1.com", +- "mail.com", +- "fotostrana.ru", +- "accountonline.com", +- "forgeofempires.com", +- "dribbble.com", +- "city-data.com", +- "drupal.org", +- "tunein.com", +- "51fanli.com", +- "ibtimes.com", +- "intel.com", +- "polyvore.com", +- "cbs.com", +- "bab.la", +- "imobile.com.cn", +- "bestadbid.com", +- "eztv.it", +- "smashingmagazine.com", +- "skyrock.com", +- "copyscape.com", +- "cookpad.com", +- "smallseotools.com", +- "asus.com", +- "anysex.com", +- "nbcsports.com", +- "kinox.to", +- "mbank.com.pl", +- "500px.com", +- "sofanti.com", +- "marktplaats.nl", +- "cpanel.net", +- "hm.com", +- "chicagotribune.com", +- "ultimate-guitar.com", +- "infolinks.com", +- "merdeka.com", +- "yandex.by", +- "tribalfusion.com", +- "livedoor.biz", +- "prezi.com", +- "last.fm", +- "sznews.com", +- "junbi-tracker.com", +- "so-net.ne.jp", +- "cocolog-nifty.com", +- "ocn.ne.jp", +- "perezhilton.com", +- "yaplakal.com", +- "championat.com", +- "ebay.ca", +- "mangareader.net", +- "donanimhaber.com", +- "miniclip.com", +- "vcommission.com", +- "noaa.gov", +- "imagefap.com", +- "gumtree.com.au", +- "liveperson.net", +- "gfycat.com", +- "hollywoodreporter.com", +- "dropboxusercontent.com", +- "akhbarak.net", +- "sou300.com", +- "kicker.de", +- "livestream.com", +- "tribunnews.com", +- "kp.ru", +- "techradar.com", +- "315che.com", +- "dw.de", +- "codeproject.com", +- "newsru.com", +- "pconline.com.cn", +- "aa.com", +- "usaa.com", +- "asahi.com", +- "themetapicture.com", +- "quicksprout.com", +- "piriform.com", +- "888poker.com", +- "gittigidiyor.com", +- "nhk.or.jp", +- "statigr.am", +- "ipage.com", +- "gazzetta.it", +- "letv.com", +- "yourlust.com", +- "freepik.com", +- "trello.com", +- "mixi.jp", +- "livememe.com", +- "ew.com", +- "seosprint.net", +- "doisongphapluat.com", +- "autotrader.com", +- "docstoc.com", +- "viva.co.id", +- "livestrong.com", +- "inc.com", +- "hunantv.com", +- "bahn.de", +- "depositphotos.com", +- "rackspace.com", +- "flippa.com", +- "norton.com", +- "lynda.com", +- "teamviewer.com", +- "vip.com", +- "ksl.com", +- "solarmovie.so", +- "klout.com", +- "pikabu.ru", +- "vporn.com", +- "apache.org", +- "sportbox.ru", +- "correios.com.br", +- "toptenreviews.com", +- "ea.com", +- "thenextweb.com", +- "superuser.com", +- "delicious.com", +- "zoosk.com", +- "inbox.com", +- "kongregate.com", +- "starbaby.cn", +- "888casino.com", +- "brazzers.com", +- "sockshare.com", +- "megashare.info", +- "vistaprint.com", +- "porntube.com", +- "seriesyonkis.com", +- "20minutos.es", +- "jagran.com", +- "programme-tv.net", +- "elcomercio.pe", +- "blogspot.kr", +- "t411.me", +- "googleapis.com", +- "blog.com", +- "qingdaonews.com", +- "sedo.com", +- "itmedia.co.jp", +- "mtv.com", +- "ynet.co.il", +- "playstation.com", +- "pornhublive.com", +- "thedailybeast.com", +- "r7.com", +- "sabah.com.tr", +- "126.com", +- "topix.com", +- "liga.net", +- "marriott.com", +- "tvn24.pl", +- "sitesell.com", +- "netdna-cdn.com", +- "startimes.com", +- "hstpnetwork.com", +- "blogspot.com.au", +- "17u.cn", +- "subscribe.ru", +- "woot.com", +- "rozblog.com", +- "wimp.com", +- "vg.no", +- "t-mobile.com", +- "bmi.ir", +- "kankan.com", +- "tsn.ua", +- "gumtree.co.za", +- "googleadservices.com", +- "pnc.com", +- "cars.com", +- "soccerway.com", +- "o2.pl", +- "zeit.de", +- "zopim.com", +- "cloudflare.com", +- "givemesport.com", +- "statscrop.com", +- "gravatar.com", +- "flightradar24.com", +- "ubuntu.com", +- "salon.com", +- "ytimg.com", +- "trovigo.com", +- "sunporno.com", +- "libertagia.com", +- "mihanwebads.com", +- "shopathome.com", +- "cdiscount.com", +- "commbank.com.au", +- "elwatannews.com", +- "discovercard.com", +- "infowars.com", +- "blogimg.jp", +- "portaldosites.com", +- "fixya.com", +- "drom.ru", +- "fastpic.ru", +- "pbs.org", +- "kandao.com", +- "okwave.jp", +- "faz.net", +- "sbnation.com", +- "hilton.com", +- "duba.com", +- "homeshop18.com", +- "ultimasnoticias.com.ve", +- "bankrate.com", +- "megasesso.com", +- "studiopress.com", +- "sports.ru", +- "asriran.com", +- "etoro.com", +- "cafemom.com", +- "dhl.de", +- "indiegogo.com", +- "tdcanadatrust.com", +- "1tv.ru", +- "gogvo.com", +- "bt.com", +- "blogspot.tw", +- "zergnet.com", +- "garanti.com.tr", +- "privatbank.ua", +- "sanook.com", +- "travelocity.com", +- "networksolutions.com", +- "thqafawe3lom.com", +- "trklnks.com", +- "torchbrowser.com", +- "logmein.com", +- "williamhill.com", +- "zhihu.com", +- "auto.ru", +- "craigslist.ca", +- "olx.com.pk", +- "smi2.ru", +- "ukr.net", +- "dpreview.com", +- "boston.com", +- "folha.uol.com.br", +- "name.com", +- "ashemaletube.com", +- "slimspots.com", +- "envato.com", +- "6pm.com", +- "fandango.com", +- "sozcu.com.tr", +- "nikkeibp.co.jp", +- "aufeminin.com", +- "baiducontent.com", +- "buscape.com.br", +- "funnyordie.com", +- "337.com", +- "sakshi.com", +- "airasia.com", +- "samanyoluhaber.com", +- "picofile.com", +- "blackberry.com", +- "google.com.gt", +- "io9.com", +- "easyhits4u.com", +- "qianyan001.com", +- "flashx.tv", +- "zap2it.com", +- "dnsrsearch.com", +- "patch.com", +- "staticflickr.com", +- "clicksor.com", +- "mcafee.com", +- "zerohedge.com", +- "zara.com", +- "freelotto.com", +- "tutorialspoint.com", +- "qone8.com", +- "olx.com.br", +- "axisbank.com", +- "marketgid.com", +- "your-server.de", +- "game321.com", +- "harvard.edu", +- "indianexpress.com", +- "fatwallet.com", +- "nudevista.com", +- "paper.li", +- "opera.com", +- "serving-sys.com", +- "nowvideo.sx", +- "theatlantic.com", +- "cisco.com", +- "bookmyshow.com", +- "webmasterworld.com", +- "metro.co.uk", +- "leparisien.fr", +- "orbitz.com", +- "h2porn.com", +- "4cdn.org", +- "itar-tass.com", +- "nasa.gov", +- "macrumors.com", +- "google.si", +- "usnews.com", +- "premierleague.com", +- "largeporntube.com", +- "blogsky.com", +- "bufferapp.com", +- "zeroredirect1.com", +- "sendspace.com", +- "stanford.edu", +- "state.gov", +- "yjc.ir", +- "abc.net.au", +- "pornsharing.com", +- "4pda.ru", +- "52pk.net", +- "meituan.com", +- "mmgp.ru", +- "sponichi.co.jp", +- "masrawy.com", +- "whatismyipaddress.com", +- "onlinewebfind.com", +- "news24.com", +- "zdnet.com", +- "imagevenue.com", +- "gameaholic.com", +- "mediaplex.com", +- "clip.vn", +- "2mdn.net", +- "nmisr.com", +- "musica.com", +- "networkedblogs.com", +- "metrolyrics.com", +- "chacha.com", +- "internetdownloadmanager.com", +- "legacy.com", +- "wwe.com", +- "icbc.com.cn", +- "ny.gov", +- "chomikuj.pl", +- "alexa.com", +- "pcworld.com", +- "overthumbs.com", +- "adp.com", +- "ad2games.com", +- "adme.ru", +- "bidvertiser.com", +- "rtl.de", +- "sweetim.com", +- "gaana.com", +- "7k7k.com", +- "livingsocial.com", +- "netteller.com", +- "rakuten.com", +- "chess.com", +- "blackboard.com", +- "thekitchn.com", +- "ilfattoquotidiano.it", +- "20minutes.fr", +- "soufun.com", +- "nerdbux.com", +- "breitbart.com", +- "webtretho.com", +- "tvguide.com", +- "miralinks.ru", +- "weather.com.cn", +- "zalando.de", +- "dangdang.com", +- "bubblews.com", +- "thoughtcatalog.com", +- "114la.com", +- "msn.ca", +- "blogmura.com", +- "americanas.com.br", +- "elitedaily.com", +- "lightinthebox.com", +- "bizjournals.com", +- "yixun.com", +- "itau.com.br", +- "51.la", +- "doodle.com", +- "arabyonline.com", +- "opencart.com", +- "bomnegocio.com", +- "lego.com", +- "pclady.com.cn", +- "metacafe.com", +- "kimiss.com", +- "journaldunet.com", +- "gnavi.co.jp", +- "51auto.com", +- "clickey.com", +- "chekb.com", +- "searchnu.com", +- "diply.com", +- "walgreens.com", +- "descargar.es", +- "mirrorcreator.com", +- "pornerbros.com", +- "askmen.com", +- "shop.com", +- "inmotionhosting.com", +- "filmweb.pl", +- "kbb.com", +- "appround.biz", +- "aljazeera.com", +- "lumosity.com", +- "sweet-page.com", +- "pole-emploi.fr", +- "fishki.net", +- "rollingstone.com", +- "kapanlagi.com", +- "yandex.com", +- "cnblogs.com", +- "plaintube.com", +- "intentmedia.net", +- "about.me", +- "torrentz.in", +- "01net.com", +- "gyazo.com", +- "nic.ru", +- "juicyads.com", +- "trend.az", +- "askubuntu.com", +- "unam.mx", +- "tradus.com", +- "tigerdirect.com", +- "letras.mus.br", +- "imagetwist.com", +- "perfectmoney.is", +- "wpbeginner.com", +- "thepiratetrader.com", +- "victoriassecret.com", +- "images-amazon.com", +- "tusfiles.net", +- "chefkoch.de", +- "ojooo.com", +- "alphaporno.com", +- "betfair.com", +- "tympanus.net", +- "td.com", +- "4tube.com", +- "phonearena.com", +- "bankmandiri.co.id", +- "cox.net", +- "ozon.ru", +- "perfectgirls.net", +- "asana.com", +- "sprint.com", +- "berniaga.com", +- "vente-privee.com", +- "ing.nl", +- "finn.no", +- "atwiki.jp", +- "toysrus.com", +- "petflow.com", +- "reverbnation.com", +- "freeones.com", +- "abc.go.com", +- "bradesco.com.br", +- "yenisafak.com.tr", +- "profit-partner.ru", +- "redfin.com", +- "mangafox.me", +- "appnexus.com", +- "sxc.hu", +- "speedanalysis.net", +- "n-tv.de", +- "qidian.com", +- "teespring.com", +- "break.com", +- "nailedhard.com", +- "jalan.net", +- "authorize.net", +- "adultadworld.com", +- "sootoo.com", +- "roboform.com", +- "kotaku.com", +- "multitran.ru", +- "food.com", +- "twitpic.com", +- "pogo.com", +- "sabq.org", +- "priceminister.com", +- "lexpress.fr", +- "livetv.sx", +- "nikkansports.com", +- "securepaynet.net", +- "vodoumedia.com", +- "airbnb.com", +- "trafficholder.com", +- "rr.com", +- "expireddomains.net", +- "bandcamp.com", +- "wayfair.com", +- "tut.by", +- "maybank2u.com.my", +- "similarweb.com", +- "zol.com.cn", +- "247realmedia.com", +- "asp.net", +- "lonelyplanet.com", +- "seopult.ru", +- "whois.net", +- "academia.edu", +- "univision.com", +- "interfax.ru", +- "amarillasinternet.com", +- "miercn.com", +- "barclays.co.uk", +- "societe.com", +- "khabaronline.ir", +- "unity3d.com", +- "nyaa.se", +- "euronews.com", +- "verizon.net", +- "rutube.ru", +- "wetter.com", +- "imlive.com", +- "ggpht.com", +- "docin.com", +- "yify-torrents.com", +- "yhd.com", +- "citibank.co.in", +- "xdating.com", +- "roblox.com", +- "voyages-sncf.com", +- "189.cn", +- "identi.li", +- "bayt.com", +- "medicinenet.com", +- "wmaraci.com", +- "stern.de", +- "eluniversal.com", +- "zoopla.co.uk", +- "easyjet.com", +- "dhl.com", +- "freakshare.com", +- "rojadirecta.me", +- "sp.gov.br", +- "friendfeed.com", +- "beamtele.com", +- "searchenginejournal.com", +- "nocookie.net", +- "reliancenetconnect.co.in", +- "google.co.ma", +- "fanpop.com", +- "adk2.co", +- "tagesschau.de", +- "nate.com", +- "ole.com.ar", +- "index.hu", +- "aruba.it", +- "eltiempo.com", +- "resellerclub.com", +- "qip.ru", +- "xossip.com", +- "siteground.com", +- "royalbank.com", +- "advfn.com", +- "tebyan.net", +- "iciba.com", +- "bigcartel.com", +- "sciencedirect.com", +- "hepsiburada.com", +- "cpasbien.me", +- "alfabank.ru", +- "microsoftstore.com", +- "discogs.com", +- "onliner.by", +- "socialmediaexaminer.com", +- "seasonvar.ru", +- "tripadvisor.in", +- "360doc.com", +- "chinabroadcast.cn", +- "realestate.com.au", +- "avira.com", +- "herokuapp.com", +- "downloadsetup.net", +- "torcache.net", +- "uefa.com", +- "rg.ru", +- "qianlong.com", +- "hugedomains.com", +- "arstechnica.com", +- "fifa.com", +- "ryanair.com", +- "i.ua", +- "axisbank.co.in", +- "alimama.com", +- "wanggou.com", +- "radikal.com.tr", +- "echoroukonline.com", +- "unian.net", +- "slashdot.org", +- "dmv.org", +- "mayoclinic.org", +- "newsmax.com", +- "google.com.et", +- "icontact.com", +- "vanguardngr.com", +- "infojobs.net", +- "say-move.org", +- "ileehoo.com", +- "mirtesen.ru", +- "yam.com", +- "e-hentai.org", +- "wikimapia.org", +- "shop-pro.jp", +- "bukalapak.com", +- "jcpenney.com", +- "ilmeteo.it", +- "iltasanomat.fi", +- "telecomitalia.it", +- "kariyer.net", +- "shutterfly.com", +- "santabanta.com", +- "softlayer.com", +- "complex.com", +- "mamba.ru", +- "netshoes.com.br", +- "theweathernetwork.com", +- "politico.com", +- "advego.ru", +- "eroprofile.com", +- "mainichi.jp", +- "nta.go.jp", +- "sfimg.com", +- "ap.org", +- "webex.com", +- "hinet.net", +- "skyscrapercity.com", +- "affili.net", +- "adplxmd.com", +- "iltalehti.fi", +- "impress.co.jp", +- "jezebel.com", +- "extremetube.com", +- "digitaltrends.com", +- "one.com", +- "ranker.com", +- "qiwi.com", +- "collegehumor.com", +- "nbc.com", +- "boursorama.com", +- "watch32.com", +- "meetcheap.com", +- "forums.wordpress.com", +- "cvs.com", +- "kenh14.vn", +- "yallakora.com", +- "plurk.com", +- "xtool.ru", +- "airtel.com", +- "wp.com", +- "sftimes.co", +- "economist.com", +- "rapidshare.com", +- "redbox.com", +- "audible.com", +- "kissmetrics.com", +- "atpanel.com", +- "wargaming.net", +- "1337x.org", +- "shahrekhabar.com", +- "bdnews24.com", +- "tvrain.ru", +- "wykop.pl", +- "mts.ru", +- "nnm-club.me", +- "schwab.com", +- "elconfidencial.com", +- "modelmayhem.com", +- "zhidao.baidu.com/user/admin", +- "aastocks.com", +- "tiscali.it", +- "qadabra.com", +- "autoscout24.de", +- "vatanim.com.tr", +- "gotowebinar.com", +- "edmunds.com", +- "ebaumsworld.com", +- "megafilmeshd.net", +- "poste.it", +- "mcssl.com", +- "aljazeera.net", +- "netvibes.com", +- "sme.sk", +- "tesco.com", +- "525j.com.cn", +- "tf1.fr", +- "ccidnet.com", +- "ldblog.jp", +- "blockchain.info", +- "played.to", +- "nthwall.com", +- "justanswer.com", +- "clickbank.net", +- "fnac.com", +- "gmarket.co.kr", +- "clipconverter.cc", +- "nextmedia.com", +- "bb.com.br", +- "learntotradethemarket.com", +- "pornoid.com", +- "downloadha.com", +- "hellporno.com", +- "ooo-sex.com", +- "blocket.se", +- "tubeplus.me", +- "seek.com.au", +- "filestube.to", +- "ceneo.pl", +- "walmart.com.br", +- "sonymobile.com", +- "dyndns.org", +- "ulmart.ru", +- "vrbo.com", +- "sport.pl", +- "ashleymadison.com", +- "el-wlid.com", +- "boredpanda.com", +- "udemy.com", +- "mobogenie.com", +- "tubegalore.com", +- "theglobeandmail.com", +- "bancobrasil.com.br", +- "888.com", +- "adreactor.com", +- "zomato.com", +- "depositfiles.com", +- "moneysavingexpert.com", +- "dofus.com", +- "oanda.com", +- "sport1.de", +- "justhost.com", +- "longhoo.net", +- "otomoto.pl", +- "techrepublic.com", +- "westpac.com.au", +- "dreamhost.com", +- "ilsole24ore.com", +- "clubic.com", +- "gamme.com.tw", +- "doctissimo.fr", +- "isna.ir", +- "s2d6.com", +- "tdbank.com", +- "zwaar.net", +- "slando.ua", +- "segodnya.ua", +- "appannie.com", +- "bartarinha.ir", +- "egotastic.com", +- "ed.gov", +- "lg.com", +- "120ask.com", +- "hostmonster.com", +- "super.cz", +- "mercola.com", +- "bayproxy.me", +- "day.az", +- "dummies.com", +- "azet.sk", +- "huffingtonpost.co.uk", +- "okezone.com", +- "medu.ir", +- "lavanguardia.com", +- "espreso.tv", +- "nymag.com", +- "autotrader.co.uk", +- "socialmediatoday.com", +- "wn.com", +- "rtbpop.com", +- "99designs.com", +- "sanspo.com", +- "proboards.com", +- "virginmedia.com", +- "99acres.com", +- "blic.rs", +- "pingomatic.com", +- "prnewswire.com", +- "sony.com", +- "seobuilding.ru", +- "www.gov.uk", +- "jugem.jp", +- "watchtower.com", +- "seoprofiler.com", +- "centrum.cz", +- "techbrowsing.com", +- "almasryalyoum.com", +- "lolking.net", +- "nipic.com", +- "fanfiction.net", +- "bwin.com", +- "anyporn.com", +- "sulit.com.ph", +- "quickmeme.com", +- "carview.co.jp", +- "haizhangs.com", +- "airtelforum.com", +- "flirt4free.com", +- "billboard.com", +- "trademe.co.nz", +- "rapgenius.com", +- "pchouse.com.cn", +- "beforeitsnews.com", +- "peopleperhour.com", +- "basecamphq.com", +- "onlinedown.net", +- "bet365.es", +- "fucked-tube.com", +- "santander.co.uk", +- "speedbit.com", +- "gi-akademie.com", +- "google.com.pr", +- "winupdatevideos.com", +- "bizrate.com", +- "xxxbunker.com", +- "coursera.org", +- "zoominfo.com", +- "rarbg.com", +- "ahram.org.eg", +- "howtogeek.com", +- "focus.cn", +- "duden.de", +- "mufg.jp", +- "ex.ua", +- "titan24.com", +- "greatandhra.com", +- "qqbaobao.com", +- "rtve.es", +- "yandex.net", +- "yle.fi", +- "panoramio.com", +- "google.com.af", +- "scol.com.cn", +- "gamestop.com", +- "xiami.com", +- "webpagetest.org", +- "creativecommons.org", +- "archive.is", +- "timesjobs.com", +- "centurylink.com", +- "wowhead.com", +- "wordstream.com", +- "lloydsbank.co.uk", +- "incredibar.com", +- "vagalume.com.br", +- "installerapplicationusa.com", +- "shinobi.jp", +- "ruvr.ru", +- "natwest.com", +- "roulettebotplus.com", +- "wildberries.ru", +- "huaban.com", +- "buenosearch.com", +- "reg.ru", +- "tempo.co", +- "qvc.com", +- "mangahere.com", +- "tv.com", +- "boc.cn", +- "fnb.co.za", +- "made-in-china.com", +- "eleconomista.es", +- "ubuntuforums.org", +- "derstandard.at", +- "xml-sitemaps.com", +- "jang.com.pk", +- "jiayuan.com", +- "credit-agricole.fr", +- "androidcentral.com", +- "urbanspoon.com", +- "pornoxo.com", +- "regnum.ru", +- "bedbathandbeyond.com", +- "skladchik.com", +- "daily.co.jp", +- "n-mobile.net", +- "suntrust.com", +- "justjared.com", +- "vid2c.com", +- "gettyimages.com", +- "tubecup.com", +- "kinogo.net", +- "similarsites.com", +- "fling.com", +- "vine.co", +- "banglanews24.com", +- "pudelek.pl", +- "support.wordpress.com", +- "cox.com", +- "xkcd.com", +- "adbooth.com", +- "anz.com", +- "adxcore.com", +- "google.com.sv", +- "indeed.co.in", +- "scottrade.com", +- "v9.com", +- "isohunt.to", +- "srclick.ru", +- "gharreh.com", +- "zaman.com.tr", +- "monsterindia.com", +- "delfi.lt", +- "chewen.com", +- "empowernetwork.com/QUbsgqDwpjjbkpOgwgOeaw==", +- "state.tx.us", +- "segundamano.es", +- "utro.ru", +- "sitescout.com", +- "justclick.ru", +- "wnd.com", +- "cosmopolitan.com", +- "local.com", +- "anitube.se", +- "sport.es", +- "google.com.qa", +- "ads-id.com", +- "google.lv", +- "capitalone360.com", +- "hattrick.org", +- "qualtrics.com", +- "inagist.com", +- "filgoal.com", +- "incredibar-search.com", +- "adslgate.com", +- "directv.com", +- "ilivid.com", +- "warthunder.ru", +- "jasmin.com", +- "cyberciti.biz", +- "msn.co.jp", +- "canalblog.com", +- "boerse.bz", +- "tnaflix.com", +- "apa.az", +- "prchecker.info", +- "reclameaqui.com.br", +- "onlyworldnews.com", +- "submarino.com.br", +- "kuronekoyamato.co.jp", +- "paipai.com", +- "realitykings.com", +- "deadspin.com", +- "islamweb.net", +- "no-ip.com", +- "lostfilm.tv", +- "wattpad.com", +- "wav.tv", +- "citi.com", +- "buysellads.com", +- "prezentacya.ru", +- "forocoches.com", +- "donga.com", +- "drive2.ru", +- "netsuite.com", +- "privalia.com", +- "bidorbuy.co.za", +- "cmbchina.com", +- "searchresultsguide.com", +- "odatv.com", +- "skrill.com", +- "en.wordpress.com", +- "dojki.com", +- "unibet.com", +- "hotpepper.jp", +- "simplyhired.com", +- "vesti.ua", +- "ibtimes.co.uk", +- "creativebloq.com", +- "filmesonlinegratis.net", +- "videohive.net", +- "kmart.com", +- "metacritic.com", +- "rikunabi.com", +- "zozo.jp", +- "venturebeat.com", +- "1and1.es", +- "banesconline.com", +- "internethaber.com", +- "rae.es", +- "planetsuzy.org", +- "wpengine.com", +- "kizi.com", +- "armorgames.com", +- "argos.co.uk", +- "dtiblog.com", +- "diigo.com", +- "forever21.com", +- "flashscore.com", +- "vedomosti.ru", +- "ccavenue.com", +- "att.net", +- "esporte.uol.com.br", +- "empowernetwork.com/PXQ7Uz1Kyg+LR1APrG7pKQ==", +- "to8to.com", +- "hotwire.com", +- "all.biz", +- "info.com", +- "xhamster.com/user/video", +- "000webhost.com", +- "worldoftanks.ru", +- "dagbladet.no", +- "computerbild.de", +- "nasdaq.com", +- "chitika.com", +- "ipeen.com.tw", +- "abola.pt", +- "wiley.com", +- "lpcloudsvr303.com", +- "tinsao.net", +- "mehrnews.com", +- "hugesex.tv", +- "christian-dogma.com", +- "search.us.com", +- "garmin.com", +- "tgbus.com", +- "iherb.com", +- "torntv-tvv.org", +- "chosun.com", +- "kinozal.tv", +- "berkeley.edu", +- "techtarget.com", +- "labanquepostale.fr", +- "fitbit.com", +- "folkd.com", +- "theonion.com", +- "idealista.com", +- "oscar.go.com", +- "jiji.com", +- "anonym.to", +- "allabout.co.jp", +- "wufoo.com", +- "rantlifestyle.com", +- "google.com.bo", +- "28.com", +- "rocketnews24.com", +- "hotspotshield.com", +- "opentable.com", +- "admngronline.com", +- "naturalnews.com", +- "zeroredirect2.com", +- "ero-video.net", +- "dinamalar.com", +- "fl.ru", +- "mtsindia.in", +- "kapook.com", +- "theage.com.au", +- "allmyvideos.net", +- "dinodirect.com", +- "videodownloadconverter.com", +- "tripleclicks.com", +- "brassring.com", +- "fapdu.com", +- "cafepress.com", +- "infospace.com", +- "express.com.pk", +- "fumu.com", +- "infibeam.com", +- "etrade.com", +- "meneame.net", +- "seroundtable.com", +- "bigpoint.com", +- "chinadaily.com.cn", +- "myfonts.com", +- "ezdownloadpro.info", +- "codeplex.com", +- "xl.pt", +- "kaspersky.com", +- "khabarfarsi.com", +- "admitad.com", +- "flirchi.com", +- "dpstream.net", +- "miniinthebox.com", +- "samsclub.com", +- "charter.net", +- "techbang.com", +- "tiu.ru", +- "fanpage.it", +- "spokeo.com", +- "imageshack.com", +- "ijreview.com", +- "bc.vc", +- "lazada.co.id", +- "gofirstrow.eu", +- "uptobox.com", +- "newsnow.co.uk", +- "symantec.com", +- "editor.wix.com", +- "avaxhome.cc", +- "canalplus.fr", +- "copyblogger.com", +- "vetogate.com", +- "yahoo-mbga.jp", +- "manoramaonline.com", +- "ah-me.com", +- "elheddaf.com", +- "bitcointalk.org", +- "haqaik.com", +- "bbandt.com", +- "linguee.de", +- "blogspot.nl", +- "minus.com", +- "amarujala.com", +- "openclassrooms.com", +- "bigmir.net", +- "koramgame.com", +- "commonfloor.com", +- "gayromeo.com", +- "cleartrip.com", +- "kompasiana.com", +- "tankionline.com", +- "google.co.tz", +- "springer.com", +- "lifenews.ru", +- "sify.com", +- "tvoyauda4a.ru", +- "dfiles.ru", +- "technorati.com", +- "myorderbox.com", +- "fanatik.com.tr", +- "activesearchresults.com", +- "laposte.net", +- "whirlpool.net.au", +- "stockcharts.com", +- "leadimpact.com", +- "cardekho.com", +- "ryushare.com", +- "blog.jp", +- "fastcompany.com", +- "eurosport.fr", +- "emirates.com", +- "lb.ua", +- "serverfault.com", +- "forbes.ru", +- "bfmtv.com", +- "google.jo", +- "17173.com", +- "wikispaces.com", +- "tokopedia.com", +- "liberation.fr", +- "a10.com", +- "kdnet.net", +- "variety.com", +- "blog.me", +- "homeaway.com", +- "ameritrade.com", +- "adult-empire.com", +- "national.com.au", +- "haraj.com.sa", +- "timewarnercable.com", +- "casino.com", +- "sheknows.com", +- "google.com.uy", +- "abv.bg", +- "liputan6.com", +- "etxt.ru", +- "bigstockphoto.com", +- "strato.de", +- "cashtasks.com", +- "columbia.edu", +- "zdf.de", +- "pptv.com", +- "cricbuzz.com", +- "sharesuper.info", +- "radaronline.com", +- "pornolab.net", +- "google.ba", +- "opensubtitles.org", +- "abclocal.go.com", +- "ansa.it", +- "pbskids.org", +- "vz.ru", +- "iconfinder.com", +- "vitaminl.tv", +- "ntv.ru", +- "peliculasyonkis.com", +- "foto-hd.com", +- "paytm.com", +- "rantsports.com", +- "optimum.net", +- "postbank.de", +- "index.hr", +- "smugmug.com", +- "haivl.com", +- "arbeitsagentur.de", +- "dailycaller.com", +- "freshbooks.com", +- "genieo.com", +- "alnaddy.com", +- "britishairways.com", +- "20min.ch", +- "findthebest.com", +- "autoblog.com", +- "warez-bb.org", +- "iza.ne.jp", +- "filmaffinity.com", +- "megogo.net", +- "soccermanager.com", +- "dawanda.com", +- "parallels.com", +- "clickjogos.uol.com.br", +- "12306.cn", +- "jstv.com", +- "cliphunter.com", +- "pixabay.com", +- "milenio.com", +- "keybinary.com", +- "suumo.jp", +- "mediatakeout.com", +- "vodafone.in", +- "cheapoair.com", +- "seobook.com", +- "videoyoum7.com", +- "yr.no", +- "gofundme.com", +- "ixbt.com", +- "starbucks.com", +- "conferenceplus.com", +- "media1first.com", +- "sergey-mavrodi.com", +- "rafflecopter.com", +- "591.com.tw", +- "mangapanda.com", +- "huffingtonpost.fr", +- "tiboo.cn", +- "bancomer.com.mx", +- "handelsblatt.com", +- "hpylgr.com", +- "psu.edu", +- "bancomercantil.com", +- "sport-express.ru", +- "codepen.io", +- "foundationapi.com", +- "ow.ly", +- "vatgia.com", +- "kommersant.ru", +- "srvsinf.com", +- "telderi.ru", +- "mercadolibre.com.co", +- "hsbc.com.hk", +- "t3n.de", +- "magicbricks.com", +- "shopstyle.com", +- "mudah.my", +- "punchng.com", +- "therichest.com", +- "fansshare.com", +- "lepoint.fr", +- "vipzona.info", +- "globaltestmarket.com", +- "jqueryui.com", +- "bcsh.com", +- "mundodeportivo.com", +- "newyorker.com", +- "funnyjunk.com", +- "gongchang.com", +- "a8.net", +- "ecollege.com", +- "newhdplugin.net", +- "befuck.com", +- "elespectador.com", +- "drugs.com", +- "abplive.in", +- "feelcars.com", +- "psychologytoday.com", +- "instaforex.com", +- "strtsrv.com", +- "atpworldtour.com", +- "incruit.com", +- "starwoodhotels.com", +- "zone-telechargement.com", +- "songspk.name", +- "hatenablog.com", +- "enfemenino.com", +- "msnbc.com", +- "freebitco.in", +- "akairan.com", +- "discovery.com", +- "angieslist.com", +- "lesechos.fr", +- "transfermarkt.de", +- "sephora.com", +- "come.in", +- "dailykos.com", +- "deutsche-bank.de", +- "warriorplus.com", +- "awwwards.com", +- "lomadee.com", +- "365jia.cn", +- "lotterypost.com", +- "egrana.com.br", +- "rivals.com", +- "literotica.com", +- "myfreshnet.com", +- "ihg.com", +- "fazenda.gov.br", +- "tomnod.com", +- "filesharefanatic.com", +- "hotukdeals.com", +- "bitsnoop.com", +- "tenpay.com", +- "putlocker.bz", +- "ziddu.com", +- "ntvmsnbc.com", +- "surveyzrewardcenter.com", +- "aliyun.com", +- "media.net", +- "comdirect.de", +- "yoox.com", +- "hotelscombined.com", +- "vgsgaming-ads.com", +- "robokassa.ru", +- "webdesignerdepot.com", +- "rotoworld.com", +- "jmw.com.cn", +- "seloger.com", +- "dsdomination.com", +- "affiliatewindow.com", +- "abs-cbnnews.com", +- "bmo.com", +- "iconarchive.com", +- "funshion.com", +- "admin5.com", +- "playhe.com", +- "bigcommerce.com", +- "yodobashi.com", +- "bigfishgames.com", +- "onlinecreditcenter6.com", +- "homes.co.jp", +- "gameninja.com", +- "ebates.com", +- "banamex.com.mx", +- "google.com.lb", +- "2chblog.jp", +- "entertainment-factory.com", +- "asg.to", +- "walla.co.il", +- "mktmobi.com", +- "opensooq.com", +- "adam4adam.com", +- "expressen.se", +- "elephanttube.com", +- "ingdirect.es", +- "clicrbs.com.br", +- "seriespepito.com", +- "skyscanner.net", +- "shine.com", +- "appround.us", +- "washingtontimes.com", +- "nrk.no", +- "1stwebdesigner.com", +- "gucheng.com", +- "ghanaweb.com", +- "jzip.com", +- "rozetka.com.ua", +- "wiziwig.tv", +- "jobsdb.com", +- "kitco.com", +- "rpp.com.pe", +- "aljaras.com", +- "telecinco.es", +- "storify.com", +- "netease.com", +- "business-standard.com", +- "babble.com", +- "noticias.uol.com.br", +- "alice.it", +- "bizdec.ru", +- "voanews.com", +- "freejobalert.com", +- "origo.hu", +- "list-manage2.com", +- "gavick.com", +- "national-lottery.co.uk", +- "gazzetta.gr", +- "freevideodownloadforpc.com", +- "xmarks.com", +- "wikibooks.org", +- "sexad.net", +- "alc.co.jp", +- "emol.com", +- "careesma.in", +- "cdc.gov", +- "toshiba.com", +- "imgchili.net", +- "rbcroyalbank.com", +- "indowebster.com", +- "zynga.com", +- "telekom.com", +- "jiameng.com", +- "adsmarket.com", +- "utorrent.com", +- "aarp.org", +- "cityadspix.com", +- "ekstrabladet.dk", +- "doc88.com", +- "fetlife.com", +- "fh21.com.cn", +- "cambridge.org", +- "tune.pk", +- "auction.co.kr", +- "patheos.com", +- "search-results.com", +- "lds.org", +- "webrankinfo.com", +- "newsit.gr", +- "techtudo.com.br", +- "moviepilot.com", +- "mercador.ro", +- "nguoiduatin.vn", +- "tripadvisor.it", +- "lurkmore.to", +- "europapress.es", +- "uspto.gov", +- "excelsior.com.mx", +- "myvideo.de", +- "jetblue.com", +- "camfrog.com", +- "blick.ch", +- "batepapo.uol.com.br", +- "manager.co.th", +- "goibibo.com", +- "cornell.edu", +- "apetube.com", +- "nation.com", +- "allmusic.com", +- "naughtyamerica.com", +- "obozrevatel.com", +- "telegrafi.com", +- "neimanmarcus.com", +- "yabancidiziizle1.com", +- "globalewallet.com", +- "beeline.ru", +- "hinkhoj.com", +- "sitemeter.com", +- "almesryoon.com", +- "localmoxie.com", +- "grotal.com", +- "knowyourmeme.com", +- "qiwi.ru", +- "yieldmanager.com", +- "yimg.com", +- "horoscopedays.com", +- "gfy.com", +- "mxtoolbox.com", +- "searchgol.com", +- "inquirer.net", +- "hollywoodlife.com", +- "ebrun.com", +- "shopbop.com", +- "mysmartprice.com", +- "kijiji.it", +- "visual.ly", +- "mop.com", +- "1fichier.com", +- "prlog.org", +- "xjtour.com", +- "shorouknews.com", +- "thegioinet.net", +- "hln.be", +- "enom.com", +- "thaqafnafsak.com", +- "wahuu.com", +- "ganji.com", +- "russianpost.ru", +- "myplaycity.com", +- "dzone.com", +- "dns-shop.ru", +- "aif.ru", +- "ssisurveys.com", +- "uploadboy.com", +- "madpandatv.net", +- "pcauto.com.cn", +- "meinestadt.de", +- "tasnimnews.com", +- "rockettheme.com", +- "imesh.com", +- "home.pl", +- "lindaikeji.blogspot.com", +- "zamunda.net", +- "with2.net", +- "calameo.com", +- "myonlinearcade.com", +- "xcams.com", +- "unicredit.it", +- "clip2net.com", +- "mediatemple.net", +- "nosub.tv", +- "click.in", +- "alluc.to", +- "thestar.com.my", +- "niksalehi.com", +- "lastampa.it", +- "itv.com", +- "hihi2.com", +- "digitalocean.com", +- "tripadvisor.fr", +- "willhaben.at", +- "laodong.com.vn", +- "591hx.com", +- "tineye.com", +- "ptt.cc", +- "beatport.com", +- "infoseek.co.jp", +- "avangate.com", +- "indiaproperty.com", +- "books.com.tw", +- "nj.com", +- "avaaz.org", +- "wikitravel.org", +- "direct.gov.uk", +- "wangtu.com", +- "discover.com", +- "slon.ru", +- "startpage.com", +- "thestar.com", +- "meishichina.com", +- "finanzen.net", +- "estadao.com.br", +- "indeed.co.uk", +- "expansion.com", +- "irpopup.ir", +- "arvixe.com", +- "secureinternetbank.com", +- "csmonitor.com", +- "carwale.com", +- "mtime.com", +- "ceconline.com", +- "abchina.com", +- "cgbchina.com.cn", +- "mediotiempo.com", +- "vic.gov.au", +- "cnbeta.com", +- "alarab.net", +- "vietnamnet.vn", +- "gay.com", +- "watchmygf.net", +- "myanimelist.net", +- "bannersbroker.com", +- "asklaila.com", +- "heureka.cz", +- "grepolis.com", +- "meteofrance.com", +- "bol.com", +- "hasoffers.com", +- "bigrock.in", +- "ibanking-services.com", +- "nos.nl", +- "google.com.gh", +- "beppegrillo.it", +- "nhaccuatui.com", +- "hamariweb.com", +- "wikiquote.org", +- "evite.com", +- "jobdiagnosis.com", +- "17track.net", +- "baixing.com", +- "awempire.com", +- "healthgrades.com", +- "unifiedlayer.com", +- "thisav.com", +- "himado.in", +- "zcool.com.cn", +- "tsn.ca", +- "atlassian.net", +- "binary500.com", +- "alotporn.com", +- "dnaindia.com", +- "sherdog.com", +- "www.nhs.uk", +- "gruposantander.es", +- "quantcast.com", +- "usearchmedia.com", +- "merchantcircle.com", +- "blog.hu", +- "wallstcheatsheet.com", +- "iptorrents.com", +- "apsense.com", +- "redirsvc.com", +- "indiarailinfo.com", +- "mobile.ir", +- "xvideo-jp.com", +- "boxofficemojo.com", +- "scamadviser.com", +- "rotapost.ru", +- "someecards.com", +- "mydealz.de", +- "lvye.cn", +- "videoweed.es", +- "xlovecam.com", +- "pepperjamnetwork.com", +- "khabarpu.com", +- "mathrubhumi.com", +- "online-convert.com", +- "b92.net", +- "tiptopsoft.org", +- "el-balad.com", +- "qihoo.com", +- "iheart.com", +- "campaign-archive1.com", +- "photodune.net", +- "labnol.org", +- "kotobank.jp", +- "medium.com", +- "google.lu", +- "tm1111.com", +- "gigazine.net", +- "mypcbackup.com", +- "instantcheckmate.com", +- "seemorgh.com", +- "topky.sk", +- "puu.sh", +- "aeriagames.com", +- "whatismyip.com", +- "rising.cn", +- "scotiabank.com", +- "wo.com.cn", +- "yootheme.com", +- "channel4.com", +- "heavy-r.com", +- "omgpm.com", +- "milli.az", +- "bnpparibas.net", +- "vmware.com", +- "diretta.it", +- "skycn.com", +- "sap.com", +- "zyalt.livejournal.com", +- "bookryanair.com", +- "kkbox.com", +- "subtitleseeker.com", +- "abckj123.com", +- "mashreghnews.ir", +- "websitewelcome.com", +- "2ch-c.net", +- "health.com", +- "uproxx.com", +- "uast.ac.ir", +- "bol.uol.com.br", +- "feedsportal.com", +- "ip-adress.com", +- "sedty.com", +- "ilsistemabinario.com", +- "nabble.com", +- "hightail.com", +- "superjob.ru", +- "tokyo.jp", +- "hrblock.com", +- "china.cn", +- "tsetmc.com", +- "unfranchise.com.tw", +- "bhg.com", +- "htmlbook.ru", +- "stardoll.com", +- "crictime.com", +- "hsn.com", +- "royalmail.com", +- "globallshare.com", +- "wikiwiki.jp", +- "petardas.com", +- "usembassy.gov", +- "rakuten-bank.co.jp", +- "golem.de", +- "stepstone.de", +- "aucfan.com", +- "stubhub.com", +- "rbcdaily.ru", +- "ro2.biz", +- "huffingtonpost.ca", +- "timeout.com", +- "digitalspy.co.uk", +- "foreningssparbanken.se", +- "autodesk.com", +- "98ia.com", +- "gtbank.com", +- "runetki.com", +- "freshdesk.com", +- "ieee.org", +- "getpocket.com", +- "jutarnji.hr", +- "caisse-epargne.fr", +- "profitcentr.com", +- "51.com", +- "oi.com.br", +- "sina.com.tw", +- "fontspace.com", +- "dynamicdrive.com", +- "maduradas.com", +- "ligtv.com.tr", +- "sport24.gr", +- "stargazete.com", +- "bola.net", +- "template-help.com", +- "codecademy.com", +- "officedepot.com", +- "researchgate.net", +- "17u.com", +- "gfxtra.com", +- "weiphone.com", +- "shoutmeloud.com", +- "hc360.com", +- "lintas.me", +- "mk.ru", +- "wplocker.com", +- "thumbtack.com", +- "szn.cz", +- "yatra.com", +- "societegenerale.fr", +- "wyborcza.pl", +- "demotywatory.pl", +- "thomann.de", +- "imperiaonline.org", +- "magento.com", +- "skillpages.com", +- "cam4ads.com", +- "spiceworks.com", +- "homestead.com", +- "locanto.in", +- "hotelurbano.com", +- "sinaimg.cn", +- "chetxia.com", +- "menshealth.com", +- "ideacellular.com", +- "snopes.com", +- "newgrounds.com", +- "autosottocosto.com", +- "admob.com", +- "linguee.fr", +- "net-a-porter.com", +- "text.ru", +- "sharebeast.com", +- "televisionfanatic.com", +- "netlog.com", +- "lufthansa.com", +- "ngoisao.net", +- "3911.net", +- "worldssl.net", +- "rabobank.nl", +- "lvmama.com", +- "sharethis.com", +- "sambaporno.com", +- "mci.ir", +- "inosmi.ru", +- "joyreactor.cc", +- "cartfill.in", +- "cooltext.com", +- "qz.com", +- "onthe.io", +- "citilink.ru", +- "apartmenttherapy.com", +- "lloydsbank.com", +- "metroer.com", +- "koyotesoft.com", +- "subdivx.com", +- "alriyadh.com", +- "backlinkwatch.com", +- "coindesk.com", +- "porntube1.xxx", +- "zovi.com", +- "thestreet.com", +- "rtbstream.com", +- "etnet.com.hk", +- "creditkarma.com", +- "lifebuzz.com", +- "opodo.co.uk", +- "developpez.net", +- "tinydeal.com", +- "nature.com", +- "oxforddictionaries.com", +- "anchorfree.net", +- "tn.com.ar", +- "findicons.com", +- "joomlart.com", +- "hmrc.gov.uk", +- "btc-e.com", +- "extra.com.br", +- "ad.nl", +- "megafon.ru", +- "qafqazinfo.az", +- "shahvani.com", +- "googlecode.com", +- "milliyet.tv", +- "deadline.com", +- "grindtv.com", +- "logitech.com", +- "nzherald.co.nz", +- "ninisite.com", +- "webgains.com", +- "oschina.net", +- "webmasters.ru", +- "filmix.net", +- "seowhy.com", +- "met-art.com", +- "discart.ru", +- "keywordblocks.com", +- "vodly.to", +- "redvak.com", +- "tomshardware.co.uk", +- "2shared.com", +- "zoznam.sk", +- "icims.com", +- "virtapay.com", +- "blomaga.jp", +- "wasu.cn", +- "carsensor.net", +- "sportsdirect.com", +- "uservoice.com", +- "livescience.com", +- "gamebase.com.tw", +- "persiangig.com", +- "livesmi.com", +- "eharmony.com", +- "banorte.com", +- "radiojavan.com", +- "startv.com.tr", +- "coolmath-games.com", +- "downloadquick.net", +- "worldoftanks.eu", +- "filelist.ro", +- "fontsquirrel.com", +- "superpages.com", +- "yolasite.com", +- "funnie.st", +- "51cto.com", +- "goo-net.com", +- "builtwith.com", +- "shaparak.ir", +- "nuomi.com", +- "omegle.com", +- "poringa.net", +- "lan.com", +- "desi-tashan.com", +- "shabdkosh.com", +- "freedigitalphotos.net", +- "betradar.com", +- "womenshealthmag.com", +- "realsimple.com", +- "maxbounty.com", +- "bbva.es", +- "sweetpacks.com", +- "pinoy-ako.info", +- "jobstreet.com", +- "cafe24.com", +- "goldenbirds.biz", +- "anandtech.com", +- "mapion.co.jp", +- "rawstory.com", +- "streamate.com", +- "celebuzz.com", +- "freepornvs.com", +- "divyabhaskar.co.in", +- "lifehack.org", +- "holidaycheck.de", +- "quizlet.com", +- "zhibo8.cc", +- "askmefast.com", +- "manageflitter.com", +- "campaign-archive2.com", +- "cityheaven.net", +- "uniqlo.com", +- "seoclerks.com", +- "tecmundo.com.br", +- "the-binary-options-guide.com", +- "gigaom.com", +- "mywot.com", +- "playcast.ru", +- "tatadocomo.com", +- "csfd.cz", +- "ganool.com", +- "kaschpo.ru", +- "webdunia.com", +- "philly.com", +- "doctoroz.com", +- "jumei.com", +- "poponclick.com", +- "rueducommerce.fr", +- "fararu.com", +- "po.st", +- "nextag.com", +- "manhunt.net", +- "sistrix.com", +- "woman.ru", +- "appbank.net", +- "iobit.com", +- "joins.com", +- "vidtomp3.com", +- "un.org", +- "volusion.com", +- "lipsum.com", +- "afkarnews.ir", +- "goldenline.pl", +- "clickansave.net", +- "softgozar.com", +- "thefind.com", +- "mozzi.com", +- "wenxuecity.com", +- "up2c.com", +- "searchfunmoods.com", +- "cabelas.com", +- "coffetube.com", +- "otto.de", +- "webalta.ru", +- "tataindicom.com", +- "ctvnews.ca", +- "inlinkz.com", +- "kajabi.com", +- "greatergood.com", +- "whmcs.com", +- "telekom.de", +- "christianpost.com", +- "fiducia.de", +- "bancsabadell.com", +- "pirateproxy.net", +- "woobox.com", +- "google.cm", +- "noulinx.com", +- "nick.com", +- "moviehuts.com", +- "mvideo.ru", +- "couchtuner.eu", +- "wyborcza.biz", +- "tradeindia.com", +- "girlsgogames.com", +- "healthcare.gov", +- "videolan.org", +- "sky.it", +- "tuniu.com", +- "ime.nu", +- "n4g.com", +- "cyberforum.ru", +- "justin.tv", +- "createspace.com", +- "joemonster.org", +- "registro.br", +- "elkhabar.com", +- "open24news.tv", +- "irr.ru", +- "sanjesh.org", +- "standardbank.co.za", +- "neogaf.com", +- "doyo.cn", +- "am15.net", +- "ana.co.jp", +- "amd.com", +- "gidonlinekino.com", +- "sitetalk.com", +- "nesn.com", +- "arabseed.com", +- "ingbank.pl", +- "webpronews.com", +- "saavn.com", +- "yourdictionary.com", +- "mobile9.com", +- "jagranjosh.com", +- "www.net.cn", +- "computerbase.de", +- "3djuegos.com", +- "htc.com", +- "the-binary-theorem.com", +- "google.com.np", +- "n11.com", +- "vivastreet.com", +- "mthai.com", +- "seomastering.com", +- "mercadolibre.cl", +- "searchmetrics.com", +- "mentalfloss.com", +- "russia.tv", +- "ubi.com", +- "dwnews.com", +- "ecplaza.net", +- "trafficfactory.biz", +- "loopnet.com", +- "refinery29.com", +- "minecraftforum.net", +- "moviefone.com", +- "bom.gov.au", +- "google.com.bh", +- "eltiempo.es", +- "cuantarazon.com", +- "2258.com", +- "google.ee", +- "nwolb.com", +- "bezaat.com", +- "eelly.com", +- "icmwebserv.com", +- "techsmith.com", +- "timeweb.ru", +- "johnlewis.com", +- "independent.ie", +- "bankia.es", +- "dkb.de", +- "gilt.com", +- "duolingo.com", +- "3file.info", +- "cam4.de.com", +- "pcanalysis.net", +- "br.de", +- "vodlocker.com", +- "adfoc.us", +- "ymlp.com", +- "dailyfx.com", +- "business2community.com", +- "banki.ru", +- "yell.com", +- "smartresponder.ru", +- "yaske.to", +- "bokra.net", +- "mercadolibre.com", +- "viewster.com", +- "recipesfinder.com", +- "rei.com", +- "dogpile.com", +- "caf.fr", +- "sbrf.ru", +- "soha.vn", +- "voila.fr", +- "rp-online.de", +- "members.webs.com", +- "duvamis.com", +- "nazwa.pl", +- "google.com.ni", +- "ilovemobi.com", +- "retrogamer.com", +- "blogtalkradio.com", +- "utexas.edu", +- "sonyentertainmentnetwork.com", +- "dr.dk", +- "jjwxc.net", +- "service-public.fr", +- "care2.com", +- "musavat.com", +- "h12-media.com", +- "smartfren.com", +- "immowelt.de", +- "discuz.net", +- "m1905.com", +- "cas.sk", +- "bitcoinwisdom.com", +- "monografias.com", +- "mindbodygreen.com", +- "getfirebug.com", +- "godlikeproductions.com", +- "mydrivers.com", +- "voc.com.cn", +- "truecaller.com", +- "livemook.com", +- "i8ti.com", +- "agame.com", +- "kurir-info.rs", +- "urbanoutfitters.com", +- "shopping.uol.com.br", +- "2ip.ru", +- "91.com", +- "banquepopulaire.fr", +- "rappler.com", +- "mint.com", +- "jz123.cn", +- "zurb.com", +- "sport.cz", +- "justunfollow.com", +- "billionuploads.com", +- "thaivisa.com", +- "seitwert.de", +- "ciudad.com.ar", +- "archdaily.com", +- "jalopnik.com", +- "1news.az", +- "dailyfinance.com", +- "okitspace.com", +- "dn.se", +- "el-nacional.com", +- "larousse.fr", +- "mojo-themes.com", +- "draugiem.lv", +- "teamtreehouse.com", +- "xiu.com", +- "ennaharonline.com", +- "oricon.co.jp", +- "openoffice.org", +- "tny.cz", +- "forumfree.it", +- "youthwant.com.tw", +- "khamsat.com", +- "vitacost.com", +- "alrakoba.net", +- "marmiton.org", +- "yebhi.com", +- "the-binary-trader.biz", +- "dominos.com", +- "dice.com", +- "like4like.org", +- "tvmuse.com", +- "standardchartered.com", +- "bitbucket.org", +- "driveropti.net", +- "google.hn", +- "indiblogger.in", +- "torrenthound.com", +- "wolframalpha.com", +- "experienceproject.com", +- "nsw.gov.au", +- "olx.pt", +- "sciencedaily.com", +- "viglink.com", +- "plala.or.jp", +- "sxsw.com", +- "mileroticos.com", +- "namejet.com", +- "1hai.cn", +- "skroutz.gr", +- "bilibili.tv", +- "travelzoo.com", +- "saksfifthavenue.com", +- "get-a-fuck-tonight.com", +- "barclaycardus.com", +- "withgoogle.com", +- "whitehouse.gov", +- "oprah.com", +- "fishwrapper.com", +- "softbank.jp", +- "slutload.com", +- "latercera.cl", +- "100bestbuy.com", +- "nur.kz", +- "topit.me", +- "computerhope.com", +- "snob.ru", +- "rackcdn.com", +- "3158.cn", +- "artlebedev.ru", +- "yobt.com", +- "rai.it", +- "hs.fi", +- "tinhte.vn", +- "fotocasa.es", +- "nyu.edu", +- "dawn.com", +- "series.ly", +- "movshare.net", +- "fineartamerica.com", +- "westernunion.com", +- "leaseweb.com", +- "wayn.com", +- "ivi.ru", +- "bloomingdales.com", +- "pons.com", +- "rapidtrk.com", +- "bama.ir", +- "hackforums.net", +- "dfiles.eu", +- "intercambiosvirtuales.org", +- "sdo.com", +- "homes.com", +- "colissimo.fr", +- "discuss.com.hk", +- "afreeca.com", +- "rbc.ua", +- "novamov.com", +- "jungle.gr", +- "iol.co.za", +- "btcclicks.com", +- "mapsofindia.com", +- "propellerads.com", +- "fab.com", +- "princeton.edu", +- "reliancebroadband.co.in", +- "xdf.cn", +- "mako.co.il", +- "protothema.gr", +- "booloo.com", +- "livrariasaraiva.com.br", +- "efukt.com", +- "acrobat.com", +- "globovision.com", +- "xero.com", +- "sevenforums.com", +- "semalt.com", +- "audiojungle.net", +- "e1.ru", +- "quoka.de", +- "chinaiiss.com", +- "gonzoxxxmovies.com", +- "wallpaperswide.com", +- "fapvid.com", +- "trk4.com", +- "forosdelweb.com", +- "fark.com", +- "my.tv.sohu.com/user/video", +- "kaixin001.com", +- "ntvspor.net", +- "mobafire.com", +- "zigwheels.com", +- "filmifullizle.com", +- "8tracks.com", +- "readmanga.eu", +- "lelong.com.my", +- "planetromeo.com", +- "192.com", +- "republika.co.id", +- "in.gr", +- "televisao.uol.com.br", +- "kalerkantho.com", +- "usairways.com", +- "malaysiakini.com", +- "anonymouse.org", +- "xxxhost.me", +- "stuff.co.nz", +- "dek-d.com", +- "bbvanet.com.mx", +- "watchseries-online.eu", +- "malaysiaairlines.com", +- "policymic.com", +- "serviporno.com", +- "aprod.hu", +- "gelocal.it", +- "tradetracker.com", +- "cibc.com", +- "umich.edu", +- "smartshe.com", +- "sony.jp", +- "taobaocdn.com", +- "bestgfx.biz", +- "irib.ir", +- "aliimg.com", +- "esuteru.com", +- "healthline.com", +- "cnnamador.com", +- "sat.gob.mx", +- "childsafedownloadx.asia", +- "playmillion.com", +- "strawberrynet.com", +- "alnilin.com", +- "trustedreviews.com", +- "21cn.com", +- "persianv.com", +- "baomoi.com", +- "firestorage.jp", +- "google.co.ke", +- "admaimai.com", +- "sbnlife.com", +- "surveyrouter.com", +- "megaindex.ru", +- "intodns.com", +- "yiqifa.com", +- "mixcloud.com", +- "softonic.fr", +- "bakecaincontrii.com", +- "payu.in", +- "rakuten-card.co.jp", +- "almaany.com", +- "grantland.com", +- "ricardo.ch", +- "heavy.com", +- "niusnews.com", +- "canstockphoto.com", +- "acunn.com", +- "diythemes.com", +- "canalrcnmsn.com", +- "ngs.ru", +- "rassd.com", +- "groupon.co.in", +- "depositfiles.org", +- "mango.com", +- "theregister.co.uk", +- "worldfree4u.com", +- "f-lite.ru", +- "boingboing.net", +- "bangbros.com", +- "neteller.com", +- "tonicmovies.com", +- "p2up.ir", +- "cartoonnetwork.com", +- "lun.com", +- "nk.pl", +- "webry.info", +- "burningcamel.com", +- "mplife.com", +- "nationalreview.com", +- "williamhill.es", +- "sssc.cn", +- "col3negoriginal.lk", +- "yoast.com", +- "svyaznoy.ru", +- "chengdu.cn", +- "listverse.com", +- "lastminute.com", +- "guardianlv.com", +- "39yst.com", +- "bahseazad.ir", +- "debian.org", +- "tokyo-porn-tube.com", +- "ilbe.com", +- "upsocl.com", +- "balatarin.com", +- "charter97.org", +- "wpexplorer.com", +- "immi.gov.au", +- "yokamen.cn", +- "esmas.com", +- "hbr.org", +- "livechatinc.com", +- "crazyegg.com", +- "palcomp3.com", +- "calottery.com", +- "wistia.com", +- "locaweb.com.br", +- "techspot.com", +- "bit.ly", +- "yammer.com", +- "uscis.gov", +- "bramjnet.com", +- "linio.com.mx", +- "tharunaya.co.uk", +- "desirulez.net", +- "madmimi.com", +- "everydayhealth.com", +- "secondlife.com", +- "ceskatelevize.cz", +- "enter.ru", +- "glopart.ru", +- "woso.cn", +- "pitlap.info", +- "worldoftanks.com", +- "videarn.com", +- "dafiti.com.br", +- "segundamano.mx", +- "eamroomsnacks.com", +- "vulture.com", +- "humblebundle.com", +- "rockstargames.com", +- "wsodownloads.info", +- "yazete.com", +- "pcadvisor.co.uk", +- "07073.com", +- "modcloth.com", +- "attracta.com", +- "iol.pt", +- "travideos.com", +- "sparkpeople.com", +- "rankingsandreviews.com", +- "entekhab.ir", +- "goarticles.com", +- "wonderhowto.com", +- "kankanews.com", +- "rzb.ir", +- "p30download.com", +- "infojobs.it", +- "socialspark.com", +- "picstopin.com", +- "celebritynetworth.com", +- "tweakers.net", +- "gi-backoffice.com", +- "isbank.com.tr", +- "qiyou.com", +- "templatic.com", +- "cyberpresse.ca", +- "consumerreports.org", +- "focalprice.com", +- "linkpad.ru", +- "svd.se", +- "desitvforum.net", +- "bulbagarden.net", +- "showup.tv", +- "webgozar.com", +- "3dnews.ru", +- "spyfu.com", +- "bikhir.ma", +- "trovaprezzi.it", +- "autov.com.cn", +- "podnapisi.net", +- "tocmai.ro", +- "realitatea.net", +- "geico.com", +- "joydownload.com", +- "kddi.com", +- "unbounce.com", +- "meb.gov.tr", +- "anchorfree.us", +- "gumtree.pl", +- "dbs.com", +- "ebayimg.com", +- "ptcsolution.com", +- "clip.dj", +- "samplicio.us", +- "47news.jp", +- "todo1.com", +- "anspress.com", +- "24sata.hr", +- "cineblog01.tv", +- "sport-fm.gr", +- "unetenet.com", +- "tenki.jp", +- "jia.com", +- "filefactory.com", +- "onedio.com", +- "gendai.net", +- "nickjr.com", +- "finviz.com", +- "bytes.com", +- "inkthemes.com", +- "oriflame.com", +- "aporrea.org", +- "mazika2day.com", +- "baimao.com", +- "logme.in", +- "downloadactivate.com", +- "vista.ir", +- "duowan.com", +- "sinaapp.com", +- "proceso.com.mx", +- "xxxconnect.com", +- "dvdvideosoft.com", +- "nomorerack.com", +- "almubasher.com.sa", +- "afisha.ru", +- "clicksure.com", +- "11st.co.kr", +- "turkishairlines.com", +- "freekaamaal.com", +- "findwide.com", +- "sbisec.co.jp", +- "mythemeshop.com", +- "webnode.com", +- "cumhuriyet.com.tr", +- "morningstar.com", +- "trafficshop.com", +- "gopro.com", +- "jeevansathi.com", +- "dasoertliche.de", +- "markets.com", +- "absa.co.za", +- "ikman.lk", +- "fmworld.net", +- "hyatt.com", +- "virgin-atlantic.com", +- "tfl.gov.uk", +- "immonet.de", +- "haodf.com", +- "thewrap.com", +- "appgame.com", +- "hdwallpapers.in", +- "canon.com", +- "newsle.com", +- "jorudan.co.jp", +- "pcwelt.de", +- "coinbase.com", +- "yourgirlfriends.com", +- "djmaza.info", +- "findagrave.com", +- "lainformacion.com", +- "teacup.com", +- "ezilon.com", +- "redbubble.com", +- "guru.com", +- "brothersoft.com", +- "coinmarketcap.com", +- "mediabistro.com", +- "elfagr.org", +- "glavcom.ua", +- "jino.ru", +- "1e100.net", +- "g9g.com", +- "join.me", +- "ynet.com", +- "news247.gr", +- "rcom.co.in", +- "baby.ru", +- "argentglobalnetwork.com", +- "hsselite.com", +- "foxbusiness.com", +- "cookmates.com", +- "lidl.de", +- "timesofindia.com", +- "fakt.pl", +- "bgr.com", +- "ghatreh.com", +- "woxikon.de", +- "pontofrio.com.br", +- "gizmag.com", +- "signup.wordpress.com", +- "tre.it", +- "gardenweb.com", +- "alfalfalfa.com", +- "prcm.jp", +- "freemail.hu", +- "iteye.com", +- "katproxy.com", +- "kickassunblock.info", +- "wisegeek.com", +- "zaobao.com", +- "vpsdomain4.eu", +- "naij.com", +- "olx.co.za", +- "mihanstore.org", +- "gezinti.com", +- "vistaprint.in", +- "dastelefonbuch.de", +- "blackhatteam.com", +- "yummly.com", +- "minecraft.net", +- "justcloud.com", +- "biblehub.com", +- "argentinawarez.com", +- "gandul.info", +- "trialpay.com", +- "paruvendu.fr", +- "khanacademy.org", +- "topsy.com", +- "angelfire.com", +- "nseindia.com", +- "seositecheckup.com", +- "hostelworld.com", +- "zalukaj.tv", +- "animeflv.net", +- "laptopmag.com", +- "tripadvisor.de", +- "sec.gov", +- "tripadvisor.es", +- "oreilly.com", +- "kanald.com.tr", +- "halifax-online.co.uk", +- "extremetracking.com", +- "reimageplus.com", +- "jal.co.jp", +- "vuiviet.net", +- "yeslibertin.com", +- "pichunter.com", +- "empowernetwork.com/aI3zkH7s3g6tZH8TDmh8LA==", +- "reforma.com", +- "singlessalad.com", +- "upenn.edu", +- "1ting.com", +- "hsbc.com.mx", +- "sulia.com", +- "yepporn.com", +- "scrubtheweb.com", +- "e-autopay.com", +- "rechargeitnow.com", +- "ppomppu.co.kr", +- "zemtv.com", +- "gofeminin.de", +- "peoplestylewatch.com", +- "france24.com", +- "comodo.com", +- "openmace.net", +- "maultalk.com", +- "fancy.com", +- "vodafone.it", +- "pokerstrategy.com", +- "crunchyroll.com", +- "aipai.com", +- "3dcartstores.com", +- "leancy.com", +- "myblogguest.com", +- "papajohns.com", +- "tuolar.com", +- "junkmail.co.za", +- "nyc.gov", +- "rentalcars.com", +- "sovsport.ru", +- "marketo.com", +- "smbc.co.jp", +- "yale.edu", +- "pitchfork.com", +- "thetoptens.com", +- "joyme.com", +- "linuxquestions.org", +- "htmlgoodies.com", +- "laredoute.fr", +- "0427d7.se", +- "journaldesfemmes.com", +- "xici.net", +- "alwafd.org", +- "daniweb.com", +- "mtgox.com", +- "jetstar.com", +- "plotek.pl", +- "jobvite.com", +- "adage.com", +- "aukro.cz", +- "ford.com", +- "problogger.net", +- "518.com.tw", +- "blogbigtime.com", +- "nieuwsblad.be", +- "register.com", +- "24tv.ua", +- "aftenposten.no", +- "weightwatchers.com", +- "smartpassiveincome.com", +- "radiosvoboda.org", +- "web.com", +- "caixin.com", +- "digitalmarketer.com", +- "soup.io", +- "soft98.ir", +- "muzofon.com", +- "gao7.com", +- "freefilmshd.com", +- "hsbc.com", +- "xhamsterhq.com", +- "my.tv.sohu.com/user/reg", +- "trade65.com", +- "chow.com", +- "google.com.kh", +- "inps.it", +- "seesaa.jp", +- "hoovers.com", +- "peru21.pe", +- "sdpnoticias.com", +- "schema.org", +- "linode.com", +- "theknot.com", +- "blesk.cz", +- "google.ci", +- "loltrk.com", +- "vod.pl", +- "geenstijl.nl", +- "moneymakergroup.com", +- "tupaki.com", +- "huvrtech.com", +- "metafilter.com", +- "jumia.com.ng", +- "newsvine.com", +- "mylant.com", +- "accenture.com", +- "feedjit.com", +- "twipple.jp", +- "getgoodlinks.ru", +- "radiofarda.com", +- "informador.com.mx", +- "wisc.edu", +- "windows.net", +- "zamzar.com", +- "nationalpost.com", +- "epnet.com", +- "naaptol.com", +- "x-art.com", +- "ebookbrowsee.net", +- "marketingland.com", +- "thedailyshow.com", +- "s-oman.net", +- "theme-fusion.com", +- "immobiliare.it", +- "allvoices.com", +- "adroll.com", +- "francetvinfo.fr", +- "callandput.com", +- "entireweb.com", +- "instructure.com", +- "megacinema.fr", +- "djelfa.info", +- "flightaware.com", +- "magazineluiza.com.br", +- "ighome.com", +- "mature-beauty.com", +- "yuku.com", +- "peerfly.com", +- "hardware.fr", +- "dcinside.com", +- "telerik.com", +- "pengpeng.com", +- "gazetaexpress.com", +- "publico.es", +- "nwsource.com", +- "oneandone.co.uk", +- "qoo10.sg", +- "aboutus.org", +- "adsupplyads.com", +- "wa.gov", +- "google.co.cr", +- "benchmarkemail.com", +- "valuedealshopper.com", +- "hola.com", +- "mizuhobank.co.jp", +- "zzstream.li", +- "kriesi.at", +- "exist.ru", +- "nvidia.com", +- "giallozafferano.it", +- "jusbrasil.com.br", +- "konga.com", +- "avclub.com", +- "reed.co.uk", +- "advertig.com", +- "ripoffreport.com", +- "gooddrama.net", +- "pornyaz.com", +- "budsgunshop.com", +- "78.cn", +- "livesurf.ru", +- "99114.com", +- "pornorama.com", +- "marksandspencer.com", +- "vmall.com", +- "fatcow.com", +- "mylife.com", +- "irishtimes.com", +- "medicalnewstoday.com", +- "uiuc.edu", +- "groupon.it", +- "washington.edu", +- "addictinggames.com", +- "anonymz.com", +- "kindgirls.com", +- "jne.co.id", +- "guiamais.com.br", +- "lyricsfreak.com", +- "uloz.to", +- "tagesanzeiger.ch", +- "fashionandyou.com", +- "bollywoodhungama.com", +- "nationwide.co.uk", +- "kboing.com.br", +- "python.org", +- "theladbible.com", +- "eurosport.com", +- "webinarjam.com", +- "theme.wordpress.com", +- "myfxbook.com", +- "allwomenstalk.com", +- "ucla.edu", +- "opendns.com", +- "pornbb.org", +- "money.pl", +- "domain.com.au", +- "standaard.be", +- "wanelo.com", +- "express.co.uk", +- "exam8.com", +- "zum.com", +- "amtrak.com", +- "boots.com", +- "800notes.com", +- "fabfurnish.com", +- "amoureux.com", +- "ebizmba.com", +- "ujian.cc", +- "stargames.at", +- "panasonic.com", +- "ge.tt", +- "scout.com", +- "tiexue.net", +- "nanapi.jp", +- "eclipse.org", +- "searchquotes.com", +- "wetplace.com", +- "lpcloudbox300.com", +- "hollyscoop.com", +- "bdjobs.com", +- "larepublica.pe", +- "hizliresim.com", +- "yepme.com", +- "bitcoincharts.com", +- "bsnl.co.in", +- "ucwan87.net", +- "tianji.com", +- "hgtv.com", +- "cleanfiles.net", +- "moonsy.com", +- "tomsguide.com", +- "datpiff.com", +- "net.hr", +- "orange.pl", +- "bankrate.com.cn", +- "mafiashare.net", +- "giaoduc.net.vn", +- "sucuri.net", +- "ringcentral.com", +- "gamingwonderland.com", +- "freenet.de", +- "cian.ru", +- "gayboystube.com", +- "gog.com", +- "gruenderszene.de", +- "econsultancy.com", +- "aktuality.sk", +- "webrankstats.com", +- "j-cast.com", +- "popsugar.com", +- "mr-guangdong.com", +- "on.cc", +- "jb51.net", +- "lamoda.ru", +- "sprashivai.ru", +- "animoto.com", +- "winzip.com", +- "vanityfair.com", +- "svt.se", +- "noyapps.com", +- "mnn.com", +- "lancenet.com.br", +- "e-monsite.com", +- "gazeta.ua", +- "cari.com.my", +- "coub.com", +- "veoh.com", +- "kienthuc.net.vn", +- "eldorado.ru", +- "overclock.net", +- "meetic.fr", +- "tam.com.br", +- "alfemminile.com", +- "telmex.com", +- "newsbomb.gr", +- "funda.nl", +- "netcoc.com", +- "bhinneka.com", +- "layalina.com", +- "clubpenguin.com", +- "talktalk.co.uk", +- "dumpert.nl", +- "almastba.com", +- "clker.com", +- "adweek.com", +- "gigya.com", +- "disponivel.uol.com.br", +- "tomoson.com", +- "w.org", +- "rfi.fr", +- "imgbox.com", +- "omniture.com", +- "n24.de", +- "webdesignrazzi.com", +- "medscape.com", +- "playboy.com", +- "usda.gov", +- "cuevana.tv", +- "trenitalia.com", +- "explosm.net", +- "mail.uol.com.br", +- "delfi.lv", +- "elektroda.pl", +- "hulkshare.com", +- "kotak.com", +- "gi-akademie.ning.com", +- "yelp.de", +- "lrytas.lt", +- "couchsurfing.org", +- "drugstore.com", +- "ssa.gov", +- "seriescoco.com", +- "iran-tejarat.com", +- "hafiz.gov.sa", +- "intellicast.com", +- "sub.jp", +- "paginasamarillas.es", +- "anime44.com", +- "babyschool.com.cn", +- "advertisernets.com", +- "vpsdomain2.eu", +- "arcor.de", +- "video2mp3.net", +- "marthastewart.com", +- "hawahome.com", +- "articlesbase.com", +- "spanishdict.com", +- "meilishuo.com", +- "grammarly.com", +- "sportlemon.tv", +- "zend.com", +- "bigideamastermind.com", +- "hawaaworld.com", +- "pagseguro.uol.com.br", +- "keywordspy.com", +- "7search.com", +- "cnki.net", +- "aamaadmiparty.org", +- "javaplayer.info", +- "sidereel.com", +- "azcentral.com", +- "passportindia.gov.in", +- "memurlar.net", +- "bouyguestelecom.fr", +- "buenastareas.com", +- "ernmoneynow.com", +- "eurosport.ru", +- "blog.163.com", +- "pizzahut.com", +- "bossip.com", +- "webdeveloper.com", +- "add-anime.net", +- "pimptubed.com", +- "movistar.es", +- "megashare.sh", +- "empireavenue.com", +- "btemplates.com", +- "amkspor.com", +- "payza.com", +- "farfesh.com", +- "mcgraw-hill.com", +- "motor-talk.de", +- "purepeople.com", +- "i-gamer.net", +- "sotmarket.ru", +- "anthropologie.com", +- "google.org", +- "rai.tv", +- "wikidot.com", +- "canoe.ca", +- "orange.es", +- "umn.edu", +- "emag.ro", +- "webutations.org", +- "ykb.com", +- "canadapost.ca", +- "zhubajie.com", +- "nextcar.cn", +- "next.co.uk", +- "freemovie-hd.com", +- "telegraf.com.ua", +- "ajc.com", +- "xsrv.jp", +- "vanguard.com", +- "mybroadband.co.za", +- "999120.net", +- "panet.co.il", +- "bellemaison.jp", +- "fonearena.com", +- "playvid.com", +- "purdue.edu", +- "thesuperficial.com", +- "114so.cn", +- "irna.ir", +- "websitetonight.com", +- "edublogs.org", +- "provincial.com", +- "jahaniha.com", +- "heroturko.me", +- "dynadot.com", +- "txtsrving.info", +- "adclickxpress.com", +- "sammobile.com", +- "ebay.at", +- "yaplog.jp", +- "imtranslator.net", +- "fotor.com", +- "myvidster.com", +- "williamhill.it", +- "argaam.com", +- "zoomby.ru", +- "tcsbank.ru", +- "origin.com", +- "vov.vn", +- "wrapbootstrap.com", +- "imvu.com", +- "fbsbx.com", +- "elcorteingles.es", +- "cerdas.com", +- "google.com.om", +- "dramasonline.com", +- "businesswire.com", +- "serpbook.com", +- "santanderrio.com.ar", +- "meta.ua", +- "kenhgioitre.com", +- "watchcartoononline.com", +- "athome.co.jp", +- "2checkout.com", +- "moheet.com", +- "jeu.info", +- "ankieta-online.pl", +- "triberr.com", +- "wordtracker.com", +- "blogher.com", +- "colourlovers.com", +- "maalaimalar.com", +- "bakeca.it", +- "thepostgame.com", +- "beget.ru", +- "abebooks.com", +- "certified-toolbar.com", +- "publico.pt", +- "footmercato.net", +- "indiabix.com", +- "zakzak.co.jp", +- "hotfile.com", +- "virustotal.com", +- "usgs.gov", +- "tukif.com", +- "banglamail24.com", +- "graphicstock.com", +- "svpressa.ru", +- "sanalpazar.com", +- "logsoku.com", +- "loteriasyapuestas.es", +- "youjizzlive.com", +- "all-inkl.com", +- "arcot.com", +- "blogspot.fi", +- "inbox.lv", +- "anno-online.com", +- "tikona.in", +- "newsru.ua", +- "centerblog.net", +- "jahannews.com", +- "joxi.ru", +- "proxybay.eu", +- "2gis.ru", +- "indeed.fr", +- "novayagazeta.ru", +- "intelius.com", +- "hosteurope.de", +- "autoscout24.it", +- "postjoint.com", +- "pulsk.com", +- "biobiochile.cl", +- "homevv.com", +- "zapbux.com", +- "gsp.ro", +- "priyo.com", +- "jamnews.ir", +- "addtoany.com", +- "lookbook.nu", +- "e-travel.com", +- "themelock.com", +- "bestsocialfeed.com", +- "eqla3.com", +- "klm.com", +- "realtor.ca", +- "tv2.no", +- "jqueryrain.com", +- "seo-fast.ru", +- "academic.ru", +- "clicksia.com", +- "lpcloudbox30.com", +- "worldpay.com", +- "gogoanime.com", +- "photoshelter.com", +- "mlive.com", +- "wetteronline.de", +- "jkforum.net", +- "secure.ipage.com", +- "antena3.com", +- "elsevier.com", +- "thaiseoboard.com", +- "addic7ed.com", +- "rookee.ru", +- "jstor.org", +- "rajanews.com", +- "uline.com", +- "o2online.de", +- "fbdownloader.com", +- "wetpaint.com", +- "nnm.me", +- "50onred.com", +- "tvtropes.org", +- "philips.com", +- "watchseries.to", +- "perfectinter.net", +- "progressive.com", +- "stcn.com", +- "golsearch.com", +- "sarayanews.com", +- "screenrant.com", +- "macworld.com", +- "classifiedads.com", +- "ip138.com", +- "izlesene.com", +- "ovguide.com", +- "gametop.com", +- "urlm.co", +- "isitdownrightnow.com", +- "redhat.com", +- "stafaband.info", +- "biglion.ru", +- "twitterfeed.com", +- "ttnet.com.tr", +- "panasonic.jp", +- "loc.gov", +- "telstra.com.au", +- "jiathis.com", +- "perfil.com.ar", +- "inquisitr.com", +- "ratp.fr", +- "libertaddigital.com", +- "bni.co.id", +- "ycombinator.com", +- "paginegialle.it", +- "momoshop.com.tw", +- "theweek.com", +- "tuoitre.vn", +- "scriptmafia.org", +- "megavod.fr", +- "indiavisiontv.com", +- "history.com", +- "flyeralarm.com", +- "salespider.com", +- "ard.de", +- "dslreports.com", +- "tokyo-tube.com", +- "brazzersnetwork.com", +- "bonanza.com", +- "storenvy.com", +- "37signals.com", +- "jxnews.com.cn", +- "1sale.com", +- "allanalpass.com", +- "yiiframework.com", +- "kimsufi.com", +- "nastygal.com", +- "immoral.jp", +- "icq.com", +- "loxblog.com", +- "jcrew.com", +- "diamond.jp", +- "nissen.co.jp", +- "fxstreet.com", +- "15min.lt", +- "lifo.gr", +- "alef.ir", +- "iis.net", +- "giphy.com", +- "mypopup.ir", +- "bsnl.in", +- "distractify.com", +- "foro20.com", +- "chachaba.com", +- "fx-trend.com", +- "imanhua.com", +- "playxn.com", +- "gocomics.com", +- "lcl.fr", +- "hsw.cn", +- "ellislab.com", +- "persiantools.com", +- "coupondunia.in", +- "fengniao.com", +- "coinmill.com", +- "freelancer.in", +- "blogdetik.com", +- "data.com", +- "trafficjunky.net", +- "neverblue.com", +- "flvto.com", +- "lijit.com", +- "zaycev.net", +- "salamnews.org", +- "siliconrus.com", +- "dv37.com", +- "conrad.de", +- "ascii.jp", +- "yesfreeporn.com", +- "globalpost.com", +- "d4000.com", +- "dobreprogramy.pl", +- "hammihan.com", +- "wjunction.com", +- "liverpoolfc.tv", +- "nordea.fi", +- "mail2web.com", +- "songkick.com", +- "comicbookresources.com", +- "jwplayer.com", +- "moi.gov.sa", +- "iranecar.com", +- "kayako.com", +- "listal.com", +- "technet.com", +- "infonews.com", +- "fun698.com", +- "frys.com", +- "vectorstock.com", +- "vbox7.com", +- "leroymerlin.fr", +- "gpotato.eu", +- "gulfnews.com", +- "hot-sex-tube.com", +- "buzzle.com", +- "uludagsozluk.com", +- "onlinefastpaydayloan.com", +- "forumcommunity.net", +- "potins.net", +- "bwin.es", +- "lobstertube.com", +- "katestube.com", +- "endomondo.com", +- "navalny.livejournal.com", +- "wayport.net", +- "dealspl.us", +- "pixhost.org", +- "webopedia.com", +- "flagcounter.com", +- "hotnewhiphop.com", +- "matomy.com", +- "privat24.ua", +- "fuq.com", +- "readserver.net", +- "haiwainet.cn", +- "light-dark.net", +- "decolar.com", +- "tlbb8.com", +- "tomtom.com", +- "fontanka.ru", +- "tchibo.de", +- "slutfinder.com", +- "rbc.cn", +- "pepperfry.com", +- "freshersworld.com", +- "mob.org", +- "brobible.com", +- "phim3s.net", +- "parsiblog.com", +- "link-assistant.com", +- "smotri.com", +- "flyertalk.com", +- "iefimerida.gr", +- "pornyeah.com", +- "trustpilot.com", +- "wowslider.com", +- "sekindo.com", +- "shape.com", +- "pizap.com", +- "bluedart.com", +- "cmu.edu", +- "shueisha.co.jp", +- "royal-search.com", +- "123greetings.com", +- "albawabhnews.com", +- "holiday-weather.com", +- "4travel.jp", +- "lpcloudsvr203.com", +- "panorama.com.ve", +- "htcmania.com", +- "skorer.tv", +- "mymovies.it", +- "fileice.net", +- "1and1.fr", +- "legiaodosherois.com.br", +- "tomsguide.fr", +- "baymirror.com", +- "thesun.co.uk", +- "huffingtonpost.es", +- "61baobao.com", +- "juegos.com", +- "joyclub.de", +- "qatarairways.com", +- "ayosdito.ph", +- "translate.ru", +- "yithemes.com", +- "buyvip.com", +- "pearltrees.com", +- "thinkprogress.org", +- "twitcasting.tv", +- "lusongsong.com", +- "irecommend.ru", +- "aukro.ua", +- "eldiario.es", +- "pop-music.ir", +- "libertytimes.com.tw", +- "themalaysianinsider.com", +- "paddypower.it", +- "delfi.ee", +- "appthemes.com", +- "tdameritrade.com", +- "flashback.org", +- "tubelib.com", +- "claro.com.br", +- "jotform.com", +- "bigresource.com", +- "libsyn.com", +- "sendgrid.com", +- "silikonvadisi.tv", +- "geo.tv", +- "pricegrabber.com", +- "futhead.com", +- "testberichte.de", +- "skybet.com", +- "wpcentral.com", +- "lesnumeriques.com", +- "clientoo.com", +- "mathsisfun.com", +- "expert.ru", +- "maxptp.com", +- "mediaite.com", +- "regions.com", +- "fast-torrent.ru", +- "enlacespepito.com", +- "redtram.com", +- "benesse.ne.jp", +- "jappy.de", +- "wizzair.com", +- "adevarul.ro", +- "mhlw.go.jp", +- "dev-point.com", +- "ibtimes.co.in", +- "coinwarz.com", +- "slidesharecdn.com", +- "classmates.com", +- "tsite.jp", +- "niazerooz.com", +- "jma.go.jp", +- "motherjones.com", +- "easports.com", +- "elbotola.com", +- "tripadvisor.com.au", +- "rozee.pk", +- "vivanuncios.com.mx", +- "lashou.com", +- "theaustralian.com.au", +- "superstarmagazine.com", +- "zedge.net", +- "hardwarezone.com.sg", +- "yyets.com", +- "nowgamez.com", +- "blogspot.ch", +- "gq.com", +- "adidas.com", +- "uyan.cc", +- "dailydot.com", +- "xenforo.com", +- "ilmessaggero.it", +- "state.nj.us", +- "16888.com", +- "searchengines.guru", +- "nascar.com", +- "dnb.no", +- "smosh.com", +- "shinyinnovation.com", +- "who.int", +- "mybet.com", +- "yoo7.com", +- "xrea.com", +- "fotolog.net", +- "smartprix.com", +- "esquire.com", +- "google.com.cy", +- "santander.com.br", +- "realclearpolitics.com", +- "financereports24.com", +- "onlinesoccermanager.com", +- "noticiaaldia.com", +- "kelkoo.com", +- "drakulastream.eu", +- "vodafone.de", +- "bt.dk", +- "greenwichmeantime.com", +- "ufc.com", +- "webstatsdomain.org", +- "taoche.com", +- "thinkgeek.com", +- "caranddriver.com", +- "123-reg.co.uk", +- "translit.ru", +- "w3school.com.cn", +- "zwinky.com", +- "inboxdollars.com", +- "gratka.pl", +- "vecernji.hr", +- "taikang.com", +- "bolshoyvopros.ru", +- "urbita.com", +- "api.ning.com", +- "alltop.com", +- "readwrite.com", +- "medhelp.org", +- "totaljobs.com", +- "accorhotels.com", +- "prom.ua", +- "cuny.edu", +- "livemint.com", +- "berlin.de", +- "blogspot.hk", +- "orkut.com.br", +- "lzjl.com", +- "metric-conversions.org", +- "nationalrail.co.uk", +- "oxu.az", +- "mql5.com", +- "chinaluxus.com", +- "linguee.es", +- "saudiairlines.com", +- "standardmedia.co.ke", +- "alkislarlayasiyorum.com", +- "apk.tw", +- "lesoir.be", +- "whatculture.com", +- "indiewire.com", +- "pccomponentes.com", +- "paytm.in", +- "ebaypartnernetwork.com", +- "haivl.tv", +- "e-junkie.com", +- "tvp.pl", +- "ifilez.org", +- "aristeguinoticias.com", +- "bangkokpost.com", +- "whatmobile.com.pk", +- "prodavalnik.com", +- "arsenal.com", +- "buyma.com", +- "torrentday.com", +- "sammydress.com", +- "blogcu.com", +- "imore.com", +- "shitaraba.com", +- "pasadrexam2014.in", +- "songspk.at", +- "eforosh.com", +- "nocoty.pl", +- "koreus.com", +- "verticalresponse.com", +- "arte.tv", +- "ocnk.net", +- "cryptsy.com", +- "haaretz.com", +- "straitstimes.com", +- "2domains.ru", +- "usnetads.com", +- "pracuj.pl", +- "edreams.it", +- "sba.gov", +- "instabang.com", +- "domainnamesales.com", +- "teensnow.com", +- "visualwebsiteoptimizer.com", +- "blogos.com", +- "santander.com.mx", +- "solidfiles.com", +- "authorstream.com", +- "teslamotors.com", +- "tema.livejournal.com", +- "kolesa.kz", +- "startribune.com", +- "vevo.com", +- "clien.net", +- "3asq.com", +- "tvnet.lv", +- "mouthshut.com", +- "binary-machine.com", +- "adultwork.com", +- "hypebeast.com", +- "itrack.it", +- "network-tools.com", +- "brandsoftheworld.com", +- "comedycentral.com", +- "hotscripts.com", +- "meristation.com", +- "rlsbb.com", +- "uzai.com", +- "volkskrant.nl", +- "terra.com.mx", +- "howtoforge.com", +- "178.com", +- "wickedfire.com", +- "dilandau.eu", +- "seriales.us", +- "xataka.com", +- "hktdc.com", +- "express.pk", +- "surfcanyon.com", +- "buildhr.com", +- "ouest-france.fr", +- "stltoday.com", +- "alternet.org", +- "site5.com", +- "payserve.com", +- "society6.com", +- "douguo.com", +- "prosieben.de", +- "verywed.com", +- "enikos.gr", +- "tubewolf.com", +- "openrice.com", +- "blankrefer.com", +- "gouv.qc.ca", +- "torrentfreak.com", +- "craveonline.com", +- "unfollowers.com", +- "deser.pl", +- "quanjing.com", +- "runetki.tv", +- "yepi.com", +- "socialbakers.com", +- "webmotors.com.br", +- "mmo-champion.com", +- "globososo.com", +- "whois.sc", +- "sportskeeda.com", +- "socialblade.com", +- "jin115.com", +- "avjavjav.com", +- "thenewstribe.com", +- "pinkrod.com", +- "blox.pl", +- "mediamarkt.de", +- "vivo.com.br", +- "facilisimo.com", +- "sinarharian.com.my", +- "leguide.com", +- "voegol.com.br", +- "j.gs", +- "okgj.com", +- "revolveclothing.com", +- "lolinez.com", +- "go2cloud.org", +- "vmoptions.com", +- "myip.ms", +- "ay.gy", +- "liquidweb.com", +- "sbi.co.in", +- "alamaula.com", +- "reshareable.tv", +- "stirileprotv.ro", +- "siriusxm.com", +- "banvenez.com", +- "sergey-mavrodi-mmm.net", +- "ocj.com.cn", +- "elderscrollsonline.com", +- "webaslan.com", +- "dereferer.org", +- "newsbeast.gr", +- "778669.com", +- "yeucahat.com", +- "guitarcenter.com", +- "mercurynews.com", +- "channeladvisor.com", +- "go2000.com", +- "google.ge", +- "pandora.tv", +- "haqqin.az", +- "google.tt", +- "32d1d3b9c.se", +- "sexdatenow.net", +- "befunky.com", +- "micromaxinfo.com", +- "jquerymobile.com", +- "radikal.ru", +- "wigetmedia.com", +- "girlsplay.com", +- "pureleverage.com", +- "mathxl.com", +- "themefuse.com", +- "giga.de", +- "freevideo.cz", +- "stylebistro.com", +- "iwriter.com", +- "winporn.com", +- "tripadvisor.ca", +- "atresplayer.com", +- "igma.tv", +- "ravelry.com", +- "semana.com", +- "verycd.com", +- "sblo.jp", +- "fansided.com", +- "goalunited.org", +- "petfinder.com", +- "worthofweb.com", +- "memuruz.net", +- "njuskalo.hr", +- "yellowpages.ca", +- "91jm.com", +- "webconfs.com", +- "interpals.net", +- "erepublik.com", +- "akismet.com", +- "gaadi.com", +- "casasbahia.com.br", +- "techsupportalert.com", +- "bostonglobe.com", +- "uploadable.ch", +- "smartprofitsystem.com", +- "cimbclicks.com.my", +- "uwants.com", +- "gamestar.de", +- "neowin.net", +- "inilah.com", +- "toster.ru", +- "gosuslugi.ru", +- "windguru.cz", +- "3366.com", +- "beinsports.net", +- "vector.co.jp", +- "memecenter.com", +- "hotnews.ro", +- "webgame.web.id", +- "llnw.com", +- "jobstreet.co.id", +- "congratulations-you-won.com", +- "libertatea.ro", +- "app111.com", +- "scientificamerican.com", +- "strava.com", +- "iranjib.ir", +- "coneco.net", +- "fdrmx.com", +- "nps.gov", +- "businessinsider.in", +- "uniblue.com", +- "proporn.com", +- "dm5.com", +- "qld.gov.au", +- "nexusmods.com", +- "mandatory.com", +- "moskva.fm", +- "prosperityteam.com", +- "lent.az", +- "appbrain.com", +- "24smi.org", +- "avaxsearch.com", +- "gorillavid.in", +- "realgm.com", +- "favicon.cc", +- "astro.com", +- "joomlaforum.ru", +- "joystiq.com", +- "computerworld.com", +- "tvspielfilm.de", +- "centos.org", +- "bugun.com.tr", +- "amctv.com", +- "relianceada.com", +- "papystreaming.com", +- "clickindia.com", +- "sayyac.com", +- "q.gs", +- "bravoerotica.com", +- "bibsonomy.org", +- "netload.in", +- "shopatron.com", +- "iautos.cn", +- "banggood.com", +- "commerzbanking.de", +- "legacyclix.com", +- "intesasanpaolo.com", +- "awesomescreenshot.com", +- "desidime.com", +- "eporner.com", +- "alwatanvoice.com", +- "ok.ru", +- "europe1.fr", +- "karnaval.com", +- "tornn-tv.com", +- "frmtr.com", +- "pulscen.ru", +- "groupon.co.uk", +- "tradera.com", +- "comingsoon.net", +- "speckyboy.com", +- "cargurus.com", +- "citysearch.com", +- "brother.com", +- "acfun.tv", +- "jamejamonline.ir", +- "enterprise.com", +- "elotrolado.net", +- "userscripts.org", +- "confirmit.com", +- "compete.com", +- "auctiva.com", +- "potterybarn.com", +- "ivoox.com", +- "multiupload.nl", +- "glavnoe.ua", +- "p30world.com", +- "snapnames.com", +- "filmon.com", +- "flipkey.com", +- "rhhbschool.com", +- "worldbank.org", +- "proz.com", +- "docusign.net", +- "akakce.com", +- "empflix.com", +- "androidforums.com", +- "mos.ru", +- "contenko.com", +- "malwarebytes.org", +- "voyeurhit.com", +- "filmvz.com", +- "windowsazure.com", +- "rlslog.net", +- "zulagames.com", +- "onlinefinder.net", +- "blekko.com", +- "tvb.com", +- "mojomarketplace.com", +- "warnerbros.com", +- "rogers.com", +- "sparkasse.at", +- "bigcinema.tv", +- "mattcutts.com", +- "vemale.com", +- "pgatour.com", +- "bakusai.com", +- "lavozdegalicia.es", +- "style.com", +- "torrentino.com", +- "activeden.net", +- "sweetpacks-search.com", +- "pcstore.com.tw", +- "starmedia.com", +- "lycos.com", +- "uncomo.com", +- "caribbeancom.com", +- "googleping.com", +- "sondakika.com", +- "premiumwp.com", +- "tribune.com.pk", +- "sc.com", +- "91mobiles.com", +- "elle.com", +- "motortrend.com", +- "starsports.com", +- "otlan.com", +- "planetminecraft.com", +- "oregonlive.com", +- "publichd.se", +- "financialexpress.com", +- "huxiu.com", +- "hotwords.com", +- "asda.com", +- "impiego24.it", +- "tunisia-sat.com", +- "xojane.com", +- "shiftdelete.net", +- "hamshahrionline.ir", +- "mp3.es", +- "minutebuzz.com", +- "footlocker.com", +- "rusnovosti.ru", +- "defencenet.gr", +- "ndr.de", +- "blogosfera.uol.com.br", +- "quibids.com", +- "soft32.com", +- "davidwalsh.name", +- "blogun.ru", +- "webbirga.net", +- "dict.cn", +- "groupon.jp", +- "abovetopsecret.com", +- "contra.gr", +- "zn.ua", +- "jetbrains.com", +- "myus.com", +- "redbus.in", +- "creativemarket.com", +- "uainfo.org", +- "rtbf.be", +- "forexpf.ru", +- "mainlink.ru", +- "fantasti.cc", +- "usagc.org", +- "narutoget.com", +- "trendyol.com", +- "carsales.com.au", +- "fujitv.co.jp", +- "dardarkom.com", +- "corrieredellosport.it", +- "mcanime.net", +- "nolo.com", +- "beareyes.com.cn", +- "familysearch.org", +- "eprice.com.tw", +- "indonetwork.co.id", +- "geizhals.at", +- "watchfreemovies.ch", +- "siweiw.com", +- "elnuevoherald.com", +- "codecupdaters.com", +- "p1.com", +- "imhonet.ru", +- "spox.com", +- "spreadshirt.com", +- "bittorrent.com", +- "airberlin.com", +- "epicurious.com", +- "adverstitial.com", +- "researchnow.com", +- "lolnexus.com", +- "xbabe.com", +- "designmodo.com", +- "hamusoku.com", +- "radioshack.com", +- "teamliquid.net", +- "helpster.de", +- "globalsources.com", +- "fasttech.com", +- "dickssportinggoods.com", +- "j-sen.jp", +- "smashwords.com", +- "adversal.com", +- "musiciansfriend.com", +- "whoishostingthis.com", +- "ads8.com", +- "trend4pay.com", +- "tribune.com", +- "xsrving.com", +- "youngleafs.com", +- "gamersky.com", +- "podio.com", +- "state.pa.us", +- "iphoneogram.com", +- "datehookup.com", +- "hbs.edu", +- "ally.com", +- "mitbbs.com", +- "siasat.pk", +- "miratuserie.tv", +- "active.com", +- "ricardoeletro.com.br", +- "html.it", +- "minnano-av.com", +- "meetly.in", +- "denverpost.com", +- "supersport.com", +- "grupobancolombia.com", +- "freemake.com", +- "bankier.pl", +- "instapaper.com", +- "derwesten.de", +- "blogspot.hu", +- "tamindir.com", +- "play.pl", +- "warthunder.com", +- "team-bhp.com", +- "freepeople.com", +- "laposte.fr", +- "cnews.ru", +- "fayerwayer.com", +- "hitta.se", +- "hao123.com.eg", +- "it-ebooks.info", +- "freep.com", +- "newser.com", +- "lexilogos.com", +- "polldaddy.com", +- "auspost.com.au", +- "aib.ie", +- "cs.com.cn", +- "providesupport.com", +- "unblocksit.es", +- "twittercounter.com", +- "luisaviaroma.com", +- "imgbabes.com", +- "tharunee.lk", +- "nexon.com", +- "airliners.net", +- "srf.ch", +- "angel.co", +- "tokyo-sports.co.jp", +- "mt5.com", +- "down1oads.com", +- "vodonet.net", +- "axar.az", +- "taknaz.ir", +- "google.com.py", +- "ss.lv", +- "stuffgate.com", +- "giveawayoftheday.com", +- "climatempo.com.br", +- "xnxxmovies.com", +- "heartinternet.co.uk", +- "digikey.com", +- "zimbra.free.fr", +- "line.me", +- "talkingpointsmemo.com", +- "dyn.com", +- "exacttarget.com", +- "yourtango.com", +- "shopping.com", +- "king.com", +- "crackberry.com", +- "sm3na.com", +- "matchesfashion.com", +- "rk.com", +- "ems.com.cn", +- "xiaomi.cn", +- "hillnews.com", +- "geforce.com", +- "internetslang.com", +- "theoldreader.com", +- "digitaljournal.com", +- "aol.co.uk", +- "straightdope.com", +- "farfetch.com", +- "lupoporno.com", +- "ilgiornale.it", +- "binzhi.com", +- "loveplanet.ru", +- "sogi.com.tw", +- "googlevideo.com", +- "nintendo.com", +- "jreast.co.jp", +- "coinad.com", +- "keek.com", +- "chegg.com", +- "sparknotes.com", +- "mywapblog.com", +- "idlebrain.com", +- "boardgamegeek.com", +- "daserste.de", +- "nicozon.net", +- "ampnetzwerk.de", +- "agenziaentrate.gov.it", +- "apec.fr", +- "redbull.com", +- "listentoyoutube.com", +- "diepresse.com", +- "gohappy.com.tw", +- "morguefile.com", +- "dallasnews.com", +- "adxpansion.com", +- "almos3a.com", +- "updatetube.com", +- "lowyat.net", +- "lolipop.jp", +- "terafile.co", +- "eversave.com", +- "sportingnews.com", +- "517dv.com", +- "milfmovs.com", +- "myflorida.com", +- "brooonzyah.net", +- "cdn-cachefront.net", +- "ig.com", +- "indiapost.gov.in", +- "hangame.co.jp", +- "ithemes.com", +- "monova.org", +- "udmserve.net", +- "impactradius.com", +- "teasernet.com", +- "gmx.at", +- "mmotraffic.com", +- "citehr.com", +- "viator.com", +- "rt.ru", +- "japannetbank.co.jp", +- "zonealarm.com", +- "ebayclassifieds.com", +- "safecart.com", +- "proptp.net", +- "51hejia.com", +- "telkomsel.com", +- "deutschepost.de", +- "startpagina.nl", +- "alexaboostup.com", +- "istgah.com", +- "aufreeads.com", +- "thinkstockphotos.com", +- "similarsitesearch.com", +- "gossiplankanews.com", +- "venere.com", +- "javascriptkit.com", +- "square-enix.com", +- "tvtoday.de", +- "netaffiliation.com", +- "computrabajo.com.mx", +- "arioo.com", +- "fromdoctopdf.com", +- "lookany.com", +- "bleepingcomputer.com", +- "perfectmoney.com", +- "dorkly.com", +- "macmillandictionary.com", +- "fotka.pl", +- "porntubevidz.com", +- "rj.gov.br", +- "1.1.1.1", +- "ebay.be", +- "divxplanet.com", +- "cyworld.com", +- "biography.com", +- "p1.cn", +- "bazos.sk", +- "55.la", +- "lockerdome.com", +- "yola.com", +- "ccbill.com", +- "groupon.de", +- "okazii.ro", +- "izismile.com", +- "velvet.hu", +- "news-postseven.com", +- "ardmediathek.de", +- "sagawa-exp.co.jp", +- "sarzamindownload.com", +- "pdfonline.com", +- "gaaks.com", +- "azhibo.com", +- "pensador.uol.com.br", +- "surveygizmo.com", +- "familydoctor.com.cn", +- "lazada.vn", +- "guokr.com", +- "enjoydressup.com", +- "sky.de", +- "afp.com", +- "imujer.com", +- "livescore.net", +- "xinnet.com", +- "mypageresults.com", +- "safaribooksonline.com", +- "extremetech.com", +- "ecnavi.jp", +- "babyblog.ru", +- "practicalecommerce.com", +- "vidspot.net", +- "studymode.com", +- "nation.co.ke", +- "cpmrocket.com", +- "es.wix.com", +- "google.com.cu", +- "pravda.ru", +- "cda.pl", +- "appszoom.com", +- "selfhtml.org", +- "zmovie.tw", +- "dba.dk", +- "domain.com", +- "brightcove.com", +- "lol55.com", +- "textsale.ru", +- "casualclub.com", +- "gudvin.tv", +- "torrentreactor.net", +- "downloadcamp.com", +- "eset.com", +- "softonic.it", +- "internations.org", +- "retre.org", +- "3quan.com", +- "companieshouse.gov.uk", +- "hautelook.com", +- "edx.org", +- "ono.es", +- "jango.com", +- "7sur7.be", +- "spinrewriter.com", +- "hqxnxx.com", +- "elperiodico.com", +- "arabiaweather.com", +- "liansuo.com", +- "pcgamer.com", +- "offervault.com", +- "mytheresa.com", +- "memegenerator.net", +- "gsm.ir", +- "britannica.com", +- "mensfitness.com", +- "flaticon.com", +- "newrelic.com", +- "greatmmos.com", +- "ifixit.com", +- "aiyellow.com", +- "my.tv.sohu.com/user/card", +- "ce4arab.com", +- "news-us.jp", +- "slando.kz", +- "redflagdeals.com", +- "gsmhosting.com", +- "raiffeisen.at", +- "tagesspiegel.de", +- "epravda.com.ua", +- "bell.ca", +- "sleazyneasy.com", +- "dhnet.be", +- "webcars.com.cn", +- "freepik.es", +- "androidpolice.com", +- "cbr.ru", +- "thanhnien.com.vn", +- "shoptime.com.br", +- "dailytelegraph.com.au", +- "fastcodesign.com", +- "full-stream.net", +- "google.al", +- "creativecow.net", +- "centrum24.pl", +- "openstat.ru", +- "unfollowed.me", +- "brb.to", +- "babal.net", +- "ibotoolbox.com", +- "torrentdownloads.me", +- "miami.com", +- "mubasher.info", +- "patient.co.uk", +- "ayudawordpress.com", +- "makepolo.com", +- "exactseek.com", +- "echosign.com", +- "epson.com", +- "somo.vn", +- "tripadvisor.jp", +- "bikroy.com", +- "postimees.ee", +- "band.uol.com.br", +- "adopteunmec.com", +- "imgserve.net", +- "toofab.com", +- "neeu.com", +- "mailjet.com", +- "kinja.com", +- "qwertypay.com", +- "cosme.net", +- "dreammovies.com", +- "avvo.com", +- "wenyard.com", +- "dir.bg", +- "digital-photography-school.com", +- "peru.com", +- "thomsonreuters.com", +- "grazia.com.cn", +- "vivastreet.co.in", +- "officemax.com", +- "creditmutuel.fr", +- "themify.me", +- "ait-themes.com", +- "share-links.biz", +- "graphixshare.com", +- "theoutnet.com", +- "revolvermaps.com", +- "careers360.com", +- "tyroodr.com", +- "escapistmagazine.com", +- "ofreegames.com", +- "surveryewadcentrez.eu", +- "notebookcheck.net", +- "k2s.cc", +- "barstoolsports.com", +- "townhall.com", +- "mk.co.kr", +- "epochtimes.com", +- "arduino.cc", +- "blogcms.jp", +- "udacity.com", +- "habervaktim.com", +- "funweek.it", +- "techtunes.com.bd", +- "shopzilla.com", +- "sun-sentinel.com", +- "tfile.me", +- "novafile.com", +- "eurogamer.net", +- "thenewporn.com", +- "tuttosport.com", +- "sverve.com", +- "simplemachines.org", +- "nginx.org", +- "kepu.com.cn", +- "jxedt.com", +- "southparkstudios.com", +- "gusuwang.com", +- "utrace.de", +- "peperonity.de", +- "hvg.hu", +- "cairodar.com", +- "mappy.com", +- "kouclo.com", +- "my.tv.sohu.com/user/lucky", +- "lushstories.com", +- "stocktwits.com", +- "atlantico.fr", +- "baihe.com", +- "wowkeren.com", +- "v7n.com", +- "mozilla.com", +- "centurylink.net", +- "1001freefonts.com", +- "pubdirecte.com", +- "mercadolibre.com.pe", +- "vandelaydesign.com", +- "cpaelites.com", +- "wanyh.com", +- "propertyguru.com.sg", +- "esy.es", +- "torrentbutler.eu", +- "final.ir", +- "53.com", +- "clips4sale.com", +- "freerepublic.com", +- "huffingtonpost.de", +- "boards.ie", +- "fluege.de", +- "parents.com", +- "gimp.org", +- "adorocinema.com", +- "yelp.ca", +- "twicsy.com", +- "kuaibo.com", +- "gnu.org", +- "parsine.com", +- "jpc.com", +- "cloudapp.net", +- "expatriates.com", +- "sproutsocial.com", +- "natemat.pl", +- "livingrichwithcoupons.com", +- "x-ho.com", +- "adv-adserver.com", +- "downloadchop.com", +- "sagepub.com", +- "eleconomista.com.mx", +- "formula1.com", +- "quackit.com", +- "dlsite.com", +- "powned.tv", +- "stream-tv.me", +- "mindbodyonline.com", +- "mindmeister.com", +- "twitlonger.com", +- "ebay.ie", +- "deccanchronicle.com", +- "domaintuno.com", +- "thethirdmedia.com", +- "laiguana.tv", +- "flurry.com", +- "eloqua.com", +- "createsend.com", +- "hrloo.com", +- "interfax.com.ua", +- "admin.ch", +- "zgzcw.com", +- "bancoestado.cl", +- "fda.gov", +- "chinayes.com", +- "beslist.nl", +- "crossfit.com", +- "skai.gr", +- "covers.com", +- "antpoker.com", +- "perfectworld.com", +- "momdot.com", +- "1c-bitrix.ru", +- "feiren.com", +- "navitime.co.jp", +- "siliconindia.com", +- "warning.or.kr", +- "qatarliving.com", +- "uber.com", +- "ing-diba.de", +- "boldsky.com", +- "animeid.tv", +- "tom.com", +- "whatsmyserp.com", +- "ftbpro.com", +- "yobt.tv", +- "toluna.com", +- "burrp.com", +- "viber.com", +- "df.eu", +- "vatera.hu", +- "songmeanings.com", +- "smbc-card.com", +- "hip2save.com", +- "wmzona.com", +- "banamex.com", +- "chinaacc.com", +- "t-online.hu", +- "indianpornvideos.com", +- "runescape.com", +- "wapka.mobi", +- "115.com", +- "blogspot.no", +- "aksam.com.tr", +- "bankcomm.com", +- "giantbomb.com", +- "maxcdn.com", +- "topshop.com", +- "livescores.com", +- "rosbalt.ru", +- "gandi.net", +- "ioffer.com", +- "mihandownload.com", +- "eweb4.com", +- "britishcouncil.org", +- "cheetahmail.com", +- "vbulletin.com", +- "bradsdeals.com", +- "empowernetwork.com/commissionloophole", +- "vueling.com", +- "raventools.com", +- "yext.com", +- "everychina.com", +- "reduxmediia.com", +- "openstreetmap.org", +- "wed114.cn", +- "dzwww.com", +- "miibeian.gov.cn", +- "ufl.edu", +- "deseretnews.com", +- "presstv.ir", +- "copy.com", +- "fourhourworkweek.com", +- "buzztheme.net", +- "bollywoodlife.com", +- "redtubelive.com", +- "pengyou.com", +- "antaranews.com", +- "selectornews.com", +- "lavoz.com.ar", +- "avm.de", +- "flalottery.com", +- "jmp9.com", +- "baltimoresun.com", +- "mozillazine.org", +- "dnevnik.hr", +- "aebn.net", +- "mightydeals.com", +- "livescore.eu", +- "publipt.com", +- "xbmc.org", +- "scmp.com", +- "sbobet.com", +- "alpari.ru", +- "harborfreight.com", +- "linio.com.pe", +- "2500sz.com", +- "rdio.com", +- "bearshare.com", +- "thetrainline.com", +- "888poker.es", +- "filecrop.com", +- "twiends.com", +- "elnuevodia.com", +- "rasekhoon.net", +- "36.cn", +- "axeso5.com", +- "mzamin.com", +- "webmastersitesi.com", +- "thinkdigit.com", +- "lifescript.com", +- "experian.com", +- "adorama.com", +- "d1net.com", +- "torrentz.pro", +- "fullhdfilmizle.org", +- "space.com", +- "collider.com", +- "zalando.it", +- "slate.fr", +- "carmax.com", +- "recode.net", +- "gfan.com", +- "fonts.com", +- "honda.com", +- "ecwid.com", +- "debate.com.mx", +- "bmail.uol.com.br", +- "santandernet.com.br", +- "coderanch.com", +- "lyricsmode.com", +- "gametrailers.com", +- "3600.com", +- "designboom.com", +- "131.com", +- "finam.ru", +- "df.gob.mx", +- "85dcf732d593.se", +- "coches.net", +- "dhs.gov", +- "neurs.com", +- "poppen.de", +- "public-api.wordpress.com", +- "magnovideo.com", +- "squareup.com", +- "balagana.net", +- "goodsearch.com", +- "blog.ir", +- "ne10.uol.com.br", +- "di.se", +- "sinembargo.mx", +- "k618.cn", +- "eventim.de", +- "mysavings.com", +- "futureshop.ca", +- "spinding.com", +- "landsend.com", +- "oqenadserving.com", +- "here.com", +- "upi.com", +- "picresize.com", +- "abnamro.nl", +- "filenuke.com", +- "yxku.com", +- "mypearson.com", +- "dinakaran.com", +- "correos.es", +- "hotchatdirect.com", +- "markafoni.com", +- "gofuckbiz.com", +- "webfindpage.com", +- "cancan.ro", +- "hostgator.in", +- "latribune.fr", +- "adxite.com", +- "mofos.com", +- "bluewin.ch", +- "24ur.com", +- "dion.ne.jp", +- "vpsdomain3.eu", +- "newsweek.com", +- "oasgames.com", +- "mtv3.fi", +- "internetworld.de", +- "yatedo.com", +- "globaltimes.cn", +- "paddypower.com", +- "berlin1.de", +- "norwegian.com", +- "opteck.com", +- "zenfolio.com", +- "kakprosto.ru", +- "ecosia.org", +- "check24.de", +- "idbibank.co.in", +- "zoomit.ir", +- "notebooksbilliger.de", +- "torontosun.com", +- "egopay.com", +- "cnnexpansion.com", +- "emoneyspace.com", +- "rsport.ru", +- "fok.nl", +- "mql4.com", +- "inhabitat.com", +- "tqn.com", +- "noticierodigital.com", +- "wrike.com", +- "bazos.cz", +- "phonegap.com", +- "microlancer.com", +- "anipo.jp", +- "fotocommunity.de", +- "kuwo.cn", +- "chinacaipu.com", +- "terra.cl", +- "500px.org", +- "qantas.com.au", +- "advertising.com", +- "push2check.net", +- "livefyre.com", +- "philstar.com", +- "erail.in", +- "mywebgrocer.com", +- "der-postillon.com", +- "ru-board.com", +- "saramin.co.kr", +- "yjbys.com", +- "aaa.com", +- "flavorwire.com", +- "fcbarcelona.com", +- "lacentrale.fr", +- "googlegroups.com", +- "luck4.me", +- "catho.com.br", +- "centauro.com.br", +- "sia.az", +- "forumactif.com", +- "paltalk.com", +- "beyond.com", +- "occ.com.mx", +- "stamps.com", +- "getoffmyinternets.net", +- "mbok.jp", +- "cleveland.com", +- "ucdavis.edu", +- "tielabs.com", +- "hkgolden.com", +- "vandal.net", +- "lyst.com", +- "mrskin.com", +- "bunshun.jp", +- "netcarshow.com", +- "b1.org", +- "hromadske.tv", +- "sf-express.com", +- "pirateproxy.ca", +- "getcashforsurveys.com", +- "clikz4freakz.com", +- "adsupply.com", +- "truste.org", +- "boxuu.com", +- "webartex.ru", +- "usc.edu", +- "moo.com", +- "winkal.com", +- "deloitte.com", +- "xvideos-field5.com", +- "suomi24.fi", +- "flexmls.com", +- "weeklystandard.com", +- "debenhams.com", +- "mejortorrent.com", +- "vconnect.com", +- "ligatus.com", +- "skynewsarabia.com", +- "herschina.com", +- "92lux.cn", +- "care.com", +- "chip.com.tr", +- "tangdou.com", +- "vatanbilgisayar.com", +- "uppit.com", +- "metronews.fr", +- "parenting.com.tw", +- "meteo.gr", +- "meetgee.com", +- "ldlc.com", +- "ubs.com", +- "elcolombiano.com", +- "mafengwo.cn", +- "moodle.org", +- "asiaone.com", +- "huffingtonpost.it", +- "ipas2free.com", +- "casa.it", +- "kaiserpermanente.org", +- "listindiario.com", +- "treehugger.com", +- "payeer.com", +- "mypoints.com", +- "pjmedia.com", +- "foreca.com", +- "luxup.ru", +- "halifax.co.uk", +- "webinarjam.net", +- "webmeup.com", +- "webdesignledger.com", +- "rte.ie", +- "18andabused.com", +- "vbulletin.org", +- "apne.tv", +- "immoweb.be", +- "colonelcassad.livejournal.com", +- "atlassian.com", +- "investors.com", +- "globalbux.net", +- "wechat.com", +- "kanoon.ir", +- "mawaly.com", +- "self.com", +- "drive.ru", +- "autozone.com", +- "creditonebank.com", +- "fdj.fr", +- "hsbc.com.br", +- "desk.com", +- "dlvr.it", +- "wpml.org", +- "newmobilelife.com", +- "crosswalk.com", +- "thehun.com", +- "hobbyking.com", +- "tiantian.com", +- "hichina.com", +- "cyanogenmod.org", +- "horoscope.com", +- "bizsugar.com", +- "popularmechanics.com", +- "egaliteetreconciliation.fr", +- "eol.cn", +- "rzd.ru", +- "escalatenetwork.net", +- "yad2.co.il", +- "cna.com.tw", +- "zi-m.com", +- "leonardo.it", +- "ap.gov.in", +- "rakuten.de", +- "wallsave.com", +- "netzwelt.de", +- "bitrix24.ru", +- "techinasia.com", +- "bitstamp.net", +- "hostelbookers.com", +- "shoplocal.com", +- "200please.com", +- "tune-up.com", +- "mapy.cz", +- "dealnews.com", +- "livescore.co.uk", +- "seocentro.com", +- "rstyle.me", +- "neoseeker.com", +- "kaban.tv", +- "visualstudio.com", +- "cinetux.org", +- "groupon.com.br", +- "lastpass.com", +- "rincondelvago.com", +- "popsci.com", +- "2144.cn", +- "clickfair.com", +- "dsebd.org", +- "banesco.com", +- "spi0n.com", +- "blogspot.cz", +- "tnews.ir", +- "nme.com", +- "paperblog.com", +- "firstcry.com", +- "tophotels.ru", +- "liepin.com", +- "korabia.com", +- "ifttt.com", +- "aemet.es", +- "alot.com", +- "manutd.com", +- "edreams.es", +- "turkcell.com.tr", +- "eva.vn", +- "techpowerup.com", +- "vkrugudruzei.ru", +- "feed2all.eu", +- "thehindubusinessline.com", +- "express.de", +- "ixquick.com", +- "thrillist.com", +- "iqilu.com", +- "seriouseats.com", +- "edgesuite.net", +- "telexads.com", +- "alza.cz", +- "en-japan.com", +- "al.com", +- "dota2lounge.com", +- "totalping.com", +- "seocheki.net", +- "iceporn.com", +- "col3negoriginel.lk", +- "porsyar.com", +- "property24.com", +- "madamenoire.com", +- "markethealth.com", +- "alphacoders.com", +- "webempresa.com", +- "empireonline.com", +- "downforeveryoneorjustme.com", +- "lankadeepa.lk", +- "darty.com", +- "census.gov", +- "wapka.me", +- "kdslife.com", +- "jpost.com", +- "cricfree.tv", +- "7xxxtube.com", +- "businesscatalyst.com", +- "dilbert.com", +- "gaymaletube.com", +- "bellanaija.com", +- "renfe.es", +- "equifax.com", +- "pornmaki.com", +- "lolesports.com", +- "yunfan.com", +- "everybitcity.com", +- "9yao.com", +- "avantlink.com", +- "paginebianche.it", +- "xrosview.com", +- "newsday.com", +- "usportnews.com", +- "petapixel.com", +- "pistonheads.com", +- "lidovky.cz", +- "cvent.com", +- "adlandpro.com", +- "wikisource.org", +- "ename.com", +- "prosport.ro", +- "sharebuilder.com", +- "prisjakt.nu", +- "cw.com.tw", +- "datafilehost.com", +- "aircanada.com", +- "osu.edu", +- "linuxmint.com", +- "toyota.com", +- "google.am", +- "adobeconnect.com", +- "h33t.to", +- "companycheck.co.uk", +- "juno.com", +- "beitaichufang.com", +- "alaskaair.com", +- "tipsandtricks-hq.com", +- "yourstory.com", +- "wow-impulse.ru", +- "wishpond.com", +- "promosite.ru", +- "weddingwire.com", +- "icicidirect.com", +- "mouser.com", +- "shopstyle.co.uk", +- "sinemalar.com", +- "addurl.nu", +- "seccionamarilla.com.mx", +- "yllix.com", +- "motorola.com", +- "huawei.com", +- "mp3juices.com", +- "fitday.com", +- "pakwheels.com", +- "uploading.com", +- "snapwidget.com", +- "rsb.ru", +- "mturk.com", +- "libreoffice.org", +- "acer.com", +- "rd.com", +- "aa.com.tr", +- "glamour.com", +- "docnhat.net", +- "cnbb.com.cn", +- "piwik.org", +- "mycompanyadmin.com", +- "ohozaa.com", +- "fox.com", +- "mastercard.com.au", +- "microsofttranslator.com", +- "myhabit.com", +- "acesso.uol.com.br", +- "cqnews.net", +- "default-search.net", +- "juntadeandalucia.es", +- "carigold.com", +- "tweepi.com", +- "gamedog.cn", +- "videomega.tv", +- "softarchive.net", +- "akamai.com", +- "adorika.net", +- "zorpia.com", +- "bitdefender.com", +- "formstack.com", +- "al3abbarq.com", +- "ruelala.com", +- "andhrajyothy.com", +- "siteheart.com", +- "spankbang.com", +- "buxp.org", +- "subtlepatterns.com", +- "cucirca.eu", +- "apontador.com.br", +- "sbs.co.kr", +- "rong360.com", +- "billmelater.com", +- "nowdownload.ch", +- "pingmyurl.com", +- "main.jp", +- "allabolag.se", +- "fastspring.com", +- "20d625b48e.se", +- "wpzoom.com", +- "dl-protect.com", +- "onvista.de", +- "iberia.com", +- "learni.st", +- "minijuegos.com", +- "ae.com", +- "india-forums.com", +- "port.hu", +- "truelocal.com.au", +- "ziprecruiter.com", +- "toyokeizai.net", +- "24timezones.com", +- "tzetze.it", +- "the-village.ru", +- "ptcapusa.com", +- "indiaresults.com", +- "desjardins.com", +- "nchsoftware.com", +- "yasdl.com", +- "delo.ua", +- "baskino.com", +- "salary.com", +- "freecontact.com", +- "wumii.com", +- "ssc.nic.in", +- "synology.com", +- "nttdocomo.co.jp", +- "racing-games.com", +- "freeonlinegames.com", +- "aftabnews.ir", +- "zumi.pl", +- "efshop.com.tw", +- "hawamer.com", +- "eastbay.com", +- "izvestia.ru", +- "mosaiquefm.net", +- "twitchy.com", +- "slaati.com", +- "bookingbuddy.com", +- "networksolutionsemail.com", +- "etsystatic.com", +- "sina.com", +- "asiandatingbeauties.com", +- "blogs.com", +- "france3.fr", +- "healthcentral.com", +- "downloadatoz.com", +- "matthewwoodward.co.uk", +- "legalzoom.com", +- "phun.org", +- "campaignmonitor.com", +- "cifraclub.com.br", +- "hir24.hu", +- "twoplustwo.com", +- "hotshame.com", +- "arvixededicated.com", +- "designcrowd.com", +- "mrexcel.com", +- "blu-ray.com", +- "bundesliga.de", +- "comments.ua", +- "filmstarts.de", +- "3sk.tv", +- "donedeal.ie", +- "natunbarta.com", +- "forex-mmcis.com", +- "lifehacker.ru", +- "sitepronews.com", +- "tudogostoso.com.br", +- "titanfall.com", +- "brainpickings.org", +- "saharareporters.com", +- "vidto.me", +- "mlit.go.jp", +- "terapeak.com", +- "techweb.com.cn", +- "premiere.fr", +- "kanui.com.br", +- "asianetnews.tv", +- "cric.lk", +- "exxxtrasmall.com", +- "hiphopdx.com", +- "5617.com", +- "namepros.com", +- "humanmetrics.com", +- "allin1convert.com", +- "ox.ac.uk", +- "msecnd.net", +- "cathaypacific.com", +- "bet365affiliates.com", +- "tcs.com", +- "trafficestimate.com", +- "lmgtfy.com", +- "finance.ua", +- "find404.com", +- "pagesperso-orange.fr", +- "curbed.com", +- "tasteofhome.com", +- "ar15.com", +- "mydigitallife.info", +- "promiflash.de", +- "technobuffalo.com", +- "gamestorrents.com", +- "labirint.ru", +- "pclab.pl", +- "indiatvnews.com", +- "finya.de", +- "redmondpie.com", +- "rabota.ru", +- "share-online.biz", +- "packtpub.com", +- "techgig.com", +- "shaw.ca", +- "apkmania.co", +- "bet-at-home.com", +- "barclaycard.co.uk", +- "onefloorserve.com", +- "raiffeisen.ru", +- "t-nation.com", +- "mbalib.com", +- "staseraintv.com", +- "uswitch.com", +- "smartadserver.com", +- "bbcgoodfood.com", +- "elitetorrent.net", +- "backlinko.com", +- "naszemiasto.pl", +- "submitexpress.com", +- "savings.com", +- "gem.pl", +- "ahlamontada.com", +- "fotomac.com.tr", +- "gougou.com", +- "payamsara.com", +- "klix.ba", +- "doostiha.ir", +- "bibliocommons.com", +- "wealthyaffiliate.com", +- "emgn.com", +- "sifyitest.com", +- "washingtonexaminer.com", +- "rakuten-sec.co.jp", +- "mysurvey.com", +- "uuu9.com", +- "uscourts.gov", +- "showroomprive.com", +- "cargocollective.com", +- "hsoub.com", +- "afterbuy.de", +- "marunadanmalayali.com", +- "jumponhottie.com", +- "avon.com", +- "lazada.com.my", +- "51netu.com.cn", +- "ria.com", +- "sankakucomplex.com", +- "tvline.com", +- "devshed.com", +- "superherohype.com", +- "tv-series.me", +- "stylecraze.com", +- "wizards.com", +- "linkcollider.com", +- "xinjunshi.com", +- "bestchange.ru", +- "1111.com.tw", +- "fakenamegenerator.com", +- "newsmth.net", +- "noupe.com", +- "marketingprofs.com", +- "bluestacks.com", +- "jemtube.com", +- "bestbuy.ca", +- "backcountry.com", +- "designshack.net", +- "pond5.com", +- "highsnobiety.com", +- "rtl.fr", +- "pearsoncmg.com", +- "hellowork.go.jp", +- "koimoi.com", +- "soali.ir", +- "incentria.com", +- "vagas.com.br", +- "huaxi100.com", +- "cheaa.com", +- "lohaco.jp", +- "gov.on.ca", +- "fabthemes.com", +- "pipl.com", +- "comscore.com", +- "pcfinancial.ca", +- "craigslist.co.in", +- "michaels.com", +- "jibjab.com", +- "sankeibiz.jp", +- "dominos.co.in", +- "supermoney.eu", +- "itusozluk.com", +- "sdchina.com", +- "allkpop.com", +- "cam4.com.br", +- "stayfriends.de", +- "futbol24.com", +- "searchina.net", +- "sgcpanel.com", +- "informe21.com", +- "alsacreations.com", +- "crateandbarrel.com", +- "alliancewarfare.com", +- "filerio.in", +- "emailsrvr.com", +- "reventmedia.com", +- "vietcombank.com.vn", +- "rxlist.com", +- "acidcow.com", +- "orange.co.uk", +- "hellocoton.fr", +- "boldchat.com", +- "psychcentral.com", +- "surfline.com", +- "xxxkinky.com", +- "es.wordpress.com", +- "publika.az", +- "shufoo.net", +- "hertz.com", +- "businessweekly.com.tw", +- "virgula.uol.com.br", +- "linkis.com", +- "ixwebhosting.com", +- "usa.gov", +- "linguee.com", +- "yengo.com", +- "huffingtonpost.jp", +- "1x3x.com", +- "mediametrics.ru", +- "ec21.com", +- "80018.cn", +- "get-tune.net", +- "yupoo.com", +- "moviepilot.de", +- "ihned.cz", +- "fio.cz", +- "pubted.com", +- "cinemablend.com", +- "stooorage.com", +- "thevault.bz", +- "journaldugeek.com", +- "sommer-sommer.com", +- "travelchannel.com", +- "softonic.de", +- "petsmart.com", +- "ufxmarkets.com", +- "e24.no", +- "spirit.com", +- "dabi.ir", +- "admin5.net", +- "serialu.net", +- "vancouversun.com", +- "submanga.com", +- "sbicard.com", +- "affaritaliani.it", +- "idownloadblog.com", +- "castorama.fr", +- "sudouest.fr", +- "payscale.com", +- "serebii.net", +- "storypick.com", +- "jobkorea.co.kr", +- "gowildcasino.com", +- "hmetro.com.my", +- "parimatch.com", +- "51pinwei.com", +- "globalnews.ca", +- "mercadopago.com", +- "sixrevisions.com", +- "saisoncard.co.jp", +- "gov.kz", +- "gossip-tv.gr", +- "zbozi.cz", +- "aliorbank.pl", +- "huanqiuauto.com", +- "okaz.com.sa", +- "cplusplus.com", +- "mochimedia.com", +- "google.sn", +- "jquery-plugins.net", +- "peoplesmart.com", +- "mmafighting.com", +- "ponpare.jp", +- "porsche.com", +- "charter.com", +- "scrabblefinder.com", +- "unpcn.com", +- "loveaholics.com", +- "geocities.co.jp", +- "ladbrokes.com", +- "52che.com", +- "swansonvitamins.com", +- "sweetwater.com", +- "ali213.net", +- "savenkeep.com", +- "hotair.com", +- "orgasmatrix.com", +- "runrun.es", +- "filezilla-project.org", +- "looti.net", +- "pagesix.com", +- "twentytwowords.com", +- "gingersoftware.com", +- "youxiduo.com", +- "isimtescil.net", +- "rui.jp", +- "d1g.com", +- "2dbook.com", +- "zigzig.ir", +- "123telugu.com", +- "wdr.de", +- "hankyung.com", +- "pr.com", +- "search.ch", +- "iranproud.com", +- "raaga.com", +- "alt1040.com", +- "okpay.com", +- "recordchina.co.jp", +- "dreamincode.net", +- "bendibao.com", +- "creativelive.com", +- "socialoomph.com", +- "cssdeck.com", +- "taxactonline.com", +- "pb.com", +- "fnac.es", +- "ucsd.edu", +- "tmart.com", +- "whorush.com", +- "spicejet.com", +- "socialadr.com", +- "tutorialzine.com", +- "christianmingle.com", +- "torrentleech.org", +- "statefarm.com", +- "orkut.com", +- "whoscored.com", +- "truthaboutonlinesluts.com", +- "32red.com", +- "wp-themes.com", +- "adpost.com", +- "cnr.cn", +- "180upload.com", +- "snagajob.com", +- "textbroker.com", +- "freshome.com", +- "talkgold.com", +- "dudamobile.com", +- "weblancer.net", +- "newone.org", +- "nacion.com", +- "takepart.com", +- "voici.fr", +- "gizmodo.jp", +- "viki.com", +- "symbaloo.com", +- "topface.com", +- "businessdictionary.com", +- "adtech.info", +- "elandroidelibre.com", +- "fux.com", +- "21-sun.com", +- "cpmfx.com", +- "siemens.com", +- "edmodo.com", +- "notitarde.com", +- "babypips.com", +- "silkroad.com", +- "onextrapixel.com", +- "notdoppler.com", +- "walmart.ca", +- "marvel.com", +- "groupon.fr", +- "us1.com", +- "bunte.de", +- "findlaw.com", +- "topito.com", +- "carrefour.fr", +- "aawsat.com", +- "super.ae", +- "kicktipp.de", +- "simplyrecipes.com", +- "i-mobile.co.jp", +- "podrobnosti.ua", +- "snn.ir", +- "successfactors.com", +- "paixie.net", +- "wiwo.de", +- "glowgaze.com", +- "mapsofworld.com", +- "limetorrents.com", +- "plarium.com", +- "tvi.ua", +- "corel.com", +- "adhitprofits.com", +- "findthecompany.com", +- "noticiasaldiayalahora.co", +- "160by2.com", +- "jobberman.com", +- "rus.ec", +- "fujitsu.com", +- "ladepeche.fr", +- "pravda.sk", +- "wwtdd.com", +- "b9dm.com", +- "marathonbet.com", +- "sexlunch.com", +- "komputronik.pl", +- "gutenberg.org", +- "dizo.com.cn", +- "comunio.de", +- "naked.com", +- "gamesradar.com", +- "moneysupermarket.com", +- "cheaptickets.com", +- "assembla.com", +- "timesonline.co.uk", +- "mckinsey.com", +- "ebook3000.com", +- "videoblocks.com", +- "ruseller.com", +- "pideo.net", +- "joomlacode.org", +- "pciconcursos.com.br", +- "channelnewsasia.com", +- "cnnturk.com", +- "consultant.ru", +- "michigan.gov", +- "manoto1.com", +- "10010.com", +- "wholefoodsmarket.com", +- "globalgrind.com", +- "pichak.net", +- "morpakampus.com", +- "crazydomains.com.au", +- "uptodown.com", +- "polygon.com", +- "raspberrypi.org", +- "atmarkit.co.jp", +- "heftig.co", +- "informationweek.com", +- "trendhunter.com", +- "state.ny.us", +- "pornpros.com", +- "tnt.com", +- "sportal.bg", +- "spritzinc.com", +- "theladders.com", +- "lulu.com", +- "applesfera.com", +- "qoo10.jp", +- "notebookreview.com", +- "startertv.fr", +- "healthkart.com", +- "imgsin.com", +- "mp3olimp.net", +- "readms.com", +- "casadellibro.com", +- "nalog.ru", +- "4gamer.net", +- "jquery4u.com", +- "betfred.com", +- "3dwwwgame.com", +- "appleinsider.com", +- "dailystar.co.uk", +- "swalif.com", +- "hushmail.com", +- "worldtimebuddy.com", +- "sportschau.de", +- "mediatraffic.com", +- "gismeteo.ua", +- "record.com.mx", +- "putnik1.livejournal.com", +- "nextbigwhat.com", +- "vinescope.com", +- "jarchi.ir", +- "yidio.com", +- "dunyanews.tv", +- "hangseng.com", +- "interpark.com", +- "scholastic.com", +- "penny-arcade.com", +- "geilundlive.com", +- "budbi.com", +- "stop55.com", +- "jaidefinichon.com", +- "smartsheet.com", +- "vector.me", +- "farecompare.com", +- "vodafone.com.eg", +- "craftsy.com", +- "theresumator.com", +- "downloadab.com", +- "abendzeitung-muenchen.de", +- "dicio.com.br", +- "fobshanghai.com", +- "2dehands.be", +- "thethao247.vn", +- "cams.com", +- "gothamist.com", +- "moneynews.com", +- "zocdoc.com", +- "rol.ro", +- "nic.ar", +- "avenues.info", +- "cleverbridge.com", +- "usajobs.gov", +- "divxstage.eu", +- "jsticket.net", +- "himasoku.com", +- "thrivethemes.com", +- "orientaltrading.com", +- "premiumpress.com", +- "house365.com", +- "drugoi.livejournal.com", +- "monster.co.uk", +- "quickanddirtytips.com", +- "virtuemart.net", +- "huffpost.com", +- "real.com", +- "teacherspayteachers.com", +- "t24.com.tr", +- "zakon.kz", +- "shoppinglifestyle.com", +- "trendmicro.com", +- "surfingbird.ru", +- "cam.ac.uk", +- "navyfederal.org", +- "rateyourmusic.com", +- "bravenet.com", +- "polo.com", +- "cl.ly", +- "nanacast.com", +- "cnfol.com", +- "24option.com", +- "myscienceacademy.org", +- "getsoftfree.com", +- "cba.pl", +- "templateism.com", +- "actudesfinances.org", +- "1.254.254.254", +- "jobtalk.jp", +- "barbie.com", +- "rahnama.com", +- "gigporno.com", +- "buddypress.org", +- "corporationwiki.com", +- "enorth.com.cn", +- "thepioneerwoman.com", +- "cam4ultimate.com", +- "phpclasses.org", +- "uplus.metroer.com/~content", +- "komando.com", +- "iha.com.tr", +- "televisa.com", +- "tmtpost.com", +- "classifiedsgiant.com", +- "sportinglife.com", +- "askul.co.jp", +- "travelagency.travel", +- "jqueryscript.net", +- "rusfolder.com", +- "netcq.net", +- "irangrand.ir", +- "interaztv.com", +- "downvids.net", +- "mongodb.org", +- "nasgo.net", +- "thesitewizard.com", +- "songspk.cc", +- "travelandleisure.com", +- "d-h.st", +- "wasanga.com", +- "cgg.gov.in", +- "silverclix.com", +- "almogaz.com", +- "sexmob.es", +- "mistreci.com", +- "nukistream.com", +- "postaffiliatepro.com", +- "dish.com", +- "ulta.com", +- "worldcat.org", +- "crackle.com", +- "cineblog01.net", +- "parispornmovies.com", +- "avito.ma", +- "nethouse.ru", +- "elfinanciero.com.mx", +- "ab-in-den-urlaub.de", +- "pixeden.com", +- "thetimenow.com", +- "divar.ir", +- "coolrom.com", +- "akbank.com", +- "saturn.de", +- "dstv.com", +- "mttbsystem.com", +- "hujiang.com", +- "bash.im", +- "sextgem.com", +- "subaonet.com", +- "cnsnews.com", +- "informationng.com", +- "utoronto.ca", +- "hetzner.de", +- "vend-o.com", +- "cybozu.com", +- "autotimes.com.cn", +- "5giay.vn", +- "theepochtimes.com", +- "penesalud.com", +- "livenation.com", +- "qoinpro.com", +- "myway.com", +- "safe-swaps.com", +- "elephantjournal.com", +- "curse.com", +- "17zwd.com", +- "hitleap.com", +- "mec.gov.br", +- "freewebcams.com", +- "westelm.com", +- "imagegals.com", +- "streeteasy.com", +- "ekitan.com", +- "git-scm.com", +- "p30day.com", +- "kapaza.be", +- "svoboda.org", +- "google.mg", +- "timesofisrael.com", +- "roodo.com", +- "malwaretips.com", +- "dumpaday.com", +- "dha.com.tr", +- "diary.ru", +- "epa.gov", +- "jonloomer.com", +- "holidaylettings.co.uk", +- "oem.com.mx", +- "oxfordjournals.org", +- "3bmeteo.com", +- "iwebtool.com", +- "yinyuetai.com", +- "ixl.com", +- "rezultati.com", +- "51sole.com", +- "moudamepo.com", +- "macromill.com", +- "nzz.ch", +- "buzznet.com", +- "roku.com", +- "posta.com.tr", +- "letsbonus.com", +- "theoatmeal.com", +- "artofmanliness.com", +- "tubepornkiss.com", +- "aviny.com", +- "sabresonicweb.com", +- "tech-wd.com", +- "qbank.ru", +- "getsatisfaction.com", +- "prokerala.com", +- "ebc.com.br", +- "typiol.com", +- "photo.net", +- "rockpapershotgun.com", +- "netgear.com", +- "mg.co.za", +- "impressrd.jp", +- "jkbk.cn", +- "bakufu.jp", +- "lgmi.com", +- "tnt-online.ru", +- "frequency.com", +- "zip-codes.com", +- "sport.ro", +- "wolfram.com", +- "pgmediaserve.com", +- "icann.org", +- "twistedsifter.com", +- "mopo.de", +- "vogue.co.uk", +- "chatrandom.com", +- "checkpagerank.net", +- "colorzilla.com", +- "autobip.com", +- "laban.vn", +- "pricecheck.co.za", +- "notimex.com.mx", +- "pik.ba", +- "monster.de", +- "google.cd", +- "economia.uol.com.br", +- "vsnl.net.in", +- "futura-sciences.com", +- "appstorm.net", +- "icefilms.info", +- "dicelacancion.com", +- "hypovereinsbank.de", +- "piratestreaming.tv", +- "101domain.com", +- "google.mn", +- "rutgers.edu", +- "behindwoods.com", +- "downloadmaster.ru", +- "smartinsights.com", +- "wiziq.com", +- "ftc.gov", +- "animenewsnetwork.com", +- "tandfonline.com", +- "seagate.com", +- "famitsu.com", +- "onekingslane.com", +- "zalando.fr", +- "convio.com", +- "seochat.com", +- "qq163.com", +- "capital.gr", +- "tamin.ir", +- "phpfreaks.com", +- "cricketcountry.com", +- "ubersuggest.org", +- "ntv.co.jp", +- "olark.com", +- "1001fonts.com", +- "appsgeyser.com", +- "elsiglodetorreon.com.mx", +- "lyricsmint.com", +- "tovima.gr", +- "petco.com", +- "campograndenews.com.br", +- "amadeus.com", +- "tinychat.com", +- "astrology.com", +- "idg.se", +- "nordea.se", +- "gelbeseiten.de", +- "nrc.nl", +- "houseoffraser.co.uk", +- "hepsibahis3.com", +- "empowernetwork.com/almostasecret", +- "phpnuke.org", +- "xfwed.com", +- "gulte.com", +- "msi.com", +- "netfirms.com", +- "ovcanada.com", +- "smzdm.com", +- "wwwhatsnew.com", +- "mydomainadvisor.com", +- "newindianexpress.com", +- "luxtarget.com", +- "evz.ro", +- "otodom.pl", +- "linkin.net", +- "moneysavingmom.com", +- "uploadbaz.com", +- "egyup.com", +- "three.co.uk", +- "co-operativebank.co.uk", +- "redad.ru", +- "ipsosinteractive.com", +- "all-union.com", +- "trustlink.ru", +- "softango.com", +- "toucharcade.com", +- "tv2.dk", +- "thisissouthwales.co.uk", +- "jra.go.jp", +- "alfavita.gr", +- "ibigdan.livejournal.com", +- "gtarcade.com", +- "jc001.cn", +- "microcenter.com", +- "optimizepress.com", +- "beyebe.com", +- "muyzorras.com", +- "expedia.co.uk", +- "volvocars.com", +- "lyd.com.cn", +- "korben.info", +- "disput.az", +- "aeroflot.ru", +- "betanews.com", +- "avangard.ru", +- "wrzko.eu", +- "cakephp.org", +- "majorgeeks.com", +- "dreamteammoney.com", +- "foroactivo.com", +- "ut.ac.ir", +- "eonet.jp", +- "vn-zoom.com", +- "footytube.com", +- "expedia.de", +- "barneys.com", +- "lieyunwang.com", +- "gartner.com", +- "lazada.com.ph", +- "ourtime.com", +- "ohnotheydidnt.livejournal.com", +- "e-rewards.com", +- "updatestar.com", +- "cafef.vn", +- "cookinglight.com", +- "expressdownload.net", +- "shockmansion.com", +- "adserverpub.com", +- "ipko.pl", +- "gsa-online.de", +- "car.gr", +- "cqcounter.com", +- "thenews.com.pk", +- "gnc.com", +- "teambeachbody.com", +- "kobobooks.com", +- "cwan.com", +- "ca.com", +- "list.ly", +- "baijob.com", +- "gunbroker.com", +- "rtl.be", +- "myadvertisingpays.com", +- "mediapost.com", +- "groupalia.com", +- "anquan.org", +- "mixshowblast.com", +- "myscore.ru", +- "bancochile.cl", +- "a2hosting.com", +- "hayneedle.com", +- "myfc.ir", +- "aktifhaber.com", +- "eater.com", +- "anymeeting.com", +- "cylex.de", +- "sayidaty.net", +- "synonym.com", +- "comprendrechoisir.com", +- "prlog.ru", +- "solidtrustpay.com", +- "cinejosh.com", +- "yelp.co.uk", +- "olx.com.ar", +- "dihitt.com", +- "donkeymails.com", +- "chainreactioncycles.com", +- "wearehairy.com", +- "ebuyer.com", +- "bplans.com", +- "ponparemall.com", +- "readthedocs.org", +- "tehparadox.com", +- "source-wave.com", +- "tbs.co.jp", +- "redcoon.de", +- "francetv.fr", +- "freelogoservices.com", +- "ogone.com", +- "jeanmarcmorandini.com", +- "lasexta.com", +- "sponsoredreviews.com", +- "govome.com", +- "vecteezy.com", +- "alhayat.com", +- "cnhubei.com", +- "mumayi.com", +- "webfail.com", +- "eluniverso.com", +- "moddb.com", +- "gaiaonline.com", +- "gordonua.com", +- "liveadexchanger.com", +- "zhe800.com", +- "softonic.com.br", +- "cnyes.com", +- "cumlouder.com", +- "krakow.pl", +- "nullrefer.com", +- "zaluu.com", +- "diretube.com", +- "seattlepi.com", +- "eanswers.com", +- "gostorego.com", +- "play.com", +- "lenskart.com", +- "unblog.fr", +- "chatwork.com", +- "bronto.com", +- "jobisjob.co.in", +- "mercadolibre.com.uy", +- "overdrive.com", +- "runkeeper.com", +- "smartshopping.com", +- "getrichradio.com", +- "grader.com", +- "101greatgoals.com", +- "elbilad.net", +- "kopp-verlag.de", +- "ranksignals.com", +- "trome.pe", +- "jobstreet.com.my", +- "farnell.com", +- "fastmail.fm", +- "faithit.com", +- "blogdohotelurbano.com", +- "sencha.com", +- "daisycon.com", +- "random.org", +- "tportal.hr", +- "rkanr.com", +- "fc2-erodouga.com", +- "youngpornvideos.com", +- "bravoteens.com", +- "mobile.free.fr", +- "mitele.es", +- "edis.at", +- "questionablecontent.net", +- "indiangilma.com", +- "comunio.es", +- "bitnami.com", +- "sliptalk.com", +- "sourceforge.jp", +- "lyoness.net", +- "nespresso.com", +- "ultrafarma.com.br", +- "lik.cl", +- "jsoftj.com", +- "metoffice.gov.uk", +- "androidauthority.com", +- "360safe.com", +- "wikimart.ru", +- "tutu.ru", +- "truetwit.com", +- "xinruijunshi.com", +- "online-sweepstakes.com", +- "singaporeair.com", +- "cwtv.com", +- "politiken.dk", +- "alaan.tv", +- "tuttomercatoweb.com", +- "imagehost123.com", +- "drakensang.com", +- "frenchweb.fr", +- "syosetu.com", +- "zhifang.com", +- "viptube.com", +- "theme123.net", +- "statista.com", +- "51bi.com", +- "clickz.com", +- "kingworldnews.com", +- "qunar.com", +- "pimpandhost.com", +- "pagina12.com.ar", +- "xinmin.cn", +- "kidshealth.org", +- "pics.livejournal.com", +- "kabum.com.br", +- "anandabazar.com", +- "pnu.ac.ir", +- "scene7.com", +- "paperpkads.com", +- "mylikes.com", +- "longtailvideo.com", +- "firmy.cz", +- "bitcoinity.org", +- "inopressa.ru", +- "expat-blog.com", +- "governmentjobs.com", +- "airdroid.com", +- "mid-day.com", +- "frandroid.com", +- "webceo.com", +- "cadenaser.com", +- "minutouno.com", +- "onamae.com", +- "onlinekhabar.com", +- "williams-sonoma.com", +- "freewebsubmission.com", +- "vozforums.com", +- "bigpicture.ru", +- "mymodernmet.com", +- "presseportal.de", +- "licindia.in", +- "ismedia.jp", +- "depor.pe", +- "sing365.com", +- "v2cigs.com", +- "postimage.org", +- "gencat.cat", +- "west263.com", +- "alohatube.com", +- "eenadupratibha.net", +- "terra.com", +- "bri.co.id", +- "silktide.com", +- "anyang.gov.cn", +- "speedanalysis.com", +- "bitcoin.org", +- "toodledo.com", +- "topgear.com", +- "rtvslo.si", +- "hotpads.com", +- "nedsecure.co.za", +- "expedia.ca", +- "thairath.co.th", +- "gizbot.com", +- "naukrigulf.com", +- "guffins.com", +- "twilio.com", +- "avsforum.com", +- "sharpnews.ru", +- "inoreader.com", +- "stgeorge.com.au", +- "shoebuy.com", +- "sbwire.com", +- "bfm.ru", +- "dongtaiwang.com", +- "mandrillapp.com", +- "176.com", +- "olx.com", +- "trustpilot.co.uk", +- "tgju.org", +- "pap.fr", +- "iphonehacks.com", +- "gry-online.pl", +- "mp3xd.com", +- "viabcp.com", +- "bizcommunity.com", +- "chillingeffects.org", +- "thomasnet.com", +- "performersoft.com", +- "paymaster.ru", +- "comdotgame.com", +- "bseindia.com", +- "foodgawker.com", +- "clicktale.com", +- "dot.tk", +- "smbc-comics.com", +- "vvmembers.co", +- "c-sharpcorner.com", +- "acdcads.com", +- "goldporntube.com", +- "abakus-internet-marketing.de", +- "babbel.com", +- "fzg360.com", +- "99inf.com", +- "cduniverse.com", +- "autobild.de", +- "tvrage.com", +- "phoenix.edu", +- "hurriyetemlak.com", +- "va.gov", +- "maxmind.com", +- "lifehacker.jp", +- "nola.com", +- "niroensani.ir", +- "ihotelier.com", +- "mianbao.com", +- "powerball.com", +- "express.com", +- "freshdesignweb.com", +- "o2.co.uk", +- "utusan.com.my", +- "overclockers.ru", +- "fsiblog.com", +- "launchpad.net", +- "prizee.com", +- "alalam.ir", +- "imtalk.org", +- "vavel.com", +- "nyc.ny.us", +- "youmob.com", +- "dailythanthi.com", +- "ksu.edu.sa", +- "nlayer.net", +- "kurier.at", +- "expert-offers.com", +- "marry52.com", +- "cityads.ru", +- "darkorbit.com", +- "cio.com", +- "a9.com", +- "symfony.com", +- "crobo.com", +- "shatel.ir", +- "opposingviews.com", +- "myvoffice.com", +- "vkmag.com", +- "starpulse.com", +- "bls.gov", +- "lifebettering.com", +- "fanhuan.com", +- "upload7.ir", +- "infoplease.com", +- "suruga-ya.jp", +- "deredactie.be", +- "shangdu.com", +- "portail.free.fr", +- "smartaddons.com", +- "w3layouts.com", +- "wallstreet-online.de", +- "yapo.cl", +- "standard.co.uk", +- "atlas.sk", +- "seowizard.ru", +- "currys.co.uk", +- "nova.cz", +- "mygully.com", +- "favstar.fm", +- "themuse.com", +- "yudu.com", +- "urlopener.com", +- "ellentv.com", +- "imgsrc.ru", +- "km.ru", +- "guildwars2.com", +- "google.mu", +- "androidpit.de", +- "mrporter.com", +- "ttt4.com", +- "cbox.ws", +- "hf365.com", +- "1mobile.com", +- "punjabkesari.in", +- "msu.edu", +- "grasscity.com", +- "abduzeedo.com", +- "sublimetext.com", +- "jtb.co.jp", +- "mensxp.com", +- "myheritage.com", +- "onvasortir.com", +- "safeway.com", +- "comicvine.com", +- "cpubenchmark.net", +- "nn.ru", +- "animefreak.tv", +- "angularjs.org", +- "managewp.com", +- "ameli.fr", +- "merrjep.com", +- "christianbook.com", +- "nubiles.net", +- "klmty.net", +- "247sports.com", +- "aramex.com", +- "tubent.com", +- "cognitiveseo.com", +- "bankpasargad.com", +- "pingler.com", +- "compareja.com.br", +- "surveyzrewardcenter.eu", +- "allyes.com", +- "graaam.com", +- "poriborton.com", +- "seslisozluk.net", +- "shopyourway.com", +- "awd.ru", +- "wa.gov.au", +- "slrclub.com", +- "apollo.lv", +- "girls-ly.com", +- "totalfilm.com", +- "cam4.it", +- "gogecapital.com", +- "sketchup.com", +- "muscleandfitness.com", +- "m24.ru", +- "blinklist.com", +- "artisteer.com", +- "nettavisen.no", +- "enjin.com", +- "pc6.com", +- "citrix.com", +- "indgovtjobs.in", +- "phpbb.com", +- "laughingsquid.com", +- "fblife.com", +- "stansberryresearch.com", +- "hugefiles.net", +- "mp3monkey.net", +- "mcdonalds.com", +- "vodafone.co.uk", +- "t-mobile.de", +- "tp-link.com.cn", +- "iflscience.com", +- "nst.com.my", +- "zoom.com.br", +- "dsw.com", +- "tigerair.com", +- "doityourself.com", +- "bongdainfo.com", +- "imacros.net", +- "paperlesspost.com", +- "sprinthost.ru", +- "lovoo.net", +- "kadinlarkulubu.com", +- "championselect.net", +- "jcb.co.jp", +- "miui.com", +- "impots.gouv.fr", +- "linkshop.com.cn", +- "pando.com", +- "ckeditor.com", +- "arabylife.com", +- "ml.com", +- "sheldonsfans.com", +- "freecharge.in", +- "magicmovies.com", +- "laweekly.com", +- "highrisehq.com", +- "tr.gg", +- "vidbull.com", +- "diy.com", +- "yieldtraffic.com", +- "cima4u.com", +- "gendama.jp", +- "netpnb.com", +- "kannaway.com", +- "soft112.com", +- "die-boersenformel.com", +- "movie25.so", +- "footyroom.com", +- "dostor.org", +- "aol.de", +- "desimartini.com", +- "themeko.org", +- "danarimedia.com", +- "toroporno.com", +- "stylemepretty.com", +- "urlm.de", +- "demotivation.me", +- "gentside.com", +- "carfax.com", +- "huzhou.gov.cn", +- "hotline.ua", +- "fullmoneysystem.com", +- "pornomovies.com", +- "fsymbols.com", +- "blog.de", +- "clickpoint.com", +- "tv-asahi.co.jp", +- "flightstats.com", +- "sonico.com", +- "afamily.vn", +- "anadolu.edu.tr", +- "rs-online.com", +- "androidpit.com", +- "a-telecharger.com", +- "wikifeet.com", +- "nix.ru", +- "tvmao.com", +- "groupon.es", +- "hitfix.com", +- "weathernews.jp", +- "dig.do", +- "googledrive.com", +- "fodors.com", +- "melon.com", +- "testflightapp.com", +- "markt.de", +- "mahua.com", +- "sedo.co.uk", +- "tuenti.com", +- "comm100.com", +- "olx.co.id", +- "lefrecce.it", +- "gov.cl", +- "wplift.com", +- "unn.com.ua", +- "arizona.edu", +- "msn.com.cn", +- "k7x.com", +- "techz.vn", +- "jobomas.com", +- "extranetinvestment.com", +- "tengrinews.kz", +- "comicbookmovie.com", +- "4porn.com", +- "rubiconproject.com", +- "gametracker.com", +- "otcmarkets.com", +- "mismarcadores.com", +- "trojmiasto.pl", +- "cleverreach.com", +- "contactform7.com", +- "weloveshopping.com", +- "runnersworld.com", +- "falabella.com", +- "airtelbroadband.in", +- "twistys.com", +- "ebesucher.de", +- "belastingdienst.nl", +- "orlandosentinel.com", +- "th3professional.com", +- "duke.edu", +- "opensubtitles.us", +- "clickme.net", +- "infor.pl", +- "unesco.org", +- "socialfabric.us", +- "ename.net", +- "alternativeto.net", +- "rotahaber.com", +- "johnchow.com", +- "pervclips.com", +- "linkfeed.ru", +- "dtvideo.com", +- "kinoman.tv", +- "siteprice.org", +- "lacuerda.net", +- "amulyam.in", +- "mandghomebusiness.com", +- "infojobs.com.br", +- "hirufm.lk", +- "mybloggertricks.com", +- "athemes.com", +- "moikrug.ru", +- "fybersearch.com", +- "wine-searcher.com", +- "davidicke.com", +- "dotabuff.com", +- "sainsburys.co.uk", +- "ovaustralia.com", +- "updatesoftnow.com", +- "desarrolloweb.com", +- "elaph.com", +- "icc-cricket.com", +- "gaytube.com", +- "di.fm", +- "99wed.com", +- "c-and-a.com", +- "mlxchange.com", +- "realgfporn.com", +- "synxis.com", +- "optymalizacja.com", +- "ibtesama.com", +- "hankooki.com", +- "shiksha.com", +- "anoox.com", +- "seamless.com", +- "stripe.com", +- "ets.org", +- "fresherslive.com", +- "webcoinpay.net", +- "oscommerce.com", +- "gratisprogramas.org", +- "football365.com", +- "mkyong.com", +- "antichat.ru", +- "spamarrest.com", +- "ubc.ca", +- "36kr.com", +- "startv.in", +- "shoutcast.com", +- "heureka.sk", +- "entheosweb.com", +- "51wan.com", +- "madadsmedia.com", +- "parse.com", +- "ngacn.cc", +- "techbargains.com", +- "tvmovie.de", +- "cpmstar.com", +- "torproject.org", +- "residentadvisor.net", +- "genbeta.com", +- "hulu.jp", +- "pluralsight.com", +- "postini.com", +- "zombie.jp", +- "skimlinks.com", +- "liverail.com", +- "phys.org", +- "slashfilm.com", +- "livemaster.ru", +- "idwebgame.com", +- "pho.to", +- "dealfish.co.th", +- "s1979.com", +- "designfloat.com", +- "live365.com", +- "pbase.com", +- "eniro.se", +- "irannaz.com", +- "socialmonkee.com", +- "uidai.gov.in", +- "joomlashine.com", +- "allhyipmon.ru", +- "upbulk.com", +- "diapers.com", +- "flypgs.com", +- "hotmart.com.br", +- "globus-inter.com", +- "airfrance.fr", +- "t3.com", +- "unetepubli.com", +- "yahoo-help.jp", +- "iphones.ru", +- "95559.com.cn", +- "glamsham.com", +- "gophoto.it", +- "statmyweb.com", +- "aftermarket.pl", +- "forumotion.com", +- "iafd.com", +- "hotlog.ru", +- "drclix.com", +- "wawa-mania.ec", +- "nichepursuits.com", +- "imp.free.fr", +- "baofeng.com", +- "binsearch.info", +- "neswangy.net", +- "parperfeito.com.br", +- "theeroticreview.com", +- "sabayacafe.com", +- "maplestage.com", +- "icook.tw", +- "customerhub.net", +- "uid.me", +- "viperchill.com", +- "askfrank.net", +- "juegosjuegos.com", +- "debonairblog.com", +- "coingeneration.com", +- "onetravel.com", +- "slutroulette.com", +- "jetpack.me", +- "embedupload.com", +- "bancodevenezuela.com", +- "mysavingsmedia.net", +- "smallbiztrends.com", +- "emirates247.com", +- "bu.edu", +- "fineco.it", +- "netbarg.com", +- "gatech.edu", +- "zik.ua", +- "peliculascoco.com", +- "hkjc.com", +- "turkiyegazetesi.com.tr", +- "cooperativa.cl", +- "challenges.fr", +- "usingenglish.com", +- "vouchercodes.co.uk", +- "bonprix.de", +- "disneylatino.com", +- "townwork.net", +- "rentanything.com", +- "krypt.com", +- "wral.com", +- "globes.co.il", +- "designtaxi.com", +- "mp-success.com", +- "invisionpower.com", +- "liontravel.com", +- "classicrummy.com", +- "mt.co.kr", +- "inccel.com", +- "santander.cl", +- "afip.gov.ar", +- "yellowpages.com.au", +- "osclass.org", +- "couriermail.com.au", +- "stream.cz", +- "wizaz.pl", +- "linkresearchtools.com", +- "cam4.co.uk", +- "allafrica.com", +- "gezginler.net", +- "free-ebooks.net", +- "hopesandfears.com", +- "ticketmaster.com.mx", +- "ohio.gov", +- "liberoquotidiano.it", +- "neurs.net", +- "forumophilia.com", +- "odnako.org", +- "gamekult.com", +- "vh1.com", +- "zxart.cn", +- "mass.gov", +- "tv-tokyo.co.jp", +- "mundopromocion.com", +- "theme-junkie.com", +- "asu.edu", +- "lalibre.be", +- "pornokopilka.info", +- "fx678.com", +- "netbeans.org", +- "chinabidding.com.cn", +- "lunapic.com", +- "dramafever.com", +- "hbogo.com", +- "torrents.net", +- "woopra.com", +- "justfab.com", +- "fitnessmagazine.com", +- "tripadvisor.com.mx", +- "183.com.cn", +- "adscendmedia.com", +- "geek.com", +- "thepetitionsite.com", +- "skyscanner.ru", +- "morningpost.com.cn", +- "concursolutions.com", +- "camplace.com", +- "smarturl.it", +- "browsershots.org", +- "piktochart.com", +- "elcorreo.com", +- "collegeboard.org", +- "kasikornbank.com", +- "adsoftheworld.com", +- "fakku.net", +- "jpn.org", +- "sahafah.net", +- "rubias19.com", +- "fc2web.com", +- "redsurf.ru", +- "iproperty.com.my", +- "browsersafeguard.com", +- "mmajunkie.com", +- "bangkokbank.com", +- "ovi.com", +- "fap.to", +- "filmygyan.in", +- "edaily.vn", +- "affilorama.com", +- "valuecommerce.ne.jp", +- "softaculous.com", +- "exchanger.ru", +- "html-color-codes.info", +- "hd-xvideos.com", +- "realself.com", +- "geocaching.com", +- "mom.me", +- "stc.com.sa", +- "video-i365.com", +- "umd.edu", +- "jeffbullas.com", +- "kora.com", +- "cyberchimps.com", +- "popupads.ir", +- "chatango.com", +- "gearslutz.com", +- "fout.jp", +- "contactmusic.com", +- "linkcrypt.ws", +- "sophos.com", +- "forum-auto.com", +- "svtplay.se", +- "newsbusters.org", +- "fileswap.com", +- "phpfox.com", +- "denic.de", +- "riverisland.com", +- "encuentra24.com", +- "foxnewsinsider.com", +- "dtdc.com", +- "tayyar.org", +- "thepushbuttonmillionaire.com", +- "brokenlinkcheck.com", +- "ju51.com", +- "stihi.ru", +- "psdgraphics.com", +- "mommyfucktube.com", +- "mangocity.com", +- "routard.com", +- "whicdn.com", +- "socialtriggers.com", +- "e-bookspdf.org", +- "songspk3.in", +- "paginasamarillas.com", +- "webgame.in.th", +- "xxxdessert.com", +- "materiel.net", +- "skillshare.com", +- "tubepleasure.com", +- "paypal.de", +- "yeahmobi.com", +- "torrentz-proxy.com", +- "aircel.com", +- "openask.com", +- "trafficg.com", +- "anthem.com", +- "aleseriale.pl", +- "f-page.ru", +- "hrsmart.com", +- "cbengine.com", +- "startlap.com", +- "spamhaus.org", +- "trovit.com", +- "sporcle.com", +- "xs8.cn", +- "romwe.com", +- "powtoon.com", +- "cybozulive.com", +- "zbiornik.com", +- "cebit.de", +- "flipboard.com", +- "news.am", +- "wm-panel.com", +- "topnews.ru", +- "usp.br", +- "realmadrid.com", +- "fastdist.net", +- "unian.ua", +- "youtube.com/user/PewDiePie", +- "unc.edu", +- "tamu.edu", +- "ip2location.com", +- "americanapparel.net", +- "virtualedge.com", +- "vikatan.com", +- "goodlayers.com", +- "feedblitz.com", +- "dateinasia.com", +- "freepdfconvert.com", +- "iweb.com", +- "lachainemeteo.com", +- "aetna.com", +- "ti.com", +- "gratisjuegos.org", +- "webhostinghub.com", +- "preev.com", +- "holidayiq.com", +- "elpais.com.uy", +- "uchicago.edu", +- "telcel.com", +- "feebbo.com", +- "webhallen.com", +- "dmir.ru", +- "emailmg.ipage.com", +- "hrs.de", +- "propakistani.pk", +- "theme.co", +- "bigpara.com", +- "finishline.com", +- "fardanews.com", +- "nat.gov.tw", +- "stoloto.ru", +- "sermepa.es", +- "radaris.com", +- "softportal.com", +- "turkiye.gov.tr", +- "nnn.ru", +- "e-familynet.com", +- "wenkang.cn", +- "teamworkpm.net", +- "videohelp.com", +- "pixmania.com", +- "games.com", +- "guns.ru", +- "plus28.com", +- "pf.pl", +- "pbworks.com", +- "sedo.de", +- "freedownloadscenter.com", +- "backpackers.com.tw", +- "mycokerewards.com", +- "chinaunix.net", +- "invisionapp.com", +- "wordhippo.com", +- "unitezz.com", +- "yan.vn", +- "sonhoo.com", +- "spielaffe.de", +- "d.pr", +- "technologyreview.com", +- "democraticunderground.com", +- "molotok.ru", +- "watchever.de", +- "wdc.com", +- "torg.com", +- "ivillage.com", +- "portableapps.com", +- "ovh.es", +- "vse.kz", +- "alrajhibank.com.sa", +- "dhl-usa.com", +- "pingan.com", +- "excite.com", +- "cincodias.com", +- "marksdailyapple.com", +- "bter.com", +- "nationaljournal.com", +- "fao.org", +- "oddee.com", +- "digitalriver.com", +- "livescore.in", +- "siilu.com", +- "gofirstrowus.eu", +- "alquds.co.uk", +- "autoevolution.com", +- "zerx.ru", +- "trovit.it", +- "hvylya.org", +- "carters.com", +- "shejis.com", +- "radio-canada.ca", +- "vodafone.es", +- "sky.fm", +- "maturetube.com", +- "virtualtourist.com", +- "line25.com", +- "rzeczpospolita.pl", +- "megacurioso.com.br", +- "beliefnet.com", +- "eklablog.com", +- "hbo.com", +- "bsi.ir", +- "fastweb.it", +- "webrazzi.com", +- "telam.com.ar", +- "downloadming.me", +- "bluefly.com", +- "thewire.com", +- "erotube.org", +- "vt.edu", +- "jsbin.com", +- "ibosocial.com", +- "brides.com.cn", +- "jn.pt", +- "togetter.com", +- "olhardigital.uol.com.br", +- "ebookee.org", +- "socialgamenet.com", +- "romaniatv.net", +- "epweike.com", +- "pronto.com", +- "blog.pl", +- "top81.cn", +- "flagfox.wordpress.com", +- "unionbank.com", +- "visitkorea.or.kr", +- "blogspot.dk", +- "fermasosedi.ru", +- "inmobi.com", +- "abc.com.py", +- "iqoo.me", +- "17k.com", +- "onlineapplicationsdownloads.com", +- "komli.com", +- "tala.ir", +- "videopremium.me", +- "job.ru", +- "sunbiz.org", +- "tw116.com", +- "browserstack.com", +- "youtu.be", +- "yardbarker.com", +- "flvmplayer.com", +- "kulichki.net", +- "gravity.com", +- "levelclix.com", +- "kissanime.com", +- "insightexpressai.com", +- "colorhexa.com", +- "citizensbankonline.com", +- "hjenglish.com", +- "voeazul.com.br", +- "paraskhnio.gr", +- "es.tl", +- "busuu.com", +- "appsumo.com", +- "metacrawler.com", +- "ciku5.com", +- "android-hilfe.de", +- "laterooms.com", +- "google.com.bn", +- "gamefront.com", +- "rev2pub.com", +- "bharatiyamobile.com", +- "publicidees.com", +- "jossandmain.com", +- "babycentre.co.uk", +- "zetabux.com", +- "movieweb.com", +- "timescity.com", +- "dnevnik.ru", +- "nlcafe.hu", +- "magazine3k.com", +- "irancell.ir", +- "kalaydo.de", +- "e5.ru", +- "lecai.com", +- "sbs.com.au", +- "sierratradingpost.com", +- "girlfriendvideos.com", +- "ink361.com", +- "corporate-ir.net", +- "allgameshome.com", +- "povarenok.ru", +- "typo3.org", +- "turbosquid.com", +- "miniurls.co", +- "thinkwithgoogle.com", +- "haber3.com", +- "newsmeback.com", +- "sipse.com", +- "osxdaily.com", +- "9lessons.info", +- "cyclopaedia.net", +- "reallifecam.com", +- "gameblog.fr", +- "colourbox.com", +- "mixedmartialarts.com", +- "prostoporno.net", +- "chanel.com", +- "maxim.com", +- "cam4.es", +- "olx.com.mx", +- "newscientist.com", +- "netcombo.com.br", +- "serienjunkies.org", +- "shablol.com", +- "bnpparibasfortis.be", +- "canada.com", +- "timeslive.co.za", +- "cinematoday.jp", +- "21cineplex.com", +- "bodisparking.com", +- "cruisecritic.com", +- "vertoz.com", +- "glosbe.com", +- "nstarikov.ru", +- "epinions.com", +- "colbertnation.com", +- "marketglory.com", +- "emailmeform.com", +- "angloinfo.com", +- "filfan.com", +- "yougetsignal.com", +- "broker.to", +- "quickbux.net", +- "gottabemobile.com", +- "beyondtherack.com", +- "tripadvisor.ru", +- "jschina.com.cn", +- "registraduria.gov.co", +- "thisoldhouse.com", +- "appcelerator.com", +- "noticias24carabobo.com", +- "skelbiu.lt", +- "ru.wix.com", +- "iransong.com", +- "i-sux.com", +- "telerama.fr", +- "mydala.com", +- "pia.jp", +- "fusebux.com", +- "biquge.com", +- "microworkers.com", +- "onlywire.com", +- "fanbox.com", +- "ambitoweb.com", +- "tripadvisor.com.br", +- "postgresql.org", +- "telenet.be", +- "thegeekstuff.com", +- "primelocation.com", +- "ee.co.uk", +- "phoenixads.co.in", +- "brigitte.de", +- "360kad.com", +- "kathimerini.gr", +- "batoto.net", +- "babebuns.com", +- "webimpresion.com", +- "olx.com.ng", +- "which.co.uk", +- "f5haber.com", +- "cic.fr", +- "talkfusion.com", +- "ctrlq.org", +- "caracol.com.co", +- "wer-weiss-was.de", +- "invisionzone.com", +- "head-fi.org", +- "thingiverse.com", +- "manager-magazin.de", +- "bzwbk.pl", +- "f1news.ru", +- "tweetreach.com", +- "sj998.com", +- "streetdirectory.com", +- "asos.fr", +- "kalahari.com", +- "classiccars.com", +- "bitacoras.com", +- "bravotv.com", +- "beanfun.com", +- "bonappetit.com", +- "fashionara.com", +- "techdirt.com", +- "newlook.com", +- "iyinet.com", +- "mogujie.com", +- "carros.com.br", +- "starfall.com", +- "rp5.ru", +- "pocket-lint.com", +- "homeadvisor.com", +- "webhostbox.net", +- "cameraboys.com", +- "pricerunner.com", +- "worldcarfans.com", +- "meganovosti.net", +- "taxheaven.gr", +- "freewebsitetemplates.com", +- "mr90.ir", +- "cheapflights.co.uk", +- "bankinter.com", +- "euroresidentes.com", +- "bettycrocker.com", +- "filmey.com", +- "sheinside.com", +- "2ememain.be", +- "tu.tv", +- "kugou.com", +- "destructoid.com", +- "todoist.com", +- "karmaloop.com", +- "appadvice.com", +- "html5rocks.com", +- "osdir.com", +- "webisgreat.info", +- "dailyblogtips.com", +- "mca.gov.in", +- "e-estekhdam.com", +- "hlntv.com", +- "proprofs.com", +- "his-j.com", +- "im286.com", +- "mmorpg.com", +- "shooshtime.com", +- "terra.es", +- "lpcloudbox301.com", +- "tubepornstars.com", +- "tableausoftware.com", +- "soccersuck.com", +- "websurf.ru", +- "indiafreestuff.in", +- "pimei.com", +- "colatour.com.tw", +- "fssnet.co.in", +- "maxpark.com", +- "foodandwine.com", +- "apachefriends.org", +- "standardchartered.co.in", +- "waveapps.com", +- "gosong.net", +- "spring.me", +- "weatherbug.com", +- "iw33.com", +- "apserver.net", +- "thenationonlineng.net", +- "tjournal.ru", +- "greatschools.net", +- "3movs.com", +- "61.com", +- "directpaybiz.com", +- "w3snoop.com", +- "jsonline.com", +- "grainger.com", +- "prevention.com", +- "blizzard.com", +- "baseball-reference.com", +- "cjn.cn", +- "fasthosts.co.uk", +- "kym-cdn.com", +- "cuponation.in", +- "cam4.fr", +- "lalawan67.net", +- "videovantage.co", +- "elimparcial.com", +- "edlen24.com", +- "donya-e-eqtesad.com", +- "englishforums.com", +- "dom2.ru", +- "cinepolis.com", +- "healthtap.com", +- "astroawani.com", +- "autosport.com", +- "finalfantasyxiv.com", +- "valueclickmedia.com", +- "vitaminshoppe.com", +- "apartmentguide.com", +- "notjustok.com", +- "gratispeliculas.org", +- "intporn.com", +- "eroticbeauties.net", +- "egloos.com", +- "nujij.nl", +- "godvine.com", +- "punishtube.com", +- "wisegeek.org", +- "somuch.com", +- "taz.de", +- "zetaboards.com", +- "gravityforms.com", +- "telegraf.rs", +- "odn.ne.jp", +- "topeleven.com", +- "peekyou.com", +- "razerzone.com", +- "furaffinity.net", +- "mobikwik.com", +- "eventful.com", +- "sextube.fm", +- "treccani.it", +- "phatograph.com", +- "feedthebot.com", +- "netdoctor.co.uk", +- "collarme.com", +- "reformal.ru", +- "hemnet.se", +- "jacquieetmicheltv.net", +- "9ku.com", +- "kraloyun.com", +- "directadmin.com", +- "bongda.com.vn", +- "ddizi.org", +- "tedata.net", +- "fb.org", +- "pagemodo.com", +- "satu.kz", +- "nodejs.org", +- "tiberiumalliances.com", +- "wallst.com", +- "dezeen.com", +- "rense.com", +- "hawkhost.com", +- "vonage.com", +- "zjol.com.cn", +- "housefun.com.tw", +- "ad1.ru", +- "myredbook.com", +- "rarlab.com", +- "audiopoisk.com", +- "pbebank.com", +- "whocallsme.com", +- "playground.ru", +- "tnr.com", +- "firstdirect.com", +- "xinhua.jp", +- "gmane.org", +- "verseriesynovelas.com", +- "broadwayworld.com", +- "thefrisky.com", +- "rapmls.com", +- "skapiec.pl", +- "wholesale-dress.net", +- "alison.com", +- "n4hr.com", +- "prefiles.com", +- "vtc.vn", +- "coral.co.uk", +- "azyya.com", +- "smithsonianmag.com", +- "ticksy.com", +- "theync.com", +- "pcinpact.com", +- "eventbrite.co.uk", +- "buenosaires.gob.ar", +- "a5cee7.se", +- "bazingamob.com", +- "pp.cc", +- "shortnews.de", +- "responsinator.com", +- "filepost.com", +- "securefreedom.com", +- "notepad-plus-plus.org", +- "thekrazycouponlady.com", +- "apktops.ir", +- "nr2.ru", +- "timinternet.it", +- "man.lv", +- "forexpeacearmy.com", +- "plius.lt", +- "vcp.ir", +- "mysitecost.ru", +- "yourfiledownloader.com", +- "dealguardian.com", +- "sql.ru", +- "laravel.com", +- "shape5.com", +- "visa.com", +- "vocus.com", +- "stackthatmoney.com", +- "pornicom.com", +- "my.tv.sohu.com/user/cc128", +- "urban-rivals.com", +- "robotstxt.org", +- "colorlabsproject.com", +- "mg.gov.br", +- "local.ch", +- "adbooth.net", +- "se.pl", +- "al-akhbar.com", +- "he.net", +- "covoiturage.fr", +- "sakshieducation.com", +- "thisdaylive.com", +- "thestudentroom.co.uk", +- "pzy.be", +- "designyoutrust.com", +- "forbes.ua", +- "fandongxi.com", +- "expertreviews.co.uk", +- "dream-demo.com", +- "barchart.com", +- "ht.ly", +- "burbuja.info", +- "edgecastcdn.net", +- "amazinglytimedphotos.com", +- "value-domain.com", +- "shareaholic.com", +- "promptfile.com", +- "voetbalzone.nl", +- "ziare.com", +- "trafficbroker.com", +- "coolsport.tv", +- "vanguardia.com.mx", +- "makeshop.jp", +- "mobilism.org", +- "rebelmouse.com", +- "brisbanetimes.com.au", +- "publimetro.com.mx", +- "coolkora.com", +- "realsparrow.com", +- "honda.co.jp", +- "dealcatcher.com", +- "sinoptik.ua", +- "lefeng.com", +- "mamaclub.com", +- "bezuzyteczna.pl", +- "smn.gov.ar", +- "manhub.com", +- "pcgameshardware.de", +- "shipstation.com", +- "zive.cz", +- "disneystore.com", +- "despegar.com.mx", +- "addictivetips.com", +- "path.com", +- "pathofexile.com", +- "seitenreport.de", +- "pardot.com", +- "decathlon.fr", +- "flvrunner.com", +- "xat.com", +- "matchendirect.fr", +- "roem.ru", +- "wat.tv", +- "edline.net", +- "znds.com", +- "northwestern.edu", +- "friendscout24.de", +- "movoto.com", +- "dengiprosto.info", +- "dlisted.com", +- "sports.fr", +- "maxifoot.fr", +- "hubspot.net", +- "natalie.mu", +- "tabloidpulsa.co.id", +- "polki.pl", +- "gamasutra.com", +- "matomeantena.com", +- "adwords-community.com", +- "gallup.com", +- "redtubenacional.com", +- "mangastream.com", +- "zulutrade.com", +- "wunderlist.com", +- "taste.com.au", +- "myhosting.com", +- "totalbeauty.com", +- "8pic.ir", +- "sltrib.com", +- "88db.com", +- "minikoyuncu.com", +- "net4.in", +- "nuevoloquo.com", +- "cago365.com", +- "afip.gob.ar", +- "keep2share.cc", +- "kw.com", +- "terra.com.pe", +- "profi-forex.org", +- "filecloud.io", +- "peliculas4.com", +- "mysitemyway.com", +- "ilmattino.it", +- "geizhals.de", +- "sheershanews.com", +- "whatwpthemeisthat.com", +- "teknosa.com", +- "myshopping.com.au", +- "teamskeet.com", +- "gandalfporn.com", +- "2670.com", +- "peoplefinders.com", +- "elo7.com.br", +- "sofoot.com", +- "uhaul.com", +- "sagepay.com", +- "unb.br", +- "jhu.edu", +- "barrons.com", +- "hasznaltauto.hu", +- "winfxstrategy.com", +- "spamcop.net", +- "az.pl", +- "op.fi", +- "istruzione.it", +- "eveonline.com", +- "imgnip.com", +- "jjoobb.cn", +- "itesm.mx", +- "wptavern.com", +- "kproxy.com", +- "pulptastic.com", +- "quidco.com", +- "ekantipur.com", +- "joann.com", +- "whattoexpect.com", +- "tomshw.it", +- "internetbookshop.it", +- "followerwonk.com", +- "cisionpoint.com", +- "cint.com", +- "quondos.com", +- "suntimes.com", +- "saveinter.net", +- "eiga.com", +- "jdzj.com", +- "goldprice.org", +- "websitemagazine.com", +- "051jk.com", +- "inweb24.com", +- "gamgos.ae", +- "elog-ch.com", +- "trovit.com.mx", +- "webnode.cz", +- "ethnos.gr", +- "oodle.com", +- "subtitulos.es", +- "gameinformer.com", +- "9to5mac.com", +- "youwatch.org", +- "ibps.in", +- "biggerpockets.com", +- "sport24.co.za", +- "my.tv.sohu.com/user/cc133", +- "capsulecrm.com", +- "fuett.mx", +- "poznan.pl", +- "melateiran.com", +- "divxtotal.com", +- "aftabir.com", +- "cyberlink.com", +- "ulozto.cz", +- "jetswap.com", +- "premium.wix.com", +- "eprize.com", +- "huntington.com", +- "careerlink.vn", +- "allhyipmonitors.com", +- "autorambler.ru", +- "jamieoliver.com", +- "minube.com", +- "credomatic.com", +- "oddschecker.com", +- "listia.com", +- "mrrebates.com", +- "8684.cn", +- "kabam.com", +- "tripit.com", +- "gry.pl", +- "ecvv.com", +- "utanbaby.com", +- "lavoixdunord.fr", +- "just-eat.co.uk", +- "go-for-files.com", +- "afpbb.com", +- "mybb.com", +- "madmoizelle.com", +- "sensacine.com", +- "jtl-software.de", +- "worldtimeserver.com", +- "sunmaker.com", +- "marieforleo.com", +- "123sdfsdfsdfsd.ru", +- "duga.jp", +- "avery.com", +- "tvguide.co.uk", +- "salliemae.com", +- "zap.com.br", +- "my.tv.sohu.com/user/cc112", +- "bookmark4you.com", +- "twodollarclick.com", +- "encontreinarede.com", +- "joomshaper.com", +- "marinetraffic.com", +- "feedermatrix.com", +- "nowvideo.at", +- "millenium.org", +- "newalbumreleases.net", +- "frankkern.com", +- "onlineconversion.com", +- "ahlalhdeeth.com", +- "mediawiki.org", +- "xseo.in", +- "generation-nt.com", +- "naftemporiki.gr", +- "hardforum.com", +- "hornbunny.com", +- "my.tv.sohu.com/user/cc124", +- "housing.com", +- "vogue.es", +- "safemls.net", +- "cuisineaz.com", +- "estekhtam.com", +- "coqnu.com", +- "despegar.com.ar", +- "fedoraproject.org", +- "france2.fr", +- "autovit.ro", +- "tradetang.com", +- "levelupgames.uol.com.br", +- "dnforum.com", +- "homebank.kz", +- "carnival.com", +- "hzycsj.com", +- "army.mil", +- "bootsnipp.com", +- "istockimg.com", +- "po-kaki-to.com", +- "qiushibaike.com", +- "tsb.co.uk", +- "gzmama.com", +- "aitnews.com", +- "tripwiremagazine.com", +- "torrenty.org", +- "djangoproject.com", +- "chelseafc.com", +- "gamesgames.com", +- "herold.at", +- "baur.de", +- "kauppalehti.fi", +- "nrelate.com", +- "clickwebinar.com", +- "entropay.com", +- "gridserver.com", +- "virginia.gov", +- "tuan800.com", +- "trueactivist.com", +- "caras.uol.com.br", +- "fontawesome.io", +- "haodou.com", +- "reshareworthy.com", +- "royalcaribbean.com", +- "crakrevenue.com", +- "motika.com.mk", +- "xovi.de", +- "deutsche-startups.de", +- "inven.co.kr", +- "atrapalo.com", +- "ictv.ua", +- "muji.net", +- "kingplayer.com", +- "adworkmedia.com", +- "xjtu.edu.cn", +- "thenounproject.com", +- "professionali.ru", +- "xizhi.com", +- "boo-box.com", +- "customink.com", +- "groupon.my", +- "spartoo.com", +- "bannersdontwork.com", +- "ncore.cc", +- "reklama5.mk", +- "macrojuegos.com", +- "zenhabits.net", +- "te3p.com", +- "utah.gov", +- "telesurtv.net", +- "101.ru", +- "5yi.com", +- "lide.cz", +- "ancestry.co.uk", +- "sana.sy", +- "siteslike.com", +- "vg247.com", +- "tyzhden.ua", +- "ncsu.edu", +- "apherald.com", +- "taaza.com", +- "traffic-delivery.com", +- "uuyoyo.com", +- "hwupgrade.it", +- "game-debate.com", +- "jetpack.wordpress.com", +- "anycodes.com", +- "femina.hu", +- "zattoo.com", +- "acm.org", +- "comenity.net", +- "tarot.com", +- "azadliq.org", +- "advertiserdigital.com", +- "osym.gov.tr", +- "empornium.me", +- "netzero.net", +- "myfico.com", +- "nolix.ru", +- "cnwnews.com", +- "springpad.com", +- "ahangestan.in", +- "localbitcoins.com", +- "nikkei.co.jp", +- "youlikehits.com", +- "boyfriendtv.com", +- "wampserver.com", +- "elnorte.com", +- "codeschool.com", +- "si.edu", +- "nosis.com", +- "downloadhelper.net", +- "global-free-classified-ads.com", +- "flagmantube.com", +- "elnuevodiario.com.ni", +- "handelsbanken.se", +- "sverigesradio.se", +- "femjoy.com", +- "444.hu", +- "calcalist.co.il", +- "asiatech.ir", +- "tv.nu", +- "installmac.com", +- "programmableweb.com", +- "fotki.com", +- "vidivodo.com", +- "websquash.com", +- "selfgrowth.com", +- "wehkamp.nl", +- "amawebs.com", +- "3dlat.com", +- "comunidades.net", +- "streamin.to", +- "idbi.com", +- "cshtracker.com", +- "cdbaby.com", +- "mycommerce.com", +- "united-domains.de", +- "tradingview.com", +- "niniweblog.com", +- "avn.info.ve", +- "apa.tv", +- "pinnaclesports.com", +- "adafruit.com", +- "ipower.com", +- "lebuteur.com", +- "utah.edu", +- "mobeoffice.com", +- "lingualeo.com", +- "fuub.net", +- "tvmongol.com", +- "namasthetelangaana.com", +- "secretsearchenginelabs.com", +- "whowhatwear.com", +- "hiapk.com", +- "torrentz.sx", +- "php.su", +- "sodahead.com", +- "sbb.ch", +- "k12.ca.us", +- "jecontacte.com", +- "thehollywoodgossip.com", +- "pekao24.pl", +- "yourtest-india.com", +- "screwfix.com", +- "humoron.com", +- "yiwugou.com", +- "mulher.uol.com.br", +- "thehackernews.com", +- "shopmania.ro", +- "dlink.com", +- "despegar.com", +- "archlinux.org", +- "nielsen.com", +- "rosnet.ru", +- "appsapk.com", +- "funfarsi.ir", +- "4over.com", +- "subscribe.wordpress.com", +- "lewrockwell.com", +- "portalnet.cl", +- "antenam.info", +- "letribunaldunet.fr", +- "see-tube.com", +- "tureng.com", +- "topcashback.co.uk", +- "contactcars.com", +- "jeux.fr", +- "khan.co.kr", +- "ffffound.com", +- "gmail.com", +- "laprensa.com.ni", +- "jizzhut.com", +- "liilas.com", +- "muare.vn", +- "kting.cn", +- "heteml.jp", +- "genericsteps.com", +- "searchcompletion.com", +- "dwayir.com", +- "dicionarioinformal.com.br", +- "vcita.com", +- "fitsugar.com", +- "kleiderkreisel.de", +- "collective-evolution.com", +- "ethz.ch", +- "sendreach.com", +- "abidjan.net", +- "islamicfinder.org", +- "elong.com", +- "yonhapnews.co.kr", +- "seratnews.ir", +- "stream2watch.me", +- "content-watch.ru", +- "seotechnocrat.com", +- "todaoferta.uol.com.br", +- "toyota.jp", +- "purevid.com", +- "incredimail.com", +- "kia.com", +- "intensedebate.com", +- "kaufmich.com", +- "servis24.cz", +- "brusheezy.com", +- "rtbtraf.com", +- "tejiawang.com", +- "expedia.co.in", +- "food52.com", +- "top-channel.tv", +- "jpnn.com", +- "desitorrents.com", +- "faxingw.cn", +- "crutchfield.com", +- "seneweb.com", +- "usenet.nl", +- "aviasales.ru", +- "nesine.com", +- "appshopper.com", +- "dressupgamesite.com", +- "lowendtalk.com", +- "muslima.com", +- "v-webs.com", +- "linkomanija.net", +- "geniuzz.com", +- "caringbridge.org", +- "gooya.com", +- "dospy.com", +- "siol.net", +- "games.co.id", +- "archiveofourown.org", +- "rocketlawyer.com", +- "free-downloadz.net", +- "pastemagazine.com", +- "invest-system.net", +- "el-ahly.com", +- "todayhumor.co.kr", +- "racingpost.com", +- "stereogum.com", +- "soompi.com", +- "pof.com.br", +- "brainabundance.com", +- "fontpalace.com", +- "canon.jp", +- "eldeforma.com", +- "sacbee.com", +- "jobscore.com", +- "fashionista.com", +- "mywork.vn", +- "thisis50.com", +- "cubadebate.cu", +- "healthguru.com", +- "instatheme.com", +- "apotheken-umschau.de", +- "blizko.ru", +- "tinymce.com", +- "virtualbox.org", +- "tehran.ir", +- "pr.gov.br", +- "mlmleadsystempro.com", +- "resbux.com", +- "komonews.com", +- "childrensplace.com", +- "yoyopress.com", +- "cloudify.cc", +- "24livenewspaper.com", +- "w4.com", +- "islamway.net", +- "fantagazzetta.com", +- "imgspice.com", +- "bovada.lv", +- "payback.de", +- "peb.pl", +- "hotnigerianjobs.com", +- "dev7studios.com", +- "tejaratbank.net", +- "takuhai.jp", +- "travelmath.com", +- "cultofmac.com", +- "wakeupnow.com", +- "insidefacebook.com", +- "mediamarkt.es", +- "500wan.com", +- "rumah123.com", +- "contentmarketinginstitute.com", +- "ed.ac.uk", +- "phimvang.com", +- "womansday.com", +- "lookatme.ru", +- "citizensbank.com", +- "esam.ir", +- "phandroid.com", +- "canadiantire.ca", +- "serienjunkies.de", +- "bbspink.com", +- "yaranehkala.ir", +- "vesti.bg", +- "el-carabobeno.com", +- "smarty.net", +- "6tie.com", +- "antpedia.com", +- "p-world.co.jp", +- "camelcamelcamel.com", +- "sudu.cn", +- "priberam.pt", +- "infoworld.com", +- "myrecipes.com", +- "metrodeal.com", +- "widgetbox.com", +- "krone.at", +- "outfox.tv", +- "mymp4.in", +- "685wo.com", +- "sadanduseless.com", +- "cgd.pt", +- "mrmlsmatrix.com", +- "parenting.com", +- "tradepub.com", +- "linkvehicle.com", +- "mobiledia.com", +- "rghost.ru", +- "xxsy.net", +- "goanimate.com", +- "pikacn.com", +- "metropcs.com", +- "byu.edu", +- "bitelia.com", +- "designscrazed.com", +- "wpde.org", +- "paheal.net", +- "nulled.cc", +- "hmv.co.jp", +- "openx.com", +- "hyundai.com", +- "vvvdj.com", +- "reason.com", +- "livesports.pl", +- "polskieradio.pl", +- "oszone.net", +- "chinhphu.vn", +- "performancehorizon.com", +- "internetretailer.com", +- "skoob.com.br", +- "mediaworld.it", +- "imgrind.com", +- "bancopopular.es", +- "seogadget.ru", +- "m6.fr", +- "rongbay.com", +- "niazpardaz.com", +- "rewity.com", +- "ssense.com", +- "sky-fire.com", +- "flibusta.net", +- "eat24hours.com", +- "lotto.pl", +- "cnw.com.cn", +- "takvim.com.tr", +- "englishtown.com", +- "letudiant.fr", +- "peliculasmas.com", +- "askme.com", +- "linksmanagement.com", +- "webseoanalytics.com", +- "presse-citron.net", +- "eldiariodeamerica.com", +- "instantshift.com", +- "ampxchange.com", +- "xe.gr", +- "experts-exchange.com", +- "sportcategory.com", +- "sharecash.org", +- "linksys.com", +- "yninfo.com", +- "onlinelic.in", +- "aflamneek.com", +- "22.cn", +- "ubuntu-fr.org", +- "cjs.com.cn", +- "mp3clan.com", +- "grani.ru", +- "zen-cart.com", +- "shippingchina.com", +- "jsfor.net", +- "wanadoo.es", +- "zurker.com", +- "chotot.vn", +- "masaladesi.com", +- "insight.ly", +- "trivago.de", +- "neue-sexpartner.com", +- "boe.es", +- "military.com", +- "moonbasa.com", +- "langlaoda.com", +- "tnooz.com", +- "zacks.com", +- "liverpool.com.mx", +- "internic.net", +- "ecuavisa.com", +- "autonews.ru", +- "mcafeesecure.com", +- "peopleclick.com", +- "madthumbs.com", +- "hot-live-chat.com", +- "sugarcrm.com", +- "notonthehighstreet.com", +- "linio.com.co", +- "smartbrief.com", +- "auto-motor-und-sport.de", +- "kyivpost.com", +- "instantteleseminar.com", +- "dillards.com", +- "5i5j.com", +- "runtastic.com", +- "danawa.com", +- "ladunliadi.blogspot.com", +- "getnews.jp", +- "romedic.ro", +- "rodfile.com", +- "instyle.com", +- "swoodoo.com", +- "bannersnack.com", +- "evolife.cn", +- "ktonanovenkogo.ru", +- "office.com", +- "zamalekfans.com", +- "magiran.com", +- "ithome.com", +- "ktrmr.com", +- "spoonful.com", +- "olleh.com", +- "bgr.in", +- "industrialthemes.com", +- "adbkm.com", +- "tsa-algerie.com", +- "bloggang.com", +- "mojang.com", +- "geoiptool.com", +- "autocarindia.com", +- "ajansspor.com", +- "onmeda.de", +- "midwayusa.com", +- "alicdn.com", +- "sportdog.gr", +- "ideeli.com", +- "haspa.de", +- "gladbux.com", +- "porn-star.com", +- "experiandirect.com", +- "yicheshi.com", +- "acervoamador.com", +- "designwall.com", +- "balkanweb.com", +- "response.jp", +- "nettoos.com", +- "beruby.com", +- "manageyourloans.com", +- "kidstaff.com.ua", +- "indeed.co.za", +- "monoprice.com", +- "chsi.com.cn", +- "boorsekala.com", +- "mstaml.com", +- "trafficvance.com", +- "tatatele.in", +- "startbootstrap.com", +- "graphicburger.com", +- "ad-vid-webs.com", +- "jp.dk", +- "one.co.il", +- "athensvoice.gr", +- "payu2blog.com", +- "epidemz.net", +- "dondominio.com", +- "doviz.com", +- "disquscdn.com", +- "work.ua", +- "vsemayki.ru", +- "ikyu.com", +- "songlyrics.com", +- "onlinebank.com", +- "thebump.com", +- "travian.com.tr", +- "java2s.com", +- "twittmate.com", +- "ignou.ac.in", +- "relink.us", +- "4738.com", +- "printvenue.com", +- "tekstowo.pl", +- "natro.com", +- "dengi-tut.info", +- "freeservers.com", +- "inbound.org", +- "free-press-release.com", +- "mydirtyhobby.com", +- "gamefly.com", +- "overclockers.co.uk", +- "eci.nic.in", +- "196.1.211.6", +- "versus.com", +- "batdongsan.com.vn", +- "vrisko.gr", +- "albayan.ae", +- "trendcounter.com", +- "500.com", +- "pagomiscuentas.com", +- "wankoz.com", +- "duote.com", +- "javascript.ru", +- "chevrolet.com", +- "coach.com", +- "decidatriunfar.net", +- "rememberthemilk.com", +- "virginmobileusa.com", +- "google.com.jm", +- "ucm.es", +- "ninja.co.jp", +- "rqzao.com", +- "periodistadigital.com", +- "heritage.org", +- "momtubesex.xxx", +- "vocabulary.com", +- "kupujemprodajem.com", +- "e-cigarette-forum.com", +- "paxum.com", +- "ilpost.it", +- "abercrombie.com", +- "pearsonmylabandmastering.com", +- "echoecho.com", +- "expedia.co.jp", +- "ticketfly.com", +- "colostate.edu", +- "sjtu.edu.cn", +- "seobudget.ru", +- "gigabyte.com", +- "gsmspain.com", +- "misr5.com", +- "enterfactory.com", +- "ciao.de", +- "wuv.de", +- "dagospia.com", +- "slashgear.com", +- "urdupoint.com", +- "themepunch.com", +- "travian.com", +- "discuz.com", +- "pixroute.com", +- "otzovik.com", +- "ubergizmo.com", +- "edreams.fr", +- "internet-positif.org", +- "asmcentral.com", +- "copadomundo.uol.com.br", +- "adjal.com", +- "gotomypc.com", +- "partycity.com", +- "leggo.it", +- "blogosfere.it", +- "teamcoco.com", +- "pricedealsindia.com", +- "glennbeck.com", +- "allyou.com", +- "china.org.cn", +- "xitek.com", +- "photoshopessentials.com", +- "infopraca.pl", +- "boardingarea.com", +- "geni.com", +- "rotaban.ru", +- "foxtab.com", +- "sadistic.pl", +- "socialbro.com", +- "tradesparq.com", +- "itp.ne.jp", +- "swefilmer.com", +- "jobsite.co.uk", +- "topwar.ru", +- "yemeksepeti.com", +- "tokfm.pl", +- "businessinsider.com.au", +- "moe.gov.eg", +- "swedbank.lt", +- "jxgdw.com", +- "bayern.de", +- "alistapart.com", +- "bebinin.com", +- "annunci69.it", +- "plimus.com", +- "cuevana2.tv", +- "viamichelin.fr", +- "whatsmydns.net", +- "tarad.com", +- "hostgator.com.br", +- "hasbro.com", +- "hi-chic.com", +- "driverscollection.com", +- "onetad.com", +- "game2.com.cn", +- "elitepvpers.com", +- "tvuol.uol.com.br", +- "caclubindia.com", +- "diariocorreo.pe", +- "c-rewards.com", +- "business.gov.au", +- "chooseauto.com.cn", +- "timetrade.com", +- "alternate.de", +- "syracuse.com", +- "advanceautoparts.com", +- "shopware.de", +- "newpct.com", +- "proranktracker.com", +- "cex.io", +- "thebot.net", +- "tradekorea.com", +- "legifrance.gouv.fr", +- "cpan.org", +- "rightel.ir", +- "247wallst.com", +- "goldentowns.com", +- "bankifsccode.com", +- "color-hex.com", +- "consumerist.com", +- "juegosdiarios.com", +- "on24.com", +- "stockfreeimages.com", +- "m4.cn", +- "sponsoredtweets.com", +- "open.ac.uk", +- "bilyoner.com", +- "lexisnexis.com", +- "gsu.edu", +- "popscreen.com", +- "stiftung-warentest.de", +- "education.com", +- "leckerficken.de", +- "hostinger.ru", +- "staples.ca", +- "greenpeace.org", +- "mes-meilleurs-films.fr", +- "delish.com", +- "register.it", +- "idiva.com", +- "static.squarespace.com", +- "ololo.fm", +- "basketball-reference.com", +- "tro-ma-ktiko.blogspot.gr", +- "arabianbusiness.com", +- "avianca.com", +- "watchuseek.com", +- "6play.fr", +- "kora-online.tv", +- "armagedomfilmes.biz", +- "531314.com", +- "craigslist.co.uk", +- "inchallah.com", +- "bongdaso.com", +- "toprankblog.com", +- "k12.com", +- "itimes.com", +- "html.net", +- "utsandiego.com", +- "gyakorikerdesek.hu", +- "viddyhddownload.com", +- "wannonce.com", +- "qudong.com", +- "ibicn.com", +- "w3resource.com", +- "socialsecurity.gov", +- "tvn.pl", +- "momsexclipz.com", +- "fstoppers.com", +- "kafeteria.pl", +- "boulanger.fr", +- "guj.nic.in", +- "divaina.com", +- "desktopnexus.com", +- "topseda.ir", +- "payumoney.com", +- "klicktel.de", +- "foxtv.es", +- "cuatro.com", +- "publix.com", +- "astrosage.com", +- "kompass.com", +- "web-hosting.com", +- "nus.edu.sg", +- "jamiiforums.com", +- "lancers.jp", +- "peixeurbano.com.br", +- "buysub.com", +- "yp.com", +- "enstage.com", +- "6eat.com", +- "1ent.com.cn", +- "unionpaysecure.com", +- "pcgames.de", +- "ccidcom.com", +- "lavenir.net", +- "novaposhta.ua", +- "hotpornshow.com", +- "telebank.ru", +- "avaz.ba", +- "doit.com.cn", +- "setlinks.ru", +- "zagat.com", +- "sportmaster.ru", +- "utarget.ru", +- "lingualeo.ru", +- "compucalitv.com", +- "anastasiadate.com", +- "webmaster-rank.info", +- "fastcoexist.com", +- "lavasoft.com", +- "ppvguru.com", +- "greatist.com", +- "knack.be", +- "wowwiki.com", +- "ilcorsaronero.info", +- "jword.jp", +- "750g.com", +- "pantipmarket.com", +- "top.de", +- "photofunia.com", +- "dryicons.com", +- "alweeam.com.sa", +- "dnfight.com", +- "wpolityce.pl", +- "vimeocdn.com", +- "visit-x.net", +- "takungpao.com", +- "perfectworld.eu", +- "kat.ph", +- "hefei.cc", +- "cmse.ru", +- "virginia.edu", +- "fudan.edu.cn", +- "sethgodin.typepad.com", +- "caracaschronicles.com", +- "18qt.com", +- "be2.com.br", +- "rakuten.tw", +- "bukkit.org", +- "miss-no1.com", +- "nts.org.pk", +- "ulozto.net", +- "mixpanel.com", +- "glavred.info", +- "vui.vn", +- "mindspark.com", +- "worldmarket.com", +- "walmart.com.mx", +- "deperu.com", +- "taxact.com", +- "m5zn.com", +- "navy.mil", +- "hibapress.com", +- "cpasbien.com", +- "interjet.com.mx", +- "llbean.com", +- "kenrockwell.com", +- "japan-guide.com", +- "financialpost.com", +- "rankingsinstitute.com", +- "master-x.com", +- "pandawill.com", +- "marketingweek.co.uk", +- "freeforums.org", +- "ysear.ch", +- "pokerstars.com", +- "wired.co.uk", +- "amino.dk", +- "rapidcrush.com", +- "vivanuncios.com", +- "blogsvertise.com", +- "cwb.gov.tw", +- "piter.tv", +- "gistmania.com", +- "topdocumentaryfilms.com", +- "shoghlanty.com", +- "bankmillennium.pl", +- "burberry.com", +- "youporngay.com", +- "webresourcesdepot.com", +- "beachbody.com", +- "asstr.org", +- "pwc.com", +- "competitor.com", +- "rss2search.com", +- "vocuspr.com", +- "behindthename.com", +- "moniker.com", +- "jayde.com", +- "opensuse.org", +- "poemhunter.com", +- "toranoana.jp", +- "interaksyon.com", +- "aeon.co.jp", +- "gungho.jp", +- "fgov.be", +- "xpg.uol.com.br", +- "logic-immo.com", +- "worldsex.com", +- "watchonlineseries.eu", +- "google.co.mz", +- "discas.net", +- "chmail.ir", +- "consumercomplaints.in", +- "allstate.com", +- "twelveskip.com", +- "ibibo.com", +- "noelshack.com", +- "bonprix.ru", +- "directupload.net", +- "equipobimlatino.com", +- "weather2umbrella.com", +- "aibang.com", +- "blog.wordpress.com", +- "turner.com", +- "mediapart.fr", +- "bloog.pl", +- "monotaro.com", +- "online.net", +- "bodmillenium.com", +- "distancesfrom.com", +- "naosalvo.com.br", +- "ap7am.com", +- "focus.ua", +- "cokeandpopcorn.ch", +- "qwant.com", +- "megaplan.ru", +- "sinhvienit.net", +- "dream-marriage.com", +- "voicefive.com", +- "forex.com.cn", +- "xabbs.com", +- "netmums.com", +- "tuxboard.com", +- "cs-cart.com", +- "bitcoin.it", +- "boblil.com", +- "nirsoft.net", +- "neopets.com", +- "spin.com", +- "costco.ca", +- "mirraw.com", +- "ara.cat", +- "klamm.de", +- "glam.com", +- "guenstiger.de", +- "citruspay.com", +- "dnslink.com", +- "guyism.com", +- "shopotam.ru", +- "tim.it", +- "3suisses.fr", +- "gooroops.com", +- "kau.edu.sa", +- "ukbusinessforums.co.uk", +- "gree.jp", +- "komikid.com", +- "redakcja.pl", +- "qpic.cn", +- "voyeurweb.com", +- "mathworks.com", +- "monster.fr", +- "seniat.gob.ve", +- "computrabajo.com.co", +- "xilu.com", +- "madrid.org", +- "ostraining.com", +- "bharian.com.my", +- "telegram.org", +- "sumofus.org", +- "whosdatedwho.com", +- "moreofit.com", +- "meetic.it", +- "femina.mk", +- "itworld.com", +- "indiaglitz.com", +- "cheatcc.com", +- "filmfanatic.com", +- "the-bux.net", +- "very.co.uk", +- "fetishshrine.com", +- "speakingtree.in", +- "iu.edu", +- "modern.az", +- "tak.ru", +- "internetmarketingninjas.com", +- "example.com", +- "sportgeza.hu", +- "wrestlezone.com", +- "jameda.de", +- "caikuu.com", +- "gioco.it", +- "yourtv.com.au", +- "euro.com.pl", +- "anz.co.nz", +- "daft.ie", +- "tirerack.com", +- "vivareal.com.br", +- "definebabe.com", +- "ittefaq.com.bd", +- "lastfm.es", +- "zocalo.com.mx", +- "dpd.de", +- "somethingawful.com", +- "virgin.com", +- "shtyle.fm", +- "viralforest.com", +- "dntrck.com", +- "its-mo.com", +- "q.cc", +- "kinghost.net", +- "elpais.com.co", +- "joomlaspanish.org", +- "sopitas.com", +- "wallbase.cc", +- "cpalead.com", +- "torrentfunk.com", +- "bizcom.com.ru", +- "quizony.com", +- "rcgroups.com", +- "spring.io", +- "kuaidi100.com", +- "xatakandroid.com", +- "mlstatic.com", +- "borsaat.com", +- "jagobd.com", +- "cosmiq.de", +- "crucial.com", +- "cdstm.cn", +- "betclic.fr", +- "telewebion.com", +- "exhentai.org", +- "gnezdo.ru", +- "cebupacificair.com", +- "fusionmls.com", +- "shafaf.ir", +- "ticketmaster.co.uk", +- "adslzone.net", +- "k8.cn", +- "recipdonor.com", +- "in.gov", +- "mforos.com", +- "asscj.com", +- "linkconnector.com", +- "ohfreesex.com", +- "cntraveler.com", +- "scambioetico.org", +- "ladenzeile.de", +- "ntn24.com", +- "beyazperde.com", +- "motherearthnews.com", +- "yupptv.com", +- "220tube.com", +- "fizzle.co", +- "lakii.com", +- "deutsche-wirtschafts-nachrichten.de", +- "saaid.net", +- "bimlatino.com", +- "verisign.com", +- "funpatogh.com", +- "matadornetwork.com", +- "seatguru.com", +- "lululemon.com", +- "uzise.com", +- "networkworld.com", +- "hottube.me", +- "jobsdb.com.hk", +- "life.hu", +- "bonusvid.com", +- "incometaxindiaefiling.gov.in", +- "ey.com", +- "alraimedia.com", +- "allposters.com", +- "authorityroi.com", +- "bmwusa.com", +- "ebaystatic.com", +- "entertainmentcrave.com", +- "ehow.com.br", +- "prisonplanet.com", +- "elnashra.com", +- "email.cz", +- "yes123.com.tw", +- "uitzendinggemist.nl", +- "mindtools.com", +- "atv.com.tr", +- "shoes.net.cn", +- "joomlaportal.de", +- "themoneyconverter.com", +- "meteomedia.com", +- "bankaustria.at", +- "advertise.com", +- "trafficswarm.com", +- "aztecaporno.com", +- "fourseasons.com", +- "movie-blog.org", +- "govdelivery.com", +- "didigames.com", +- "invideo.biz", +- "linux.org.ru", +- "omelete.uol.com.br", +- "babybus.cn", +- "oursogo.com", +- "ero-an.com", +- "mediafax.ro", +- "football.ua", +- "sii.cl", +- "dreamamateurs.com", +- "cheaperthandirt.com", +- "iplocation.net", +- "insideview.com", +- "hihe.vn", +- "stop-sex.com", +- "fubiz.net", +- "url.org", +- "greenmangaming.com", +- "pornup.me", +- "indofeed.com", +- "forumhouse.ru", +- "restaurant.com", +- "key.com", +- "windstream.net", +- "brightedge.com", +- "foreignpolicy.com", +- "noticiasdatv.uol.com.br", +- "logopond.com", +- "datemule.com", +- "webrootanywhere.com", +- "stomp.com.sg", +- "trthaber.com", +- "bitterstrawberry.com", +- "turbo.az", +- "kbs.co.kr", +- "joblo.com", +- "seatimes.com.vn", +- "kuwait.tt", +- "258.com", +- "kp.ua", +- "moviesmobile.net", +- "flamingtext.com", +- "youngt.com", +- "etradenow.cn", +- "copart.com", +- "tuanweihui.com", +- "zinkwaphd.com", +- "adsl.free.fr", +- "infomaniak.ch", +- "re-direcciona.me", +- "mejorenvo.com", +- "instantservice.com", +- "harpersbazaar.com", +- "colorado.edu", +- "belboon.com", +- "telelistas.net", +- "photofans.cn", +- "51seer.com", +- "danjur.com", +- "wunderweib.de", +- "extratorrentlive.com", +- "serpfox.com", +- "androidkade.com", +- "raja.ir", +- "tampabay.com", +- "ser-mujer.org", +- "imasters.com.br", +- "coachfactory.com", +- "mojopages.com", +- "makezine.com", +- "forexschoolonline.com", +- "bochk.com", +- "siamsport.co.th", +- "mdpr.jp", +- "serialssolutions.com", +- "videosexarchive.com", +- "enlnks.com", +- "cision.com", +- "scratchinginfo.com", +- "skidrowgames.net", +- "optimizely.com", +- "video2brain.com", +- "ariva.de", +- "audiomack.com", +- "pimproll.com", +- "house.gov", +- "acs.org", +- "pijamasurf.com", +- "autoc-one.jp", +- "southcn.com", +- "vesti.az", +- "300mbfilms.com", +- "speedmystream.com", +- "wooservers.com", +- "siteliner.com", +- "tinmoi.vn", +- "extremepornvideos.com", +- "cqsq.com", +- "hello-today.com", +- "turkcealtyazi.org", +- "tvyo.com", +- "dealmoon.com", +- "openenglish.com", +- "golfchannel.com", +- "irancloob.com", +- "ebs.in", +- "portalcorreio.uol.com.br", +- "beemp3s.org", +- "condenast.com", +- "mtwebcenters.com.tw", +- "hatelabo.jp", +- "pathci.net", +- "mamsy.ru", +- "noticiasdelmundo.org", +- "guru3d.com", +- "logomaker.com", +- "adhitz.com", +- "swiki.jp", +- "turnitin.com", +- "patoghu.com", +- "carnaval.uol.com.br", +- "cancer.org", +- "clickprime8.com", +- "fahrinfo-berlin.de", +- "unisender.com", +- "flashkhor.com", +- "goodfon.ru", +- "ethiotube.net", +- "cunbang.com", +- "ti-da.net", +- "1phads.com", +- "bien.hu", +- "home77.com", +- "mbabycare.com", +- "vudu.com", +- "fantasy8.com", +- "landrover.com", +- "opencartforum.ru", +- "antena3.ro", +- "getapp.com", +- "torlock.com", +- "wind.it", +- "expatads.com", +- "bloglines.com", +- "sexytube.me", +- "frontier.com", +- "asandownload.com", +- "groupon.pl", +- "storesonlinepro.com", +- "brands4friends.de", +- "infogr.am", +- "webeffector.ru", +- "google.com.mm", +- "ppchero.com", +- "privacystar.com", +- "ocregister.com", +- "liex.ru", +- "kopatheme.com", +- "toggl.com", +- "raywenderlich.com", +- "hecha.cn", +- "vpls.net", +- "manpianyi.com", +- "1881.no", +- "scbeasy.com", +- "plex.tv", +- "selfridges.com", +- "anumex.com", +- "postplanner.com", +- "thisiscolossal.com", +- "you-will-date.com", +- "idealist.org", +- "emarketer.com", +- "anibis.ch", +- "dansmovies.com", +- "footballitarin.com", +- "fragrantica.com", +- "10minutemail.com", +- "ntu.edu.tw", +- "clasicooo.com", +- "onsugar.com", +- "vr-zone.com", +- "walkerplus.com", +- "easymobilerecharge.com", +- "cz001.com.cn", +- "sportsseoul.com", +- "inazumanews2.com", +- "marketingdirecto.com", +- "chartboost.com", +- "unblocked.co", +- "rhymezone.com", +- "portalinmobiliario.com", +- "afrointroductions.com", +- "transunion.com", +- "panorama.it", +- "powershow.com", +- "avval.ir", +- "onlinemeetingnow.com", +- "xoom.com", +- "wnbc.com", +- "tlen.pl", +- "jetairways.com", +- "vtb24.ru", +- "offcn.com", +- "crx7601.com", +- "adverts.ie", +- "kasserver.com", +- "minhavida.com.br", +- "jkpj.com", +- "123contactform.com", +- "imgtiger.com", +- "folha.com.br", +- "npcgo.com", +- "semprot.com", +- "moonfruit.com", +- "jizzbell.com", +- "online-stopwatch.com", +- "allhiphop.com", +- "hackaday.com", +- "digitalplayground.com", +- "careers24.com", +- "cwq.com", +- "wondershare.com", +- "filesend.to", +- "puromarketing.com", +- "workopolis.com", +- "mudainodocument.com", +- "home.ne.jp", +- "shorte.st", +- "tanea.gr", +- "sporza.be", +- "vgorode.ua", +- "google.co.zm", +- "argumentua.com", +- "3m.com", +- "komputerswiat.pl", +- "bongdaplus.vn", +- "supersonicads.com", +- "soundclick.com", +- "lollipop-network.com", +- "lpcloudsvr304.com", +- "313.cn", +- "rtl2.de", +- "ts.cn", +- "mglradio.com", +- "diynetwork.com", +- "komikcaps.net", +- "all-that-is-interesting.com", +- "ultipro.com", +- "frombar.com", +- "sitedeals.nl", +- "codingforums.com", +- "kansascity.com", +- "twtrland.com", +- "cengage.com", +- "lolspotsarticles.com", +- "jackthreads.com", +- "jobstreet.com.sg", +- "diffen.com", +- "eme2000.com", +- "superbru.com", +- "droid-life.com", +- "itb-berlin.de", +- "estibot.com", +- "yourepeat.com", +- "112.ua", +- "70e.com", +- "grid.mk", +- "cromaretail.com", +- "jobstreet.com.ph", +- "gloadmarket.com", +- "gemius.com", +- "huuto.net", +- "vogue.it", +- "divxonline.info", +- "mytoys.de", +- "cashnhits.com", +- "minkchan.com", +- "talabat.com", +- "helpareporter.com", +- "grandascent.com", +- "catalunyacaixa.com", +- "sparwelt.de", +- "tvboxnow.com", +- "imagecurl.org", +- "coocan.jp", +- "eatingwell.com", +- "truelife.com", +- "binaryoptionsbrands.com", +- "foxsportsla.com", +- "jjshouse.com", +- "makaan.com", +- "yamaha.com", +- "activerain.com", +- "excelforum.com", +- "mobinnet.ir", +- "kasikornbankgroup.com", +- "googleplex.com", +- "medianama.com", +- "fullsail.edu", +- "makeupandbeauty.com", +- "marketwired.com", +- "beachbodycoach.com", +- "taloussanomat.fi", +- "youngliving.us", +- "dana.ir", +- "adsgostar.com", +- "esquire.com.cn", +- "meyerweb.com", +- "positivemed.com", +- "harvestapp.com", +- "tim.com.br", +- "sumorobo.net", +- "zbigz.com", +- "schulferien.org", +- "quzhao.com", +- "tsinghua.edu.cn", +- "vogue.com", +- "ecrater.com", +- "internetbs.net", +- "oper.ru", +- "kingstone.com.tw", +- "olympic.org", +- "code.org", +- "wp.tv", +- "adchakra.net", +- "passarela.com.br", +- "damn.com", +- "spn.com.cn", +- "sacitaslan.com", +- "uplod.ir", +- "kununu.com", +- "englishclub.com", +- "ibood.com", +- "buzzfed.com", +- "peopledaily.com.cn", +- "vivastreet.it", +- "adshostnet.com", +- "npmjs.org", +- "lovethatsex.com", +- "garena.tw", +- "hq-sex-tube.com", +- "tvsubtitles.net", +- "trademarkia.com", +- "96down.com", +- "morhipo.com", +- "chuguoqu.com", +- "free-css.com", +- "getsecuredfiles.com", +- "justia.com", +- "paypal-community.com", +- "wezoner.com", +- "google-analytics.com", +- "outsideonline.com", +- "simplymeasured.com", +- "wattsupwiththat.com", +- "vancl.com", +- "leadership.ng", +- "plaisio.gr", +- "fastcocreate.com", +- "fewo-direkt.de", +- "dedecms.com", +- "bostonherald.com", +- "elmundo.com.ve", +- "idhostinger.com", +- "animaljam.com", +- "infoq.com", +- "exler.ru", +- "leprosorium.ru", +- "avis.com", +- "ulusalpost.com", +- "namnak.com", +- "goindigo.in", +- "activeboard.com", +- "fatsecret.com", +- "4umf.com", +- "porn-w.org", +- "sarkariexam.co.in", +- "patagonia.com", +- "3u5.net", +- "roshd.ir", +- "netechangisme.com", +- "ojogo.pt", +- "ujipin.com", +- "topuniversities.com", +- "consequenceofsound.net", +- "no-ip.biz", +- "webdesignerwall.com", +- "fin24.com", +- "openculture.com", +- "pbh2.com", +- "dota2.com", +- "secureupload.eu", +- "alfajertv.com", +- "canlidizihdtv.com", +- "muffingroup.com", +- "imageforum.com", +- "paris.fr", +- "kaufda.de", +- "pelis24.com", +- "ixian.cn", +- "ebenpagan.com", +- "sportsauthority.com", +- "wish.com", +- "ganeshaspeaks.com", +- "meritnation.com", +- "ijie.com", +- "vodafone.com.tr", +- "trovit.es", +- "farsisubtitle.com", +- "musawvir.com", +- "resellerratings.com", +- "soyentrepreneur.com", +- "samakal.net", +- "dietnavi.com", +- "55tuan.com", +- "elcomercio.com", +- "hereisthecity.com", +- "buienradar.nl", +- "arenabg.com", +- "indiansexstories.net", +- "slideboom.com", +- "findsection.net", +- "rankrecon.com", +- "e-radio.gr", +- "cnn.co.jp", +- "gucci.com", +- "natura.net", +- "googlesyndication.com", +- "advancedwebranking.com", +- "lib.ru", +- "sfora.pl", +- "uci.edu", +- "haaretz.co.il", +- "ing.be", +- "yokboylebirsey.com.tr", +- "myfact.tv", +- "yenibiris.com", +- "stuff.tv", +- "dn.pt", +- "whydontyoutrythis.com", +- "nediyor.com", +- "worldoftanks.asia", +- "megamillions.com", +- "elemanonline.net", +- "computrabajo.com.pe", +- "arxiv.org", +- "livescore.tv", +- "aintitcool.com", +- "girlschannel.net", +- "madbid.com", +- "tadawul.com.sa", +- "liqpay.com", +- "softonic.jp", +- "alhilal.com", +- "bizpowa.com", +- "thatguywiththeglasses.com", +- "yemeneconomist.com", +- "pazar3.mk", +- "repai.com", +- "1jux.net", +- "solvusoft.com", +- "yotpo.com", +- "cuantocabron.com", +- "ba.gov.br", +- "arin.net", +- "loginza.ru", +- "homebank.ro", +- "0755car.com", +- "carscoops.com", +- "antarvasna.com", +- "tizag.com", +- "offerpop.com", +- "techmeme.com", +- "ipress.ua", +- "emuparadise.me", +- "sexvidx.com", +- "whatseek.com", +- "become.co.jp", +- "snapfish.com", +- "gsis.gr", +- "speedyshare.com", +- "uncrate.com", +- "doda.jp", +- "straighttalk.com", +- "rsjoomla.com", +- "vozpopuli.com", +- "gotprint.net", +- "finansbank.com.tr", +- "chinatrust.com.tw", +- "stratoserver.net", +- "icnetwork.co.uk", +- "getpopcornti.me", +- "pornper.com", +- "3dmgame.com", +- "squirt.org", +- "mbusa.com", +- "katespade.com", +- "skat.dk", +- "radiko.jp", +- "dexonline.ro", +- "bicaps.net", +- "bitsoma.com", +- "brasil247.com", +- "alittlemarket.com", +- "bd-pratidin.com", +- "amorincontro.com", +- "bigxvideos.com", +- "nissan.co.jp", +- "incomediary.com", +- "theranking.com", +- "el7l.co", +- "webcamtoy.com", +- "steamgifts.com", +- "miles-and-more.com", +- "szonline.net", +- "blocked-website.com", +- "kaztorka.org", +- "avforums.com", +- "indulgy.com", +- "extendcp.co.uk", +- "yonkis.com", +- "ad1111.com", +- "unionbankph.com", +- "job.com", +- "samanepay.com", +- "aceona.com", +- "kar.nic.in", +- "tipico.com", +- "sa.ae", +- "froma.com", +- "songza.com", +- "calciomercato.com", +- "besaba.com", +- "x-rates.com", +- "arsys.es", +- "sisal.it", +- "amateur.tv", +- "designyourway.net", +- "alpha.gr", +- "nimble.com", +- "livefreefun.com", +- "wipo.int", +- "webssearches.com", +- "vodjk.com", +- "91tiger.com", +- "swisscom.com", +- "tuvaro.com", +- "parsonline.net", +- "uolhost.com.br", +- "cnwest.com", +- "roksa.pl", +- "socialmention.com", +- "unibytes.com", +- "screamingfrog.co.uk", +- "owncloud.org", +- "jacquielawson.com", +- "openclipart.org", +- "zimbra.com", +- "poczta-polska.pl", +- "hayah.cc", +- "ringtonematcher.com", +- "emai.com", +- "wealink.com", +- "celebzen.com", +- "pichost.me", +- "rediffmail.com", +- "dinos.co.jp", +- "netvasco.com.br", +- "meilele.com", +- "career.ru", +- "signupgenius.com", +- "screencast-o-matic.com", +- "nav.no", +- "reactiongifs.com", +- "italki.com", +- "mo.gov", +- "bandsintown.com", +- "elwatan.com", +- "jdate.com", +- "quiente.net", +- "skynet.be", +- "googlekeywordtool.com", +- "nubilefilms.com", +- "memedeportes.com", +- "rewardingzonez.com", +- "litmus.com", +- "iyaxin.com", +- "collegeconfidential.com", +- "semperplugins.com", +- "sofort.com", +- "ineedhits.com", +- "live24.gr", +- "acronymfinder.com", +- "jobui.com", +- "9show.com", +- "thedirty.com", +- "tsutaya.co.jp", +- "9787.com", +- "brighthouse.com", +- "boxingscene.com", +- "indeed.com.br", +- "morazzia.com", +- "privatejobshub.blogspot.in", +- "searchenginepeople.com", +- "pozdravok.ru", +- "watchstore.com.cn", +- "rts.ch", +- "pluska.sk", +- "villagevoice.com", +- "sprintrade.com", +- "conversionxl.com", +- "evsuite.com", +- "bci.cl", +- "lampsplus.com", +- "gossipcop.com", +- "valuecommerce.com", +- "zalora.co.id", +- "fastshop.com.br", +- "hockeysfuture.com", +- "bootply.com", +- "chinavasion.com", +- "menards.com", +- "kinobar.net", +- "tokyodisneyresort.jp", +- "knownhost.com", +- "ozbargain.com.au", +- "olx.com.ve", +- "sgk.gov.tr", +- "berliner-sparkasse.de", +- "bancogalicia.com.ar", +- "joomla-master.org", +- "augsburger-allgemeine.de", +- "kroger.com", +- "pulse.ng", +- "putlocker.com", +- "jrtj.com", +- "tapuz.co.il", +- "madhyamam.com", +- "donews.com", +- "showhaber.com", +- "allxnxx.com", +- "uned.es", +- "adsharebux.com", +- "d-addicts.com", +- "banki.ir", +- "levi.com", +- "e97527f0.se", +- "entertainmentwise.com", +- "xvideos-field.com", +- "naver.net", +- "urbia.de", +- "fashionsfriend.com", +- "emuch.net", +- "yelp.fr", +- "metatube.com", +- "sina.com.hk", +- "omb100.com", +- "grameenphone.com", +- "stylebook.de", +- "funny-games.biz", +- "googlewebmastercentral.blogspot.com", +- "vogella.com", +- "surveymonkey.net", +- "forex4you.org", +- "mex.tl", +- "online-fish-games.com", +- "millenniumbcp.pt", +- "fileom.com", +- "friendorfollow.com", +- "downloads.nl", +- "typekit.com", +- "gongkong.com", +- "iqoption.com", +- "tori.fi", +- "smartsource.com", +- "1616.net", +- "1shoppingcart.com", +- "novosti.rs", +- "yofond.com", +- "idokep.hu", +- "motor.ru", +- "xbiao.com", +- "colorcombos.com", +- "pway.cn", +- "egynews.net", +- "elshaab.org", +- "telus.com", +- "olx.com.co", +- "cctvcj.com", +- "kpopstarz.com", +- "razorsocial.com", +- "ncrypt.in", +- "zonetheme.com", +- "gumroad.com", +- "e-shop.gr", +- "kugli.com", +- "levif.be", +- "bookfi.org", +- "globalresearch.ca", +- "sas.com", +- "cloudaccess.net", +- "uplooder.net", +- "exposedwebcams.com", +- "1prime.ru", +- "webappers.com", +- "crocko.com", +- "remax.com", +- "ikco.com", +- "dinside.no", +- "winbank.gr", +- "mijnwoordenboek.nl", +- "weatherzone.com.au", +- "allday2.com", +- "sunat.gob.pe", +- "getit.in", +- "entrance-exam.net", +- "i2ya.com", +- "tlife.gr", +- "qyer.com", +- "calibre-ebook.com", +- "internetcorkboard.com", +- "unitedhyipleague.com", +- "spyrestudios.com", +- "metal-archives.com", +- "aeromexico.com", +- "cv-library.co.uk", +- "bdr1.net", +- "aremo.com.br", +- "blip.tv", +- "afilio.com.br", +- "renewalcoupons.com", +- "proxfree.com", +- "magix.com", +- "jobs.net", +- "souism.com", +- "adtcstrk.com", +- "goodhousekeeping.com", +- "lastfm.ru", +- "sharecare.com", +- "porn.xxx", +- "deathandtaxesmag.com", +- "unocero.com", +- "wer-kennt-wen.de", +- "hotfrog.com", +- "intraship.de", +- "press24.mk", +- "yournewscorner.com", +- "rbc.com", +- "eventure.com", +- "minglebox.com", +- "legendas.tv", +- "drp.su", +- "voicefrom.me", +- "venezuelaaldia.com", +- "cooks.com", +- "numbeo.com", +- "chilehardware.cl", +- "cryptocointalk.com", +- "venusfactor.com", +- "recruitmentcareer.in", +- "larazon.es", +- "sptechs.com", +- "asx.com.au", +- "ahlife.com", +- "st001.com", +- "actudesfinances.info", +- "talkarcades.com", +- "nitori-net.jp", +- "chinahr.com", +- "websitetestlink.com", +- "hypem.com", +- "demorgen.be", +- "sharefile.com", +- "prensalibre.com", +- "eldia.com.ar", +- "billiger.de", +- "3docean.net", +- "streamsend.com", +- "tuaw.com", +- "portafolio.co", +- "trivago.com", +- "olxpix.com", +- "geotrust.com", +- "torrentgun.net", +- "enha.kr", +- "pcastuces.com", +- "t.cn", +- "dimsemenov.com", +- "cam4.nl", +- "basspro.com", +- "macupdate.com", +- "strawpoll.me", +- "elintransigente.com", +- "homeaway.co.uk", +- "my.ecwid.com", +- "graphpaperpress.com", +- "architonic.com", +- "flowplayer.org", +- "syshl.com", +- "18schoolgirlz.com" +- }); +- +- return urls; ++std::vector const& urls_large_data() { ++ static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; ++ return hosts; + } +--- upstream/http/client/crawl/urls_large_data.hpp ++++ port/http/client/crawl/urls_large_data.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -12,7 +28,6 @@ + + #include + +-std::vector const& +-urls_large_data(); ++std::vector const& urls_large_data(); + + #endif +--- upstream/http/client/methods/http_client_methods.cpp ++++ port/http/client/methods/http_client_methods.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,27 +31,23 @@ + + //[example_http_client_methods + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from +- ++using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request +-void do_get(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_get(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); +@@ -43,11 +55,8 @@ + } + + // perform a head request +-void do_head(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_head(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); +@@ -68,106 +77,84 @@ + res = p.release(); + } + +- + // perform a patch request +-void do_patch(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_patch(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // perform a put request +-void do_put(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_put(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; +- req.prepare_payload(); // set content-length based on the body ++ req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); + } + + // perform a post request +-void do_post(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_post(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // perform a delete request +-void do_delete(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_delete(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // Performs an HTTP request against httpbin.cpp.al and prints request & response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 2) +- { +- std::cerr << +- "Usage: http-client-method \n" << +- "Example:\n" << +- " http-client-method get\n" << +- " http-client-method post\n"; ++ if (argc != 2) { ++ std::cerr << "Usage: http-client-method \n" ++ << "Example:\n" ++ << " http-client-method get\n" ++ << " http-client-method post\n"; + return EXIT_FAILURE; + } + +- for (char * c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) + *c = static_cast(std::tolower(*c)); + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +- auto const results = resolver.resolve("httpbin.cpp.al", "http"); ++ auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + +- + // Set up an HTTP GET request message + http::request req; +- req.set(http::field::host, "httpbin.cpp.al"); ++ req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); +- + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; +@@ -187,20 +174,16 @@ + do_post(stream, req, buffer, res); + else if (method == "delete") + do_delete(stream, req, buffer, res); +- else +- { ++ else { + std::cerr << "Unknown method: " << method << std::endl; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" +- << req << std::endl; +- ++ std::cout << "Request send:\n-----------------------------\n" << req << std::endl; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" +- << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; +@@ -209,13 +192,11 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/client/sync/http_client_sync.cpp ++++ port/http/client/sync/http_client_sync.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,33 +31,30 @@ + + //[example_http_client + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-sync []\n" << +- "Example:\n" << +- " http-client-sync www.example.com 80 /\n" << +- " http-client-sync www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-sync []\n" ++ << "Example:\n" ++ << " http-client-sync www.example.com 80 /\n" ++ << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -50,7 +63,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); +@@ -89,13 +102,11 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ port/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,36 +30,33 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + +-#include +-#include +-#include + #include + #include + #include ++#include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = net::ssl; // from +-using tcp = net::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = net::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-sync-ssl []\n" << +- "Example:\n" << +- " http-client-sync-ssl www.example.com 443 /\n" << +- " http-client-sync-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-sync-ssl []\n" ++ << "Example:\n" ++ << " http-client-sync-ssl www.example.com 443 /\n" ++ << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -51,7 +65,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); +@@ -62,16 +76,14 @@ + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + +- // These objects perform our I/O ++ // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host)) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification +@@ -127,11 +139,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + throw beast::system_error{ec}; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/async/http_server_async.cpp ++++ port/http/server/async/http_server_async.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,13 +29,11 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include ++#include + #include + #include ++#include + #include +-#include + #include + #include + #include +@@ -27,69 +41,85 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -101,15 +131,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -120,9 +145,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -133,9 +156,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -146,19 +167,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -167,19 +186,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -189,10 +207,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -203,15 +219,12 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -219,31 +232,20 @@ + + public: + // Take ownership of the stream +- session( +- tcp::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- } ++ session(tcp::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), +- beast::bind_front_handler( +- &session::do_read, +- shared_from_this())); +- } +- +- void +- do_read() +- { ++ beast::bind_front_handler(&session::do_read, shared_from_this())); ++ } ++ ++ void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -253,56 +255,39 @@ + + // Read a request + http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, shared_from_this(), keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); +@@ -312,9 +297,7 @@ + do_read(); + } + +- void +- do_close() +- { ++ void do_close() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -326,90 +309,63 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- return; // To avoid infinite loop +- } +- else +- { ++ return; // To avoid infinite loop ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket), +- doc_root_)->run(); ++ std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection +@@ -419,15 +375,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-async
\n" << +- "Example:\n" << +- " http-server-async 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-async
\n" ++ << "Example:\n" ++ << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -436,24 +389,19 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port +- std::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/async-local/http_server_async_local.cpp ++++ port/http/server/async-local/http_server_async_local.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -17,10 +33,10 @@ + #include + #include + #include +-#include +-#include + #include + #include ++#include ++#include + + #include + #include +@@ -32,68 +48,82 @@ + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -105,15 +135,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -124,9 +149,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -137,9 +160,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -150,19 +171,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -171,19 +190,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -193,10 +211,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -207,50 +223,34 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session : public std::enable_shared_from_this +-{ +- beast::basic_stream< +- stream_protocol, +- net::any_io_executor, +- beast::unlimited_rate_policy> stream_; ++class session : public std::enable_shared_from_this { ++ beast::basic_stream ++ stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + + public: + // Take ownership of the stream +- session( +- stream_protocol::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- } ++ session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), +- beast::bind_front_handler( +- &session::do_read, +- shared_from_this())); +- } +- +- void +- do_read() +- { ++ beast::bind_front_handler(&session::do_read, shared_from_this())); ++ } ++ ++ void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -260,56 +260,39 @@ + + // Read a request + http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, shared_from_this(), keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); +@@ -319,9 +302,7 @@ + do_read(); + } + +- void +- do_close() +- { ++ void do_close() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); +@@ -333,56 +314,33 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- stream_protocol::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc), std::move(endpoint)) +- , doc_root_(doc_root) +- { +- } ++ listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, stream_protocol::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, stream_protocol::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- return; // To avoid infinite loop +- } +- else +- { ++ return; // To avoid infinite loop ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket), +- doc_root_)->run(); ++ std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection +@@ -392,17 +350,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: http-server-async-local \n" << +- "Example:\n" << +- " http-server-async-local /tmp/http.sock . 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: http-server-async-local \n" ++ << "Example:\n" ++ << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; +@@ -410,32 +364,25 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + std::remove(path); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- stream_protocol::endpoint{path}, +- doc_root)->run(); ++ std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -443,12 +390,9 @@ + + #else + +-int +-main(int, char*[]) +-{ +-std::cerr << +- "Local sockets not available on this platform" << std::endl; +-return EXIT_FAILURE; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; ++ return EXIT_FAILURE; + } + + #endif +--- upstream/http/server/async-ssl/http_server_async_ssl.cpp ++++ port/http/server/async-ssl/http_server_async_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,86 +30,100 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -104,15 +135,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -123,9 +149,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -136,9 +160,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -149,19 +171,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -170,19 +190,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -192,10 +211,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -206,9 +223,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -226,15 +241,14 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -242,58 +256,38 @@ + + public: + // Take ownership of the socket +- explicit +- session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket), ctx) +- , doc_root_(doc_root) +- { +- } ++ explicit session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- stream_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); +- } +- +- void +- on_run() +- { ++ net::dispatch(stream_.get_executor(), ++ beast::bind_front_handler(&session::on_run, shared_from_this())); ++ } ++ ++ void on_run() { + // Set the timeout. +- beast::get_lowest_layer(stream_).expires_after( +- std::chrono::seconds(30)); ++ beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -303,58 +297,39 @@ + + // Read a request + http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, +- this->shared_from_this(), +- keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); +@@ -364,23 +339,17 @@ + do_read(); + } + +- void +- do_close() +- { ++ void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -390,94 +359,64 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(ioc) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- return; // To avoid infinite loop +- } +- else +- { ++ return; // To avoid infinite loop ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection +@@ -487,15 +426,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-async-ssl
\n" << +- "Example:\n" << +- " http-server-async-ssl 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-async-ssl
\n" ++ << "Example:\n" ++ << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -504,7 +440,7 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -513,22 +449,16 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/awaitable/http_server_awaitable.cpp ++++ port/http/server/awaitable/http_server_awaitable.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -17,10 +33,10 @@ + #include + #include + #include +-#include +-#include + #include + #include ++#include ++#include + + #include + #include +@@ -32,67 +48,81 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -104,15 +134,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -123,9 +148,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -136,9 +159,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -149,19 +170,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -170,19 +189,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -192,10 +210,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -204,16 +220,12 @@ + } + + // Handles an HTTP server connection +-net::awaitable +-do_session( +- beast::tcp_stream stream, +- std::shared_ptr doc_root) +-{ ++net::awaitable do_session(beast::tcp_stream stream, ++ std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + +@@ -230,8 +242,7 @@ + // Send the response + co_await beast::async_write(stream, std::move(msg)); + +- if(!keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -239,7 +250,7 @@ + } + + // Send a TCP shutdown +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have +@@ -247,89 +258,68 @@ + } + + // Accepts incoming connections and launches the sessions +-net::awaitable +-do_listen(net::ip::tcp::endpoint endpoint, std::shared_ptr doc_root) +-{ ++net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, ++ std::shared_ptr doc_root) { + auto executor = co_await net::this_coro::executor; +- auto acceptor = net::ip::tcp::acceptor{ executor, endpoint }; +- +- for(;;) +- { +- net::co_spawn( +- executor, +- do_session( +- beast::tcp_stream{ co_await acceptor.async_accept() }, +- doc_root), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error in session: " << e.what() << "\n"; +- } +- } +- }); ++ auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; ++ ++ for (;;) { ++ net::co_spawn(executor, ++ do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception const& e) { ++ std::cerr << "Error in session: " << e.what() << "\n"; ++ } ++ } ++ }); + } + } + +-int +-main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if(argc != 5) +- { ++ if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +- << "Example:\n" +- << " http-server-awaitable 0.0.0.0 8080 . 1\n"; ++ << "Example:\n" ++ << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } +- auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{ threads }; ++ webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port +- net::co_spawn( +- ioc, +- do_listen(net::ip::tcp::endpoint{ address, port }, doc_root), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error: " << e.what() << std::endl; +- } +- } +- }); ++ net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception const& e) { ++ std::cerr << "Error: " << e.what() << std::endl; ++ } ++ } ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back([&ioc] { ioc.run(); }); +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back( ++ [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/http/server/coro/http_server_coro.cpp ++++ port/http/server/coro/http_server_coro.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,83 +29,97 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include ++#include ++#include ++#include + #include +-#include +-#include +-#include + #include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -101,15 +131,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -120,9 +145,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -133,9 +156,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -146,19 +167,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -167,19 +186,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -189,10 +207,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -203,42 +219,33 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + +- + // Handles an HTTP server connection +-void +-do_session( +- beast::tcp_stream& stream, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, ++ net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages +- for(;;) +- { ++ for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle the request +- http::message_generator msg = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -246,11 +253,10 @@ + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -266,65 +272,52 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else +- boost::asio::spawn( +- acceptor.get_executor(), +- std::bind( +- &do_session, +- beast::tcp_stream(std::move(socket)), +- doc_root, +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ boost::asio::spawn(acceptor.get_executor(), ++ std::bind(&do_session, beast::tcp_stream(std::move(socket)), ++ doc_root, std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-coro
\n" << +- "Example:\n" << +- " http-server-coro 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-coro
\n" ++ << "Example:\n" ++ << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -333,38 +326,32 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- tcp::endpoint{address, port}, +- doc_root, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, ++ std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ port/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,86 +30,100 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -104,15 +135,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -123,9 +149,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -136,9 +160,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -149,19 +171,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -170,19 +190,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -192,10 +211,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -206,9 +223,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -226,19 +241,15 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-void +-do_session( +- ssl::stream& stream, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_session(ssl::stream& stream, ++ std::shared_ptr const& doc_root, net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + +@@ -247,28 +258,26 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle the request +- http::message_generator res = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); +@@ -276,10 +285,9 @@ + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -291,7 +299,7 @@ + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -300,67 +308,53 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_session, +- ssl::stream( +- std::move(socket), ctx), +- doc_root, +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ std::bind(&do_session, ssl::stream(std::move(socket), ctx), ++ doc_root, std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-coro-ssl
\n" << +- "Example:\n" << +- " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-coro-ssl
\n" ++ << "Example:\n" ++ << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -369,7 +363,7 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -379,35 +373,28 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- std::ref(ctx), +- tcp::endpoint{address, port}, +- doc_root, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ std::bind(&do_listen, std::ref(ioc), std::ref(ctx), ++ tcp::endpoint{address, port}, doc_root, std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/fast/fields_alloc.hpp ++++ port/http/server/fast/fields_alloc.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -17,56 +33,37 @@ + + namespace detail { + +-struct static_pool +-{ ++struct static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + +- char* +- end() +- { +- return reinterpret_cast(this + 1) + size_; ++ char* end() { return reinterpret_cast(this + 1) + size_; } ++ ++ explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} ++ ++public: ++ static static_pool& construct(std::size_t size) { ++ auto p = new char[sizeof(static_pool) + size]; ++ return *(::new (p) static_pool{size}); + } + +- explicit +- static_pool(std::size_t size) +- : size_(size) +- , p_(reinterpret_cast(this + 1)) +- { ++ static static_pool& share(static_pool& pool) { ++ ++pool.refs_; ++ return pool; + } + +-public: +- static +- static_pool& +- construct(std::size_t size) +- { +- auto p = new char[sizeof(static_pool) + size]; +- return *(::new(p) static_pool{size}); +- } +- +- static_pool& +- share() +- { +- ++refs_; +- return *this; +- } +- +- void +- destroy() +- { +- if(--refs_) ++ void destroy() { ++ if (--refs_) + return; + this->~static_pool(); + delete[] reinterpret_cast(this); + } + +- void* +- alloc(std::size_t n) +- { ++ void* alloc(std::size_t n) { + auto last = p_ + n; +- if(last >= end()) ++ if (last >= end()) + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + ++count_; + auto p = p_; +@@ -74,16 +71,14 @@ + return p; + } + +- void +- dealloc() +- { +- if(--count_) ++ void dealloc() { ++ if (--count_) + return; + p_ = reinterpret_cast(this + 1); + } + }; + +-} // detail ++} // namespace detail + + /** A non-thread-safe allocator optimized for @ref basic_fields. + +@@ -101,9 +96,8 @@ + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. + */ +-template +-struct fields_alloc +-{ ++template ++struct fields_alloc { + detail::static_pool* pool_; + + public: +@@ -116,9 +110,8 @@ + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + +- template +- struct rebind +- { ++ template ++ struct rebind { + using other = fields_alloc; + }; + +@@ -129,76 +122,41 @@ + fields_alloc() = default; + #endif + +- explicit +- fields_alloc(std::size_t size) +- : pool_(&detail::static_pool::construct(size)) +- { ++ explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ ++ fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ ++ template ++ fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ ++ ~fields_alloc() { pool_->destroy(); } ++ ++ value_type* allocate(size_type n) { ++ return static_cast(pool_->alloc(n * sizeof(T))); + } + +- fields_alloc(fields_alloc const& other) +- : pool_(&other.pool_->share()) +- { ++ void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ ++#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 ++ template ++ void construct(U* ptr, Args&&... args) { ++ ::new (static_cast(ptr)) U(std::forward(args)...); + } + +- template +- fields_alloc(fields_alloc const& other) +- : pool_(&other.pool_->share()) +- { +- } +- +- ~fields_alloc() +- { +- pool_->destroy(); +- } +- +- value_type* +- allocate(size_type n) +- { +- return static_cast( +- pool_->alloc(n * sizeof(T))); +- } +- +- void +- deallocate(value_type*, size_type) +- { +- pool_->dealloc(); +- } +- +-#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 +- template +- void +- construct(U* ptr, Args&&... args) +- { +- ::new(static_cast(ptr)) U( +- std::forward(args)...); +- } +- +- template +- void +- destroy(U* ptr) +- { ++ template ++ void destroy(U* ptr) { + ptr->~U(); + } + #endif + +- template +- friend +- bool +- operator==( +- fields_alloc const& lhs, +- fields_alloc const& rhs) +- { ++ template ++ friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool_ == &rhs.pool_; + } + +- template +- friend +- bool +- operator!=( +- fields_alloc const& lhs, +- fields_alloc const& rhs) +- { +- return ! (lhs == rhs); ++ template ++ friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { ++ return !(lhs == rhs); + } + }; + +--- upstream/http/server/fast/http_server_fast.cpp ++++ port/http/server/fast/http_server_fast.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) + // +@@ -15,10 +31,8 @@ + + #include "fields_alloc.hpp" + +-#include +-#include ++#include + #include +-#include + #include + #include + #include +@@ -26,69 +40,84 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + +-class http_worker +-{ ++class http_worker { + public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + +- http_worker(tcp::acceptor& acceptor, const std::string& doc_root) : +- acceptor_(acceptor), +- doc_root_(doc_root) +- { +- } +- +- void start() +- { ++ http_worker(tcp::acceptor& acceptor, const std::string& doc_root) ++ : acceptor_(acceptor), doc_root_(doc_root) {} ++ ++ void start() { + accept(); + check_deadline(); + } + + private: + using alloc_t = fields_alloc; +- //using request_body_t = http::basic_dynamic_body>; ++ // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. +@@ -110,49 +139,43 @@ + boost::optional> parser_; + + // The timer putting a time limit on requests. +- net::steady_timer request_deadline_{ +- acceptor_.get_executor(), (std::chrono::steady_clock::time_point::max)()}; ++ net::steady_timer request_deadline_{acceptor_.get_executor(), ++ (std::chrono::steady_clock::time_point::max)()}; + + // The string-based response message. +- boost::optional>> string_response_; ++ boost::optional>> ++ string_response_; + + // The string-based response serializer. +- boost::optional>> string_serializer_; ++ boost::optional>> ++ string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. +- boost::optional>> file_serializer_; +- +- void accept() +- { ++ boost::optional>> ++ file_serializer_; ++ ++ void accept() { + // Clean up any previous connection. + beast::error_code ec; + socket_.close(ec); + buffer_.consume(buffer_.size()); + +- acceptor_.async_accept( +- socket_, +- [this](beast::error_code ec) +- { +- if (ec) +- { +- accept(); +- } +- else +- { +- // Request must be fully processed within 60 seconds. +- request_deadline_.expires_after( +- std::chrono::seconds(60)); +- +- read_request(); +- } +- }); +- } +- +- void read_request() +- { ++ acceptor_.async_accept(socket_, [this](beast::error_code ec) { ++ if (ec) { ++ accept(); ++ } else { ++ // Request must be fully processed within 60 seconds. ++ request_deadline_.expires_after(std::chrono::seconds(60)); ++ ++ read_request(); ++ } ++ }); ++ } ++ ++ void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. +@@ -164,50 +187,33 @@ + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // +- parser_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); +- +- http::async_read( +- socket_, +- buffer_, +- *parser_, +- [this](beast::error_code ec, std::size_t) +- { +- if (ec) +- accept(); +- else +- process_request(parser_->get()); +- }); +- } +- +- void process_request(http::request> const& req) +- { +- switch (req.method()) +- { +- case http::verb::get: +- send_file(req.target()); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; +- } +- } +- +- void send_bad_response( +- http::status status, +- std::string const& error) +- { +- string_response_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); ++ parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); ++ ++ http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { ++ if (ec) ++ accept(); ++ else ++ process_request(parser_->get()); ++ }); ++ } ++ ++ void process_request(http::request> const& req) { ++ switch (req.method()) { ++ case http::verb::get: send_file(req.target()); break; ++ ++ default: ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); ++ break; ++ } ++ } ++ ++ void send_bad_response(http::status status, std::string const& error) { ++ string_response_.emplace(std::piecewise_construct, std::make_tuple(), ++ std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); +@@ -218,52 +224,34 @@ + + string_serializer_.emplace(*string_response_); + +- http::async_write( +- socket_, +- *string_serializer_, +- [this](beast::error_code ec, std::size_t) +- { +- socket_.shutdown(tcp::socket::shutdown_send, ec); +- string_serializer_.reset(); +- string_response_.reset(); +- accept(); +- }); +- } +- +- void send_file(beast::string_view target) +- { ++ http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { ++ socket_.shutdown(tcp::socket::shutdown_send, ec); ++ string_serializer_.reset(); ++ string_response_.reset(); ++ accept(); ++ }); ++ } ++ ++ void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) +- { +- send_bad_response( +- http::status::not_found, +- "File not found\r\n"); ++ if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; +- full_path.append( +- target.data(), +- target.size()); ++ full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; +- file.open( +- full_path.c_str(), +- beast::file_mode::read, +- ec); +- if(ec) +- { +- send_bad_response( +- http::status::not_found, +- "File not found\r\n"); ++ file.open(full_path.c_str(), beast::file_mode::read, ec); ++ if (ec) { ++ send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + +- file_response_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); ++ file_response_.emplace(std::piecewise_construct, std::make_tuple(), ++ std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); +@@ -274,47 +262,34 @@ + + file_serializer_.emplace(*file_response_); + +- http::async_write( +- socket_, +- *file_serializer_, +- [this](beast::error_code ec, std::size_t) +- { +- socket_.shutdown(tcp::socket::shutdown_send, ec); +- file_serializer_.reset(); +- file_response_.reset(); +- accept(); +- }); +- } +- +- void check_deadline() +- { ++ http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { ++ socket_.shutdown(tcp::socket::shutdown_send, ec); ++ file_serializer_.reset(); ++ file_response_.reset(); ++ accept(); ++ }); ++ } ++ ++ void check_deadline() { + // The deadline may have moved, so check it has really passed. +- if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) +- { ++ if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at( +- (std::chrono::steady_clock::time_point::max)()); +- } +- +- request_deadline_.async_wait( +- [this](beast::error_code) +- { +- check_deadline(); +- }); ++ request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ } ++ ++ request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 6) +- { +- std::cerr << "Usage: http_server_fast
{spin|block}\n"; ++ if (argc != 6) { ++ std::cerr << "Usage: http_server_fast
" ++ "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; +@@ -328,23 +303,21 @@ + int num_workers = std::atoi(argv[4]); + bool spin = (std::strcmp(argv[5], "spin") == 0); + +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; +- for (int i = 0; i < num_workers; ++i) +- { ++ for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) +- for (;;) ioc.poll(); ++ for (;;) ++ ioc.poll(); + else +- ioc.run(); +- } +- catch (const std::exception& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/flex/http_server_flex.cpp ++++ port/http/server/flex/http_server_flex.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,85 +30,99 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -103,15 +134,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -122,9 +148,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -135,9 +159,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -148,19 +170,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -169,19 +189,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -191,10 +210,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -205,9 +222,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -225,7 +240,7 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +@@ -234,16 +249,11 @@ + // Handles an HTTP server connection. + // This uses the Curiously Recurring Template Pattern so that + // the same code works with both SSL streams and regular sockets. +-template +-class session +-{ ++template ++class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. +- Derived& +- derived() +- { +- return static_cast(*this); +- } ++ Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; +@@ -253,78 +263,49 @@ + + public: + // Take ownership of the buffer +- session( +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : doc_root_(doc_root) +- , buffer_(std::move(buffer)) +- { +- } +- +- void +- do_read() +- { ++ session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) ++ : doc_root_(doc_root), buffer_(std::move(buffer)) {} ++ ++ void do_read() { + // Set the timeout. +- beast::get_lowest_layer( +- derived().stream()).expires_after(std::chrono::seconds(30)); ++ beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), +- buffer_, +- req_, +- beast::bind_front_handler( +- &session::on_read, +- derived().shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ derived().stream(), buffer_, req_, ++ beast::bind_front_handler(&session::on_read, derived().shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return derived().do_eof(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response +- beast::async_write( +- derived().stream(), +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, +- derived().shared_from_this(), +- keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::async_write(derived().stream(), std::move(msg), ++ beast::bind_front_handler(&session::on_write, ++ derived().shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); +@@ -336,49 +317,30 @@ + }; + + // Handles a plain HTTP connection +-class plain_session +- : public session +- , public std::enable_shared_from_this +-{ ++class plain_session : public session, ++ public std::enable_shared_from_this { + beast::tcp_stream stream_; + + public: + // Create the session +- plain_session( +- tcp::socket&& socket, +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(socket)) +- { +- } ++ plain_session(tcp::socket&& socket, beast::flat_buffer buffer, ++ std::shared_ptr const& doc_root) ++ : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class +- beast::tcp_stream& +- stream() +- { +- return stream_; +- } ++ beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), +- beast::bind_front_handler( +- &session::do_read, +- shared_from_this())); +- } +- +- void +- do_eof() +- { ++ beast::bind_front_handler(&session::do_read, shared_from_this())); ++ } ++ ++ void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -388,62 +350,37 @@ + }; + + // Handles an SSL HTTP connection +-class ssl_session +- : public session +- , public std::enable_shared_from_this +-{ ++class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + + public: + // Create the session +- ssl_session( +- tcp::socket&& socket, +- ssl::context& ctx, +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(socket), ctx) +- { +- } ++ ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, ++ std::shared_ptr const& doc_root) ++ : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class +- ssl::stream& +- stream() +- { +- return stream_; +- } ++ ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self]() { + // Set the timeout. +- beast::get_lowest_layer(self->stream_).expires_after( +- std::chrono::seconds(30)); ++ beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, +- self->buffer_.data(), +- beast::bind_front_handler( +- &ssl_session::on_handshake, +- self)); ++ ssl::stream_base::server, self->buffer_.data(), ++ beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + +- void +- on_handshake( +- beast::error_code ec, +- std::size_t bytes_used) +- { +- if(ec) ++ void on_handshake(beast::error_code ec, std::size_t bytes_used) { ++ if (ec) + return fail(ec, "handshake"); + + // Consume the portion of the buffer used by the handshake +@@ -452,23 +389,17 @@ + do_read(); + } + +- void +- do_eof() +- { ++ void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( +- beast::bind_front_handler( +- &ssl_session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -478,153 +409,103 @@ + //------------------------------------------------------------------------------ + + // Detects SSL handshakes +-class detect_session : public std::enable_shared_from_this +-{ ++class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + + public: +- detect_session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , ctx_(ctx) +- , doc_root_(doc_root) +- { +- } ++ detect_session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector +- void +- run() +- { ++ void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake +- async_detect_ssl( +- stream_, +- buffer_, +- beast::bind_front_handler( +- &detect_session::on_detect, +- shared_from_this())); +- } +- +- void +- on_detect(beast::error_code ec, bool result) +- { +- if(ec) ++ async_detect_ssl(stream_, buffer_, ++ beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); ++ } ++ ++ void on_detect(beast::error_code ec, bool result) { ++ if (ec) + return fail(ec, "detect"); + +- if(result) +- { ++ if (result) { + // Launch SSL session +- std::make_shared( +- stream_.release_socket(), +- ctx_, +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), ++ doc_root_) ++ ->run(); + return; + } + + // Launch plain session +- std::make_shared( +- stream_.release_socket(), +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) ++ ->run(); + } + }; + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the detector session and run it +- std::make_shared( +- std::move(socket), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection +@@ -634,15 +515,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-flex
\n" << +- "Example:\n" << +- " http-server-flex 0.0.0.0 8080 .\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-flex
\n" ++ << "Example:\n" ++ << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -651,7 +529,7 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -660,22 +538,16 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/small/http_server_small.cpp ++++ port/http/server/small/http_server_small.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) + // +@@ -13,50 +29,39 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from +- +-namespace my_program_state +-{ +- std::size_t +- request_count() +- { +- static std::size_t count = 0; +- return ++count; +- } +- +- std::time_t +- now() +- { +- return std::time(0); +- } +-} +- +-class http_connection : public std::enable_shared_from_this +-{ ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from ++ ++namespace my_program_state { ++std::size_t request_count() { ++ static std::size_t count = 0; ++ return ++count; ++} ++ ++std::time_t now() { ++ return std::time(0); ++} ++} // namespace my_program_state ++ ++class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) +- : socket_(std::move(socket)) +- { +- } ++ http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. +- void +- start() +- { ++ void start() { + read_request(); + check_deadline(); + } +@@ -75,92 +80,69 @@ + http::response response_; + + // The timer for putting a deadline on connection processing. +- net::steady_timer deadline_{ +- socket_.get_executor(), std::chrono::seconds(60)}; ++ net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. +- void +- read_request() +- { ++ void read_request() { + auto self = shared_from_this(); + +- http::async_read( +- socket_, +- buffer_, +- request_, +- [self](beast::error_code ec, +- std::size_t bytes_transferred) +- { +- boost::ignore_unused(bytes_transferred); +- if(!ec) +- self->process_request(); +- }); ++ http::async_read(socket_, buffer_, request_, ++ [self](beast::error_code ec, std::size_t bytes_transferred) { ++ boost::ignore_unused(bytes_transferred); ++ if (!ec) ++ self->process_request(); ++ }); + } + + // Determine what needs to be done with the request message. +- void +- process_request() +- { ++ void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + +- switch(request_.method()) +- { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" +- << std::string(request_.method_string()) +- << "'"; +- break; ++ switch (request_.method()) { ++ case http::verb::get: ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ break; ++ ++ default: ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; ++ break; + } + + write_response(); + } + + // Construct a response message based on the program state. +- void +- create_response() +- { +- if(request_.target() == "/count") +- { ++ void create_response() { ++ if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" +- << "Request count\n" +- << "\n" +- << "

Request count

\n" +- << "

There have been " +- << my_program_state::request_count() +- << " requests so far.

\n" +- << "\n" +- << "\n"; +- } +- else if(request_.target() == "/time") +- { ++ << "Request count\n" ++ << "\n" ++ << "

Request count

\n" ++ << "

There have been " << my_program_state::request_count() ++ << " requests so far.

\n" ++ << "\n" ++ << "\n"; ++ } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); +- beast::ostream(response_.body()) +- << "\n" +- << "Current time\n" +- << "\n" +- << "

Current time

\n" +- << "

The current time is " +- << my_program_state::now() +- << " seconds since the epoch.

\n" +- << "\n" +- << "\n"; +- } +- else +- { ++ beast::ostream(response_.body()) << "\n" ++ << "Current time\n" ++ << "\n" ++ << "

Current time

\n" ++ << "

The current time is " << my_program_state::now() ++ << " seconds since the epoch.

\n" ++ << "\n" ++ << "\n"; ++ } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; +@@ -168,62 +150,43 @@ + } + + // Asynchronously transmit the response message. +- void +- write_response() +- { ++ void write_response() { + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + +- http::async_write( +- socket_, +- response_, +- [self](beast::error_code ec, std::size_t) +- { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); +- self->deadline_.cancel(); +- }); ++ http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { ++ self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ self->deadline_.cancel(); ++ }); + } + + // Check whether we have spent enough time on this connection. +- void +- check_deadline() +- { ++ void check_deadline() { + auto self = shared_from_this(); + +- deadline_.async_wait( +- [self](beast::error_code ec) +- { +- if(!ec) +- { +- // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); +- } +- }); ++ deadline_.async_wait([self](beast::error_code ec) { ++ if (!ec) { ++ // Close socket to cancel any outstanding operation. ++ self->socket_.close(ec); ++ } ++ }); + } + }; + + // "Loop" forever accepting new connections. +-void +-http_server(tcp::acceptor& acceptor, tcp::socket& socket) +-{ +- acceptor.async_accept(socket, +- [&](beast::error_code ec) +- { +- if(!ec) +- std::make_shared(std::move(socket))->start(); +- http_server(acceptor, socket); +- }); +-} +- +-int +-main(int argc, char* argv[]) +-{ +- try +- { ++void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { ++ acceptor.async_accept(socket, [&](beast::error_code ec) { ++ if (!ec) ++ std::make_shared(std::move(socket))->start(); ++ http_server(acceptor, socket); ++ }); ++} ++ ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if(argc != 3) +- { ++ if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; +@@ -235,16 +198,14 @@ + auto const address = net::ip::make_address(argv[1]); + unsigned short port = static_cast(std::atoi(argv[2])); + +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/stackless/http_server_stackless.cpp ++++ port/http/server/stackless/http_server_stackless.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,14 +29,12 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include +@@ -28,69 +42,85 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -102,15 +132,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -121,9 +146,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -134,9 +157,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -147,19 +168,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -168,19 +187,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -190,10 +208,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -204,17 +220,12 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -223,40 +234,26 @@ + + public: + // Take ownership of the socket +- explicit +- session( +- tcp::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- } ++ explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(stream_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop(beast::error_code ec, std::size_t bytes_transferred) +- { ++ net::dispatch( ++ stream_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- reenter(*this) +- { +- for(;;) +- { ++ reenter(*this) { ++ for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -265,39 +262,33 @@ + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request +- yield http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::loop, +- shared_from_this())); +- +- if(ec == http::error::end_of_stream) +- { ++ yield http::async_read( ++ stream_, buffer_, req_, ++ beast::bind_front_handler(&session::loop, shared_from_this())); ++ ++ if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + yield { + // Handle request +- http::message_generator msg = +- handle_request(*doc_root_, std::move(req_)); ++ http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::loop, shared_from_this())); ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive_) +- { ++ if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -311,99 +302,72 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , socket_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ++ acceptor_(net::make_strand(ioc)), ++ socket_(net::make_strand(ioc)), ++ doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen(net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- beast::bind_front_handler( +- &listener::loop, +- shared_from_this())); +- if(ec) +- { ++ socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket_), +- doc_root_)->run(); ++ std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand +@@ -412,20 +376,17 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-stackless
\n" << +- "Example:\n" << +- " http-server-stackless 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-stackless
\n" ++ << "Example:\n" ++ << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -434,24 +395,19 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port +- std::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ port/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,17 +30,15 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include +@@ -31,70 +46,86 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -106,15 +137,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -125,9 +151,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -138,9 +162,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -151,19 +173,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -172,19 +192,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -194,10 +213,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -208,9 +225,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -228,17 +243,14 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -247,53 +259,37 @@ + + public: + // Take ownership of the socket +- explicit +- session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket), ctx) +- , doc_root_(doc_root) +- { +- } ++ explicit session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(stream_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop(beast::error_code ec, std::size_t bytes_transferred) +- { ++ net::dispatch( ++ stream_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- reenter(*this) +- { ++ reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, +- std::bind( +- &session::loop, shared_from_this(), +- std::placeholders::_1, 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "handshake"); + +- for(;;) +- { ++ for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + +@@ -304,20 +300,18 @@ + // Read a request + yield http::async_read( + stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::loop, shared_from_this())); ++ beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + yield { + // Handle request +- http::message_generator msg = +- handle_request(*doc_root_, std::move(req_)); ++ http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); +@@ -325,14 +319,12 @@ + // Send the response + beast::async_write( + stream_, std::move(msg), +- beast::bind_front_handler( +- &session::loop, shared_from_this())); ++ beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive_) +- { ++ if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -344,117 +336,82 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- , socket_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ++ ctx_(ctx), ++ acceptor_(net::make_strand(ioc)), ++ socket_(net::make_strand(ioc)), ++ doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- std::bind( +- &listener::loop, +- shared_from_this(), +- std::placeholders::_1)); +- if(ec) +- { ++ socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket_), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand +@@ -463,20 +420,17 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-stackless-ssl
\n" << +- "Example:\n" << +- " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-stackless-ssl
\n" ++ << "Example:\n" ++ << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -485,7 +439,7 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -494,22 +448,16 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/sync/http_server_sync.cpp ++++ port/http/server/sync/http_server_sync.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,81 +29,95 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if (base.empty()) +- return std::string(path); ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) ++ return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -99,15 +129,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -118,9 +143,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -131,9 +154,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -144,19 +165,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -165,19 +184,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -187,10 +205,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -201,36 +217,28 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-void +-do_session( +- tcp::socket& socket, +- std::shared_ptr const& doc_root) +-{ ++void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle request +- http::message_generator msg = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -238,10 +246,9 @@ + // Send the response + beast::write(socket, std::move(msg), ec); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -256,17 +263,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: http-server-sync
\n" << +- "Example:\n" << +- " http-server-sync 0.0.0.0 8080 .\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: http-server-sync
\n" ++ << "Example:\n" ++ << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -274,12 +277,11 @@ + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -287,14 +289,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread{std::bind( +- &do_session, +- std::move(socket), +- doc_root)}.detach(); ++ std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ port/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,84 +30,98 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ + #include + #include + #include ++#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -102,15 +133,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -121,9 +147,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -134,9 +158,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -147,19 +169,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -168,19 +188,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -190,10 +209,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -204,19 +221,13 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-void +-do_session( +- tcp::socket& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +-{ ++void do_session(tcp::socket& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket +@@ -224,25 +235,23 @@ + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::server, ec); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle request +- http::message_generator msg = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -250,11 +259,10 @@ + // Send the response + beast::write(stream, std::move(msg), ec); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -263,7 +271,7 @@ + + // Perform the SSL shutdown + stream.shutdown(ec); +- if(ec) ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -271,17 +279,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: http-server-sync-ssl
\n" << +- "Example:\n" << +- " http-server-sync-ssl 0.0.0.0 8080 .\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: http-server-sync-ssl
\n" ++ << "Example:\n" ++ << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -289,7 +293,7 @@ + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -299,8 +303,7 @@ + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -308,15 +311,10 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread{std::bind( +- &do_session, +- std::move(socket), +- std::ref(ctx), +- doc_root)}.detach(); ++ std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} ++ .detach(); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/client/async/websocket_client_async.cpp ++++ port/websocket/client/async/websocket_client_async.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,33 +30,30 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; +@@ -48,39 +62,22 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc) +- : resolver_(net::make_strand(ioc)) +- , ws_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) ++ : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout for the operation +@@ -88,16 +85,11 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Turn off the timeout on the tcp_stream, because +@@ -105,18 +97,13 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); ++ })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -125,64 +112,41 @@ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); +- ++ + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_close, shared_from_this())); + } + +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -194,15 +158,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async \n" << +- "Example:\n" << +- " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async \n" ++ << "Example:\n" ++ << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -210,14 +171,14 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/async-local/websocket_client_async_local.cpp ++++ port/websocket/client/async-local/websocket_client_async_local.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -16,8 +33,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -26,24 +43,21 @@ + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; +@@ -51,20 +65,10 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc) +- : ws_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* path, +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; +@@ -72,91 +76,59 @@ + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec) +- { +- if(ec) ++ void on_connect(beast::error_code ec) { ++ if (ec) + return fail(ec, "connect"); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-local"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); ++ })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); +- ++ + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_close, shared_from_this())); + } + +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -168,15 +140,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 5) +- { +- std::cerr << +- "Usage: websocket-client-async-local \n" << +- "Example:\n" << +- " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; ++ if (argc != 5) { ++ std::cerr ++ << "Usage: websocket-client-async-local \n" ++ << "Example:\n" ++ << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; +@@ -185,26 +155,23 @@ + auto const text = argv[4]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ +-std::cerr << +- "Local sockets not available on this platform" << std::endl; +-return EXIT_FAILURE; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; ++ return EXIT_FAILURE; + } + + #endif +--- upstream/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ port/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,37 +31,34 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include ++#include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -52,26 +67,15 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc, ssl::context& ctx) +- : resolver_(net::make_strand(ioc)) +- , ws_(net::make_strand(ioc), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -85,19 +89,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -105,38 +101,29 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +- ++ + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); +- ++ + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_ssl_handshake, +- shared_from_this())); +- } +- +- void +- on_ssl_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); ++ } ++ ++ void on_ssl_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -144,79 +131,51 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); ++ })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -228,15 +187,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async-ssl \n" << +- "Example:\n" << +- " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async-ssl \n" ++ << "Example:\n" ++ << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -244,7 +200,7 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -260,7 +216,7 @@ + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,38 +31,35 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include + #include ++#include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -54,32 +69,19 @@ + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) +- : resolver_(ex) +- , ws_(ex, ctx) +- { +- } ++ : resolver_(ex), ws_(ex, ctx) {} ++ + public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. +- explicit +- session(ssl::context& ctx) +- : session(net::make_strand(net::system_executor{}), ctx) +- { +- } ++ explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor{}), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -93,19 +95,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -113,16 +107,11 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -136,15 +125,11 @@ + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_ssl_handshake, +- shared_from_this())); +- } +- +- void +- on_ssl_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); ++ } ++ ++ void on_ssl_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -152,79 +137,51 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); ++ })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -236,21 +193,17 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async-ssl \n" << +- "Example:\n" << +- " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async-ssl \n" ++ << "Example:\n" ++ << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; +- + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- upstream/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ port/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -16,8 +33,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -25,18 +42,16 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; ++namespace net = boost::asio; + + // Sends a WebSocket message and prints the response +-net::awaitable +-do_session(std::string host, std::string port, std::string text) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string text) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = websocket::stream{ executor }; ++ auto resolver = webcpp::asio::ip::tcp::resolver{executor}; ++ auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); +@@ -57,18 +72,13 @@ + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket +- stream.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::client)); ++ stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- stream.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set( +- http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); +@@ -93,18 +103,13 @@ + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr +- << "Usage: websocket-client-awaitable \n" +- << "Example:\n" +- << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-awaitable \n" ++ << "Example:\n" ++ << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -112,24 +117,18 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, text), +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -138,9 +137,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/websocket/client/coro/websocket_client_coro.cpp ++++ port/websocket/client/coro/websocket_client_coro.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,38 +30,30 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-void +-do_session( +- std::string host, +- std::string const& port, +- std::string const& text, +- net::io_context& ioc, +- net::yield_context yield) +-{ ++void do_session(std::string host, std::string const& port, std::string const& text, ++ webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +@@ -53,7 +62,7 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -61,7 +70,7 @@ + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Update the host_ string. This will provide the value of the +@@ -74,27 +83,22 @@ + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message +@@ -102,12 +106,12 @@ + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -118,15 +122,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-coro \n" << +- "Example:\n" << +- " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-coro \n" ++ << "Example:\n" ++ << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -134,31 +135,27 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(text), +- std::ref(ioc), +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn(ioc, ++ std::bind(&do_session, std::string(host), std::string(port), ++ std::string(text), std::ref(ioc), std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,44 +31,35 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-void +-do_session( +- std::string host, +- std::string const& port, +- std::string const& text, +- net::io_context& ioc, +- ssl::context& ctx, +- net::yield_context yield) +-{ ++void do_session(std::string host, std::string const& port, std::string const& text, ++ webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +@@ -59,7 +68,7 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -67,12 +76,11 @@ + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) +- { ++ if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + return fail(ec, "connect"); + } +@@ -89,17 +97,14 @@ + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -107,18 +112,16 @@ + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message +@@ -126,12 +129,12 @@ + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -142,15 +145,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-coro-ssl \n" << +- "Example:\n" << +- " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-coro-ssl \n" ++ << "Example:\n" ++ << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -158,7 +158,7 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -170,29 +170,25 @@ + load_root_certificates(ctx); + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(text), +- std::ref(ioc), +- std::ref(ctx), +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_session, std::string(host), std::string(port), std::string(text), ++ std::ref(ioc), std::ref(ctx), std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/sync/websocket_client_sync.cpp ++++ port/websocket/client/sync/websocket_client_sync.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,40 +32,36 @@ + + //[example_websocket_client + +-#include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-sync \n" << +- "Example:\n" << +- " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-sync \n" ++ << "Example:\n" ++ << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const port = argv[2]; ++ auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver{ioc}; +@@ -66,13 +79,10 @@ + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + ws.handshake(host, "/"); +@@ -93,9 +103,7 @@ + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,45 +31,41 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + +-#include +-#include +-#include + #include + #include + #include ++#include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-sync-ssl \n" << +- "Example:\n" << +- " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-sync-ssl \n" ++ << "Example:\n" ++ << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const port = argv[2]; ++ auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -73,11 +87,9 @@ + auto ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification +@@ -92,13 +104,10 @@ + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + ws.handshake(host, "/"); +@@ -119,9 +128,7 @@ + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/server/async/websocket_server_async.cpp ++++ port/websocket/server/async/websocket_server_async.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,11 +30,9 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include + #include +-#include + #include + #include + #include +@@ -25,126 +40,88 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- session(tcp::socket&& socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation +- void +- on_run() +- { ++ void on_run() { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-async"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); ++ })); + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) +- return; +- +- if(ec) ++ if (ec == websocket::error::closed) ++ return; ++ ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -158,82 +135,57 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(ioc) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } +@@ -245,15 +197,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-async
\n" << +- "Example:\n" << +- " websocket-server-async 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-async
\n" ++ << "Example:\n" ++ << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -261,7 +210,7 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); +@@ -269,13 +218,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/async-local/websocket_server_async_local.cpp ++++ port/websocket/server/async-local/websocket_server_async_local.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -17,8 +34,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -30,125 +47,85 @@ + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- session(stream_protocol::socket&& socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation +- void +- on_run() +- { ++ void on_run() { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-async-local"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); ++ })); + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + return; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -162,49 +139,29 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + + public: +- listener( +- net::io_context& ioc, +- stream_protocol::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(ioc, std::move(endpoint)) +- { +- } ++ listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) ++ : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, stream_protocol::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, stream_protocol::socket socket) { ++ if (ec) { + fail(ec, "accept"); + return; +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } +@@ -216,24 +173,20 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 3) +- { +- std::cerr << +- "Usage: websocket-server-async-local \n" << +- "Example:\n" << +- " websocket-server-async-local /tmp/ws.sock 1\n"; ++ if (argc != 3) { ++ std::cerr << "Usage: websocket-server-async-local \n" ++ << "Example:\n" ++ << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; + auto const threads = std::max(1, std::atoi(argv[2])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + std::remove(path); +@@ -244,18 +197,14 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -263,11 +212,8 @@ + + #else + +-int +-main(int, char*[]) +-{ +- std::cerr << +- "Local sockets not available on this platform" << std::endl; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; + return EXIT_FAILURE; + } + +--- upstream/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ port/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,84 +31,68 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- session(tcp::socket&& socket, ssl::context& ctx) +- : ws_(std::move(socket), ctx) +- { +- } ++ session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation +- void +- on_run() +- { ++ void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + +- // Perform the SSL handshake ++ // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -98,78 +100,51 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-async-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); ++ })); + + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) +- return; +- +- if(ec) ++ if (ec == websocket::error::closed) ++ return; ++ ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -183,85 +158,59 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) ++ : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } +@@ -273,15 +222,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-async-ssl
\n" << +- "Example:\n" << +- " websocket-server-async-ssl 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-async-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -289,7 +235,7 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -303,13 +249,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ port/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -17,8 +34,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -29,45 +46,37 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; ++namespace net = boost::asio; + + // Echoes back all received WebSocket messages +-net::awaitable +-do_session(websocket::stream stream) +-{ ++net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket +- stream.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::server)); ++ stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- stream.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set( +- http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-coro"); +- })); ++ stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); ++ })); + + // Accept the websocket handshake + co_await stream.async_accept(); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + co_return; + +- if(ec) +- throw boost::system::system_error{ ec }; ++ if (ec) ++ throw boost::system::system_error{ec}; + + // Echo the message back + stream.text(stream.got_text()); +@@ -76,28 +85,19 @@ + } + + // Accepts incoming connections and launches the sessions +-net::awaitable +-do_listen(net::ip::tcp::endpoint endpoint) +-{ ++net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { + auto executor = co_await net::this_coro::executor; +- auto acceptor = net::ip::tcp::acceptor{ executor, endpoint }; ++ auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + +- for(;;) +- { ++ for (;;) { + net::co_spawn( + executor, +- do_session(websocket::stream{ +- co_await acceptor.async_accept() }), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { ++ do_session(websocket::stream{co_await acceptor.async_accept()}), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { + std::rethrow_exception(e); +- } +- catch(std::exception& e) +- { ++ } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } +@@ -105,59 +105,47 @@ + } + } + +-int +-main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr +- << "Usage: websocket-server-awaitable
\n" +- << "Example:\n" +- << " websocket-server-awaitable 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-awaitable
\n" ++ << "Example:\n" ++ << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc(threads); ++ webcpp::asio::io_context ioc(threads); + + // Spawn a listening port +- net::co_spawn( +- ioc, +- do_listen(net::ip::tcp::endpoint{ address, port }), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error: " << e.what() << std::endl; +- } +- } +- }); ++ net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception const& e) { ++ std::cerr << "Error: " << e.what() << std::endl; ++ } ++ } ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back([&ioc] { ioc.run(); }); +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back( ++ [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/websocket/server/chat-multi/beast.hpp ++++ port/websocket/server/chat-multi/beast.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,10 +27,10 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +-#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from + + #endif +--- upstream/websocket/server/chat-multi/chat_client.html ++++ port/websocket/server/chat-multi/chat_client.html +@@ -1,3 +1,14 @@ ++ + + + +--- upstream/websocket/server/chat-multi/http_session.cpp ++++ port/websocket/server/chat-multi/http_session.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,70 +24,84 @@ + // Official repository: https://github.com/vinniefalco/CppCon2018 + // + ++#include ++#include + #include "http_session.hpp" + #include "websocket_session.hpp" +-#include +-#include + + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -82,15 +113,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -101,9 +127,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -114,9 +138,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -127,19 +149,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -148,19 +168,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -170,10 +189,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -183,38 +200,23 @@ + + //------------------------------------------------------------------------------ + +-http_session:: +-http_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state) +- : stream_(std::move(socket)) +- , state_(state) +-{ +-} +- +-void +-http_session:: +-run() +-{ ++http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) ++ : stream_(std::move(socket)), state_(state) {} ++ ++void http_session::run() { + do_read(); + } + + // Report a failure +-void +-http_session:: +-fail(beast::error_code ec, char const* what) +-{ ++void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if(ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + +-void +-http_session:: +-do_read() +-{ ++void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + +@@ -226,44 +228,32 @@ + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request +- http::async_read( +- stream_, +- buffer_, +- parser_->get(), +- beast::bind_front_handler( +- &http_session::on_read, +- shared_from_this())); +-} +- +-void +-http_session:: +-on_read(beast::error_code ec, std::size_t) +-{ ++ http::async_read(stream_, buffer_, parser_->get(), ++ beast::bind_front_handler(&http_session::on_read, shared_from_this())); ++} ++ ++void http_session::on_read(beast::error_code ec, std::size_t) { + // This means they closed the connection +- if(ec == http::error::end_of_stream) +- { ++ if (ec == http::error::end_of_stream) { + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + return; + } + + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade +- if(websocket::is_upgrade(parser_->get())) +- { ++ if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. +- boost::make_shared( +- stream_.release_socket(), +- state_)->run(parser_->release()); ++ boost::make_shared(stream_.release_socket(), state_) ++ ->run(parser_->release()); + return; + } + + // Handle request +- http::message_generator msg = +- handle_request(state_->doc_root(), parser_->release()); ++ http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -271,24 +261,18 @@ + auto self = shared_from_this(); + + // Send the response +- beast::async_write( +- stream_, std::move(msg), +- [self, keep_alive](beast::error_code ec, std::size_t bytes) +- { +- self->on_write(ec, bytes, keep_alive); +- }); +-} +- +-void +-http_session:: +-on_write(beast::error_code ec, std::size_t, bool keep_alive) +-{ ++ beast::async_write(stream_, std::move(msg), ++ [self, keep_alive](beast::error_code ec, std::size_t bytes) { ++ self->on_write(ec, bytes, keep_alive); ++ }); ++} ++ ++void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +--- upstream/websocket/server/chat-multi/http_session.hpp ++++ port/websocket/server/chat-multi/http_session.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,18 +26,17 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +-#include "net.hpp" +-#include "beast.hpp" +-#include "shared_state.hpp" + #include + #include + #include + #include ++#include "beast.hpp" ++#include "net.hpp" ++#include "shared_state.hpp" + + /** Represents an established HTTP connection +-*/ +-class http_session : public boost::enable_shared_from_this +-{ ++ */ ++class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; +@@ -38,9 +53,7 @@ + void on_write(beast::error_code ec, std::size_t, bool close); + + public: +- http_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state); ++ http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); + }; +--- upstream/websocket/server/chat-multi/listener.cpp ++++ port/websocket/server/chat-multi/listener.cpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,95 +23,67 @@ + // Official repository: https://github.com/vinniefalco/CppCon2018 + // + ++#include ++#include "http_session.hpp" + #include "listener.hpp" +-#include "http_session.hpp" +-#include + +-listener:: +-listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- boost::shared_ptr const& state) +- : ioc_(ioc) +- , acceptor_(ioc) +- , state_(state) +-{ ++listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ boost::shared_ptr const& state) ++ : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + +-void +-listener:: +-run() +-{ ++void listener::run() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + // Report a failure +-void +-listener:: +-fail(beast::error_code ec, char const* what) +-{ ++void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if(ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) + return; + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection +-void +-listener:: +-on_accept(beast::error_code ec, tcp::socket socket) +-{ +- if(ec) ++void listener::on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) + return fail(ec, "accept"); + else + // Launch a new session for this connection +- boost::make_shared( +- std::move(socket), +- state_)->run(); ++ boost::make_shared(std::move(socket), state_)->run(); + + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } +--- upstream/websocket/server/chat-multi/listener.hpp ++++ port/websocket/server/chat-multi/listener.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,19 +26,18 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +-#include "beast.hpp" +-#include "net.hpp" + #include + #include + #include ++#include "beast.hpp" ++#include "net.hpp" + + // Forward declaration + class shared_state; + + // Accepts incoming connections and launches the sessions +-class listener : public boost::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + +@@ -30,10 +45,8 @@ + void on_accept(beast::error_code ec, tcp::socket socket); + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- boost::shared_ptr const& state); ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +--- upstream/websocket/server/chat-multi/main.cpp ++++ port/websocket/server/chat-multi/main.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -26,16 +43,12 @@ + #include + #include + +-int +-main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: websocket-chat-multi
\n" << +- "Example:\n" << +- " websocket-chat-server 0.0.0.0 8080 . 5\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: websocket-chat-multi
\n" ++ << "Example:\n" ++ << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto address = net::ip::make_address(argv[1]); +@@ -44,40 +57,35 @@ + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Create and launch a listening port +- boost::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- boost::make_shared(doc_root))->run(); ++ boost::make_shared(ioc, tcp::endpoint{address, port}, ++ boost::make_shared(doc_root)) ++ ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); +- signals.async_wait( +- [&ioc](boost::system::error_code const&, int) +- { +- // Stop the io_context. This will cause run() +- // to return immediately, eventually destroying the +- // io_context and any remaining handlers in it. +- ioc.stop(); +- }); ++ signals.async_wait([&ioc](boost::system::error_code const&, int) { ++ // Stop the io_context. This will cause run() ++ // to return immediately, eventually destroying the ++ // io_context and any remaining handlers in it. ++ ioc.stop(); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for(auto& t : v) ++ for (auto& t : v) + t.join(); + + return EXIT_SUCCESS; +--- upstream/websocket/server/chat-multi/net.hpp ++++ port/websocket/server/chat-multi/net.hpp +@@ -1,3 +1,19 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -12,7 +28,7 @@ + + #include + +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + #endif +--- upstream/websocket/server/chat-multi/shared_state.cpp ++++ port/websocket/server/chat-multi/shared_state.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,33 +27,20 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state:: +-shared_state(std::string doc_root) +- : doc_root_(std::move(doc_root)) +-{ +-} ++shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} + +-void +-shared_state:: +-join(websocket_session* session) +-{ ++void shared_state::join(websocket_session* session) { + std::lock_guard lock(mutex_); + sessions_.insert(session); + } + +-void +-shared_state:: +-leave(websocket_session* session) +-{ ++void shared_state::leave(websocket_session* session) { + std::lock_guard lock(mutex_); + sessions_.erase(session); + } + + // Broadcast a message to all websocket client sessions +-void +-shared_state:: +-send(std::string message) +-{ ++void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + +@@ -47,13 +51,13 @@ + { + std::lock_guard lock(mutex_); + v.reserve(sessions_.size()); +- for(auto p : sessions_) ++ for (auto p : sessions_) + v.emplace_back(p->weak_from_this()); + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for(auto const& wp : v) +- if(auto sp = wp.lock()) ++ for (auto const& wp : v) ++ if (auto sp = wp.lock()) + sp->send(ss); + } +--- upstream/websocket/server/chat-multi/shared_state.hpp ++++ port/websocket/server/chat-multi/shared_state.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -20,8 +37,7 @@ + class websocket_session; + + // Represents the shared server state +-class shared_state +-{ ++class shared_state { + std::string const doc_root_; + + // This mutex synchronizes all access to sessions_ +@@ -31,18 +47,13 @@ + std::unordered_set sessions_; + + public: +- explicit +- shared_state(std::string doc_root); ++ explicit shared_state(std::string doc_root); + +- std::string const& +- doc_root() const noexcept +- { +- return doc_root_; +- } ++ std::string const& doc_root() const noexcept { return doc_root_; } + +- void join (websocket_session* session); +- void leave (websocket_session* session); +- void send (std::string message); ++ void join(websocket_session* session); ++ void leave(websocket_session* session); ++ void send(std::string message); + }; + + #endif +--- upstream/websocket/server/chat-multi/websocket_session.cpp ++++ port/websocket/server/chat-multi/websocket_session.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,62 +24,42 @@ + // Official repository: https://github.com/vinniefalco/CppCon2018 + // + ++#include + #include "websocket_session.hpp" +-#include + +-websocket_session:: +-websocket_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state) +- : ws_(std::move(socket)) +- , state_(state) +-{ +-} ++websocket_session::websocket_session(tcp::socket&& socket, ++ boost::shared_ptr const& state) ++ : ws_(std::move(socket)), state_(state) {} + +-websocket_session:: +-~websocket_session() +-{ ++websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); + } + +-void +-websocket_session:: +-fail(beast::error_code ec, char const* what) +-{ ++void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if( ec == net::error::operation_aborted || +- ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + +-void +-websocket_session:: +-on_accept(beast::error_code ec) +-{ ++void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "accept"); + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void +-websocket_session:: +-on_read(beast::error_code ec, std::size_t) +-{ ++void websocket_session::on_read(beast::error_code ec, std::size_t) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send to all connections +@@ -72,64 +69,43 @@ + buffer_.consume(buffer_.size()); + + // Read another message +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void +-websocket_session:: +-send(boost::shared_ptr const& ss) +-{ ++void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + +- net::post( +- ws_.get_executor(), +- beast::bind_front_handler( +- &websocket_session::on_send, +- shared_from_this(), +- ss)); ++ net::post(ws_.get_executor(), ++ beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); + } + +-void +-websocket_session:: +-on_send(boost::shared_ptr const& ss) +-{ ++void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? +- if(queue_.size() > 1) ++ if (queue_.size() > 1) + return; + + // We are not currently writing, so send this immediately +- ws_.async_write( +- net::buffer(*queue_.front()), +- beast::bind_front_handler( +- &websocket_session::on_write, +- shared_from_this())); ++ ws_.async_write(net::buffer(*queue_.front()), ++ beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void +-websocket_session:: +-on_write(beast::error_code ec, std::size_t) +-{ ++void websocket_session::on_write(beast::error_code ec, std::size_t) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if(! queue_.empty()) ++ if (!queue_.empty()) + ws_.async_write( + net::buffer(*queue_.front()), +- beast::bind_front_handler( +- &websocket_session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +--- upstream/websocket/server/chat-multi/websocket_session.hpp ++++ port/websocket/server/chat-multi/websocket_session.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,8 +27,8 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + ++#include "beast.hpp" + #include "net.hpp" +-#include "beast.hpp" + #include "shared_state.hpp" + + #include +@@ -23,9 +40,8 @@ + class shared_state; + + /** Represents an active WebSocket connection to the server +-*/ +-class websocket_session : public boost::enable_shared_from_this +-{ ++ */ ++class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; +@@ -37,50 +53,34 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred); + + public: +- websocket_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state); ++ websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + +- template +- void +- run(http::request> req); ++ template ++ void run(http::request> req); + + // Send a message +- void +- send(boost::shared_ptr const& ss); ++ void send(boost::shared_ptr const& ss); + + private: +- void +- on_send(boost::shared_ptr const& ss); ++ void on_send(boost::shared_ptr const& ss); + }; + +-template +-void +-websocket_session:: +-run(http::request> req) +-{ ++template ++void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-chat-multi"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); ++ })); + + // Accept the websocket handshake +- ws_.async_accept( +- req, +- beast::bind_front_handler( +- &websocket_session::on_accept, +- shared_from_this())); ++ ws_.async_accept(req, ++ beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + + #endif +--- upstream/websocket/server/coro/websocket_server_coro.cpp ++++ port/websocket/server/coro/websocket_server_coro.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,11 +30,9 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include + #include +-#include + #include + #include + #include +@@ -25,51 +40,41 @@ + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-void +-do_session( +- websocket::stream& ws, +- net::yield_context yield) +-{ ++void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); ++ })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -77,16 +82,16 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } +@@ -94,64 +99,52 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_session, +- websocket::stream< +- beast::tcp_stream>(std::move(socket)), +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ std::bind(&do_session, websocket::stream(std::move(socket)), ++ std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-coro
\n" << +- "Example:\n" << +- " websocket-server-coro 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-coro
\n" ++ << "Example:\n" ++ << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -159,37 +152,32 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc(threads); ++ webcpp::asio::io_context ioc(threads); + + // Spawn a listening port +- boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- tcp::endpoint{address, port}, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,44 +31,38 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-void +-do_session( +- websocket::stream>& ws, +- net::yield_context yield) +-{ ++void do_session(websocket::stream>& ws, net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. +@@ -58,7 +70,7 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -66,26 +78,20 @@ + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-coro-ssl"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); ++ })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -93,16 +99,16 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } +@@ -110,65 +116,54 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_session, +- websocket::stream>(std::move(socket), ctx), +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ std::bind(&do_session, ++ websocket::stream>(std::move(socket), ctx), ++ std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-coro-ssl
\n" << +- "Example:\n" << +- " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-coro-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -176,7 +171,7 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -186,34 +181,28 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- std::ref(ctx), +- tcp::endpoint{address, port}, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ std::bind(&do_listen, std::ref(ioc), std::ref(ctx), ++ tcp::endpoint{address, port}, std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/fast/websocket_server_fast.cpp ++++ port/websocket/server/fast/websocket_server_fast.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -26,14 +43,11 @@ + https://github.com/crossbario/autobahn-testsuite + */ + +-#include +-#include +-#include +-#include ++#include + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -41,27 +55,26 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); + } + + // Adjust settings on the stream +-template +-void +-setup_stream(websocket::stream& ws) +-{ ++template ++void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + +@@ -79,156 +92,110 @@ + + //------------------------------------------------------------------------------ + +-void +-do_sync_session(websocket::stream& ws) +-{ ++void do_sync_session(websocket::stream& ws) { + beast::error_code ec; + + setup_stream(ws); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, std::string( +- BOOST_BEAST_VERSION_STRING) + "-Sync"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Sync"); ++ })); + + ws.accept(ec); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + beast::flat_buffer buffer; + + ws.read(buffer, ec); +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } + +-void +-do_sync_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint) +-{ ++void do_sync_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) { + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; +- for(;;) +- { ++ for (;;) { + tcp::socket socket{ioc}; + + acceptor.accept(socket, ec); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- std::thread(std::bind( +- &do_sync_session, +- websocket::stream( +- std::move(socket)))).detach(); ++ std::thread( ++ std::bind(&do_sync_session, websocket::stream(std::move(socket)))) ++ .detach(); + } + } + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages +-class async_session : public std::enable_shared_from_this +-{ ++class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- async_session(tcp::socket&& socket) +- : ws_(std::move(socket)) +- { +- setup_stream(ws_); +- } ++ explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, std::string( +- BOOST_BEAST_VERSION_STRING) + "-Async"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); ++ })); + + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &async_session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &async_session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&async_session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed +- if(ec == websocket::error::closed) +- return; +- +- if(ec) ++ if (ec == websocket::error::closed) ++ return; ++ ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &async_session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&async_session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -240,82 +207,59 @@ + }; + + // Accepts incoming connections and launches the sessions +-class async_listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class async_listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + + public: +- async_listener( +- net::io_context& ioc, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- { ++ async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), +- beast::bind_front_handler( +- &async_listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } +@@ -327,110 +271,89 @@ + + //------------------------------------------------------------------------------ + +-void +-do_coro_session( +- websocket::stream& ws, +- net::yield_context yield) +-{ ++void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, std::string( +- BOOST_BEAST_VERSION_STRING) + "-Fiber"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); ++ })); + + ws.async_accept(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } + +-void +-do_coro_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- net::yield_context yield) +-{ ++void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); +- if(ec) +- { ++ if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_coro_session, +- websocket::stream< +- beast::tcp_stream>(std::move(socket)), +- std::placeholders::_1), boost::asio::detached); +- } +-} +- +-//------------------------------------------------------------------------------ +- +-int main(int argc, char* argv[]) +-{ ++ std::bind(&do_coro_session, websocket::stream(std::move(socket)), ++ std::placeholders::_1), ++ boost::asio::detached); ++ } ++} ++ ++//------------------------------------------------------------------------------ ++ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-fast
\n" << +- "Example:\n" +- " websocket-server-fast 0.0.0.0 8080 1\n" +- " Connect to:\n" +- " starting-port+0 for synchronous,\n" +- " starting-port+1 for asynchronous,\n" +- " starting-port+2 for coroutine.\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-fast
\n" ++ << "Example:\n" ++ " websocket-server-fast 0.0.0.0 8080 1\n" ++ " Connect to:\n" ++ " starting-port+0 for synchronous,\n" ++ " starting-port+1 for asynchronous,\n" ++ " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -438,44 +361,34 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create sync port +- std::thread(beast::bind_front_handler( +- &do_sync_listen, +- std::ref(ioc), +- tcp::endpoint{ +- address, +- static_cast(port + 0u)} +- )).detach(); ++ std::thread( ++ beast::bind_front_handler(&do_sync_listen, std::ref(ioc), ++ tcp::endpoint{address, static_cast(port + 0u)})) ++ .detach(); + + // Create async port +- std::make_shared( +- ioc, +- tcp::endpoint{ +- address, +- static_cast(port + 1u)})->run(); ++ std::make_shared(ioc, ++ tcp::endpoint{address, static_cast(port + 1u)}) ++ ->run(); + + // Create coro port + boost::asio::spawn(ioc, +- std::bind( +- &do_coro_listen, +- std::ref(ioc), +- tcp::endpoint{ +- address, +- static_cast(port + 2u)}, +- std::placeholders::_1), boost::asio::detached); ++ std::bind(&do_coro_listen, std::ref(ioc), ++ tcp::endpoint{address, static_cast(port + 2u)}, ++ std::placeholders::_1), ++ boost::asio::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/stackless/websocket_server_stackless.cpp ++++ port/websocket/server/stackless/websocket_server_stackless.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,12 +30,10 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include ++#include + #include +-#include +-#include + #include + #include + #include +@@ -26,115 +41,80 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- session(tcp::socket socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(ws_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ net::dispatch( ++ ws_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- reenter(*this) +- { ++ reenter(*this) { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-stackless"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); ++ })); + + // Accept the websocket handshake + yield ws_.async_accept( +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // Read a message into our buffer + yield ws_.async_read( +- buffer_, +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec == websocket::error::closed) +- { ++ buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write( +- buffer_.data(), +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec) ++ yield ws_.async_write(buffer_.data(), ++ std::bind(&session::loop, shared_from_this(), ++ std::placeholders::_1, std::placeholders::_2)); ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -143,94 +123,65 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , socket_(net::make_strand(ioc)) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- std::bind( +- &listener::loop, +- shared_from_this(), +- std::placeholders::_1)); +- if(ec) +- { ++ socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } +@@ -241,20 +192,17 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-stackless
\n" << +- "Example:\n" << +- " websocket-server-stackless 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-stackless
\n" ++ << "Example:\n" ++ << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -262,7 +210,7 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); +@@ -270,13 +218,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,16 +31,14 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -30,76 +46,57 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- session(tcp::socket&& socket, ssl::context& ctx) +- : ws_(std::move(socket), ctx) +- { +- } ++ session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(ws_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ net::dispatch( ++ ws_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- reenter(*this) +- { ++ reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -107,57 +104,38 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-stackless-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + ++ " websocket-server-stackless-ssl"); ++ })); + + // Accept the websocket handshake + yield ws_.async_accept( +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // Read a message into our buffer + yield ws_.async_read( +- buffer_, +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec == websocket::error::closed) +- { ++ buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write( +- buffer_.data(), +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec) ++ yield ws_.async_write(buffer_.data(), ++ std::bind(&session::loop, shared_from_this(), ++ std::placeholders::_1, std::placeholders::_2)); ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -166,97 +144,66 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(ioc) +- , socket_(ioc) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) ++ : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- std::bind( +- &listener::loop, +- shared_from_this(), +- std::placeholders::_1)); +- if(ec) +- { ++ socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } +@@ -267,20 +214,17 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-async-ssl
\n" << +- "Example:\n" << +- " websocket-server-async-ssl 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-async-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -288,7 +232,7 @@ + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -302,13 +246,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); ++ for (auto i = threads - 1; i > 0; --i) ++ v.emplace_back([&ioc] { ++ ioc.run(); // lint-run: drives the application's network operations + }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/sync/websocket_server_sync.cpp ++++ port/websocket/server/sync/websocket_server_sync.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,46 +30,39 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages +-void +-do_session(tcp::socket socket) +-{ +- try +- { ++void do_session(tcp::socket socket) { ++ try { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-sync"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); ++ })); + + // Accept the websocket handshake + ws.accept(); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -63,44 +73,35 @@ + ws.text(ws.got_text()); + ws.write(buffer.data()); + } +- } +- catch(beast::system_error const& se) +- { ++ } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if(se.code() != websocket::error::closed) ++ if (se.code() != websocket::error::closed) + std::cerr << "Error: " << se.code().message() << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 3) +- { +- std::cerr << +- "Usage: websocket-server-sync
\n" << +- "Example:\n" << +- " websocket-server-sync 0.0.0.0 8080\n"; ++ if (argc != 3) { ++ std::cerr << "Usage: websocket-server-sync
\n" ++ << "Example:\n" ++ << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -108,13 +109,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread( +- &do_session, +- std::move(socket)).detach(); ++ std::thread(&do_session, std::move(socket)).detach(); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,34 +31,31 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" ++#include "common/server_certificate.hpp" + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages +-void +-do_session(tcp::socket socket, ssl::context& ctx) +-{ +- try +- { ++void do_session(tcp::socket socket, ssl::context& ctx) { ++ try { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + +@@ -48,19 +63,15 @@ + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-sync-ssl"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); ++ })); + + // Accept the websocket handshake + ws.accept(); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -71,39 +82,31 @@ + ws.text(ws.got_text()); + ws.write(buffer.data()); + } +- } +- catch(beast::system_error const& se) +- { ++ } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if(se.code() != websocket::error::closed) ++ if (se.code() != websocket::error::closed) + std::cerr << "Error: " << se.code().message() << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 3) +- { +- std::cerr << +- "Usage: websocket-server-sync-ssl
\n" << +- "Example:\n" << +- " websocket-server-sync-ssl 0.0.0.0 8080\n"; ++ if (argc != 3) { ++ std::cerr << "Usage: websocket-server-sync-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -113,8 +116,7 @@ + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -122,14 +124,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread( +- &do_session, +- std::move(socket), +- std::ref(ctx)).detach(); ++ std::thread(&do_session, std::move(socket), std::ref(ctx)).detach(); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser.patch b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser.patch new file mode 100644 index 0000000..48300e1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser.patch @@ -0,0 +1,14457 @@ +--- upstream/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,76 +31,52 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = webcpp::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; +- ssl::stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++class session : public std::enable_shared_from_this { ++ webcpp::asio::ip::tcp::resolver resolver_; ++ beast::ssl_stream stream_; ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- session(net::strand strand, ssl::context& ctx) +- : resolver_(strand) +- , stream_(strand, ctx) +- { +- } ++ session(net::strand strand, ssl::context& ctx) ++ : resolver_(strand), stream_(strand, ctx) {} + + public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. +- explicit +- session(ssl::context& ctx) +- : session(net::make_strand(net::system_executor()), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; +- std::cerr << ec.message() << "\n"; +- return; +- } ++ beast::set_server_name(stream_, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); +@@ -92,23 +86,14 @@ + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); +- req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -116,30 +101,22 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation +@@ -147,36 +124,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -187,14 +152,10 @@ + + // Gracefully close the stream + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -212,23 +173,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (bool(ec)) + return fail(ec, "shutdown"); + } + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int application_main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async-ssl-system-executor []\n" << +- "Example:\n" << +- " http-client-async-ssl-system-executor www.example.com 443 /\n" << +- " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async-ssl-system-executor []\n" ++ << "Example:\n" ++ << " http-client-async-ssl-system-executor www.example.com 443 /\n" ++ << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -236,23 +195,49 @@ + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + ++ webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +- ssl::context ctx{ssl::context::tlsv12_client}; ++ ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- std::make_shared(ctx)->run(host, port, target, version); +- ++ std::make_shared(ioc, ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. +- net::query(net::system_executor(), net::execution::context).join(); ++ ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-async-ssl-system-executor", "127.0.0.1", port, ++ "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-async-ssl-system-executor: passed\n"; ++ return 0; ++} +--- upstream/http/client/async-ssl/http_client_async_ssl.cpp ++++ browser/http/client/async-ssl/http_client_async_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,68 +31,44 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include ++#include + #include +-#include +-#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = webcpp::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; +- ssl::stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++class session : public std::enable_shared_from_this { ++ webcpp::asio::ip::tcp::resolver resolver_; ++ beast::ssl_stream stream_; ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: +- explicit +- session( +- net::any_io_executor ex, +- ssl::context& ctx) +- : resolver_(ex) +- , stream_(ex, ctx) +- { +- } ++ explicit session(net::any_io_executor ex, ssl::context& ctx) ++ : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; +- std::cerr << ec.message() << "\n"; +- return; +- } ++ beast::set_server_name(stream_, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); +@@ -84,23 +78,14 @@ + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); +- req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -108,30 +93,22 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation +@@ -139,36 +116,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -179,14 +144,10 @@ + + // Gracefully close the stream + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -204,23 +165,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (bool(ec)) + return fail(ec, "shutdown"); + } + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int application_main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async-ssl []\n" << +- "Example:\n" << +- " http-client-async-ssl www.example.com 443 /\n" << +- " http-client-async-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async-ssl []\n" ++ << "Example:\n" ++ << " http-client-async-ssl www.example.com 443 /\n" ++ << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -229,13 +188,13 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ssl::context::tlsv12_client}; ++ ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); +@@ -243,14 +202,36 @@ + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. +- std::make_shared( +- net::make_strand(ioc), +- ctx +- )->run(host, port, target, version); ++ std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-async-ssl", "127.0.0.1", port, "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-async-ssl: passed\n"; ++ return 0; ++} +--- upstream/http/client/async/http_client_async.cpp ++++ browser/http/client/async/http_client_async.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,96 +30,70 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp::asio::ip::tcp::resolver resolver_; + beast::tcp_stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- explicit +- session(net::io_context& ioc) +- : resolver_(net::make_strand(ioc)) +- , stream_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) ++ : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); +- req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ stream_.async_connect(results, ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -110,36 +101,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -149,7 +128,7 @@ + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -158,16 +137,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int application_main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async []\n" << +- "Example:\n" << +- " http-client-async www.example.com 80 /\n" << +- " http-client-async www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async []\n" ++ << "Example:\n" ++ << " http-client-async www.example.com 80 /\n" ++ << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -176,14 +153,39 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-async", "127.0.0.1", port, "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-async: passed\n"; ++ return 0; ++} +--- upstream/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -17,12 +35,10 @@ + #include + #include + #include +-#include +-#include +-#include + #include +- +-#include "example/common/root_certificates.hpp" ++#include ++#include ++#include + + #include + #include +@@ -30,62 +46,50 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = boost::asio::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = webcpp::asio::ssl; + + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response +-net::awaitable +-do_session( +- std::string host, +- std::string port, +- std::string target, +- int version, +- ssl::context& ctx) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string target, int version, ++ ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = ssl::stream{ executor, ctx }; ++ auto resolver = webcpp::asio::ip::tcp::resolver{executor}; ++ auto stream = beast::ssl_stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); +- } ++ beast::set_server_name(stream, host.c_str()).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name +- auto const results = co_await resolver.async_resolve(host, port); ++ auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- co_await beast::get_lowest_layer(stream).async_connect(results); ++ co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake +- co_await stream.async_handshake(ssl::stream_base::client); ++ co_await stream.async_handshake(ssl::stream_base::client, net::use_awaitable); + + // Set up an HTTP GET request message +- http::request req{ http::verb::get, target, version }; ++ http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); +- req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host +- co_await http::async_write(stream, req); ++ co_await http::async_write(stream, req, net::use_awaitable); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; +@@ -94,7 +98,7 @@ + http::response res; + + // Receive the HTTP response +- co_await http::async_read(stream, buffer, res); ++ co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out + std::cout << res << std::endl; +@@ -103,7 +107,7 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! +- auto [ec] = co_await stream.async_shutdown(net::as_tuple); ++ auto [ec] = co_await stream.async_shutdown(net::as_tuple(net::use_awaitable)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -122,64 +126,54 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec && ec != net::ssl::error::stream_truncated) ++ if (ec && bool(ec)) + throw boost::system::system_error(ec, "shutdown"); + } + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr +- << "Usage: http-client-awaitable []\n" +- << "Example:\n" +- << " http-client-awaitable www.example.com 443 /\n" +- << " http-client-awaitable www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-awaitable []\n" ++ << "Example:\n" ++ << " http-client-awaitable www.example.com 443 /\n" ++ << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; ++ auto const host = argv[1]; ++ auto const port = argv[2]; + auto const target = argv[3]; +- auto const version = +- argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ ssl::context::tlsv12_client }; ++ ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, target, version, ctx), +- // If the awaitable exists with an exception, it gets delivered here +- // as `e`. This can happen for regular errors, such as connection +- // drops. +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, target, version, ctx), ++ // If the awaitable exists with an exception, it gets delivered here ++ // as `e`. This can happen for regular errors, such as connection ++ // drops. ++ [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -188,11 +182,34 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int application_main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } + + #endif ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-awaitable-ssl", "127.0.0.1", port, "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-awaitable-ssl: passed\n"; ++ return 0; ++} +--- upstream/http/client/awaitable/http_client_awaitable.cpp ++++ browser/http/client/awaitable/http_client_awaitable.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -16,9 +33,9 @@ + #include + #include + #include +-#include +-#include + #include ++#include ++#include + + #include + #include +@@ -26,37 +43,35 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; + + // Performs an HTTP GET and prints the response +-net::awaitable +-do_session(std::string host, std::string port, std::string target, int version) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string target, ++ int version) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = beast::tcp_stream{ executor }; ++ auto resolver = webcpp::asio::ip::tcp::resolver{executor}; ++ auto stream = beast::tcp_stream{executor}; + + // Look up the domain name +- auto const results = co_await resolver.async_resolve(host, port); ++ auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- co_await stream.async_connect(results); ++ co_await stream.async_connect(results, net::use_awaitable); + + // Set up an HTTP GET request message +- http::request req{ http::verb::get, target, version }; ++ http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); +- req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host +- co_await http::async_write(stream, req); ++ co_await http::async_write(stream, req, net::use_awaitable); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; +@@ -65,19 +80,19 @@ + http::response res; + + // Receive the HTTP response +- co_await http::async_read(stream, buffer, res); ++ co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec); ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw boost::system::system_error(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -85,48 +100,39 @@ + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << "Usage: http-client-awaitable []\n" ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; ++ auto const host = argv[1]; ++ auto const port = argv[2]; + auto const target = argv[3]; +- auto const version = +- argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, target, version), +- // If the awaitable exists with an exception, it gets delivered here +- // as `e`. This can happen for regular errors, such as connection +- // drops. +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, target, version), ++ // If the awaitable exists with an exception, it gets delivered here ++ // as `e`. This can happen for regular errors, such as connection ++ // drops. ++ [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -135,11 +141,34 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int application_main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } + + #endif ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-awaitable", "127.0.0.1", port, "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-awaitable: passed\n"; ++ return 0; ++} +--- upstream/http/client/body/json_body.hpp ++++ browser/http/client/body/json_body.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -16,90 +33,68 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include ++#include + #include +-#include +-#include +-#include ++#include + + namespace json = boost::json; + +-struct json_body +-{ ++struct json_body { + using value_type = json::value; + +- struct writer +- { ++ struct writer { + using const_buffers_type = boost::asio::const_buffer; +- template +- writer( +- boost::beast::http::header const&, +- value_type const& body) +- { ++ ++ template ++ writer(webcpp::beast::http::header const&, value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer.reset(&body); + } + +- void +- init(boost::system::error_code& ec) +- { ++ void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } +- +- boost::optional> +- get(boost::system::error_code& ec) +- { ++ ++ boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer.read(buffer, sizeof(buffer)); +- return std::make_pair( +- boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), ++ !serializer.done()); + } +- private: ++ ++ private: + json::serializer serializer; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ char buffer[32768]; + }; + +- struct reader +- { +- template +- reader( +- boost::beast::http::header&, +- value_type& body) +- : body(body) +- { +- } +- void +- init( +- boost::optional const& content_length, +- boost::system::error_code& ec) +- { +- +- // If we know the content-length, we can allocate a monotonic resource to increase the parsing speed. +- // We're using it rather then a static_resource, so a consumer can modify the resulting value. +- // It is also only assumption that the parsed json will be smaller than the serialize one, +- // it might not always be the case. ++ struct reader { ++ template ++ reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ ++ void init(boost::optional const& content_length, ++ boost::system::error_code& ec) { ++ // If we know the content-length, we can allocate a monotonic resource to increase the ++ // parsing speed. We're using it rather then a static_resource, so a consumer can modify ++ // the resulting value. It is also only assumption that the parsed json will be smaller ++ // than the serialize one, it might not always be the case. + if (content_length) + parser.reset(json::make_shared_resource(*content_length)); + ec = {}; + } + +- template +- std::size_t +- put(ConstBufferSequence const& buffers, boost::system::error_code& ec) +- { ++ template ++ std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some( +- static_cast(buffers.data()), buffers.size(), ec); ++ return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + +- void +- finish(boost::system::error_code& ec) +- { ++ void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser.done()) +@@ -108,11 +103,10 @@ + ec = boost::json::error::incomplete; + } + +- private: ++ private: + json::stream_parser parser; + value_type& body; + }; + }; + +- + #endif--- upstream/http/client/body/json_client.cpp ++++ browser/http/client/body/json_client.cpp +@@ -1,31 +1,47 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + #include "json_body.hpp" +-#include + +-#include +-#include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char **) +-{ ++int application_main(int, char**) { + // Our test endpoint for testing the json +- const auto host = "postman-echo.com"; ++ const auto host = webcpp_fixture::host(); + const auto target = "/post"; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +- auto const results = resolver.resolve(host, "80"); ++ auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); +@@ -33,13 +49,13 @@ + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); +- req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); ++ + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); +- ++ + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + +@@ -56,6 +72,30 @@ + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + +- + return 0; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"json_client"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application json_client: passed\n"; ++ return 0; ++} +--- upstream/http/client/crawl/http_crawl.cpp ++++ browser/http/client/crawl/http_crawl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,15 +32,13 @@ + + #include "urls_large_data.hpp" + +-#include +-#include +-#include ++#include + #include + #include + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -31,62 +46,49 @@ + #include + #include + #include +-#include ++#include ++#include ++ ++#include + #include +-#include +- +-namespace chrono = std::chrono; // from +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++ ++namespace chrono = std::chrono; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites +-class crawl_report +-{ +- net::strand< +- net::io_context::executor_type> strand_; ++class crawl_report { ++ net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + + public: +- crawl_report(net::io_context& ioc) +- : strand_(ioc.get_executor()) +- , index_(0) +- , hosts_(urls_large_data()) +- { +- } ++ crawl_report(webcpp::asio::io_context& ioc) ++ : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. +- template +- void +- aggregate(F const& f) +- { +- net::post( +- strand_, +- [&, f] +- { +- f(*this); +- if(count_ % 100 == 0) +- { +- std::cerr << +- "Progress: " << count_ << " of " << hosts_.size() << "\n"; +- //std::cerr << *this; +- } +- ++count_; +- }); ++ template ++ void aggregate(F const& f) { ++ net::post(strand_, [&, f] { ++ f(*this); ++ if (count_ % 100 == 0) { ++ std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; ++ // std::cerr << *this; ++ } ++ ++count_; ++ }); + } + + // Returns the next host to check +- char const* +- get_host() +- { ++ char const* get_host() { + auto const n = index_++; +- if(n >= hosts_.size()) ++ if (n >= hosts_.size()) + return nullptr; + return hosts_[n]; + } +@@ -113,25 +115,20 @@ + std::map status_codes; + }; + +-std::ostream& +-operator<<(std::ostream& os, crawl_report const& report) +-{ ++std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report +- os << +- "Crawl report\n" << +- " Failure counts\n" << +- " Timer : " << report.timer_failures << "\n" << +- " Resolve : " << report.resolve_failures << "\n" << +- " Connect : " << report.connect_failures << "\n" << +- " Write : " << report.write_failures << "\n" << +- " Read : " << report.read_failures << "\n" << +- " Success : " << report.success << "\n" << +- " Status codes\n" +- ; +- for(auto const& result : report.status_codes) +- os << +- " " << std::setw(3) << result.first << ": " << result.second << +- " (" << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ os << "Crawl report\n" ++ << " Failure counts\n" ++ << " Timer : " << report.timer_failures << "\n" ++ << " Resolve : " << report.resolve_failures << "\n" ++ << " Connect : " << report.connect_failures << "\n" ++ << " Write : " << report.write_failures << "\n" ++ << " Read : " << report.read_failures << "\n" ++ << " Success : " << report.success << "\n" ++ << " Status codes\n"; ++ for (auto const& result : report.status_codes) ++ os << " " << std::setw(3) << result.first << ": " << result.second << " (" ++ << http::obsolete_reason(static_cast(result.first)) << ")\n"; + os.flush(); + return os; + } +@@ -139,19 +136,17 @@ + //------------------------------------------------------------------------------ + + // Performs HTTP GET requests and aggregates the results into a report +-class worker : public std::enable_shared_from_this +-{ +- enum +- { ++class worker : public std::enable_shared_from_this { ++ enum { + // Use a small timeout to keep things lively + timeout = 5 + }; + + crawl_report& report_; +- net::strand ex_; +- tcp::resolver resolver_; ++ net::strand ex_; ++ webcpp::asio::ip::tcp::resolver resolver_; + beast::tcp_stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +@@ -159,36 +154,23 @@ + worker(worker&&) = default; + + // Resolver and socket require an io_context +- worker( +- crawl_report& report, +- net::io_context& ioc) +- : report_(report) +- , ex_(net::make_strand(ioc.get_executor())) +- , resolver_(ex_) +- , stream_(ex_) +- { ++ worker(crawl_report& report, webcpp::asio::io_context& ioc) ++ : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); +- req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation +- void +- run() +- { +- do_get_host(); +- } +- +- void +- do_get_host() +- { ++ void run() { do_get_host(); } ++ ++ void do_get_host() { + // Grab another host + auto const host = report_.get_host(); + + // nullptr means no more work +- if(! host) ++ if (!host) + return; + + // The Host HTTP field is required +@@ -196,26 +178,13 @@ + + // Set up an HTTP GET request message + // Look up the domain name +- resolver_.async_resolve( +- host, +- "http", +- beast::bind_front_handler( +- &worker::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.resolve_failures; +- }); ++ resolver_.async_resolve(host, webcpp_fixture::port(), ++ beast::bind_front_handler(&worker::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + return do_get_host(); + } + +@@ -223,23 +192,14 @@ + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- results, +- beast::bind_front_handler( +- &worker::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.connect_failures; +- }); ++ stream_.async_connect(results, ++ beast::bind_front_handler(&worker::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + return do_get_host(); + } + +@@ -247,63 +207,34 @@ + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host +- http::async_write( +- stream_, +- req_, +- beast::bind_front_handler( +- &worker::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ http::async_write(stream_, req_, ++ beast::bind_front_handler(&worker::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.write_failures; +- }); ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + return do_get_host(); + } + + // Receive the HTTP response + res_ = {}; +- http::async_read( +- stream_, +- buffer_, +- res_, +- beast::bind_front_handler( +- &worker::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ http::async_read(stream_, buffer_, res_, ++ beast::bind_front_handler(&worker::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.read_failures; +- }); ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + return do_get_host(); + } + + auto const code = res_.result_int(); +- report_.aggregate( +- [code](crawl_report& rep) +- { ++ report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); +@@ -318,8 +249,7 @@ + } + }; + +-class timer +-{ ++class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; +@@ -327,79 +257,60 @@ + public: + using duration = clock_type::duration; + +- timer() +- : when_(clock_type::now()) +- { +- } +- +- duration +- elapsed() const +- { +- return clock_type::now() - when_; +- } ++ timer() : when_(clock_type::now()) {} ++ ++ duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) +-{ ++int application_main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 2) +- { +- std::cerr << +- "Usage: http-crawl \n" << +- "Example:\n" << +- " http-crawl 100\n"; ++ if (argc != 2) { ++ std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- auto const threads = std::max(1, std::atoi(argv[1])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[1])); + + // The io_context is used to aggregate the statistics +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + timer t; + +- // Create and launch the worker threads. +- std::vector workers; +- workers.reserve(threads + 1); +- for(int i = 0; i < threads; ++i) +- { +- // Each worker will eventually add some data to the aggregated +- // report. Outstanding work is tracked in each worker to +- // represent the forthcoming delivery of this data by that +- // worker. +- auto reporting_work = net::require( +- ioc.get_executor(), +- net::execution::outstanding_work.tracked); +- +- workers.emplace_back( +- [&report, reporting_work] { +- // We use a separate io_context for each worker because +- // the asio resolver simulates asynchronous operation using +- // a dedicated worker thread per io_context, and we want to +- // do a lot of name resolutions in parallel. +- net::io_context ioc; +- std::make_shared(report, ioc)->run(); +- ioc.run(); +- }); +- } +- +- // Add another thread to run the main io_context which +- // is used to aggregate the statistics +- workers.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- +- // Now block until all threads exit +- for(std::size_t i = 0; i < workers.size(); ++i) +- workers[i].join(); +- +- std::cout << +- "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() << " seconds\n"; ++ // Each worker preserves the original crawl state machine on one explicit executor. ++ for (int index = 0; index < threads; ++index) ++ std::make_shared(report, ioc)->run(); ++ ioc.run(); // lint-run: advances every crawl worker and its aggregate report ++ ++ std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() ++ << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-crawl", "2"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Success : 3") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-crawl: passed\n"; ++ return 0; ++} +--- upstream/http/client/crawl/urls_large_data.cpp ++++ browser/http/client/crawl/urls_large_data.cpp +@@ -1,10021 +1,24 @@ ++// Copyright (c) 2026 WebCpp.org + // +-// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) + // +-// Distributed under the Boost Software License, Version 1.0. (See accompanying +-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-// +-// Official repository: https://github.com/boostorg/beast +-// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. + + #include "urls_large_data.hpp" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + +-// Data from Alexa top 1 million sites +-// http://s3.amazonaws.com/alexa-static/top-1m.csv.zip +-// +-std::vector const& +-urls_large_data() +-{ +- static std::vector const urls ({ +- "google.com", +- "facebook.com", +- "youtube.com", +- "yahoo.com", +- "baidu.com", +- "wikipedia.org", +- "qq.com", +- "linkedin.com", +- "taobao.com", +- "twitter.com", +- "live.com", +- "amazon.com", +- "sina.com.cn", +- "google.co.in", +- "hao123.com", +- "blogspot.com", +- "weibo.com", +- "wordpress.com", +- "yandex.ru", +- "yahoo.co.jp", +- "tmall.com", +- "bing.com", +- "vk.com", +- "ebay.com", +- "360.cn", +- "google.de", +- "sohu.com", +- "pinterest.com", +- "google.co.uk", +- "ask.com", +- "google.fr", +- "msn.com", +- "163.com", +- "soso.com", +- "tumblr.com", +- "google.co.jp", +- "instagram.com", +- "mail.ru", +- "google.com.br", +- "microsoft.com", +- "paypal.com", +- "google.ru", +- "xvideos.com", +- "google.es", +- "imdb.com", +- "apple.com", +- "google.it", +- "adcash.com", +- "craigslist.org", +- "stackoverflow.com", +- "amazon.co.jp", +- "neobux.com", +- "google.com.hk", +- "imgur.com", +- "ifeng.com", +- "cnn.com", +- "google.com.mx", +- "xhamster.com", +- "xinhuanet.com", +- "gmw.cn", +- "reddit.com", +- "bbc.co.uk", +- "blogger.com", +- "google.ca", +- "fc2.com", +- "vube.com", +- "go.com", +- "akamaihd.net", +- "alipay.com", +- "about.com", +- "people.com.cn", +- "t.co", +- "googleusercontent.com", +- "wordpress.org", +- "odnoklassniki.ru", +- "alibaba.com", +- "google.com.tr", +- "aliexpress.com", +- "youku.com", +- "conduit.com", +- "huffingtonpost.com", +- "godaddy.com", +- "flickr.com", +- "pornhub.com", +- "google.com.au", +- "amazon.de", +- "blogspot.in", +- "kickass.to", +- "ebay.de", +- "netflix.com", +- "google.pl", +- "thepiratebay.se", +- "bp.blogspot.com", +- "adobe.com", +- "dailymotion.com", +- "china.com", +- "vimeo.com", +- "dailymail.co.uk", +- "cnet.com", +- "rakuten.co.jp", +- "espn.go.com", +- "ku6.com", +- "ebay.co.uk", +- "themeforest.net", +- "xnxx.com", +- "livejasmin.com", +- "indiatimes.com", +- "aol.com", +- "redtube.com", +- "dropbox.com", +- "amazonaws.com", +- "uol.com.br", +- "weather.com", +- "m2newmedia.com", +- "amazon.co.uk", +- "google.com.ar", +- "google.com.sa", +- "pixnet.net", +- "nytimes.com", +- "slideshare.net", +- "youporn.com", +- "google.com.eg", +- "buzzfeed.com", +- "wikimedia.org", +- "booking.com", +- "livejournal.com", +- "globo.com", +- "fiverr.com", +- "adf.ly", +- "secureserver.net", +- "mozilla.org", +- "google.com.pk", +- "google.com.tw", +- "google.nl", +- "yelp.com", +- "sogou.com", +- "ameblo.jp", +- "directrev.com", +- "clkmon.com", +- "hootsuite.com", +- "deviantart.com", +- "blogfa.com", +- "wikia.com", +- "outbrain.com", +- "flipkart.com", +- "wikihow.com", +- "etsy.com", +- "google.co.th", +- "soundcloud.com", +- "google.co.za", +- "avg.com", +- "w3schools.com", +- "theguardian.com", +- "stumbleupon.com", +- "espncricinfo.com", +- "livedoor.com", +- "forbes.com", +- "archive.org", +- "4shared.com", +- "foxnews.com", +- "files.wordpress.com", +- "answers.com", +- "bankofamerica.com", +- "chase.com", +- "google.co.ve", +- "mediafire.com", +- "torrentz.eu", +- "badoo.com", +- "salesforce.com", +- "aweber.com", +- "sourceforge.net", +- "bbc.com", +- "addthis.com", +- "liveinternet.ru", +- "china.com.cn", +- "indeed.com", +- "reference.com", +- "github.com", +- "skype.com", +- "hostgator.com", +- "google.gr", +- "bet365.com", +- "spiegel.de", +- "ask.fm", +- "so.com", +- "statcounter.com", +- "gameforge.com", +- "onet.pl", +- "naver.com", +- "google.com.co", +- "developunit.info", +- "google.com.vn", +- "google.co.id", +- "nicovideo.jp", +- "shutterstock.com", +- "walmart.com", +- "google.be", +- "mailchimp.com", +- "softonic.com", +- "stackexchange.com", +- "google.com.ng", +- "google.com.ua", +- "popads.net", +- "allegro.pl", +- "gamer.com.tw", +- "wordreference.com", +- "wellsfargo.com", +- "loading-delivery1.com", +- "zillow.com", +- "tripadvisor.com", +- "quikr.com", +- "pandora.com", +- "wsj.com", +- "goo.ne.jp", +- "bild.de", +- "tube8.com", +- "wix.com", +- "google.se", +- "coccoc.com", +- "google.ro", +- "suning.com", +- "photobucket.com", +- "weebly.com", +- "tianya.cn", +- "warriorforum.com", +- "telegraph.co.uk", +- "google.dz", +- "naver.jp", +- "php.net", +- "ups.com", +- "rambler.ru", +- "zedo.com", +- "reuters.com", +- "google.at", +- "media.tumblr.com", +- "taringa.net", +- "google.com.ph", +- "chinaz.com", +- "mashable.com", +- "blogspot.com.es", +- "hurriyet.com.tr", +- "google.com.pe", +- "bleacherreport.com", +- "gmx.net", +- "wp.pl", +- "goodreads.com", +- "leboncoin.fr", +- "rutracker.org", +- "lenta.ru", +- "babylon.com", +- "domaintools.com", +- "sharelive.net", +- "rediff.com", +- "google.ch", +- "comcast.net", +- "twitch.tv", +- "avito.ru", +- "kaskus.co.id", +- "nbcnews.com", +- "onclickads.net", +- "businessinsider.com", +- "ikea.com", +- "codecanyon.net", +- "ndtv.com", +- "usps.com", +- "google.cl", +- "doublepimp.com", +- "moz.com", +- "google.com.sg", +- "usatoday.com", +- "dmm.co.jp", +- "amazon.fr", +- "google.pt", +- "ucoz.ru", +- "rt.com", +- "milliyet.com.tr", +- "xuite.net", +- "samsung.com", +- "fedex.com", +- "uploaded.net", +- "pcpop.com", +- "google.com.bd", +- "bitly.com", +- "goodgamestudios.com", +- "ettoday.net", +- "baomihua.com", +- "39.net", +- "web.de", +- "rbc.ru", +- "9gag.com", +- "disqus.com", +- "snapdeal.com", +- "xcar.com.cn", +- "washingtonpost.com", +- "bloomberg.com", +- "scribd.com", +- "hp.com", +- "constantcontact.com", +- "4dsply.com", +- "gsmarena.com", +- "intuit.com", +- "meetup.com", +- "nih.gov", +- "americanexpress.com", +- "ehow.com", +- "infusionsoft.com", +- "google.cz", +- "mercadolivre.com.br", +- "myntra.com", +- "varzesh3.com", +- "mobile01.com", +- "hardsextube.com", +- "goal.com", +- "thefreecamsecret.com", +- "thefreedictionary.com", +- "douban.com", +- "iqiyi.com", +- "it168.com", +- "mama.cn", +- "tmz.com", +- "time.com", +- "olx.in", +- "microsoftonline.com", +- "hulu.com", +- "enet.com.cn", +- "speedtest.net", +- "orange.fr", +- "free.fr", +- "detik.com", +- "bluehost.com", +- "libero.it", +- "histats.com", +- "webmd.com", +- "eazel.com", +- "hudong.com", +- "extratorrent.cc", +- "google.co.kr", +- "chaturbate.com", +- "huanqiu.com", +- "cnzz.com", +- "daum.net", +- "xing.com", +- "force.com", +- "jrj.com.cn", +- "pchome.net", +- "cj.com", +- "youjizz.com", +- "delta-search.com", +- "techcrunch.com", +- "motherless.com", +- "tinyurl.com", +- "beeg.com", +- "kooora.com", +- "google.cn", +- "clickbank.com", +- "yandex.ua", +- "ad6media.fr", +- "google.no", +- "amazon.cn", +- "zippyshare.com", +- "acesse.com", +- "google.co.hu", +- "google.ae", +- "hdfcbank.com", +- "nba.com", +- "zendesk.com", +- "blogspot.co.uk", +- "bestbuy.com", +- "accuweather.com", +- "getresponse.com", +- "repubblica.it", +- "xywy.com", +- "ci123.com", +- "ebay.in", +- "in.com", +- "ign.com", +- "groupon.com", +- "yesky.com", +- "elpais.com", +- "marca.com", +- "kwejk.pl", +- "caijing.com.cn", +- "google.ie", +- "cloudfront.net", +- "intoday.in", +- "wideinfo.org", +- "pof.com", +- "kakaku.com", +- "bitauto.com", +- "life.com.tw", +- "xe.com", +- "goo.gl", +- "google.az", +- "feedly.com", +- "tagged.com", +- "amazon.in", +- "list-manage.com", +- "w3.org", +- "quora.com", +- "ixxx.com", +- "mysearchdial.com", +- "dell.com", +- "seznam.cz", +- "t-online.de", +- "plugrush.com", +- "nydailynews.com", +- "okcupid.com", +- "istockphoto.com", +- "snapdo.com", +- "abcnews.go.com", +- "target.com", +- "latimes.com", +- "mywebsearch.com", +- "joomla.org", +- "odesk.com", +- "surveymonkey.com", +- "elmundo.es", +- "siteadvisor.com", +- "aili.com", +- "uimserv.net", +- "ebay.com.au", +- "doubleclick.com", +- "zeobit.com", +- "google.co.il", +- "fbcdn.net", +- "ero-advertising.com", +- "issuu.com", +- "naukri.com", +- "gazeta.pl", +- "ck101.com", +- "udn.com", +- "google.dk", +- "ce.cn", +- "capitalone.com", +- "att.com", +- "drudgereport.com", +- "blackhatworld.com", +- "adrotator.se", +- "retailmenot.com", +- "justdial.com", +- "icicibank.com", +- "likes.com", +- "elance.com", +- "cntv.cn", +- "ameba.jp", +- "java.com", +- "lifehacker.com", +- "jabong.com", +- "gizmodo.com", +- "ebay.it", +- "lenovo.com", +- "hypergames.net", +- "google.fi", +- "doorblog.jp", +- "blogspot.de", +- "jimdo.com", +- "probux.com", +- "blogspot.it", +- "habrahabr.ru", +- "webmoney.ru", +- "irctc.co.in", +- "sahibinden.com", +- "github.io", +- "informer.com", +- "mysearchresults.com", +- "upworthy.com", +- "pch.com", +- "eyny.com", +- "canadaalltax.com", +- "b5m.com", +- "freelancer.com", +- "match.com", +- "searchfun.in", +- "adnxs.com", +- "sberbank.ru", +- "ig.com.br", +- "trulia.com", +- "subscene.com", +- "corriere.it", +- "livescore.com", +- "irs.gov", +- "twoo.com", +- "clixsense.com", +- "4399.com", +- "xda-developers.com", +- "iminent.com", +- "google.com.my", +- "onlinesbi.com", +- "empowernetwork.com", +- "zing.vn", +- "youdao.com", +- "systweak.com", +- "flipora.com", +- "ning.com", +- "engadget.com", +- "abril.com.br", +- "exoclick.com", +- "semrush.com", +- "commentcamarche.net", +- "shareasale.com", +- "vnexpress.net", +- "battle.net", +- "youm7.com", +- "digg.com", +- "rapidgator.net", +- "expedia.com", +- "twimg.com", +- "newegg.com", +- "lady8844.com", +- "xgo.com.cn", +- "pcgames.com.cn", +- "fotolia.com", +- "rednet.cn", +- "inspsearch.com", +- "lemonde.fr", +- "adultfriendfinder.com", +- "typepad.com", +- "mercadolibre.com.ar", +- "homedepot.com", +- "chip.de", +- "lefigaro.fr", +- "swagbucks.com", +- "taleo.net", +- "kinopoisk.ru", +- "oracle.com", +- "who.is", +- "2ch.net", +- "qtrax.com", +- "eonline.com", +- "sochi2014.com", +- "myfreecams.com", +- "pcbaby.com.cn", +- "gome.com.cn", +- "amazon.it", +- "timeanddate.com", +- "bestusefuldownloads.com", +- "foursquare.com", +- "telexfree.com", +- "gc.ca", +- "58.com", +- "hubspot.com", +- "backpage.com", +- "examiner.com", +- "ria.ru", +- "google.sk", +- "opensiteexplorer.org", +- "awesomehp.com", +- "sexlog.com", +- "gutefrage.net", +- "steampowered.com", +- "slate.com", +- "marketwatch.com", +- "beva.com", +- "shaadi.com", +- "v1.cn", +- "teensdigest.com", +- "blogspot.ru", +- "taboola.com", +- "citrixonline.com", +- "hatena.ne.jp", +- "seesaa.net", +- "houzz.com", +- "bodybuilding.com", +- "webs.com", +- "chexun.com", +- "ya.ru", +- "citibank.com", +- "viralnova.com", +- "2345.com", +- "ashleyrnadison.com", +- "verizonwireless.com", +- "55bbs.com", +- "theblaze.com", +- "123rf.com", +- "gotomeeting.com", +- "kijiji.ca", +- "linkbucks.com", +- "haber7.com", +- "pravda.com.ua", +- "altervista.org", +- "mihanblog.com", +- "terra.com.br", +- "soku.com", +- "urbandictionary.com", +- "mercadolibre.com.mx", +- "pixiv.net", +- "oneindia.in", +- "yellowpages.com", +- "hotels.com", +- "drtuber.com", +- "scoop.it", +- "blogspot.jp", +- "cbslocal.com", +- "movie4k.to", +- "cpmterra.com", +- "hubpages.com", +- "mobile.de", +- "yaolan.com", +- "etao.com", +- "hidemyass.com", +- "ca.gov", +- "dreamstime.com", +- "firedrive.com", +- "searchengines.ru", +- "m-w.com", +- "ebay.fr", +- "templatemonster.com", +- "evernote.com", +- "fastdailyfind.com", +- "amazon.es", +- "gateable.com", +- "hupu.com", +- "y8.com", +- "blogspot.com.tr", +- "tokobagus.com", +- "azlyrics.com", +- "website-unavailable.com", +- "r10.net", +- "wiktionary.org", +- "bongacams.com", +- "focus.de", +- "linksynergy.com", +- "steamcommunity.com", +- "vk.me", +- "sakura.ne.jp", +- "foxsports.com", +- "optmd.com", +- "tabelog.com", +- "narod.ru", +- "glassdoor.com", +- "outlook.com", +- "europa.eu", +- "viadeo.com", +- "leadpages.net", +- "ouedkniss.com", +- "facenama.com", +- "lpcloudsvr302.com", +- "agoda.com", +- "qvo6.com", +- "majesticseo.com", +- "mirror.co.uk", +- "google.com.kw", +- "filehippo.com", +- "moneycontrol.com", +- "duckduckgo.com", +- "npr.org", +- "coupons.com", +- "mynet.com", +- "allrecipes.com", +- "priceline.com", +- "liveleak.com", +- "jqw.com", +- "slickdeals.net", +- "webcrawler.com", +- "babytree.com", +- "amung.us", +- "tomshardware.com", +- "openadserving.com", +- "independent.co.uk", +- "kompas.com", +- "turbobit.net", +- "google.kz", +- "leo.org", +- "yandex.com.tr", +- "mp3skull.com", +- "nordstrom.com", +- "news.com.au", +- "traidnt.net", +- "wunderground.com", +- "cnbc.com", +- "jquery.com", +- "dict.cc", +- "persianblog.ir", +- "clarin.com", +- "all-free-download.com", +- "fhserve.com", +- "sape.ru", +- "asos.com", +- "addmefast.com", +- "lequipe.fr", +- "lapatilla.com", +- "ancestry.com", +- "stockstar.com", +- "monster.com", +- "people.com", +- "gawker.com", +- "howstuffworks.com", +- "tradedoubler.com", +- "over-blog.com", +- "cbc.ca", +- "fishcod.com", +- "yoka.com", +- "macys.com", +- "gazeta.ru", +- "free-tv-video-online.me", +- "google.bg", +- "google.lk", +- "southwest.com", +- "realtor.com", +- "custhelp.com", +- "bhaskar.com", +- "softpedia.com", +- "farsnews.com", +- "cy-pr.com", +- "theverge.com", +- "tudou.com", +- "youboy.com", +- "porn.com", +- "wetransfer.com", +- "virgilio.it", +- "mega.co.nz", +- "sfgate.com", +- "delta-homes.com", +- "squarespace.com", +- "watchseries.lt", +- "overstock.com", +- "nifty.com", +- "jvzoo.com", +- "lanacion.com.ar", +- "prntscr.com", +- "vesti.ru", +- "zimbio.com", +- "adscale.de", +- "google.co.nz", +- "yac.mx", +- "tickld.com", +- "kayak.com", +- "youth.cn", +- "jd.com", +- "shopclues.com", +- "allocine.fr", +- "cracked.com", +- "eventbrite.com", +- "behance.net", +- "youtube-mp3.org", +- "bankmellat.ir", +- "echo.msk.ru", +- "autohome.com.cn", +- "yandex.kz", +- "sex.com", +- "smh.com.au", +- "digikala.com", +- "mackolik.com", +- "rottentomatoes.com", +- "renren.com", +- "wired.com", +- "imageshack.us", +- "interia.pl", +- "zanox.com", +- "eastday.com", +- "fool.com", +- "chinabyte.com", +- "haberturk.com", +- "hespress.com", +- "wow.com", +- "jobrapido.com", +- "idnes.cz", +- "qinbei.com", +- "pr-cy.ru", +- "klikbca.com", +- "17ok.com", +- "gamefaqs.com", +- "immobilienscout24.de", +- "biblegateway.com", +- "espnfc.com", +- "ehowenespanol.com", +- "tabnak.ir", +- "avazutracking.net", +- "sapo.pt", +- "welt.de", +- "google.com.ec", +- "sears.com", +- "pcmag.com", +- "nownews.com", +- "kickstarter.com", +- "pixlr.com", +- "hongkiat.com", +- "chinatimes.com", +- "zoho.com", +- "reverso.net", +- "indianrail.gov.in", +- "privatehomeclips.com", +- "cbssports.com", +- "entrepreneur.com", +- "sporx.com", +- "bhphotovideo.com", +- "fatakat.com", +- "xunlei.com", +- "nikkei.com", +- "chron.com", +- "24h.com.vn", +- "basecamp.com", +- "airtel.in", +- "dealshark.com", +- "shopify.com", +- "babycenter.com", +- "letitbit.net", +- "nuvid.com", +- "yts.re", +- "aparat.com", +- "r2games.com", +- "prestashop.com", +- "alarabiya.net", +- "india.com", +- "magentocommerce.com", +- "heise.de", +- "sulekha.com", +- "mpnrs.com", +- "ibm.com", +- "cbsnews.com", +- "searchengineland.com", +- "mapquest.com", +- "ccb.com", +- "zappos.com", +- "rightmove.co.uk", +- "sahadan.com", +- "milanuncios.com", +- "wenku.baidu.com/user/reg", +- "ovh.net", +- "screencast.com", +- "ahrefs.com", +- "6.cn", +- "businessweek.com", +- "linternaute.com", +- "dafont.com", +- "bestblackhatforum.com", +- "streamcloud.eu", +- "as.com", +- "gtmetrix.com", +- "wmmail.ru", +- "spankwire.com", +- "google.com.do", +- "jeuxvideo.com", +- "digitalpoint.com", +- "amazon.ca", +- "mlb.com", +- "weheartit.com", +- "list.ru", +- "leagueoflegends.com", +- "56.com", +- "bloglovin.com", +- "payoneer.com", +- "nokia.com", +- "aizhan.com", +- "novinky.cz", +- "ustream.tv", +- "getbootstrap.com", +- "seekingalpha.com", +- "codwide.com", +- "vice.com", +- "usmagazine.com", +- "primewire.ag", +- "cam4.com", +- "thehindu.com", +- "deezer.com", +- "graphicriver.net", +- "dmm.com", +- "biglobe.ne.jp", +- "google.rs", +- "z5x.net", +- "tutsplus.com", +- "icicibank.co.in", +- "indiamart.com", +- "gap.com", +- "ensonhaber.com", +- "sitepoint.com", +- "rutor.org", +- "chinanews.com", +- "brainyquote.com", +- "keepvid.com", +- "censor.net.ua", +- "subito.it", +- "tablica.pl", +- "onlylady.com", +- "zulily.com", +- "squidoo.com", +- "change.org", +- "sh.st", +- "webhostingtalk.com", +- "9gag.tv", +- "nairaland.com", +- "gulfup.com", +- "staples.com", +- "gamespot.com", +- "woorank.com", +- "box.com", +- "infobae.com", +- "elegantthemes.com", +- "104.com.tw", +- "aftonbladet.se", +- "google.hr", +- "myegy.com", +- "noticias24.com", +- "eastmoney.com", +- "lowes.com", +- "xtube.com", +- "worldstarhiphop.com", +- "glispa.com", +- "verizon.com", +- "united.com", +- "linkwithin.com", +- "google.com.ly", +- "whitepages.com", +- "games.la", +- "dmoz.org", +- "imagebam.com", +- "careerbuilder.com", +- "sky.com", +- "instructables.com", +- "mercadolibre.com.ve", +- "makemytrip.com", +- "pinimg.com", +- "pingdom.com", +- "foodnetwork.com", +- "orf.at", +- "android.com", +- "wiocha.pl", +- "csdn.net", +- "appledaily.com.tw", +- "nike.com", +- "eluniversal.com.mx", +- "delta.com", +- "ezinearticles.com", +- "sueddeutsche.de", +- "woothemes.com", +- "comcast.com", +- "gismeteo.ru", +- "lotour.com", +- "nfl.com", +- "xbox.com", +- "almanar.com.lb", +- "disney.go.com", +- "ctrip.com", +- "forexfactory.com", +- "clicksvenue.com", +- "nhl.com", +- "ted.com", +- "gstatic.com", +- "forobeta.com", +- "ovh.com", +- "mystart.com", +- "maktoob.com", +- "nouvelobs.com", +- "hindustantimes.com", +- "billdesk.com", +- "1und1.de", +- "zhaopin.com", +- "weather.gov", +- "kioskea.net", +- "myspace.com", +- "firstpost.com", +- "picmonkey.com", +- "grooveshark.com", +- "exblog.jp", +- "pantip.com", +- "earthlink.net", +- "styletv.com.cn", +- "icloud.com", +- "manta.com", +- "google.by", +- "mediaset.it", +- "searchenginewatch.com", +- "japanpost.jp", +- "postimg.org", +- "mbc.net", +- "cheezburger.com", +- "workercn.cn", +- "directadvert.ru", +- "nationzoom.com", +- "caixa.gov.br", +- "gumtree.com", +- "51job.com", +- "viooz.co", +- "usbank.com", +- "wmtransfer.com", +- "fidelity.com", +- "gogetlinks.net", +- "office365.com", +- "pchome.com.tw", +- "feedburner.com", +- "mp3truck.net", +- "sfr.fr", +- "junglee.com", +- "keezmovies.com", +- "binarysystem4u.com", +- "way2sms.com", +- "oyunskor.com", +- "peyvandha.ir", +- "ticketmaster.com", +- "lacaixa.es", +- "video-one.com", +- "yomiuri.co.jp", +- "popcash.net", +- "nypost.com", +- "dubizzle.com", +- "wpmudev.org", +- "mgid.com", +- "google.lt", +- "zazzle.com", +- "nbcolympics.com", +- "battlefield.com", +- "avast.com", +- "jsfiddle.net", +- "namecheap.com", +- "css-tricks.com", +- "friv.com", +- "6park.com", +- "xhamstercams.com", +- "mysql.com", +- "dx.com", +- "thechive.com", +- "vsuch.com", +- "souq.com", +- "anyoption.com", +- "dantri.com.vn", +- "ebay.es", +- "abc.es", +- "whatsapp.com", +- "bitshare.com", +- "savefrom.net", +- "beytoote.com", +- "xiaomi.com", +- "prweb.com", +- "prothom-alo.com", +- "pagesjaunes.fr", +- "bbb.org", +- "eenadu.net", +- "tinypic.com", +- "whois.com", +- "sourtimes.org", +- "adk2.com", +- "criteo.com", +- "tistory.com", +- "ilyke.net", +- "ruten.com.tw", +- "skysports.com", +- "makeuseof.com", +- "p5w.net", +- "hh.ru", +- "nationalgeographic.com", +- "pornmd.com", +- "rakuten.ne.jp", +- "idealo.de", +- "telegraaf.nl", +- "barnesandnoble.com", +- "mynavi.jp", +- "4chan.org", +- "media-fire.org", +- "crunchbase.com", +- "bravotube.net", +- "myfitnesspal.com", +- "today.com", +- "mit.edu", +- "cnmo.com", +- "nu.nl", +- "tripadvisor.co.uk", +- "spotify.com", +- "homeway.com.cn", +- "dianping.com", +- "costco.com", +- "pastebin.com", +- "dhgate.com", +- "windowsphone.com", +- "stagram.com", +- "investopedia.com", +- "ninemsn.com.au", +- "excite.co.jp", +- "22find.com", +- "google.iq", +- "hi5.com", +- "ad4game.com", +- "kohls.com", +- "online.sh.cn", +- "geocities.jp", +- "investing.com", +- "haberler.com", +- "ft.com", +- "weblio.jp", +- "google.tn", +- "list-manage1.com", +- "hsbc.co.uk", +- "ppstream.com", +- "cloob.com", +- "korrespondent.net", +- "ucoz.com", +- "1and1.com", +- "mail.com", +- "fotostrana.ru", +- "accountonline.com", +- "forgeofempires.com", +- "dribbble.com", +- "city-data.com", +- "drupal.org", +- "tunein.com", +- "51fanli.com", +- "ibtimes.com", +- "intel.com", +- "polyvore.com", +- "cbs.com", +- "bab.la", +- "imobile.com.cn", +- "bestadbid.com", +- "eztv.it", +- "smashingmagazine.com", +- "skyrock.com", +- "copyscape.com", +- "cookpad.com", +- "smallseotools.com", +- "asus.com", +- "anysex.com", +- "nbcsports.com", +- "kinox.to", +- "mbank.com.pl", +- "500px.com", +- "sofanti.com", +- "marktplaats.nl", +- "cpanel.net", +- "hm.com", +- "chicagotribune.com", +- "ultimate-guitar.com", +- "infolinks.com", +- "merdeka.com", +- "yandex.by", +- "tribalfusion.com", +- "livedoor.biz", +- "prezi.com", +- "last.fm", +- "sznews.com", +- "junbi-tracker.com", +- "so-net.ne.jp", +- "cocolog-nifty.com", +- "ocn.ne.jp", +- "perezhilton.com", +- "yaplakal.com", +- "championat.com", +- "ebay.ca", +- "mangareader.net", +- "donanimhaber.com", +- "miniclip.com", +- "vcommission.com", +- "noaa.gov", +- "imagefap.com", +- "gumtree.com.au", +- "liveperson.net", +- "gfycat.com", +- "hollywoodreporter.com", +- "dropboxusercontent.com", +- "akhbarak.net", +- "sou300.com", +- "kicker.de", +- "livestream.com", +- "tribunnews.com", +- "kp.ru", +- "techradar.com", +- "315che.com", +- "dw.de", +- "codeproject.com", +- "newsru.com", +- "pconline.com.cn", +- "aa.com", +- "usaa.com", +- "asahi.com", +- "themetapicture.com", +- "quicksprout.com", +- "piriform.com", +- "888poker.com", +- "gittigidiyor.com", +- "nhk.or.jp", +- "statigr.am", +- "ipage.com", +- "gazzetta.it", +- "letv.com", +- "yourlust.com", +- "freepik.com", +- "trello.com", +- "mixi.jp", +- "livememe.com", +- "ew.com", +- "seosprint.net", +- "doisongphapluat.com", +- "autotrader.com", +- "docstoc.com", +- "viva.co.id", +- "livestrong.com", +- "inc.com", +- "hunantv.com", +- "bahn.de", +- "depositphotos.com", +- "rackspace.com", +- "flippa.com", +- "norton.com", +- "lynda.com", +- "teamviewer.com", +- "vip.com", +- "ksl.com", +- "solarmovie.so", +- "klout.com", +- "pikabu.ru", +- "vporn.com", +- "apache.org", +- "sportbox.ru", +- "correios.com.br", +- "toptenreviews.com", +- "ea.com", +- "thenextweb.com", +- "superuser.com", +- "delicious.com", +- "zoosk.com", +- "inbox.com", +- "kongregate.com", +- "starbaby.cn", +- "888casino.com", +- "brazzers.com", +- "sockshare.com", +- "megashare.info", +- "vistaprint.com", +- "porntube.com", +- "seriesyonkis.com", +- "20minutos.es", +- "jagran.com", +- "programme-tv.net", +- "elcomercio.pe", +- "blogspot.kr", +- "t411.me", +- "googleapis.com", +- "blog.com", +- "qingdaonews.com", +- "sedo.com", +- "itmedia.co.jp", +- "mtv.com", +- "ynet.co.il", +- "playstation.com", +- "pornhublive.com", +- "thedailybeast.com", +- "r7.com", +- "sabah.com.tr", +- "126.com", +- "topix.com", +- "liga.net", +- "marriott.com", +- "tvn24.pl", +- "sitesell.com", +- "netdna-cdn.com", +- "startimes.com", +- "hstpnetwork.com", +- "blogspot.com.au", +- "17u.cn", +- "subscribe.ru", +- "woot.com", +- "rozblog.com", +- "wimp.com", +- "vg.no", +- "t-mobile.com", +- "bmi.ir", +- "kankan.com", +- "tsn.ua", +- "gumtree.co.za", +- "googleadservices.com", +- "pnc.com", +- "cars.com", +- "soccerway.com", +- "o2.pl", +- "zeit.de", +- "zopim.com", +- "cloudflare.com", +- "givemesport.com", +- "statscrop.com", +- "gravatar.com", +- "flightradar24.com", +- "ubuntu.com", +- "salon.com", +- "ytimg.com", +- "trovigo.com", +- "sunporno.com", +- "libertagia.com", +- "mihanwebads.com", +- "shopathome.com", +- "cdiscount.com", +- "commbank.com.au", +- "elwatannews.com", +- "discovercard.com", +- "infowars.com", +- "blogimg.jp", +- "portaldosites.com", +- "fixya.com", +- "drom.ru", +- "fastpic.ru", +- "pbs.org", +- "kandao.com", +- "okwave.jp", +- "faz.net", +- "sbnation.com", +- "hilton.com", +- "duba.com", +- "homeshop18.com", +- "ultimasnoticias.com.ve", +- "bankrate.com", +- "megasesso.com", +- "studiopress.com", +- "sports.ru", +- "asriran.com", +- "etoro.com", +- "cafemom.com", +- "dhl.de", +- "indiegogo.com", +- "tdcanadatrust.com", +- "1tv.ru", +- "gogvo.com", +- "bt.com", +- "blogspot.tw", +- "zergnet.com", +- "garanti.com.tr", +- "privatbank.ua", +- "sanook.com", +- "travelocity.com", +- "networksolutions.com", +- "thqafawe3lom.com", +- "trklnks.com", +- "torchbrowser.com", +- "logmein.com", +- "williamhill.com", +- "zhihu.com", +- "auto.ru", +- "craigslist.ca", +- "olx.com.pk", +- "smi2.ru", +- "ukr.net", +- "dpreview.com", +- "boston.com", +- "folha.uol.com.br", +- "name.com", +- "ashemaletube.com", +- "slimspots.com", +- "envato.com", +- "6pm.com", +- "fandango.com", +- "sozcu.com.tr", +- "nikkeibp.co.jp", +- "aufeminin.com", +- "baiducontent.com", +- "buscape.com.br", +- "funnyordie.com", +- "337.com", +- "sakshi.com", +- "airasia.com", +- "samanyoluhaber.com", +- "picofile.com", +- "blackberry.com", +- "google.com.gt", +- "io9.com", +- "easyhits4u.com", +- "qianyan001.com", +- "flashx.tv", +- "zap2it.com", +- "dnsrsearch.com", +- "patch.com", +- "staticflickr.com", +- "clicksor.com", +- "mcafee.com", +- "zerohedge.com", +- "zara.com", +- "freelotto.com", +- "tutorialspoint.com", +- "qone8.com", +- "olx.com.br", +- "axisbank.com", +- "marketgid.com", +- "your-server.de", +- "game321.com", +- "harvard.edu", +- "indianexpress.com", +- "fatwallet.com", +- "nudevista.com", +- "paper.li", +- "opera.com", +- "serving-sys.com", +- "nowvideo.sx", +- "theatlantic.com", +- "cisco.com", +- "bookmyshow.com", +- "webmasterworld.com", +- "metro.co.uk", +- "leparisien.fr", +- "orbitz.com", +- "h2porn.com", +- "4cdn.org", +- "itar-tass.com", +- "nasa.gov", +- "macrumors.com", +- "google.si", +- "usnews.com", +- "premierleague.com", +- "largeporntube.com", +- "blogsky.com", +- "bufferapp.com", +- "zeroredirect1.com", +- "sendspace.com", +- "stanford.edu", +- "state.gov", +- "yjc.ir", +- "abc.net.au", +- "pornsharing.com", +- "4pda.ru", +- "52pk.net", +- "meituan.com", +- "mmgp.ru", +- "sponichi.co.jp", +- "masrawy.com", +- "whatismyipaddress.com", +- "onlinewebfind.com", +- "news24.com", +- "zdnet.com", +- "imagevenue.com", +- "gameaholic.com", +- "mediaplex.com", +- "clip.vn", +- "2mdn.net", +- "nmisr.com", +- "musica.com", +- "networkedblogs.com", +- "metrolyrics.com", +- "chacha.com", +- "internetdownloadmanager.com", +- "legacy.com", +- "wwe.com", +- "icbc.com.cn", +- "ny.gov", +- "chomikuj.pl", +- "alexa.com", +- "pcworld.com", +- "overthumbs.com", +- "adp.com", +- "ad2games.com", +- "adme.ru", +- "bidvertiser.com", +- "rtl.de", +- "sweetim.com", +- "gaana.com", +- "7k7k.com", +- "livingsocial.com", +- "netteller.com", +- "rakuten.com", +- "chess.com", +- "blackboard.com", +- "thekitchn.com", +- "ilfattoquotidiano.it", +- "20minutes.fr", +- "soufun.com", +- "nerdbux.com", +- "breitbart.com", +- "webtretho.com", +- "tvguide.com", +- "miralinks.ru", +- "weather.com.cn", +- "zalando.de", +- "dangdang.com", +- "bubblews.com", +- "thoughtcatalog.com", +- "114la.com", +- "msn.ca", +- "blogmura.com", +- "americanas.com.br", +- "elitedaily.com", +- "lightinthebox.com", +- "bizjournals.com", +- "yixun.com", +- "itau.com.br", +- "51.la", +- "doodle.com", +- "arabyonline.com", +- "opencart.com", +- "bomnegocio.com", +- "lego.com", +- "pclady.com.cn", +- "metacafe.com", +- "kimiss.com", +- "journaldunet.com", +- "gnavi.co.jp", +- "51auto.com", +- "clickey.com", +- "chekb.com", +- "searchnu.com", +- "diply.com", +- "walgreens.com", +- "descargar.es", +- "mirrorcreator.com", +- "pornerbros.com", +- "askmen.com", +- "shop.com", +- "inmotionhosting.com", +- "filmweb.pl", +- "kbb.com", +- "appround.biz", +- "aljazeera.com", +- "lumosity.com", +- "sweet-page.com", +- "pole-emploi.fr", +- "fishki.net", +- "rollingstone.com", +- "kapanlagi.com", +- "yandex.com", +- "cnblogs.com", +- "plaintube.com", +- "intentmedia.net", +- "about.me", +- "torrentz.in", +- "01net.com", +- "gyazo.com", +- "nic.ru", +- "juicyads.com", +- "trend.az", +- "askubuntu.com", +- "unam.mx", +- "tradus.com", +- "tigerdirect.com", +- "letras.mus.br", +- "imagetwist.com", +- "perfectmoney.is", +- "wpbeginner.com", +- "thepiratetrader.com", +- "victoriassecret.com", +- "images-amazon.com", +- "tusfiles.net", +- "chefkoch.de", +- "ojooo.com", +- "alphaporno.com", +- "betfair.com", +- "tympanus.net", +- "td.com", +- "4tube.com", +- "phonearena.com", +- "bankmandiri.co.id", +- "cox.net", +- "ozon.ru", +- "perfectgirls.net", +- "asana.com", +- "sprint.com", +- "berniaga.com", +- "vente-privee.com", +- "ing.nl", +- "finn.no", +- "atwiki.jp", +- "toysrus.com", +- "petflow.com", +- "reverbnation.com", +- "freeones.com", +- "abc.go.com", +- "bradesco.com.br", +- "yenisafak.com.tr", +- "profit-partner.ru", +- "redfin.com", +- "mangafox.me", +- "appnexus.com", +- "sxc.hu", +- "speedanalysis.net", +- "n-tv.de", +- "qidian.com", +- "teespring.com", +- "break.com", +- "nailedhard.com", +- "jalan.net", +- "authorize.net", +- "adultadworld.com", +- "sootoo.com", +- "roboform.com", +- "kotaku.com", +- "multitran.ru", +- "food.com", +- "twitpic.com", +- "pogo.com", +- "sabq.org", +- "priceminister.com", +- "lexpress.fr", +- "livetv.sx", +- "nikkansports.com", +- "securepaynet.net", +- "vodoumedia.com", +- "airbnb.com", +- "trafficholder.com", +- "rr.com", +- "expireddomains.net", +- "bandcamp.com", +- "wayfair.com", +- "tut.by", +- "maybank2u.com.my", +- "similarweb.com", +- "zol.com.cn", +- "247realmedia.com", +- "asp.net", +- "lonelyplanet.com", +- "seopult.ru", +- "whois.net", +- "academia.edu", +- "univision.com", +- "interfax.ru", +- "amarillasinternet.com", +- "miercn.com", +- "barclays.co.uk", +- "societe.com", +- "khabaronline.ir", +- "unity3d.com", +- "nyaa.se", +- "euronews.com", +- "verizon.net", +- "rutube.ru", +- "wetter.com", +- "imlive.com", +- "ggpht.com", +- "docin.com", +- "yify-torrents.com", +- "yhd.com", +- "citibank.co.in", +- "xdating.com", +- "roblox.com", +- "voyages-sncf.com", +- "189.cn", +- "identi.li", +- "bayt.com", +- "medicinenet.com", +- "wmaraci.com", +- "stern.de", +- "eluniversal.com", +- "zoopla.co.uk", +- "easyjet.com", +- "dhl.com", +- "freakshare.com", +- "rojadirecta.me", +- "sp.gov.br", +- "friendfeed.com", +- "beamtele.com", +- "searchenginejournal.com", +- "nocookie.net", +- "reliancenetconnect.co.in", +- "google.co.ma", +- "fanpop.com", +- "adk2.co", +- "tagesschau.de", +- "nate.com", +- "ole.com.ar", +- "index.hu", +- "aruba.it", +- "eltiempo.com", +- "resellerclub.com", +- "qip.ru", +- "xossip.com", +- "siteground.com", +- "royalbank.com", +- "advfn.com", +- "tebyan.net", +- "iciba.com", +- "bigcartel.com", +- "sciencedirect.com", +- "hepsiburada.com", +- "cpasbien.me", +- "alfabank.ru", +- "microsoftstore.com", +- "discogs.com", +- "onliner.by", +- "socialmediaexaminer.com", +- "seasonvar.ru", +- "tripadvisor.in", +- "360doc.com", +- "chinabroadcast.cn", +- "realestate.com.au", +- "avira.com", +- "herokuapp.com", +- "downloadsetup.net", +- "torcache.net", +- "uefa.com", +- "rg.ru", +- "qianlong.com", +- "hugedomains.com", +- "arstechnica.com", +- "fifa.com", +- "ryanair.com", +- "i.ua", +- "axisbank.co.in", +- "alimama.com", +- "wanggou.com", +- "radikal.com.tr", +- "echoroukonline.com", +- "unian.net", +- "slashdot.org", +- "dmv.org", +- "mayoclinic.org", +- "newsmax.com", +- "google.com.et", +- "icontact.com", +- "vanguardngr.com", +- "infojobs.net", +- "say-move.org", +- "ileehoo.com", +- "mirtesen.ru", +- "yam.com", +- "e-hentai.org", +- "wikimapia.org", +- "shop-pro.jp", +- "bukalapak.com", +- "jcpenney.com", +- "ilmeteo.it", +- "iltasanomat.fi", +- "telecomitalia.it", +- "kariyer.net", +- "shutterfly.com", +- "santabanta.com", +- "softlayer.com", +- "complex.com", +- "mamba.ru", +- "netshoes.com.br", +- "theweathernetwork.com", +- "politico.com", +- "advego.ru", +- "eroprofile.com", +- "mainichi.jp", +- "nta.go.jp", +- "sfimg.com", +- "ap.org", +- "webex.com", +- "hinet.net", +- "skyscrapercity.com", +- "affili.net", +- "adplxmd.com", +- "iltalehti.fi", +- "impress.co.jp", +- "jezebel.com", +- "extremetube.com", +- "digitaltrends.com", +- "one.com", +- "ranker.com", +- "qiwi.com", +- "collegehumor.com", +- "nbc.com", +- "boursorama.com", +- "watch32.com", +- "meetcheap.com", +- "forums.wordpress.com", +- "cvs.com", +- "kenh14.vn", +- "yallakora.com", +- "plurk.com", +- "xtool.ru", +- "airtel.com", +- "wp.com", +- "sftimes.co", +- "economist.com", +- "rapidshare.com", +- "redbox.com", +- "audible.com", +- "kissmetrics.com", +- "atpanel.com", +- "wargaming.net", +- "1337x.org", +- "shahrekhabar.com", +- "bdnews24.com", +- "tvrain.ru", +- "wykop.pl", +- "mts.ru", +- "nnm-club.me", +- "schwab.com", +- "elconfidencial.com", +- "modelmayhem.com", +- "zhidao.baidu.com/user/admin", +- "aastocks.com", +- "tiscali.it", +- "qadabra.com", +- "autoscout24.de", +- "vatanim.com.tr", +- "gotowebinar.com", +- "edmunds.com", +- "ebaumsworld.com", +- "megafilmeshd.net", +- "poste.it", +- "mcssl.com", +- "aljazeera.net", +- "netvibes.com", +- "sme.sk", +- "tesco.com", +- "525j.com.cn", +- "tf1.fr", +- "ccidnet.com", +- "ldblog.jp", +- "blockchain.info", +- "played.to", +- "nthwall.com", +- "justanswer.com", +- "clickbank.net", +- "fnac.com", +- "gmarket.co.kr", +- "clipconverter.cc", +- "nextmedia.com", +- "bb.com.br", +- "learntotradethemarket.com", +- "pornoid.com", +- "downloadha.com", +- "hellporno.com", +- "ooo-sex.com", +- "blocket.se", +- "tubeplus.me", +- "seek.com.au", +- "filestube.to", +- "ceneo.pl", +- "walmart.com.br", +- "sonymobile.com", +- "dyndns.org", +- "ulmart.ru", +- "vrbo.com", +- "sport.pl", +- "ashleymadison.com", +- "el-wlid.com", +- "boredpanda.com", +- "udemy.com", +- "mobogenie.com", +- "tubegalore.com", +- "theglobeandmail.com", +- "bancobrasil.com.br", +- "888.com", +- "adreactor.com", +- "zomato.com", +- "depositfiles.com", +- "moneysavingexpert.com", +- "dofus.com", +- "oanda.com", +- "sport1.de", +- "justhost.com", +- "longhoo.net", +- "otomoto.pl", +- "techrepublic.com", +- "westpac.com.au", +- "dreamhost.com", +- "ilsole24ore.com", +- "clubic.com", +- "gamme.com.tw", +- "doctissimo.fr", +- "isna.ir", +- "s2d6.com", +- "tdbank.com", +- "zwaar.net", +- "slando.ua", +- "segodnya.ua", +- "appannie.com", +- "bartarinha.ir", +- "egotastic.com", +- "ed.gov", +- "lg.com", +- "120ask.com", +- "hostmonster.com", +- "super.cz", +- "mercola.com", +- "bayproxy.me", +- "day.az", +- "dummies.com", +- "azet.sk", +- "huffingtonpost.co.uk", +- "okezone.com", +- "medu.ir", +- "lavanguardia.com", +- "espreso.tv", +- "nymag.com", +- "autotrader.co.uk", +- "socialmediatoday.com", +- "wn.com", +- "rtbpop.com", +- "99designs.com", +- "sanspo.com", +- "proboards.com", +- "virginmedia.com", +- "99acres.com", +- "blic.rs", +- "pingomatic.com", +- "prnewswire.com", +- "sony.com", +- "seobuilding.ru", +- "www.gov.uk", +- "jugem.jp", +- "watchtower.com", +- "seoprofiler.com", +- "centrum.cz", +- "techbrowsing.com", +- "almasryalyoum.com", +- "lolking.net", +- "nipic.com", +- "fanfiction.net", +- "bwin.com", +- "anyporn.com", +- "sulit.com.ph", +- "quickmeme.com", +- "carview.co.jp", +- "haizhangs.com", +- "airtelforum.com", +- "flirt4free.com", +- "billboard.com", +- "trademe.co.nz", +- "rapgenius.com", +- "pchouse.com.cn", +- "beforeitsnews.com", +- "peopleperhour.com", +- "basecamphq.com", +- "onlinedown.net", +- "bet365.es", +- "fucked-tube.com", +- "santander.co.uk", +- "speedbit.com", +- "gi-akademie.com", +- "google.com.pr", +- "winupdatevideos.com", +- "bizrate.com", +- "xxxbunker.com", +- "coursera.org", +- "zoominfo.com", +- "rarbg.com", +- "ahram.org.eg", +- "howtogeek.com", +- "focus.cn", +- "duden.de", +- "mufg.jp", +- "ex.ua", +- "titan24.com", +- "greatandhra.com", +- "qqbaobao.com", +- "rtve.es", +- "yandex.net", +- "yle.fi", +- "panoramio.com", +- "google.com.af", +- "scol.com.cn", +- "gamestop.com", +- "xiami.com", +- "webpagetest.org", +- "creativecommons.org", +- "archive.is", +- "timesjobs.com", +- "centurylink.com", +- "wowhead.com", +- "wordstream.com", +- "lloydsbank.co.uk", +- "incredibar.com", +- "vagalume.com.br", +- "installerapplicationusa.com", +- "shinobi.jp", +- "ruvr.ru", +- "natwest.com", +- "roulettebotplus.com", +- "wildberries.ru", +- "huaban.com", +- "buenosearch.com", +- "reg.ru", +- "tempo.co", +- "qvc.com", +- "mangahere.com", +- "tv.com", +- "boc.cn", +- "fnb.co.za", +- "made-in-china.com", +- "eleconomista.es", +- "ubuntuforums.org", +- "derstandard.at", +- "xml-sitemaps.com", +- "jang.com.pk", +- "jiayuan.com", +- "credit-agricole.fr", +- "androidcentral.com", +- "urbanspoon.com", +- "pornoxo.com", +- "regnum.ru", +- "bedbathandbeyond.com", +- "skladchik.com", +- "daily.co.jp", +- "n-mobile.net", +- "suntrust.com", +- "justjared.com", +- "vid2c.com", +- "gettyimages.com", +- "tubecup.com", +- "kinogo.net", +- "similarsites.com", +- "fling.com", +- "vine.co", +- "banglanews24.com", +- "pudelek.pl", +- "support.wordpress.com", +- "cox.com", +- "xkcd.com", +- "adbooth.com", +- "anz.com", +- "adxcore.com", +- "google.com.sv", +- "indeed.co.in", +- "scottrade.com", +- "v9.com", +- "isohunt.to", +- "srclick.ru", +- "gharreh.com", +- "zaman.com.tr", +- "monsterindia.com", +- "delfi.lt", +- "chewen.com", +- "empowernetwork.com/QUbsgqDwpjjbkpOgwgOeaw==", +- "state.tx.us", +- "segundamano.es", +- "utro.ru", +- "sitescout.com", +- "justclick.ru", +- "wnd.com", +- "cosmopolitan.com", +- "local.com", +- "anitube.se", +- "sport.es", +- "google.com.qa", +- "ads-id.com", +- "google.lv", +- "capitalone360.com", +- "hattrick.org", +- "qualtrics.com", +- "inagist.com", +- "filgoal.com", +- "incredibar-search.com", +- "adslgate.com", +- "directv.com", +- "ilivid.com", +- "warthunder.ru", +- "jasmin.com", +- "cyberciti.biz", +- "msn.co.jp", +- "canalblog.com", +- "boerse.bz", +- "tnaflix.com", +- "apa.az", +- "prchecker.info", +- "reclameaqui.com.br", +- "onlyworldnews.com", +- "submarino.com.br", +- "kuronekoyamato.co.jp", +- "paipai.com", +- "realitykings.com", +- "deadspin.com", +- "islamweb.net", +- "no-ip.com", +- "lostfilm.tv", +- "wattpad.com", +- "wav.tv", +- "citi.com", +- "buysellads.com", +- "prezentacya.ru", +- "forocoches.com", +- "donga.com", +- "drive2.ru", +- "netsuite.com", +- "privalia.com", +- "bidorbuy.co.za", +- "cmbchina.com", +- "searchresultsguide.com", +- "odatv.com", +- "skrill.com", +- "en.wordpress.com", +- "dojki.com", +- "unibet.com", +- "hotpepper.jp", +- "simplyhired.com", +- "vesti.ua", +- "ibtimes.co.uk", +- "creativebloq.com", +- "filmesonlinegratis.net", +- "videohive.net", +- "kmart.com", +- "metacritic.com", +- "rikunabi.com", +- "zozo.jp", +- "venturebeat.com", +- "1and1.es", +- "banesconline.com", +- "internethaber.com", +- "rae.es", +- "planetsuzy.org", +- "wpengine.com", +- "kizi.com", +- "armorgames.com", +- "argos.co.uk", +- "dtiblog.com", +- "diigo.com", +- "forever21.com", +- "flashscore.com", +- "vedomosti.ru", +- "ccavenue.com", +- "att.net", +- "esporte.uol.com.br", +- "empowernetwork.com/PXQ7Uz1Kyg+LR1APrG7pKQ==", +- "to8to.com", +- "hotwire.com", +- "all.biz", +- "info.com", +- "xhamster.com/user/video", +- "000webhost.com", +- "worldoftanks.ru", +- "dagbladet.no", +- "computerbild.de", +- "nasdaq.com", +- "chitika.com", +- "ipeen.com.tw", +- "abola.pt", +- "wiley.com", +- "lpcloudsvr303.com", +- "tinsao.net", +- "mehrnews.com", +- "hugesex.tv", +- "christian-dogma.com", +- "search.us.com", +- "garmin.com", +- "tgbus.com", +- "iherb.com", +- "torntv-tvv.org", +- "chosun.com", +- "kinozal.tv", +- "berkeley.edu", +- "techtarget.com", +- "labanquepostale.fr", +- "fitbit.com", +- "folkd.com", +- "theonion.com", +- "idealista.com", +- "oscar.go.com", +- "jiji.com", +- "anonym.to", +- "allabout.co.jp", +- "wufoo.com", +- "rantlifestyle.com", +- "google.com.bo", +- "28.com", +- "rocketnews24.com", +- "hotspotshield.com", +- "opentable.com", +- "admngronline.com", +- "naturalnews.com", +- "zeroredirect2.com", +- "ero-video.net", +- "dinamalar.com", +- "fl.ru", +- "mtsindia.in", +- "kapook.com", +- "theage.com.au", +- "allmyvideos.net", +- "dinodirect.com", +- "videodownloadconverter.com", +- "tripleclicks.com", +- "brassring.com", +- "fapdu.com", +- "cafepress.com", +- "infospace.com", +- "express.com.pk", +- "fumu.com", +- "infibeam.com", +- "etrade.com", +- "meneame.net", +- "seroundtable.com", +- "bigpoint.com", +- "chinadaily.com.cn", +- "myfonts.com", +- "ezdownloadpro.info", +- "codeplex.com", +- "xl.pt", +- "kaspersky.com", +- "khabarfarsi.com", +- "admitad.com", +- "flirchi.com", +- "dpstream.net", +- "miniinthebox.com", +- "samsclub.com", +- "charter.net", +- "techbang.com", +- "tiu.ru", +- "fanpage.it", +- "spokeo.com", +- "imageshack.com", +- "ijreview.com", +- "bc.vc", +- "lazada.co.id", +- "gofirstrow.eu", +- "uptobox.com", +- "newsnow.co.uk", +- "symantec.com", +- "editor.wix.com", +- "avaxhome.cc", +- "canalplus.fr", +- "copyblogger.com", +- "vetogate.com", +- "yahoo-mbga.jp", +- "manoramaonline.com", +- "ah-me.com", +- "elheddaf.com", +- "bitcointalk.org", +- "haqaik.com", +- "bbandt.com", +- "linguee.de", +- "blogspot.nl", +- "minus.com", +- "amarujala.com", +- "openclassrooms.com", +- "bigmir.net", +- "koramgame.com", +- "commonfloor.com", +- "gayromeo.com", +- "cleartrip.com", +- "kompasiana.com", +- "tankionline.com", +- "google.co.tz", +- "springer.com", +- "lifenews.ru", +- "sify.com", +- "tvoyauda4a.ru", +- "dfiles.ru", +- "technorati.com", +- "myorderbox.com", +- "fanatik.com.tr", +- "activesearchresults.com", +- "laposte.net", +- "whirlpool.net.au", +- "stockcharts.com", +- "leadimpact.com", +- "cardekho.com", +- "ryushare.com", +- "blog.jp", +- "fastcompany.com", +- "eurosport.fr", +- "emirates.com", +- "lb.ua", +- "serverfault.com", +- "forbes.ru", +- "bfmtv.com", +- "google.jo", +- "17173.com", +- "wikispaces.com", +- "tokopedia.com", +- "liberation.fr", +- "a10.com", +- "kdnet.net", +- "variety.com", +- "blog.me", +- "homeaway.com", +- "ameritrade.com", +- "adult-empire.com", +- "national.com.au", +- "haraj.com.sa", +- "timewarnercable.com", +- "casino.com", +- "sheknows.com", +- "google.com.uy", +- "abv.bg", +- "liputan6.com", +- "etxt.ru", +- "bigstockphoto.com", +- "strato.de", +- "cashtasks.com", +- "columbia.edu", +- "zdf.de", +- "pptv.com", +- "cricbuzz.com", +- "sharesuper.info", +- "radaronline.com", +- "pornolab.net", +- "google.ba", +- "opensubtitles.org", +- "abclocal.go.com", +- "ansa.it", +- "pbskids.org", +- "vz.ru", +- "iconfinder.com", +- "vitaminl.tv", +- "ntv.ru", +- "peliculasyonkis.com", +- "foto-hd.com", +- "paytm.com", +- "rantsports.com", +- "optimum.net", +- "postbank.de", +- "index.hr", +- "smugmug.com", +- "haivl.com", +- "arbeitsagentur.de", +- "dailycaller.com", +- "freshbooks.com", +- "genieo.com", +- "alnaddy.com", +- "britishairways.com", +- "20min.ch", +- "findthebest.com", +- "autoblog.com", +- "warez-bb.org", +- "iza.ne.jp", +- "filmaffinity.com", +- "megogo.net", +- "soccermanager.com", +- "dawanda.com", +- "parallels.com", +- "clickjogos.uol.com.br", +- "12306.cn", +- "jstv.com", +- "cliphunter.com", +- "pixabay.com", +- "milenio.com", +- "keybinary.com", +- "suumo.jp", +- "mediatakeout.com", +- "vodafone.in", +- "cheapoair.com", +- "seobook.com", +- "videoyoum7.com", +- "yr.no", +- "gofundme.com", +- "ixbt.com", +- "starbucks.com", +- "conferenceplus.com", +- "media1first.com", +- "sergey-mavrodi.com", +- "rafflecopter.com", +- "591.com.tw", +- "mangapanda.com", +- "huffingtonpost.fr", +- "tiboo.cn", +- "bancomer.com.mx", +- "handelsblatt.com", +- "hpylgr.com", +- "psu.edu", +- "bancomercantil.com", +- "sport-express.ru", +- "codepen.io", +- "foundationapi.com", +- "ow.ly", +- "vatgia.com", +- "kommersant.ru", +- "srvsinf.com", +- "telderi.ru", +- "mercadolibre.com.co", +- "hsbc.com.hk", +- "t3n.de", +- "magicbricks.com", +- "shopstyle.com", +- "mudah.my", +- "punchng.com", +- "therichest.com", +- "fansshare.com", +- "lepoint.fr", +- "vipzona.info", +- "globaltestmarket.com", +- "jqueryui.com", +- "bcsh.com", +- "mundodeportivo.com", +- "newyorker.com", +- "funnyjunk.com", +- "gongchang.com", +- "a8.net", +- "ecollege.com", +- "newhdplugin.net", +- "befuck.com", +- "elespectador.com", +- "drugs.com", +- "abplive.in", +- "feelcars.com", +- "psychologytoday.com", +- "instaforex.com", +- "strtsrv.com", +- "atpworldtour.com", +- "incruit.com", +- "starwoodhotels.com", +- "zone-telechargement.com", +- "songspk.name", +- "hatenablog.com", +- "enfemenino.com", +- "msnbc.com", +- "freebitco.in", +- "akairan.com", +- "discovery.com", +- "angieslist.com", +- "lesechos.fr", +- "transfermarkt.de", +- "sephora.com", +- "come.in", +- "dailykos.com", +- "deutsche-bank.de", +- "warriorplus.com", +- "awwwards.com", +- "lomadee.com", +- "365jia.cn", +- "lotterypost.com", +- "egrana.com.br", +- "rivals.com", +- "literotica.com", +- "myfreshnet.com", +- "ihg.com", +- "fazenda.gov.br", +- "tomnod.com", +- "filesharefanatic.com", +- "hotukdeals.com", +- "bitsnoop.com", +- "tenpay.com", +- "putlocker.bz", +- "ziddu.com", +- "ntvmsnbc.com", +- "surveyzrewardcenter.com", +- "aliyun.com", +- "media.net", +- "comdirect.de", +- "yoox.com", +- "hotelscombined.com", +- "vgsgaming-ads.com", +- "robokassa.ru", +- "webdesignerdepot.com", +- "rotoworld.com", +- "jmw.com.cn", +- "seloger.com", +- "dsdomination.com", +- "affiliatewindow.com", +- "abs-cbnnews.com", +- "bmo.com", +- "iconarchive.com", +- "funshion.com", +- "admin5.com", +- "playhe.com", +- "bigcommerce.com", +- "yodobashi.com", +- "bigfishgames.com", +- "onlinecreditcenter6.com", +- "homes.co.jp", +- "gameninja.com", +- "ebates.com", +- "banamex.com.mx", +- "google.com.lb", +- "2chblog.jp", +- "entertainment-factory.com", +- "asg.to", +- "walla.co.il", +- "mktmobi.com", +- "opensooq.com", +- "adam4adam.com", +- "expressen.se", +- "elephanttube.com", +- "ingdirect.es", +- "clicrbs.com.br", +- "seriespepito.com", +- "skyscanner.net", +- "shine.com", +- "appround.us", +- "washingtontimes.com", +- "nrk.no", +- "1stwebdesigner.com", +- "gucheng.com", +- "ghanaweb.com", +- "jzip.com", +- "rozetka.com.ua", +- "wiziwig.tv", +- "jobsdb.com", +- "kitco.com", +- "rpp.com.pe", +- "aljaras.com", +- "telecinco.es", +- "storify.com", +- "netease.com", +- "business-standard.com", +- "babble.com", +- "noticias.uol.com.br", +- "alice.it", +- "bizdec.ru", +- "voanews.com", +- "freejobalert.com", +- "origo.hu", +- "list-manage2.com", +- "gavick.com", +- "national-lottery.co.uk", +- "gazzetta.gr", +- "freevideodownloadforpc.com", +- "xmarks.com", +- "wikibooks.org", +- "sexad.net", +- "alc.co.jp", +- "emol.com", +- "careesma.in", +- "cdc.gov", +- "toshiba.com", +- "imgchili.net", +- "rbcroyalbank.com", +- "indowebster.com", +- "zynga.com", +- "telekom.com", +- "jiameng.com", +- "adsmarket.com", +- "utorrent.com", +- "aarp.org", +- "cityadspix.com", +- "ekstrabladet.dk", +- "doc88.com", +- "fetlife.com", +- "fh21.com.cn", +- "cambridge.org", +- "tune.pk", +- "auction.co.kr", +- "patheos.com", +- "search-results.com", +- "lds.org", +- "webrankinfo.com", +- "newsit.gr", +- "techtudo.com.br", +- "moviepilot.com", +- "mercador.ro", +- "nguoiduatin.vn", +- "tripadvisor.it", +- "lurkmore.to", +- "europapress.es", +- "uspto.gov", +- "excelsior.com.mx", +- "myvideo.de", +- "jetblue.com", +- "camfrog.com", +- "blick.ch", +- "batepapo.uol.com.br", +- "manager.co.th", +- "goibibo.com", +- "cornell.edu", +- "apetube.com", +- "nation.com", +- "allmusic.com", +- "naughtyamerica.com", +- "obozrevatel.com", +- "telegrafi.com", +- "neimanmarcus.com", +- "yabancidiziizle1.com", +- "globalewallet.com", +- "beeline.ru", +- "hinkhoj.com", +- "sitemeter.com", +- "almesryoon.com", +- "localmoxie.com", +- "grotal.com", +- "knowyourmeme.com", +- "qiwi.ru", +- "yieldmanager.com", +- "yimg.com", +- "horoscopedays.com", +- "gfy.com", +- "mxtoolbox.com", +- "searchgol.com", +- "inquirer.net", +- "hollywoodlife.com", +- "ebrun.com", +- "shopbop.com", +- "mysmartprice.com", +- "kijiji.it", +- "visual.ly", +- "mop.com", +- "1fichier.com", +- "prlog.org", +- "xjtour.com", +- "shorouknews.com", +- "thegioinet.net", +- "hln.be", +- "enom.com", +- "thaqafnafsak.com", +- "wahuu.com", +- "ganji.com", +- "russianpost.ru", +- "myplaycity.com", +- "dzone.com", +- "dns-shop.ru", +- "aif.ru", +- "ssisurveys.com", +- "uploadboy.com", +- "madpandatv.net", +- "pcauto.com.cn", +- "meinestadt.de", +- "tasnimnews.com", +- "rockettheme.com", +- "imesh.com", +- "home.pl", +- "lindaikeji.blogspot.com", +- "zamunda.net", +- "with2.net", +- "calameo.com", +- "myonlinearcade.com", +- "xcams.com", +- "unicredit.it", +- "clip2net.com", +- "mediatemple.net", +- "nosub.tv", +- "click.in", +- "alluc.to", +- "thestar.com.my", +- "niksalehi.com", +- "lastampa.it", +- "itv.com", +- "hihi2.com", +- "digitalocean.com", +- "tripadvisor.fr", +- "willhaben.at", +- "laodong.com.vn", +- "591hx.com", +- "tineye.com", +- "ptt.cc", +- "beatport.com", +- "infoseek.co.jp", +- "avangate.com", +- "indiaproperty.com", +- "books.com.tw", +- "nj.com", +- "avaaz.org", +- "wikitravel.org", +- "direct.gov.uk", +- "wangtu.com", +- "discover.com", +- "slon.ru", +- "startpage.com", +- "thestar.com", +- "meishichina.com", +- "finanzen.net", +- "estadao.com.br", +- "indeed.co.uk", +- "expansion.com", +- "irpopup.ir", +- "arvixe.com", +- "secureinternetbank.com", +- "csmonitor.com", +- "carwale.com", +- "mtime.com", +- "ceconline.com", +- "abchina.com", +- "cgbchina.com.cn", +- "mediotiempo.com", +- "vic.gov.au", +- "cnbeta.com", +- "alarab.net", +- "vietnamnet.vn", +- "gay.com", +- "watchmygf.net", +- "myanimelist.net", +- "bannersbroker.com", +- "asklaila.com", +- "heureka.cz", +- "grepolis.com", +- "meteofrance.com", +- "bol.com", +- "hasoffers.com", +- "bigrock.in", +- "ibanking-services.com", +- "nos.nl", +- "google.com.gh", +- "beppegrillo.it", +- "nhaccuatui.com", +- "hamariweb.com", +- "wikiquote.org", +- "evite.com", +- "jobdiagnosis.com", +- "17track.net", +- "baixing.com", +- "awempire.com", +- "healthgrades.com", +- "unifiedlayer.com", +- "thisav.com", +- "himado.in", +- "zcool.com.cn", +- "tsn.ca", +- "atlassian.net", +- "binary500.com", +- "alotporn.com", +- "dnaindia.com", +- "sherdog.com", +- "www.nhs.uk", +- "gruposantander.es", +- "quantcast.com", +- "usearchmedia.com", +- "merchantcircle.com", +- "blog.hu", +- "wallstcheatsheet.com", +- "iptorrents.com", +- "apsense.com", +- "redirsvc.com", +- "indiarailinfo.com", +- "mobile.ir", +- "xvideo-jp.com", +- "boxofficemojo.com", +- "scamadviser.com", +- "rotapost.ru", +- "someecards.com", +- "mydealz.de", +- "lvye.cn", +- "videoweed.es", +- "xlovecam.com", +- "pepperjamnetwork.com", +- "khabarpu.com", +- "mathrubhumi.com", +- "online-convert.com", +- "b92.net", +- "tiptopsoft.org", +- "el-balad.com", +- "qihoo.com", +- "iheart.com", +- "campaign-archive1.com", +- "photodune.net", +- "labnol.org", +- "kotobank.jp", +- "medium.com", +- "google.lu", +- "tm1111.com", +- "gigazine.net", +- "mypcbackup.com", +- "instantcheckmate.com", +- "seemorgh.com", +- "topky.sk", +- "puu.sh", +- "aeriagames.com", +- "whatismyip.com", +- "rising.cn", +- "scotiabank.com", +- "wo.com.cn", +- "yootheme.com", +- "channel4.com", +- "heavy-r.com", +- "omgpm.com", +- "milli.az", +- "bnpparibas.net", +- "vmware.com", +- "diretta.it", +- "skycn.com", +- "sap.com", +- "zyalt.livejournal.com", +- "bookryanair.com", +- "kkbox.com", +- "subtitleseeker.com", +- "abckj123.com", +- "mashreghnews.ir", +- "websitewelcome.com", +- "2ch-c.net", +- "health.com", +- "uproxx.com", +- "uast.ac.ir", +- "bol.uol.com.br", +- "feedsportal.com", +- "ip-adress.com", +- "sedty.com", +- "ilsistemabinario.com", +- "nabble.com", +- "hightail.com", +- "superjob.ru", +- "tokyo.jp", +- "hrblock.com", +- "china.cn", +- "tsetmc.com", +- "unfranchise.com.tw", +- "bhg.com", +- "htmlbook.ru", +- "stardoll.com", +- "crictime.com", +- "hsn.com", +- "royalmail.com", +- "globallshare.com", +- "wikiwiki.jp", +- "petardas.com", +- "usembassy.gov", +- "rakuten-bank.co.jp", +- "golem.de", +- "stepstone.de", +- "aucfan.com", +- "stubhub.com", +- "rbcdaily.ru", +- "ro2.biz", +- "huffingtonpost.ca", +- "timeout.com", +- "digitalspy.co.uk", +- "foreningssparbanken.se", +- "autodesk.com", +- "98ia.com", +- "gtbank.com", +- "runetki.com", +- "freshdesk.com", +- "ieee.org", +- "getpocket.com", +- "jutarnji.hr", +- "caisse-epargne.fr", +- "profitcentr.com", +- "51.com", +- "oi.com.br", +- "sina.com.tw", +- "fontspace.com", +- "dynamicdrive.com", +- "maduradas.com", +- "ligtv.com.tr", +- "sport24.gr", +- "stargazete.com", +- "bola.net", +- "template-help.com", +- "codecademy.com", +- "officedepot.com", +- "researchgate.net", +- "17u.com", +- "gfxtra.com", +- "weiphone.com", +- "shoutmeloud.com", +- "hc360.com", +- "lintas.me", +- "mk.ru", +- "wplocker.com", +- "thumbtack.com", +- "szn.cz", +- "yatra.com", +- "societegenerale.fr", +- "wyborcza.pl", +- "demotywatory.pl", +- "thomann.de", +- "imperiaonline.org", +- "magento.com", +- "skillpages.com", +- "cam4ads.com", +- "spiceworks.com", +- "homestead.com", +- "locanto.in", +- "hotelurbano.com", +- "sinaimg.cn", +- "chetxia.com", +- "menshealth.com", +- "ideacellular.com", +- "snopes.com", +- "newgrounds.com", +- "autosottocosto.com", +- "admob.com", +- "linguee.fr", +- "net-a-porter.com", +- "text.ru", +- "sharebeast.com", +- "televisionfanatic.com", +- "netlog.com", +- "lufthansa.com", +- "ngoisao.net", +- "3911.net", +- "worldssl.net", +- "rabobank.nl", +- "lvmama.com", +- "sharethis.com", +- "sambaporno.com", +- "mci.ir", +- "inosmi.ru", +- "joyreactor.cc", +- "cartfill.in", +- "cooltext.com", +- "qz.com", +- "onthe.io", +- "citilink.ru", +- "apartmenttherapy.com", +- "lloydsbank.com", +- "metroer.com", +- "koyotesoft.com", +- "subdivx.com", +- "alriyadh.com", +- "backlinkwatch.com", +- "coindesk.com", +- "porntube1.xxx", +- "zovi.com", +- "thestreet.com", +- "rtbstream.com", +- "etnet.com.hk", +- "creditkarma.com", +- "lifebuzz.com", +- "opodo.co.uk", +- "developpez.net", +- "tinydeal.com", +- "nature.com", +- "oxforddictionaries.com", +- "anchorfree.net", +- "tn.com.ar", +- "findicons.com", +- "joomlart.com", +- "hmrc.gov.uk", +- "btc-e.com", +- "extra.com.br", +- "ad.nl", +- "megafon.ru", +- "qafqazinfo.az", +- "shahvani.com", +- "googlecode.com", +- "milliyet.tv", +- "deadline.com", +- "grindtv.com", +- "logitech.com", +- "nzherald.co.nz", +- "ninisite.com", +- "webgains.com", +- "oschina.net", +- "webmasters.ru", +- "filmix.net", +- "seowhy.com", +- "met-art.com", +- "discart.ru", +- "keywordblocks.com", +- "vodly.to", +- "redvak.com", +- "tomshardware.co.uk", +- "2shared.com", +- "zoznam.sk", +- "icims.com", +- "virtapay.com", +- "blomaga.jp", +- "wasu.cn", +- "carsensor.net", +- "sportsdirect.com", +- "uservoice.com", +- "livescience.com", +- "gamebase.com.tw", +- "persiangig.com", +- "livesmi.com", +- "eharmony.com", +- "banorte.com", +- "radiojavan.com", +- "startv.com.tr", +- "coolmath-games.com", +- "downloadquick.net", +- "worldoftanks.eu", +- "filelist.ro", +- "fontsquirrel.com", +- "superpages.com", +- "yolasite.com", +- "funnie.st", +- "51cto.com", +- "goo-net.com", +- "builtwith.com", +- "shaparak.ir", +- "nuomi.com", +- "omegle.com", +- "poringa.net", +- "lan.com", +- "desi-tashan.com", +- "shabdkosh.com", +- "freedigitalphotos.net", +- "betradar.com", +- "womenshealthmag.com", +- "realsimple.com", +- "maxbounty.com", +- "bbva.es", +- "sweetpacks.com", +- "pinoy-ako.info", +- "jobstreet.com", +- "cafe24.com", +- "goldenbirds.biz", +- "anandtech.com", +- "mapion.co.jp", +- "rawstory.com", +- "streamate.com", +- "celebuzz.com", +- "freepornvs.com", +- "divyabhaskar.co.in", +- "lifehack.org", +- "holidaycheck.de", +- "quizlet.com", +- "zhibo8.cc", +- "askmefast.com", +- "manageflitter.com", +- "campaign-archive2.com", +- "cityheaven.net", +- "uniqlo.com", +- "seoclerks.com", +- "tecmundo.com.br", +- "the-binary-options-guide.com", +- "gigaom.com", +- "mywot.com", +- "playcast.ru", +- "tatadocomo.com", +- "csfd.cz", +- "ganool.com", +- "kaschpo.ru", +- "webdunia.com", +- "philly.com", +- "doctoroz.com", +- "jumei.com", +- "poponclick.com", +- "rueducommerce.fr", +- "fararu.com", +- "po.st", +- "nextag.com", +- "manhunt.net", +- "sistrix.com", +- "woman.ru", +- "appbank.net", +- "iobit.com", +- "joins.com", +- "vidtomp3.com", +- "un.org", +- "volusion.com", +- "lipsum.com", +- "afkarnews.ir", +- "goldenline.pl", +- "clickansave.net", +- "softgozar.com", +- "thefind.com", +- "mozzi.com", +- "wenxuecity.com", +- "up2c.com", +- "searchfunmoods.com", +- "cabelas.com", +- "coffetube.com", +- "otto.de", +- "webalta.ru", +- "tataindicom.com", +- "ctvnews.ca", +- "inlinkz.com", +- "kajabi.com", +- "greatergood.com", +- "whmcs.com", +- "telekom.de", +- "christianpost.com", +- "fiducia.de", +- "bancsabadell.com", +- "pirateproxy.net", +- "woobox.com", +- "google.cm", +- "noulinx.com", +- "nick.com", +- "moviehuts.com", +- "mvideo.ru", +- "couchtuner.eu", +- "wyborcza.biz", +- "tradeindia.com", +- "girlsgogames.com", +- "healthcare.gov", +- "videolan.org", +- "sky.it", +- "tuniu.com", +- "ime.nu", +- "n4g.com", +- "cyberforum.ru", +- "justin.tv", +- "createspace.com", +- "joemonster.org", +- "registro.br", +- "elkhabar.com", +- "open24news.tv", +- "irr.ru", +- "sanjesh.org", +- "standardbank.co.za", +- "neogaf.com", +- "doyo.cn", +- "am15.net", +- "ana.co.jp", +- "amd.com", +- "gidonlinekino.com", +- "sitetalk.com", +- "nesn.com", +- "arabseed.com", +- "ingbank.pl", +- "webpronews.com", +- "saavn.com", +- "yourdictionary.com", +- "mobile9.com", +- "jagranjosh.com", +- "www.net.cn", +- "computerbase.de", +- "3djuegos.com", +- "htc.com", +- "the-binary-theorem.com", +- "google.com.np", +- "n11.com", +- "vivastreet.com", +- "mthai.com", +- "seomastering.com", +- "mercadolibre.cl", +- "searchmetrics.com", +- "mentalfloss.com", +- "russia.tv", +- "ubi.com", +- "dwnews.com", +- "ecplaza.net", +- "trafficfactory.biz", +- "loopnet.com", +- "refinery29.com", +- "minecraftforum.net", +- "moviefone.com", +- "bom.gov.au", +- "google.com.bh", +- "eltiempo.es", +- "cuantarazon.com", +- "2258.com", +- "google.ee", +- "nwolb.com", +- "bezaat.com", +- "eelly.com", +- "icmwebserv.com", +- "techsmith.com", +- "timeweb.ru", +- "johnlewis.com", +- "independent.ie", +- "bankia.es", +- "dkb.de", +- "gilt.com", +- "duolingo.com", +- "3file.info", +- "cam4.de.com", +- "pcanalysis.net", +- "br.de", +- "vodlocker.com", +- "adfoc.us", +- "ymlp.com", +- "dailyfx.com", +- "business2community.com", +- "banki.ru", +- "yell.com", +- "smartresponder.ru", +- "yaske.to", +- "bokra.net", +- "mercadolibre.com", +- "viewster.com", +- "recipesfinder.com", +- "rei.com", +- "dogpile.com", +- "caf.fr", +- "sbrf.ru", +- "soha.vn", +- "voila.fr", +- "rp-online.de", +- "members.webs.com", +- "duvamis.com", +- "nazwa.pl", +- "google.com.ni", +- "ilovemobi.com", +- "retrogamer.com", +- "blogtalkradio.com", +- "utexas.edu", +- "sonyentertainmentnetwork.com", +- "dr.dk", +- "jjwxc.net", +- "service-public.fr", +- "care2.com", +- "musavat.com", +- "h12-media.com", +- "smartfren.com", +- "immowelt.de", +- "discuz.net", +- "m1905.com", +- "cas.sk", +- "bitcoinwisdom.com", +- "monografias.com", +- "mindbodygreen.com", +- "getfirebug.com", +- "godlikeproductions.com", +- "mydrivers.com", +- "voc.com.cn", +- "truecaller.com", +- "livemook.com", +- "i8ti.com", +- "agame.com", +- "kurir-info.rs", +- "urbanoutfitters.com", +- "shopping.uol.com.br", +- "2ip.ru", +- "91.com", +- "banquepopulaire.fr", +- "rappler.com", +- "mint.com", +- "jz123.cn", +- "zurb.com", +- "sport.cz", +- "justunfollow.com", +- "billionuploads.com", +- "thaivisa.com", +- "seitwert.de", +- "ciudad.com.ar", +- "archdaily.com", +- "jalopnik.com", +- "1news.az", +- "dailyfinance.com", +- "okitspace.com", +- "dn.se", +- "el-nacional.com", +- "larousse.fr", +- "mojo-themes.com", +- "draugiem.lv", +- "teamtreehouse.com", +- "xiu.com", +- "ennaharonline.com", +- "oricon.co.jp", +- "openoffice.org", +- "tny.cz", +- "forumfree.it", +- "youthwant.com.tw", +- "khamsat.com", +- "vitacost.com", +- "alrakoba.net", +- "marmiton.org", +- "yebhi.com", +- "the-binary-trader.biz", +- "dominos.com", +- "dice.com", +- "like4like.org", +- "tvmuse.com", +- "standardchartered.com", +- "bitbucket.org", +- "driveropti.net", +- "google.hn", +- "indiblogger.in", +- "torrenthound.com", +- "wolframalpha.com", +- "experienceproject.com", +- "nsw.gov.au", +- "olx.pt", +- "sciencedaily.com", +- "viglink.com", +- "plala.or.jp", +- "sxsw.com", +- "mileroticos.com", +- "namejet.com", +- "1hai.cn", +- "skroutz.gr", +- "bilibili.tv", +- "travelzoo.com", +- "saksfifthavenue.com", +- "get-a-fuck-tonight.com", +- "barclaycardus.com", +- "withgoogle.com", +- "whitehouse.gov", +- "oprah.com", +- "fishwrapper.com", +- "softbank.jp", +- "slutload.com", +- "latercera.cl", +- "100bestbuy.com", +- "nur.kz", +- "topit.me", +- "computerhope.com", +- "snob.ru", +- "rackcdn.com", +- "3158.cn", +- "artlebedev.ru", +- "yobt.com", +- "rai.it", +- "hs.fi", +- "tinhte.vn", +- "fotocasa.es", +- "nyu.edu", +- "dawn.com", +- "series.ly", +- "movshare.net", +- "fineartamerica.com", +- "westernunion.com", +- "leaseweb.com", +- "wayn.com", +- "ivi.ru", +- "bloomingdales.com", +- "pons.com", +- "rapidtrk.com", +- "bama.ir", +- "hackforums.net", +- "dfiles.eu", +- "intercambiosvirtuales.org", +- "sdo.com", +- "homes.com", +- "colissimo.fr", +- "discuss.com.hk", +- "afreeca.com", +- "rbc.ua", +- "novamov.com", +- "jungle.gr", +- "iol.co.za", +- "btcclicks.com", +- "mapsofindia.com", +- "propellerads.com", +- "fab.com", +- "princeton.edu", +- "reliancebroadband.co.in", +- "xdf.cn", +- "mako.co.il", +- "protothema.gr", +- "booloo.com", +- "livrariasaraiva.com.br", +- "efukt.com", +- "acrobat.com", +- "globovision.com", +- "xero.com", +- "sevenforums.com", +- "semalt.com", +- "audiojungle.net", +- "e1.ru", +- "quoka.de", +- "chinaiiss.com", +- "gonzoxxxmovies.com", +- "wallpaperswide.com", +- "fapvid.com", +- "trk4.com", +- "forosdelweb.com", +- "fark.com", +- "my.tv.sohu.com/user/video", +- "kaixin001.com", +- "ntvspor.net", +- "mobafire.com", +- "zigwheels.com", +- "filmifullizle.com", +- "8tracks.com", +- "readmanga.eu", +- "lelong.com.my", +- "planetromeo.com", +- "192.com", +- "republika.co.id", +- "in.gr", +- "televisao.uol.com.br", +- "kalerkantho.com", +- "usairways.com", +- "malaysiakini.com", +- "anonymouse.org", +- "xxxhost.me", +- "stuff.co.nz", +- "dek-d.com", +- "bbvanet.com.mx", +- "watchseries-online.eu", +- "malaysiaairlines.com", +- "policymic.com", +- "serviporno.com", +- "aprod.hu", +- "gelocal.it", +- "tradetracker.com", +- "cibc.com", +- "umich.edu", +- "smartshe.com", +- "sony.jp", +- "taobaocdn.com", +- "bestgfx.biz", +- "irib.ir", +- "aliimg.com", +- "esuteru.com", +- "healthline.com", +- "cnnamador.com", +- "sat.gob.mx", +- "childsafedownloadx.asia", +- "playmillion.com", +- "strawberrynet.com", +- "alnilin.com", +- "trustedreviews.com", +- "21cn.com", +- "persianv.com", +- "baomoi.com", +- "firestorage.jp", +- "google.co.ke", +- "admaimai.com", +- "sbnlife.com", +- "surveyrouter.com", +- "megaindex.ru", +- "intodns.com", +- "yiqifa.com", +- "mixcloud.com", +- "softonic.fr", +- "bakecaincontrii.com", +- "payu.in", +- "rakuten-card.co.jp", +- "almaany.com", +- "grantland.com", +- "ricardo.ch", +- "heavy.com", +- "niusnews.com", +- "canstockphoto.com", +- "acunn.com", +- "diythemes.com", +- "canalrcnmsn.com", +- "ngs.ru", +- "rassd.com", +- "groupon.co.in", +- "depositfiles.org", +- "mango.com", +- "theregister.co.uk", +- "worldfree4u.com", +- "f-lite.ru", +- "boingboing.net", +- "bangbros.com", +- "neteller.com", +- "tonicmovies.com", +- "p2up.ir", +- "cartoonnetwork.com", +- "lun.com", +- "nk.pl", +- "webry.info", +- "burningcamel.com", +- "mplife.com", +- "nationalreview.com", +- "williamhill.es", +- "sssc.cn", +- "col3negoriginal.lk", +- "yoast.com", +- "svyaznoy.ru", +- "chengdu.cn", +- "listverse.com", +- "lastminute.com", +- "guardianlv.com", +- "39yst.com", +- "bahseazad.ir", +- "debian.org", +- "tokyo-porn-tube.com", +- "ilbe.com", +- "upsocl.com", +- "balatarin.com", +- "charter97.org", +- "wpexplorer.com", +- "immi.gov.au", +- "yokamen.cn", +- "esmas.com", +- "hbr.org", +- "livechatinc.com", +- "crazyegg.com", +- "palcomp3.com", +- "calottery.com", +- "wistia.com", +- "locaweb.com.br", +- "techspot.com", +- "bit.ly", +- "yammer.com", +- "uscis.gov", +- "bramjnet.com", +- "linio.com.mx", +- "tharunaya.co.uk", +- "desirulez.net", +- "madmimi.com", +- "everydayhealth.com", +- "secondlife.com", +- "ceskatelevize.cz", +- "enter.ru", +- "glopart.ru", +- "woso.cn", +- "pitlap.info", +- "worldoftanks.com", +- "videarn.com", +- "dafiti.com.br", +- "segundamano.mx", +- "eamroomsnacks.com", +- "vulture.com", +- "humblebundle.com", +- "rockstargames.com", +- "wsodownloads.info", +- "yazete.com", +- "pcadvisor.co.uk", +- "07073.com", +- "modcloth.com", +- "attracta.com", +- "iol.pt", +- "travideos.com", +- "sparkpeople.com", +- "rankingsandreviews.com", +- "entekhab.ir", +- "goarticles.com", +- "wonderhowto.com", +- "kankanews.com", +- "rzb.ir", +- "p30download.com", +- "infojobs.it", +- "socialspark.com", +- "picstopin.com", +- "celebritynetworth.com", +- "tweakers.net", +- "gi-backoffice.com", +- "isbank.com.tr", +- "qiyou.com", +- "templatic.com", +- "cyberpresse.ca", +- "consumerreports.org", +- "focalprice.com", +- "linkpad.ru", +- "svd.se", +- "desitvforum.net", +- "bulbagarden.net", +- "showup.tv", +- "webgozar.com", +- "3dnews.ru", +- "spyfu.com", +- "bikhir.ma", +- "trovaprezzi.it", +- "autov.com.cn", +- "podnapisi.net", +- "tocmai.ro", +- "realitatea.net", +- "geico.com", +- "joydownload.com", +- "kddi.com", +- "unbounce.com", +- "meb.gov.tr", +- "anchorfree.us", +- "gumtree.pl", +- "dbs.com", +- "ebayimg.com", +- "ptcsolution.com", +- "clip.dj", +- "samplicio.us", +- "47news.jp", +- "todo1.com", +- "anspress.com", +- "24sata.hr", +- "cineblog01.tv", +- "sport-fm.gr", +- "unetenet.com", +- "tenki.jp", +- "jia.com", +- "filefactory.com", +- "onedio.com", +- "gendai.net", +- "nickjr.com", +- "finviz.com", +- "bytes.com", +- "inkthemes.com", +- "oriflame.com", +- "aporrea.org", +- "mazika2day.com", +- "baimao.com", +- "logme.in", +- "downloadactivate.com", +- "vista.ir", +- "duowan.com", +- "sinaapp.com", +- "proceso.com.mx", +- "xxxconnect.com", +- "dvdvideosoft.com", +- "nomorerack.com", +- "almubasher.com.sa", +- "afisha.ru", +- "clicksure.com", +- "11st.co.kr", +- "turkishairlines.com", +- "freekaamaal.com", +- "findwide.com", +- "sbisec.co.jp", +- "mythemeshop.com", +- "webnode.com", +- "cumhuriyet.com.tr", +- "morningstar.com", +- "trafficshop.com", +- "gopro.com", +- "jeevansathi.com", +- "dasoertliche.de", +- "markets.com", +- "absa.co.za", +- "ikman.lk", +- "fmworld.net", +- "hyatt.com", +- "virgin-atlantic.com", +- "tfl.gov.uk", +- "immonet.de", +- "haodf.com", +- "thewrap.com", +- "appgame.com", +- "hdwallpapers.in", +- "canon.com", +- "newsle.com", +- "jorudan.co.jp", +- "pcwelt.de", +- "coinbase.com", +- "yourgirlfriends.com", +- "djmaza.info", +- "findagrave.com", +- "lainformacion.com", +- "teacup.com", +- "ezilon.com", +- "redbubble.com", +- "guru.com", +- "brothersoft.com", +- "coinmarketcap.com", +- "mediabistro.com", +- "elfagr.org", +- "glavcom.ua", +- "jino.ru", +- "1e100.net", +- "g9g.com", +- "join.me", +- "ynet.com", +- "news247.gr", +- "rcom.co.in", +- "baby.ru", +- "argentglobalnetwork.com", +- "hsselite.com", +- "foxbusiness.com", +- "cookmates.com", +- "lidl.de", +- "timesofindia.com", +- "fakt.pl", +- "bgr.com", +- "ghatreh.com", +- "woxikon.de", +- "pontofrio.com.br", +- "gizmag.com", +- "signup.wordpress.com", +- "tre.it", +- "gardenweb.com", +- "alfalfalfa.com", +- "prcm.jp", +- "freemail.hu", +- "iteye.com", +- "katproxy.com", +- "kickassunblock.info", +- "wisegeek.com", +- "zaobao.com", +- "vpsdomain4.eu", +- "naij.com", +- "olx.co.za", +- "mihanstore.org", +- "gezinti.com", +- "vistaprint.in", +- "dastelefonbuch.de", +- "blackhatteam.com", +- "yummly.com", +- "minecraft.net", +- "justcloud.com", +- "biblehub.com", +- "argentinawarez.com", +- "gandul.info", +- "trialpay.com", +- "paruvendu.fr", +- "khanacademy.org", +- "topsy.com", +- "angelfire.com", +- "nseindia.com", +- "seositecheckup.com", +- "hostelworld.com", +- "zalukaj.tv", +- "animeflv.net", +- "laptopmag.com", +- "tripadvisor.de", +- "sec.gov", +- "tripadvisor.es", +- "oreilly.com", +- "kanald.com.tr", +- "halifax-online.co.uk", +- "extremetracking.com", +- "reimageplus.com", +- "jal.co.jp", +- "vuiviet.net", +- "yeslibertin.com", +- "pichunter.com", +- "empowernetwork.com/aI3zkH7s3g6tZH8TDmh8LA==", +- "reforma.com", +- "singlessalad.com", +- "upenn.edu", +- "1ting.com", +- "hsbc.com.mx", +- "sulia.com", +- "yepporn.com", +- "scrubtheweb.com", +- "e-autopay.com", +- "rechargeitnow.com", +- "ppomppu.co.kr", +- "zemtv.com", +- "gofeminin.de", +- "peoplestylewatch.com", +- "france24.com", +- "comodo.com", +- "openmace.net", +- "maultalk.com", +- "fancy.com", +- "vodafone.it", +- "pokerstrategy.com", +- "crunchyroll.com", +- "aipai.com", +- "3dcartstores.com", +- "leancy.com", +- "myblogguest.com", +- "papajohns.com", +- "tuolar.com", +- "junkmail.co.za", +- "nyc.gov", +- "rentalcars.com", +- "sovsport.ru", +- "marketo.com", +- "smbc.co.jp", +- "yale.edu", +- "pitchfork.com", +- "thetoptens.com", +- "joyme.com", +- "linuxquestions.org", +- "htmlgoodies.com", +- "laredoute.fr", +- "0427d7.se", +- "journaldesfemmes.com", +- "xici.net", +- "alwafd.org", +- "daniweb.com", +- "mtgox.com", +- "jetstar.com", +- "plotek.pl", +- "jobvite.com", +- "adage.com", +- "aukro.cz", +- "ford.com", +- "problogger.net", +- "518.com.tw", +- "blogbigtime.com", +- "nieuwsblad.be", +- "register.com", +- "24tv.ua", +- "aftenposten.no", +- "weightwatchers.com", +- "smartpassiveincome.com", +- "radiosvoboda.org", +- "web.com", +- "caixin.com", +- "digitalmarketer.com", +- "soup.io", +- "soft98.ir", +- "muzofon.com", +- "gao7.com", +- "freefilmshd.com", +- "hsbc.com", +- "xhamsterhq.com", +- "my.tv.sohu.com/user/reg", +- "trade65.com", +- "chow.com", +- "google.com.kh", +- "inps.it", +- "seesaa.jp", +- "hoovers.com", +- "peru21.pe", +- "sdpnoticias.com", +- "schema.org", +- "linode.com", +- "theknot.com", +- "blesk.cz", +- "google.ci", +- "loltrk.com", +- "vod.pl", +- "geenstijl.nl", +- "moneymakergroup.com", +- "tupaki.com", +- "huvrtech.com", +- "metafilter.com", +- "jumia.com.ng", +- "newsvine.com", +- "mylant.com", +- "accenture.com", +- "feedjit.com", +- "twipple.jp", +- "getgoodlinks.ru", +- "radiofarda.com", +- "informador.com.mx", +- "wisc.edu", +- "windows.net", +- "zamzar.com", +- "nationalpost.com", +- "epnet.com", +- "naaptol.com", +- "x-art.com", +- "ebookbrowsee.net", +- "marketingland.com", +- "thedailyshow.com", +- "s-oman.net", +- "theme-fusion.com", +- "immobiliare.it", +- "allvoices.com", +- "adroll.com", +- "francetvinfo.fr", +- "callandput.com", +- "entireweb.com", +- "instructure.com", +- "megacinema.fr", +- "djelfa.info", +- "flightaware.com", +- "magazineluiza.com.br", +- "ighome.com", +- "mature-beauty.com", +- "yuku.com", +- "peerfly.com", +- "hardware.fr", +- "dcinside.com", +- "telerik.com", +- "pengpeng.com", +- "gazetaexpress.com", +- "publico.es", +- "nwsource.com", +- "oneandone.co.uk", +- "qoo10.sg", +- "aboutus.org", +- "adsupplyads.com", +- "wa.gov", +- "google.co.cr", +- "benchmarkemail.com", +- "valuedealshopper.com", +- "hola.com", +- "mizuhobank.co.jp", +- "zzstream.li", +- "kriesi.at", +- "exist.ru", +- "nvidia.com", +- "giallozafferano.it", +- "jusbrasil.com.br", +- "konga.com", +- "avclub.com", +- "reed.co.uk", +- "advertig.com", +- "ripoffreport.com", +- "gooddrama.net", +- "pornyaz.com", +- "budsgunshop.com", +- "78.cn", +- "livesurf.ru", +- "99114.com", +- "pornorama.com", +- "marksandspencer.com", +- "vmall.com", +- "fatcow.com", +- "mylife.com", +- "irishtimes.com", +- "medicalnewstoday.com", +- "uiuc.edu", +- "groupon.it", +- "washington.edu", +- "addictinggames.com", +- "anonymz.com", +- "kindgirls.com", +- "jne.co.id", +- "guiamais.com.br", +- "lyricsfreak.com", +- "uloz.to", +- "tagesanzeiger.ch", +- "fashionandyou.com", +- "bollywoodhungama.com", +- "nationwide.co.uk", +- "kboing.com.br", +- "python.org", +- "theladbible.com", +- "eurosport.com", +- "webinarjam.com", +- "theme.wordpress.com", +- "myfxbook.com", +- "allwomenstalk.com", +- "ucla.edu", +- "opendns.com", +- "pornbb.org", +- "money.pl", +- "domain.com.au", +- "standaard.be", +- "wanelo.com", +- "express.co.uk", +- "exam8.com", +- "zum.com", +- "amtrak.com", +- "boots.com", +- "800notes.com", +- "fabfurnish.com", +- "amoureux.com", +- "ebizmba.com", +- "ujian.cc", +- "stargames.at", +- "panasonic.com", +- "ge.tt", +- "scout.com", +- "tiexue.net", +- "nanapi.jp", +- "eclipse.org", +- "searchquotes.com", +- "wetplace.com", +- "lpcloudbox300.com", +- "hollyscoop.com", +- "bdjobs.com", +- "larepublica.pe", +- "hizliresim.com", +- "yepme.com", +- "bitcoincharts.com", +- "bsnl.co.in", +- "ucwan87.net", +- "tianji.com", +- "hgtv.com", +- "cleanfiles.net", +- "moonsy.com", +- "tomsguide.com", +- "datpiff.com", +- "net.hr", +- "orange.pl", +- "bankrate.com.cn", +- "mafiashare.net", +- "giaoduc.net.vn", +- "sucuri.net", +- "ringcentral.com", +- "gamingwonderland.com", +- "freenet.de", +- "cian.ru", +- "gayboystube.com", +- "gog.com", +- "gruenderszene.de", +- "econsultancy.com", +- "aktuality.sk", +- "webrankstats.com", +- "j-cast.com", +- "popsugar.com", +- "mr-guangdong.com", +- "on.cc", +- "jb51.net", +- "lamoda.ru", +- "sprashivai.ru", +- "animoto.com", +- "winzip.com", +- "vanityfair.com", +- "svt.se", +- "noyapps.com", +- "mnn.com", +- "lancenet.com.br", +- "e-monsite.com", +- "gazeta.ua", +- "cari.com.my", +- "coub.com", +- "veoh.com", +- "kienthuc.net.vn", +- "eldorado.ru", +- "overclock.net", +- "meetic.fr", +- "tam.com.br", +- "alfemminile.com", +- "telmex.com", +- "newsbomb.gr", +- "funda.nl", +- "netcoc.com", +- "bhinneka.com", +- "layalina.com", +- "clubpenguin.com", +- "talktalk.co.uk", +- "dumpert.nl", +- "almastba.com", +- "clker.com", +- "adweek.com", +- "gigya.com", +- "disponivel.uol.com.br", +- "tomoson.com", +- "w.org", +- "rfi.fr", +- "imgbox.com", +- "omniture.com", +- "n24.de", +- "webdesignrazzi.com", +- "medscape.com", +- "playboy.com", +- "usda.gov", +- "cuevana.tv", +- "trenitalia.com", +- "explosm.net", +- "mail.uol.com.br", +- "delfi.lv", +- "elektroda.pl", +- "hulkshare.com", +- "kotak.com", +- "gi-akademie.ning.com", +- "yelp.de", +- "lrytas.lt", +- "couchsurfing.org", +- "drugstore.com", +- "ssa.gov", +- "seriescoco.com", +- "iran-tejarat.com", +- "hafiz.gov.sa", +- "intellicast.com", +- "sub.jp", +- "paginasamarillas.es", +- "anime44.com", +- "babyschool.com.cn", +- "advertisernets.com", +- "vpsdomain2.eu", +- "arcor.de", +- "video2mp3.net", +- "marthastewart.com", +- "hawahome.com", +- "articlesbase.com", +- "spanishdict.com", +- "meilishuo.com", +- "grammarly.com", +- "sportlemon.tv", +- "zend.com", +- "bigideamastermind.com", +- "hawaaworld.com", +- "pagseguro.uol.com.br", +- "keywordspy.com", +- "7search.com", +- "cnki.net", +- "aamaadmiparty.org", +- "javaplayer.info", +- "sidereel.com", +- "azcentral.com", +- "passportindia.gov.in", +- "memurlar.net", +- "bouyguestelecom.fr", +- "buenastareas.com", +- "ernmoneynow.com", +- "eurosport.ru", +- "blog.163.com", +- "pizzahut.com", +- "bossip.com", +- "webdeveloper.com", +- "add-anime.net", +- "pimptubed.com", +- "movistar.es", +- "megashare.sh", +- "empireavenue.com", +- "btemplates.com", +- "amkspor.com", +- "payza.com", +- "farfesh.com", +- "mcgraw-hill.com", +- "motor-talk.de", +- "purepeople.com", +- "i-gamer.net", +- "sotmarket.ru", +- "anthropologie.com", +- "google.org", +- "rai.tv", +- "wikidot.com", +- "canoe.ca", +- "orange.es", +- "umn.edu", +- "emag.ro", +- "webutations.org", +- "ykb.com", +- "canadapost.ca", +- "zhubajie.com", +- "nextcar.cn", +- "next.co.uk", +- "freemovie-hd.com", +- "telegraf.com.ua", +- "ajc.com", +- "xsrv.jp", +- "vanguard.com", +- "mybroadband.co.za", +- "999120.net", +- "panet.co.il", +- "bellemaison.jp", +- "fonearena.com", +- "playvid.com", +- "purdue.edu", +- "thesuperficial.com", +- "114so.cn", +- "irna.ir", +- "websitetonight.com", +- "edublogs.org", +- "provincial.com", +- "jahaniha.com", +- "heroturko.me", +- "dynadot.com", +- "txtsrving.info", +- "adclickxpress.com", +- "sammobile.com", +- "ebay.at", +- "yaplog.jp", +- "imtranslator.net", +- "fotor.com", +- "myvidster.com", +- "williamhill.it", +- "argaam.com", +- "zoomby.ru", +- "tcsbank.ru", +- "origin.com", +- "vov.vn", +- "wrapbootstrap.com", +- "imvu.com", +- "fbsbx.com", +- "elcorteingles.es", +- "cerdas.com", +- "google.com.om", +- "dramasonline.com", +- "businesswire.com", +- "serpbook.com", +- "santanderrio.com.ar", +- "meta.ua", +- "kenhgioitre.com", +- "watchcartoononline.com", +- "athome.co.jp", +- "2checkout.com", +- "moheet.com", +- "jeu.info", +- "ankieta-online.pl", +- "triberr.com", +- "wordtracker.com", +- "blogher.com", +- "colourlovers.com", +- "maalaimalar.com", +- "bakeca.it", +- "thepostgame.com", +- "beget.ru", +- "abebooks.com", +- "certified-toolbar.com", +- "publico.pt", +- "footmercato.net", +- "indiabix.com", +- "zakzak.co.jp", +- "hotfile.com", +- "virustotal.com", +- "usgs.gov", +- "tukif.com", +- "banglamail24.com", +- "graphicstock.com", +- "svpressa.ru", +- "sanalpazar.com", +- "logsoku.com", +- "loteriasyapuestas.es", +- "youjizzlive.com", +- "all-inkl.com", +- "arcot.com", +- "blogspot.fi", +- "inbox.lv", +- "anno-online.com", +- "tikona.in", +- "newsru.ua", +- "centerblog.net", +- "jahannews.com", +- "joxi.ru", +- "proxybay.eu", +- "2gis.ru", +- "indeed.fr", +- "novayagazeta.ru", +- "intelius.com", +- "hosteurope.de", +- "autoscout24.it", +- "postjoint.com", +- "pulsk.com", +- "biobiochile.cl", +- "homevv.com", +- "zapbux.com", +- "gsp.ro", +- "priyo.com", +- "jamnews.ir", +- "addtoany.com", +- "lookbook.nu", +- "e-travel.com", +- "themelock.com", +- "bestsocialfeed.com", +- "eqla3.com", +- "klm.com", +- "realtor.ca", +- "tv2.no", +- "jqueryrain.com", +- "seo-fast.ru", +- "academic.ru", +- "clicksia.com", +- "lpcloudbox30.com", +- "worldpay.com", +- "gogoanime.com", +- "photoshelter.com", +- "mlive.com", +- "wetteronline.de", +- "jkforum.net", +- "secure.ipage.com", +- "antena3.com", +- "elsevier.com", +- "thaiseoboard.com", +- "addic7ed.com", +- "rookee.ru", +- "jstor.org", +- "rajanews.com", +- "uline.com", +- "o2online.de", +- "fbdownloader.com", +- "wetpaint.com", +- "nnm.me", +- "50onred.com", +- "tvtropes.org", +- "philips.com", +- "watchseries.to", +- "perfectinter.net", +- "progressive.com", +- "stcn.com", +- "golsearch.com", +- "sarayanews.com", +- "screenrant.com", +- "macworld.com", +- "classifiedads.com", +- "ip138.com", +- "izlesene.com", +- "ovguide.com", +- "gametop.com", +- "urlm.co", +- "isitdownrightnow.com", +- "redhat.com", +- "stafaband.info", +- "biglion.ru", +- "twitterfeed.com", +- "ttnet.com.tr", +- "panasonic.jp", +- "loc.gov", +- "telstra.com.au", +- "jiathis.com", +- "perfil.com.ar", +- "inquisitr.com", +- "ratp.fr", +- "libertaddigital.com", +- "bni.co.id", +- "ycombinator.com", +- "paginegialle.it", +- "momoshop.com.tw", +- "theweek.com", +- "tuoitre.vn", +- "scriptmafia.org", +- "megavod.fr", +- "indiavisiontv.com", +- "history.com", +- "flyeralarm.com", +- "salespider.com", +- "ard.de", +- "dslreports.com", +- "tokyo-tube.com", +- "brazzersnetwork.com", +- "bonanza.com", +- "storenvy.com", +- "37signals.com", +- "jxnews.com.cn", +- "1sale.com", +- "allanalpass.com", +- "yiiframework.com", +- "kimsufi.com", +- "nastygal.com", +- "immoral.jp", +- "icq.com", +- "loxblog.com", +- "jcrew.com", +- "diamond.jp", +- "nissen.co.jp", +- "fxstreet.com", +- "15min.lt", +- "lifo.gr", +- "alef.ir", +- "iis.net", +- "giphy.com", +- "mypopup.ir", +- "bsnl.in", +- "distractify.com", +- "foro20.com", +- "chachaba.com", +- "fx-trend.com", +- "imanhua.com", +- "playxn.com", +- "gocomics.com", +- "lcl.fr", +- "hsw.cn", +- "ellislab.com", +- "persiantools.com", +- "coupondunia.in", +- "fengniao.com", +- "coinmill.com", +- "freelancer.in", +- "blogdetik.com", +- "data.com", +- "trafficjunky.net", +- "neverblue.com", +- "flvto.com", +- "lijit.com", +- "zaycev.net", +- "salamnews.org", +- "siliconrus.com", +- "dv37.com", +- "conrad.de", +- "ascii.jp", +- "yesfreeporn.com", +- "globalpost.com", +- "d4000.com", +- "dobreprogramy.pl", +- "hammihan.com", +- "wjunction.com", +- "liverpoolfc.tv", +- "nordea.fi", +- "mail2web.com", +- "songkick.com", +- "comicbookresources.com", +- "jwplayer.com", +- "moi.gov.sa", +- "iranecar.com", +- "kayako.com", +- "listal.com", +- "technet.com", +- "infonews.com", +- "fun698.com", +- "frys.com", +- "vectorstock.com", +- "vbox7.com", +- "leroymerlin.fr", +- "gpotato.eu", +- "gulfnews.com", +- "hot-sex-tube.com", +- "buzzle.com", +- "uludagsozluk.com", +- "onlinefastpaydayloan.com", +- "forumcommunity.net", +- "potins.net", +- "bwin.es", +- "lobstertube.com", +- "katestube.com", +- "endomondo.com", +- "navalny.livejournal.com", +- "wayport.net", +- "dealspl.us", +- "pixhost.org", +- "webopedia.com", +- "flagcounter.com", +- "hotnewhiphop.com", +- "matomy.com", +- "privat24.ua", +- "fuq.com", +- "readserver.net", +- "haiwainet.cn", +- "light-dark.net", +- "decolar.com", +- "tlbb8.com", +- "tomtom.com", +- "fontanka.ru", +- "tchibo.de", +- "slutfinder.com", +- "rbc.cn", +- "pepperfry.com", +- "freshersworld.com", +- "mob.org", +- "brobible.com", +- "phim3s.net", +- "parsiblog.com", +- "link-assistant.com", +- "smotri.com", +- "flyertalk.com", +- "iefimerida.gr", +- "pornyeah.com", +- "trustpilot.com", +- "wowslider.com", +- "sekindo.com", +- "shape.com", +- "pizap.com", +- "bluedart.com", +- "cmu.edu", +- "shueisha.co.jp", +- "royal-search.com", +- "123greetings.com", +- "albawabhnews.com", +- "holiday-weather.com", +- "4travel.jp", +- "lpcloudsvr203.com", +- "panorama.com.ve", +- "htcmania.com", +- "skorer.tv", +- "mymovies.it", +- "fileice.net", +- "1and1.fr", +- "legiaodosherois.com.br", +- "tomsguide.fr", +- "baymirror.com", +- "thesun.co.uk", +- "huffingtonpost.es", +- "61baobao.com", +- "juegos.com", +- "joyclub.de", +- "qatarairways.com", +- "ayosdito.ph", +- "translate.ru", +- "yithemes.com", +- "buyvip.com", +- "pearltrees.com", +- "thinkprogress.org", +- "twitcasting.tv", +- "lusongsong.com", +- "irecommend.ru", +- "aukro.ua", +- "eldiario.es", +- "pop-music.ir", +- "libertytimes.com.tw", +- "themalaysianinsider.com", +- "paddypower.it", +- "delfi.ee", +- "appthemes.com", +- "tdameritrade.com", +- "flashback.org", +- "tubelib.com", +- "claro.com.br", +- "jotform.com", +- "bigresource.com", +- "libsyn.com", +- "sendgrid.com", +- "silikonvadisi.tv", +- "geo.tv", +- "pricegrabber.com", +- "futhead.com", +- "testberichte.de", +- "skybet.com", +- "wpcentral.com", +- "lesnumeriques.com", +- "clientoo.com", +- "mathsisfun.com", +- "expert.ru", +- "maxptp.com", +- "mediaite.com", +- "regions.com", +- "fast-torrent.ru", +- "enlacespepito.com", +- "redtram.com", +- "benesse.ne.jp", +- "jappy.de", +- "wizzair.com", +- "adevarul.ro", +- "mhlw.go.jp", +- "dev-point.com", +- "ibtimes.co.in", +- "coinwarz.com", +- "slidesharecdn.com", +- "classmates.com", +- "tsite.jp", +- "niazerooz.com", +- "jma.go.jp", +- "motherjones.com", +- "easports.com", +- "elbotola.com", +- "tripadvisor.com.au", +- "rozee.pk", +- "vivanuncios.com.mx", +- "lashou.com", +- "theaustralian.com.au", +- "superstarmagazine.com", +- "zedge.net", +- "hardwarezone.com.sg", +- "yyets.com", +- "nowgamez.com", +- "blogspot.ch", +- "gq.com", +- "adidas.com", +- "uyan.cc", +- "dailydot.com", +- "xenforo.com", +- "ilmessaggero.it", +- "state.nj.us", +- "16888.com", +- "searchengines.guru", +- "nascar.com", +- "dnb.no", +- "smosh.com", +- "shinyinnovation.com", +- "who.int", +- "mybet.com", +- "yoo7.com", +- "xrea.com", +- "fotolog.net", +- "smartprix.com", +- "esquire.com", +- "google.com.cy", +- "santander.com.br", +- "realclearpolitics.com", +- "financereports24.com", +- "onlinesoccermanager.com", +- "noticiaaldia.com", +- "kelkoo.com", +- "drakulastream.eu", +- "vodafone.de", +- "bt.dk", +- "greenwichmeantime.com", +- "ufc.com", +- "webstatsdomain.org", +- "taoche.com", +- "thinkgeek.com", +- "caranddriver.com", +- "123-reg.co.uk", +- "translit.ru", +- "w3school.com.cn", +- "zwinky.com", +- "inboxdollars.com", +- "gratka.pl", +- "vecernji.hr", +- "taikang.com", +- "bolshoyvopros.ru", +- "urbita.com", +- "api.ning.com", +- "alltop.com", +- "readwrite.com", +- "medhelp.org", +- "totaljobs.com", +- "accorhotels.com", +- "prom.ua", +- "cuny.edu", +- "livemint.com", +- "berlin.de", +- "blogspot.hk", +- "orkut.com.br", +- "lzjl.com", +- "metric-conversions.org", +- "nationalrail.co.uk", +- "oxu.az", +- "mql5.com", +- "chinaluxus.com", +- "linguee.es", +- "saudiairlines.com", +- "standardmedia.co.ke", +- "alkislarlayasiyorum.com", +- "apk.tw", +- "lesoir.be", +- "whatculture.com", +- "indiewire.com", +- "pccomponentes.com", +- "paytm.in", +- "ebaypartnernetwork.com", +- "haivl.tv", +- "e-junkie.com", +- "tvp.pl", +- "ifilez.org", +- "aristeguinoticias.com", +- "bangkokpost.com", +- "whatmobile.com.pk", +- "prodavalnik.com", +- "arsenal.com", +- "buyma.com", +- "torrentday.com", +- "sammydress.com", +- "blogcu.com", +- "imore.com", +- "shitaraba.com", +- "pasadrexam2014.in", +- "songspk.at", +- "eforosh.com", +- "nocoty.pl", +- "koreus.com", +- "verticalresponse.com", +- "arte.tv", +- "ocnk.net", +- "cryptsy.com", +- "haaretz.com", +- "straitstimes.com", +- "2domains.ru", +- "usnetads.com", +- "pracuj.pl", +- "edreams.it", +- "sba.gov", +- "instabang.com", +- "domainnamesales.com", +- "teensnow.com", +- "visualwebsiteoptimizer.com", +- "blogos.com", +- "santander.com.mx", +- "solidfiles.com", +- "authorstream.com", +- "teslamotors.com", +- "tema.livejournal.com", +- "kolesa.kz", +- "startribune.com", +- "vevo.com", +- "clien.net", +- "3asq.com", +- "tvnet.lv", +- "mouthshut.com", +- "binary-machine.com", +- "adultwork.com", +- "hypebeast.com", +- "itrack.it", +- "network-tools.com", +- "brandsoftheworld.com", +- "comedycentral.com", +- "hotscripts.com", +- "meristation.com", +- "rlsbb.com", +- "uzai.com", +- "volkskrant.nl", +- "terra.com.mx", +- "howtoforge.com", +- "178.com", +- "wickedfire.com", +- "dilandau.eu", +- "seriales.us", +- "xataka.com", +- "hktdc.com", +- "express.pk", +- "surfcanyon.com", +- "buildhr.com", +- "ouest-france.fr", +- "stltoday.com", +- "alternet.org", +- "site5.com", +- "payserve.com", +- "society6.com", +- "douguo.com", +- "prosieben.de", +- "verywed.com", +- "enikos.gr", +- "tubewolf.com", +- "openrice.com", +- "blankrefer.com", +- "gouv.qc.ca", +- "torrentfreak.com", +- "craveonline.com", +- "unfollowers.com", +- "deser.pl", +- "quanjing.com", +- "runetki.tv", +- "yepi.com", +- "socialbakers.com", +- "webmotors.com.br", +- "mmo-champion.com", +- "globososo.com", +- "whois.sc", +- "sportskeeda.com", +- "socialblade.com", +- "jin115.com", +- "avjavjav.com", +- "thenewstribe.com", +- "pinkrod.com", +- "blox.pl", +- "mediamarkt.de", +- "vivo.com.br", +- "facilisimo.com", +- "sinarharian.com.my", +- "leguide.com", +- "voegol.com.br", +- "j.gs", +- "okgj.com", +- "revolveclothing.com", +- "lolinez.com", +- "go2cloud.org", +- "vmoptions.com", +- "myip.ms", +- "ay.gy", +- "liquidweb.com", +- "sbi.co.in", +- "alamaula.com", +- "reshareable.tv", +- "stirileprotv.ro", +- "siriusxm.com", +- "banvenez.com", +- "sergey-mavrodi-mmm.net", +- "ocj.com.cn", +- "elderscrollsonline.com", +- "webaslan.com", +- "dereferer.org", +- "newsbeast.gr", +- "778669.com", +- "yeucahat.com", +- "guitarcenter.com", +- "mercurynews.com", +- "channeladvisor.com", +- "go2000.com", +- "google.ge", +- "pandora.tv", +- "haqqin.az", +- "google.tt", +- "32d1d3b9c.se", +- "sexdatenow.net", +- "befunky.com", +- "micromaxinfo.com", +- "jquerymobile.com", +- "radikal.ru", +- "wigetmedia.com", +- "girlsplay.com", +- "pureleverage.com", +- "mathxl.com", +- "themefuse.com", +- "giga.de", +- "freevideo.cz", +- "stylebistro.com", +- "iwriter.com", +- "winporn.com", +- "tripadvisor.ca", +- "atresplayer.com", +- "igma.tv", +- "ravelry.com", +- "semana.com", +- "verycd.com", +- "sblo.jp", +- "fansided.com", +- "goalunited.org", +- "petfinder.com", +- "worthofweb.com", +- "memuruz.net", +- "njuskalo.hr", +- "yellowpages.ca", +- "91jm.com", +- "webconfs.com", +- "interpals.net", +- "erepublik.com", +- "akismet.com", +- "gaadi.com", +- "casasbahia.com.br", +- "techsupportalert.com", +- "bostonglobe.com", +- "uploadable.ch", +- "smartprofitsystem.com", +- "cimbclicks.com.my", +- "uwants.com", +- "gamestar.de", +- "neowin.net", +- "inilah.com", +- "toster.ru", +- "gosuslugi.ru", +- "windguru.cz", +- "3366.com", +- "beinsports.net", +- "vector.co.jp", +- "memecenter.com", +- "hotnews.ro", +- "webgame.web.id", +- "llnw.com", +- "jobstreet.co.id", +- "congratulations-you-won.com", +- "libertatea.ro", +- "app111.com", +- "scientificamerican.com", +- "strava.com", +- "iranjib.ir", +- "coneco.net", +- "fdrmx.com", +- "nps.gov", +- "businessinsider.in", +- "uniblue.com", +- "proporn.com", +- "dm5.com", +- "qld.gov.au", +- "nexusmods.com", +- "mandatory.com", +- "moskva.fm", +- "prosperityteam.com", +- "lent.az", +- "appbrain.com", +- "24smi.org", +- "avaxsearch.com", +- "gorillavid.in", +- "realgm.com", +- "favicon.cc", +- "astro.com", +- "joomlaforum.ru", +- "joystiq.com", +- "computerworld.com", +- "tvspielfilm.de", +- "centos.org", +- "bugun.com.tr", +- "amctv.com", +- "relianceada.com", +- "papystreaming.com", +- "clickindia.com", +- "sayyac.com", +- "q.gs", +- "bravoerotica.com", +- "bibsonomy.org", +- "netload.in", +- "shopatron.com", +- "iautos.cn", +- "banggood.com", +- "commerzbanking.de", +- "legacyclix.com", +- "intesasanpaolo.com", +- "awesomescreenshot.com", +- "desidime.com", +- "eporner.com", +- "alwatanvoice.com", +- "ok.ru", +- "europe1.fr", +- "karnaval.com", +- "tornn-tv.com", +- "frmtr.com", +- "pulscen.ru", +- "groupon.co.uk", +- "tradera.com", +- "comingsoon.net", +- "speckyboy.com", +- "cargurus.com", +- "citysearch.com", +- "brother.com", +- "acfun.tv", +- "jamejamonline.ir", +- "enterprise.com", +- "elotrolado.net", +- "userscripts.org", +- "confirmit.com", +- "compete.com", +- "auctiva.com", +- "potterybarn.com", +- "ivoox.com", +- "multiupload.nl", +- "glavnoe.ua", +- "p30world.com", +- "snapnames.com", +- "filmon.com", +- "flipkey.com", +- "rhhbschool.com", +- "worldbank.org", +- "proz.com", +- "docusign.net", +- "akakce.com", +- "empflix.com", +- "androidforums.com", +- "mos.ru", +- "contenko.com", +- "malwarebytes.org", +- "voyeurhit.com", +- "filmvz.com", +- "windowsazure.com", +- "rlslog.net", +- "zulagames.com", +- "onlinefinder.net", +- "blekko.com", +- "tvb.com", +- "mojomarketplace.com", +- "warnerbros.com", +- "rogers.com", +- "sparkasse.at", +- "bigcinema.tv", +- "mattcutts.com", +- "vemale.com", +- "pgatour.com", +- "bakusai.com", +- "lavozdegalicia.es", +- "style.com", +- "torrentino.com", +- "activeden.net", +- "sweetpacks-search.com", +- "pcstore.com.tw", +- "starmedia.com", +- "lycos.com", +- "uncomo.com", +- "caribbeancom.com", +- "googleping.com", +- "sondakika.com", +- "premiumwp.com", +- "tribune.com.pk", +- "sc.com", +- "91mobiles.com", +- "elle.com", +- "motortrend.com", +- "starsports.com", +- "otlan.com", +- "planetminecraft.com", +- "oregonlive.com", +- "publichd.se", +- "financialexpress.com", +- "huxiu.com", +- "hotwords.com", +- "asda.com", +- "impiego24.it", +- "tunisia-sat.com", +- "xojane.com", +- "shiftdelete.net", +- "hamshahrionline.ir", +- "mp3.es", +- "minutebuzz.com", +- "footlocker.com", +- "rusnovosti.ru", +- "defencenet.gr", +- "ndr.de", +- "blogosfera.uol.com.br", +- "quibids.com", +- "soft32.com", +- "davidwalsh.name", +- "blogun.ru", +- "webbirga.net", +- "dict.cn", +- "groupon.jp", +- "abovetopsecret.com", +- "contra.gr", +- "zn.ua", +- "jetbrains.com", +- "myus.com", +- "redbus.in", +- "creativemarket.com", +- "uainfo.org", +- "rtbf.be", +- "forexpf.ru", +- "mainlink.ru", +- "fantasti.cc", +- "usagc.org", +- "narutoget.com", +- "trendyol.com", +- "carsales.com.au", +- "fujitv.co.jp", +- "dardarkom.com", +- "corrieredellosport.it", +- "mcanime.net", +- "nolo.com", +- "beareyes.com.cn", +- "familysearch.org", +- "eprice.com.tw", +- "indonetwork.co.id", +- "geizhals.at", +- "watchfreemovies.ch", +- "siweiw.com", +- "elnuevoherald.com", +- "codecupdaters.com", +- "p1.com", +- "imhonet.ru", +- "spox.com", +- "spreadshirt.com", +- "bittorrent.com", +- "airberlin.com", +- "epicurious.com", +- "adverstitial.com", +- "researchnow.com", +- "lolnexus.com", +- "xbabe.com", +- "designmodo.com", +- "hamusoku.com", +- "radioshack.com", +- "teamliquid.net", +- "helpster.de", +- "globalsources.com", +- "fasttech.com", +- "dickssportinggoods.com", +- "j-sen.jp", +- "smashwords.com", +- "adversal.com", +- "musiciansfriend.com", +- "whoishostingthis.com", +- "ads8.com", +- "trend4pay.com", +- "tribune.com", +- "xsrving.com", +- "youngleafs.com", +- "gamersky.com", +- "podio.com", +- "state.pa.us", +- "iphoneogram.com", +- "datehookup.com", +- "hbs.edu", +- "ally.com", +- "mitbbs.com", +- "siasat.pk", +- "miratuserie.tv", +- "active.com", +- "ricardoeletro.com.br", +- "html.it", +- "minnano-av.com", +- "meetly.in", +- "denverpost.com", +- "supersport.com", +- "grupobancolombia.com", +- "freemake.com", +- "bankier.pl", +- "instapaper.com", +- "derwesten.de", +- "blogspot.hu", +- "tamindir.com", +- "play.pl", +- "warthunder.com", +- "team-bhp.com", +- "freepeople.com", +- "laposte.fr", +- "cnews.ru", +- "fayerwayer.com", +- "hitta.se", +- "hao123.com.eg", +- "it-ebooks.info", +- "freep.com", +- "newser.com", +- "lexilogos.com", +- "polldaddy.com", +- "auspost.com.au", +- "aib.ie", +- "cs.com.cn", +- "providesupport.com", +- "unblocksit.es", +- "twittercounter.com", +- "luisaviaroma.com", +- "imgbabes.com", +- "tharunee.lk", +- "nexon.com", +- "airliners.net", +- "srf.ch", +- "angel.co", +- "tokyo-sports.co.jp", +- "mt5.com", +- "down1oads.com", +- "vodonet.net", +- "axar.az", +- "taknaz.ir", +- "google.com.py", +- "ss.lv", +- "stuffgate.com", +- "giveawayoftheday.com", +- "climatempo.com.br", +- "xnxxmovies.com", +- "heartinternet.co.uk", +- "digikey.com", +- "zimbra.free.fr", +- "line.me", +- "talkingpointsmemo.com", +- "dyn.com", +- "exacttarget.com", +- "yourtango.com", +- "shopping.com", +- "king.com", +- "crackberry.com", +- "sm3na.com", +- "matchesfashion.com", +- "rk.com", +- "ems.com.cn", +- "xiaomi.cn", +- "hillnews.com", +- "geforce.com", +- "internetslang.com", +- "theoldreader.com", +- "digitaljournal.com", +- "aol.co.uk", +- "straightdope.com", +- "farfetch.com", +- "lupoporno.com", +- "ilgiornale.it", +- "binzhi.com", +- "loveplanet.ru", +- "sogi.com.tw", +- "googlevideo.com", +- "nintendo.com", +- "jreast.co.jp", +- "coinad.com", +- "keek.com", +- "chegg.com", +- "sparknotes.com", +- "mywapblog.com", +- "idlebrain.com", +- "boardgamegeek.com", +- "daserste.de", +- "nicozon.net", +- "ampnetzwerk.de", +- "agenziaentrate.gov.it", +- "apec.fr", +- "redbull.com", +- "listentoyoutube.com", +- "diepresse.com", +- "gohappy.com.tw", +- "morguefile.com", +- "dallasnews.com", +- "adxpansion.com", +- "almos3a.com", +- "updatetube.com", +- "lowyat.net", +- "lolipop.jp", +- "terafile.co", +- "eversave.com", +- "sportingnews.com", +- "517dv.com", +- "milfmovs.com", +- "myflorida.com", +- "brooonzyah.net", +- "cdn-cachefront.net", +- "ig.com", +- "indiapost.gov.in", +- "hangame.co.jp", +- "ithemes.com", +- "monova.org", +- "udmserve.net", +- "impactradius.com", +- "teasernet.com", +- "gmx.at", +- "mmotraffic.com", +- "citehr.com", +- "viator.com", +- "rt.ru", +- "japannetbank.co.jp", +- "zonealarm.com", +- "ebayclassifieds.com", +- "safecart.com", +- "proptp.net", +- "51hejia.com", +- "telkomsel.com", +- "deutschepost.de", +- "startpagina.nl", +- "alexaboostup.com", +- "istgah.com", +- "aufreeads.com", +- "thinkstockphotos.com", +- "similarsitesearch.com", +- "gossiplankanews.com", +- "venere.com", +- "javascriptkit.com", +- "square-enix.com", +- "tvtoday.de", +- "netaffiliation.com", +- "computrabajo.com.mx", +- "arioo.com", +- "fromdoctopdf.com", +- "lookany.com", +- "bleepingcomputer.com", +- "perfectmoney.com", +- "dorkly.com", +- "macmillandictionary.com", +- "fotka.pl", +- "porntubevidz.com", +- "rj.gov.br", +- "1.1.1.1", +- "ebay.be", +- "divxplanet.com", +- "cyworld.com", +- "biography.com", +- "p1.cn", +- "bazos.sk", +- "55.la", +- "lockerdome.com", +- "yola.com", +- "ccbill.com", +- "groupon.de", +- "okazii.ro", +- "izismile.com", +- "velvet.hu", +- "news-postseven.com", +- "ardmediathek.de", +- "sagawa-exp.co.jp", +- "sarzamindownload.com", +- "pdfonline.com", +- "gaaks.com", +- "azhibo.com", +- "pensador.uol.com.br", +- "surveygizmo.com", +- "familydoctor.com.cn", +- "lazada.vn", +- "guokr.com", +- "enjoydressup.com", +- "sky.de", +- "afp.com", +- "imujer.com", +- "livescore.net", +- "xinnet.com", +- "mypageresults.com", +- "safaribooksonline.com", +- "extremetech.com", +- "ecnavi.jp", +- "babyblog.ru", +- "practicalecommerce.com", +- "vidspot.net", +- "studymode.com", +- "nation.co.ke", +- "cpmrocket.com", +- "es.wix.com", +- "google.com.cu", +- "pravda.ru", +- "cda.pl", +- "appszoom.com", +- "selfhtml.org", +- "zmovie.tw", +- "dba.dk", +- "domain.com", +- "brightcove.com", +- "lol55.com", +- "textsale.ru", +- "casualclub.com", +- "gudvin.tv", +- "torrentreactor.net", +- "downloadcamp.com", +- "eset.com", +- "softonic.it", +- "internations.org", +- "retre.org", +- "3quan.com", +- "companieshouse.gov.uk", +- "hautelook.com", +- "edx.org", +- "ono.es", +- "jango.com", +- "7sur7.be", +- "spinrewriter.com", +- "hqxnxx.com", +- "elperiodico.com", +- "arabiaweather.com", +- "liansuo.com", +- "pcgamer.com", +- "offervault.com", +- "mytheresa.com", +- "memegenerator.net", +- "gsm.ir", +- "britannica.com", +- "mensfitness.com", +- "flaticon.com", +- "newrelic.com", +- "greatmmos.com", +- "ifixit.com", +- "aiyellow.com", +- "my.tv.sohu.com/user/card", +- "ce4arab.com", +- "news-us.jp", +- "slando.kz", +- "redflagdeals.com", +- "gsmhosting.com", +- "raiffeisen.at", +- "tagesspiegel.de", +- "epravda.com.ua", +- "bell.ca", +- "sleazyneasy.com", +- "dhnet.be", +- "webcars.com.cn", +- "freepik.es", +- "androidpolice.com", +- "cbr.ru", +- "thanhnien.com.vn", +- "shoptime.com.br", +- "dailytelegraph.com.au", +- "fastcodesign.com", +- "full-stream.net", +- "google.al", +- "creativecow.net", +- "centrum24.pl", +- "openstat.ru", +- "unfollowed.me", +- "brb.to", +- "babal.net", +- "ibotoolbox.com", +- "torrentdownloads.me", +- "miami.com", +- "mubasher.info", +- "patient.co.uk", +- "ayudawordpress.com", +- "makepolo.com", +- "exactseek.com", +- "echosign.com", +- "epson.com", +- "somo.vn", +- "tripadvisor.jp", +- "bikroy.com", +- "postimees.ee", +- "band.uol.com.br", +- "adopteunmec.com", +- "imgserve.net", +- "toofab.com", +- "neeu.com", +- "mailjet.com", +- "kinja.com", +- "qwertypay.com", +- "cosme.net", +- "dreammovies.com", +- "avvo.com", +- "wenyard.com", +- "dir.bg", +- "digital-photography-school.com", +- "peru.com", +- "thomsonreuters.com", +- "grazia.com.cn", +- "vivastreet.co.in", +- "officemax.com", +- "creditmutuel.fr", +- "themify.me", +- "ait-themes.com", +- "share-links.biz", +- "graphixshare.com", +- "theoutnet.com", +- "revolvermaps.com", +- "careers360.com", +- "tyroodr.com", +- "escapistmagazine.com", +- "ofreegames.com", +- "surveryewadcentrez.eu", +- "notebookcheck.net", +- "k2s.cc", +- "barstoolsports.com", +- "townhall.com", +- "mk.co.kr", +- "epochtimes.com", +- "arduino.cc", +- "blogcms.jp", +- "udacity.com", +- "habervaktim.com", +- "funweek.it", +- "techtunes.com.bd", +- "shopzilla.com", +- "sun-sentinel.com", +- "tfile.me", +- "novafile.com", +- "eurogamer.net", +- "thenewporn.com", +- "tuttosport.com", +- "sverve.com", +- "simplemachines.org", +- "nginx.org", +- "kepu.com.cn", +- "jxedt.com", +- "southparkstudios.com", +- "gusuwang.com", +- "utrace.de", +- "peperonity.de", +- "hvg.hu", +- "cairodar.com", +- "mappy.com", +- "kouclo.com", +- "my.tv.sohu.com/user/lucky", +- "lushstories.com", +- "stocktwits.com", +- "atlantico.fr", +- "baihe.com", +- "wowkeren.com", +- "v7n.com", +- "mozilla.com", +- "centurylink.net", +- "1001freefonts.com", +- "pubdirecte.com", +- "mercadolibre.com.pe", +- "vandelaydesign.com", +- "cpaelites.com", +- "wanyh.com", +- "propertyguru.com.sg", +- "esy.es", +- "torrentbutler.eu", +- "final.ir", +- "53.com", +- "clips4sale.com", +- "freerepublic.com", +- "huffingtonpost.de", +- "boards.ie", +- "fluege.de", +- "parents.com", +- "gimp.org", +- "adorocinema.com", +- "yelp.ca", +- "twicsy.com", +- "kuaibo.com", +- "gnu.org", +- "parsine.com", +- "jpc.com", +- "cloudapp.net", +- "expatriates.com", +- "sproutsocial.com", +- "natemat.pl", +- "livingrichwithcoupons.com", +- "x-ho.com", +- "adv-adserver.com", +- "downloadchop.com", +- "sagepub.com", +- "eleconomista.com.mx", +- "formula1.com", +- "quackit.com", +- "dlsite.com", +- "powned.tv", +- "stream-tv.me", +- "mindbodyonline.com", +- "mindmeister.com", +- "twitlonger.com", +- "ebay.ie", +- "deccanchronicle.com", +- "domaintuno.com", +- "thethirdmedia.com", +- "laiguana.tv", +- "flurry.com", +- "eloqua.com", +- "createsend.com", +- "hrloo.com", +- "interfax.com.ua", +- "admin.ch", +- "zgzcw.com", +- "bancoestado.cl", +- "fda.gov", +- "chinayes.com", +- "beslist.nl", +- "crossfit.com", +- "skai.gr", +- "covers.com", +- "antpoker.com", +- "perfectworld.com", +- "momdot.com", +- "1c-bitrix.ru", +- "feiren.com", +- "navitime.co.jp", +- "siliconindia.com", +- "warning.or.kr", +- "qatarliving.com", +- "uber.com", +- "ing-diba.de", +- "boldsky.com", +- "animeid.tv", +- "tom.com", +- "whatsmyserp.com", +- "ftbpro.com", +- "yobt.tv", +- "toluna.com", +- "burrp.com", +- "viber.com", +- "df.eu", +- "vatera.hu", +- "songmeanings.com", +- "smbc-card.com", +- "hip2save.com", +- "wmzona.com", +- "banamex.com", +- "chinaacc.com", +- "t-online.hu", +- "indianpornvideos.com", +- "runescape.com", +- "wapka.mobi", +- "115.com", +- "blogspot.no", +- "aksam.com.tr", +- "bankcomm.com", +- "giantbomb.com", +- "maxcdn.com", +- "topshop.com", +- "livescores.com", +- "rosbalt.ru", +- "gandi.net", +- "ioffer.com", +- "mihandownload.com", +- "eweb4.com", +- "britishcouncil.org", +- "cheetahmail.com", +- "vbulletin.com", +- "bradsdeals.com", +- "empowernetwork.com/commissionloophole", +- "vueling.com", +- "raventools.com", +- "yext.com", +- "everychina.com", +- "reduxmediia.com", +- "openstreetmap.org", +- "wed114.cn", +- "dzwww.com", +- "miibeian.gov.cn", +- "ufl.edu", +- "deseretnews.com", +- "presstv.ir", +- "copy.com", +- "fourhourworkweek.com", +- "buzztheme.net", +- "bollywoodlife.com", +- "redtubelive.com", +- "pengyou.com", +- "antaranews.com", +- "selectornews.com", +- "lavoz.com.ar", +- "avm.de", +- "flalottery.com", +- "jmp9.com", +- "baltimoresun.com", +- "mozillazine.org", +- "dnevnik.hr", +- "aebn.net", +- "mightydeals.com", +- "livescore.eu", +- "publipt.com", +- "xbmc.org", +- "scmp.com", +- "sbobet.com", +- "alpari.ru", +- "harborfreight.com", +- "linio.com.pe", +- "2500sz.com", +- "rdio.com", +- "bearshare.com", +- "thetrainline.com", +- "888poker.es", +- "filecrop.com", +- "twiends.com", +- "elnuevodia.com", +- "rasekhoon.net", +- "36.cn", +- "axeso5.com", +- "mzamin.com", +- "webmastersitesi.com", +- "thinkdigit.com", +- "lifescript.com", +- "experian.com", +- "adorama.com", +- "d1net.com", +- "torrentz.pro", +- "fullhdfilmizle.org", +- "space.com", +- "collider.com", +- "zalando.it", +- "slate.fr", +- "carmax.com", +- "recode.net", +- "gfan.com", +- "fonts.com", +- "honda.com", +- "ecwid.com", +- "debate.com.mx", +- "bmail.uol.com.br", +- "santandernet.com.br", +- "coderanch.com", +- "lyricsmode.com", +- "gametrailers.com", +- "3600.com", +- "designboom.com", +- "131.com", +- "finam.ru", +- "df.gob.mx", +- "85dcf732d593.se", +- "coches.net", +- "dhs.gov", +- "neurs.com", +- "poppen.de", +- "public-api.wordpress.com", +- "magnovideo.com", +- "squareup.com", +- "balagana.net", +- "goodsearch.com", +- "blog.ir", +- "ne10.uol.com.br", +- "di.se", +- "sinembargo.mx", +- "k618.cn", +- "eventim.de", +- "mysavings.com", +- "futureshop.ca", +- "spinding.com", +- "landsend.com", +- "oqenadserving.com", +- "here.com", +- "upi.com", +- "picresize.com", +- "abnamro.nl", +- "filenuke.com", +- "yxku.com", +- "mypearson.com", +- "dinakaran.com", +- "correos.es", +- "hotchatdirect.com", +- "markafoni.com", +- "gofuckbiz.com", +- "webfindpage.com", +- "cancan.ro", +- "hostgator.in", +- "latribune.fr", +- "adxite.com", +- "mofos.com", +- "bluewin.ch", +- "24ur.com", +- "dion.ne.jp", +- "vpsdomain3.eu", +- "newsweek.com", +- "oasgames.com", +- "mtv3.fi", +- "internetworld.de", +- "yatedo.com", +- "globaltimes.cn", +- "paddypower.com", +- "berlin1.de", +- "norwegian.com", +- "opteck.com", +- "zenfolio.com", +- "kakprosto.ru", +- "ecosia.org", +- "check24.de", +- "idbibank.co.in", +- "zoomit.ir", +- "notebooksbilliger.de", +- "torontosun.com", +- "egopay.com", +- "cnnexpansion.com", +- "emoneyspace.com", +- "rsport.ru", +- "fok.nl", +- "mql4.com", +- "inhabitat.com", +- "tqn.com", +- "noticierodigital.com", +- "wrike.com", +- "bazos.cz", +- "phonegap.com", +- "microlancer.com", +- "anipo.jp", +- "fotocommunity.de", +- "kuwo.cn", +- "chinacaipu.com", +- "terra.cl", +- "500px.org", +- "qantas.com.au", +- "advertising.com", +- "push2check.net", +- "livefyre.com", +- "philstar.com", +- "erail.in", +- "mywebgrocer.com", +- "der-postillon.com", +- "ru-board.com", +- "saramin.co.kr", +- "yjbys.com", +- "aaa.com", +- "flavorwire.com", +- "fcbarcelona.com", +- "lacentrale.fr", +- "googlegroups.com", +- "luck4.me", +- "catho.com.br", +- "centauro.com.br", +- "sia.az", +- "forumactif.com", +- "paltalk.com", +- "beyond.com", +- "occ.com.mx", +- "stamps.com", +- "getoffmyinternets.net", +- "mbok.jp", +- "cleveland.com", +- "ucdavis.edu", +- "tielabs.com", +- "hkgolden.com", +- "vandal.net", +- "lyst.com", +- "mrskin.com", +- "bunshun.jp", +- "netcarshow.com", +- "b1.org", +- "hromadske.tv", +- "sf-express.com", +- "pirateproxy.ca", +- "getcashforsurveys.com", +- "clikz4freakz.com", +- "adsupply.com", +- "truste.org", +- "boxuu.com", +- "webartex.ru", +- "usc.edu", +- "moo.com", +- "winkal.com", +- "deloitte.com", +- "xvideos-field5.com", +- "suomi24.fi", +- "flexmls.com", +- "weeklystandard.com", +- "debenhams.com", +- "mejortorrent.com", +- "vconnect.com", +- "ligatus.com", +- "skynewsarabia.com", +- "herschina.com", +- "92lux.cn", +- "care.com", +- "chip.com.tr", +- "tangdou.com", +- "vatanbilgisayar.com", +- "uppit.com", +- "metronews.fr", +- "parenting.com.tw", +- "meteo.gr", +- "meetgee.com", +- "ldlc.com", +- "ubs.com", +- "elcolombiano.com", +- "mafengwo.cn", +- "moodle.org", +- "asiaone.com", +- "huffingtonpost.it", +- "ipas2free.com", +- "casa.it", +- "kaiserpermanente.org", +- "listindiario.com", +- "treehugger.com", +- "payeer.com", +- "mypoints.com", +- "pjmedia.com", +- "foreca.com", +- "luxup.ru", +- "halifax.co.uk", +- "webinarjam.net", +- "webmeup.com", +- "webdesignledger.com", +- "rte.ie", +- "18andabused.com", +- "vbulletin.org", +- "apne.tv", +- "immoweb.be", +- "colonelcassad.livejournal.com", +- "atlassian.com", +- "investors.com", +- "globalbux.net", +- "wechat.com", +- "kanoon.ir", +- "mawaly.com", +- "self.com", +- "drive.ru", +- "autozone.com", +- "creditonebank.com", +- "fdj.fr", +- "hsbc.com.br", +- "desk.com", +- "dlvr.it", +- "wpml.org", +- "newmobilelife.com", +- "crosswalk.com", +- "thehun.com", +- "hobbyking.com", +- "tiantian.com", +- "hichina.com", +- "cyanogenmod.org", +- "horoscope.com", +- "bizsugar.com", +- "popularmechanics.com", +- "egaliteetreconciliation.fr", +- "eol.cn", +- "rzd.ru", +- "escalatenetwork.net", +- "yad2.co.il", +- "cna.com.tw", +- "zi-m.com", +- "leonardo.it", +- "ap.gov.in", +- "rakuten.de", +- "wallsave.com", +- "netzwelt.de", +- "bitrix24.ru", +- "techinasia.com", +- "bitstamp.net", +- "hostelbookers.com", +- "shoplocal.com", +- "200please.com", +- "tune-up.com", +- "mapy.cz", +- "dealnews.com", +- "livescore.co.uk", +- "seocentro.com", +- "rstyle.me", +- "neoseeker.com", +- "kaban.tv", +- "visualstudio.com", +- "cinetux.org", +- "groupon.com.br", +- "lastpass.com", +- "rincondelvago.com", +- "popsci.com", +- "2144.cn", +- "clickfair.com", +- "dsebd.org", +- "banesco.com", +- "spi0n.com", +- "blogspot.cz", +- "tnews.ir", +- "nme.com", +- "paperblog.com", +- "firstcry.com", +- "tophotels.ru", +- "liepin.com", +- "korabia.com", +- "ifttt.com", +- "aemet.es", +- "alot.com", +- "manutd.com", +- "edreams.es", +- "turkcell.com.tr", +- "eva.vn", +- "techpowerup.com", +- "vkrugudruzei.ru", +- "feed2all.eu", +- "thehindubusinessline.com", +- "express.de", +- "ixquick.com", +- "thrillist.com", +- "iqilu.com", +- "seriouseats.com", +- "edgesuite.net", +- "telexads.com", +- "alza.cz", +- "en-japan.com", +- "al.com", +- "dota2lounge.com", +- "totalping.com", +- "seocheki.net", +- "iceporn.com", +- "col3negoriginel.lk", +- "porsyar.com", +- "property24.com", +- "madamenoire.com", +- "markethealth.com", +- "alphacoders.com", +- "webempresa.com", +- "empireonline.com", +- "downforeveryoneorjustme.com", +- "lankadeepa.lk", +- "darty.com", +- "census.gov", +- "wapka.me", +- "kdslife.com", +- "jpost.com", +- "cricfree.tv", +- "7xxxtube.com", +- "businesscatalyst.com", +- "dilbert.com", +- "gaymaletube.com", +- "bellanaija.com", +- "renfe.es", +- "equifax.com", +- "pornmaki.com", +- "lolesports.com", +- "yunfan.com", +- "everybitcity.com", +- "9yao.com", +- "avantlink.com", +- "paginebianche.it", +- "xrosview.com", +- "newsday.com", +- "usportnews.com", +- "petapixel.com", +- "pistonheads.com", +- "lidovky.cz", +- "cvent.com", +- "adlandpro.com", +- "wikisource.org", +- "ename.com", +- "prosport.ro", +- "sharebuilder.com", +- "prisjakt.nu", +- "cw.com.tw", +- "datafilehost.com", +- "aircanada.com", +- "osu.edu", +- "linuxmint.com", +- "toyota.com", +- "google.am", +- "adobeconnect.com", +- "h33t.to", +- "companycheck.co.uk", +- "juno.com", +- "beitaichufang.com", +- "alaskaair.com", +- "tipsandtricks-hq.com", +- "yourstory.com", +- "wow-impulse.ru", +- "wishpond.com", +- "promosite.ru", +- "weddingwire.com", +- "icicidirect.com", +- "mouser.com", +- "shopstyle.co.uk", +- "sinemalar.com", +- "addurl.nu", +- "seccionamarilla.com.mx", +- "yllix.com", +- "motorola.com", +- "huawei.com", +- "mp3juices.com", +- "fitday.com", +- "pakwheels.com", +- "uploading.com", +- "snapwidget.com", +- "rsb.ru", +- "mturk.com", +- "libreoffice.org", +- "acer.com", +- "rd.com", +- "aa.com.tr", +- "glamour.com", +- "docnhat.net", +- "cnbb.com.cn", +- "piwik.org", +- "mycompanyadmin.com", +- "ohozaa.com", +- "fox.com", +- "mastercard.com.au", +- "microsofttranslator.com", +- "myhabit.com", +- "acesso.uol.com.br", +- "cqnews.net", +- "default-search.net", +- "juntadeandalucia.es", +- "carigold.com", +- "tweepi.com", +- "gamedog.cn", +- "videomega.tv", +- "softarchive.net", +- "akamai.com", +- "adorika.net", +- "zorpia.com", +- "bitdefender.com", +- "formstack.com", +- "al3abbarq.com", +- "ruelala.com", +- "andhrajyothy.com", +- "siteheart.com", +- "spankbang.com", +- "buxp.org", +- "subtlepatterns.com", +- "cucirca.eu", +- "apontador.com.br", +- "sbs.co.kr", +- "rong360.com", +- "billmelater.com", +- "nowdownload.ch", +- "pingmyurl.com", +- "main.jp", +- "allabolag.se", +- "fastspring.com", +- "20d625b48e.se", +- "wpzoom.com", +- "dl-protect.com", +- "onvista.de", +- "iberia.com", +- "learni.st", +- "minijuegos.com", +- "ae.com", +- "india-forums.com", +- "port.hu", +- "truelocal.com.au", +- "ziprecruiter.com", +- "toyokeizai.net", +- "24timezones.com", +- "tzetze.it", +- "the-village.ru", +- "ptcapusa.com", +- "indiaresults.com", +- "desjardins.com", +- "nchsoftware.com", +- "yasdl.com", +- "delo.ua", +- "baskino.com", +- "salary.com", +- "freecontact.com", +- "wumii.com", +- "ssc.nic.in", +- "synology.com", +- "nttdocomo.co.jp", +- "racing-games.com", +- "freeonlinegames.com", +- "aftabnews.ir", +- "zumi.pl", +- "efshop.com.tw", +- "hawamer.com", +- "eastbay.com", +- "izvestia.ru", +- "mosaiquefm.net", +- "twitchy.com", +- "slaati.com", +- "bookingbuddy.com", +- "networksolutionsemail.com", +- "etsystatic.com", +- "sina.com", +- "asiandatingbeauties.com", +- "blogs.com", +- "france3.fr", +- "healthcentral.com", +- "downloadatoz.com", +- "matthewwoodward.co.uk", +- "legalzoom.com", +- "phun.org", +- "campaignmonitor.com", +- "cifraclub.com.br", +- "hir24.hu", +- "twoplustwo.com", +- "hotshame.com", +- "arvixededicated.com", +- "designcrowd.com", +- "mrexcel.com", +- "blu-ray.com", +- "bundesliga.de", +- "comments.ua", +- "filmstarts.de", +- "3sk.tv", +- "donedeal.ie", +- "natunbarta.com", +- "forex-mmcis.com", +- "lifehacker.ru", +- "sitepronews.com", +- "tudogostoso.com.br", +- "titanfall.com", +- "brainpickings.org", +- "saharareporters.com", +- "vidto.me", +- "mlit.go.jp", +- "terapeak.com", +- "techweb.com.cn", +- "premiere.fr", +- "kanui.com.br", +- "asianetnews.tv", +- "cric.lk", +- "exxxtrasmall.com", +- "hiphopdx.com", +- "5617.com", +- "namepros.com", +- "humanmetrics.com", +- "allin1convert.com", +- "ox.ac.uk", +- "msecnd.net", +- "cathaypacific.com", +- "bet365affiliates.com", +- "tcs.com", +- "trafficestimate.com", +- "lmgtfy.com", +- "finance.ua", +- "find404.com", +- "pagesperso-orange.fr", +- "curbed.com", +- "tasteofhome.com", +- "ar15.com", +- "mydigitallife.info", +- "promiflash.de", +- "technobuffalo.com", +- "gamestorrents.com", +- "labirint.ru", +- "pclab.pl", +- "indiatvnews.com", +- "finya.de", +- "redmondpie.com", +- "rabota.ru", +- "share-online.biz", +- "packtpub.com", +- "techgig.com", +- "shaw.ca", +- "apkmania.co", +- "bet-at-home.com", +- "barclaycard.co.uk", +- "onefloorserve.com", +- "raiffeisen.ru", +- "t-nation.com", +- "mbalib.com", +- "staseraintv.com", +- "uswitch.com", +- "smartadserver.com", +- "bbcgoodfood.com", +- "elitetorrent.net", +- "backlinko.com", +- "naszemiasto.pl", +- "submitexpress.com", +- "savings.com", +- "gem.pl", +- "ahlamontada.com", +- "fotomac.com.tr", +- "gougou.com", +- "payamsara.com", +- "klix.ba", +- "doostiha.ir", +- "bibliocommons.com", +- "wealthyaffiliate.com", +- "emgn.com", +- "sifyitest.com", +- "washingtonexaminer.com", +- "rakuten-sec.co.jp", +- "mysurvey.com", +- "uuu9.com", +- "uscourts.gov", +- "showroomprive.com", +- "cargocollective.com", +- "hsoub.com", +- "afterbuy.de", +- "marunadanmalayali.com", +- "jumponhottie.com", +- "avon.com", +- "lazada.com.my", +- "51netu.com.cn", +- "ria.com", +- "sankakucomplex.com", +- "tvline.com", +- "devshed.com", +- "superherohype.com", +- "tv-series.me", +- "stylecraze.com", +- "wizards.com", +- "linkcollider.com", +- "xinjunshi.com", +- "bestchange.ru", +- "1111.com.tw", +- "fakenamegenerator.com", +- "newsmth.net", +- "noupe.com", +- "marketingprofs.com", +- "bluestacks.com", +- "jemtube.com", +- "bestbuy.ca", +- "backcountry.com", +- "designshack.net", +- "pond5.com", +- "highsnobiety.com", +- "rtl.fr", +- "pearsoncmg.com", +- "hellowork.go.jp", +- "koimoi.com", +- "soali.ir", +- "incentria.com", +- "vagas.com.br", +- "huaxi100.com", +- "cheaa.com", +- "lohaco.jp", +- "gov.on.ca", +- "fabthemes.com", +- "pipl.com", +- "comscore.com", +- "pcfinancial.ca", +- "craigslist.co.in", +- "michaels.com", +- "jibjab.com", +- "sankeibiz.jp", +- "dominos.co.in", +- "supermoney.eu", +- "itusozluk.com", +- "sdchina.com", +- "allkpop.com", +- "cam4.com.br", +- "stayfriends.de", +- "futbol24.com", +- "searchina.net", +- "sgcpanel.com", +- "informe21.com", +- "alsacreations.com", +- "crateandbarrel.com", +- "alliancewarfare.com", +- "filerio.in", +- "emailsrvr.com", +- "reventmedia.com", +- "vietcombank.com.vn", +- "rxlist.com", +- "acidcow.com", +- "orange.co.uk", +- "hellocoton.fr", +- "boldchat.com", +- "psychcentral.com", +- "surfline.com", +- "xxxkinky.com", +- "es.wordpress.com", +- "publika.az", +- "shufoo.net", +- "hertz.com", +- "businessweekly.com.tw", +- "virgula.uol.com.br", +- "linkis.com", +- "ixwebhosting.com", +- "usa.gov", +- "linguee.com", +- "yengo.com", +- "huffingtonpost.jp", +- "1x3x.com", +- "mediametrics.ru", +- "ec21.com", +- "80018.cn", +- "get-tune.net", +- "yupoo.com", +- "moviepilot.de", +- "ihned.cz", +- "fio.cz", +- "pubted.com", +- "cinemablend.com", +- "stooorage.com", +- "thevault.bz", +- "journaldugeek.com", +- "sommer-sommer.com", +- "travelchannel.com", +- "softonic.de", +- "petsmart.com", +- "ufxmarkets.com", +- "e24.no", +- "spirit.com", +- "dabi.ir", +- "admin5.net", +- "serialu.net", +- "vancouversun.com", +- "submanga.com", +- "sbicard.com", +- "affaritaliani.it", +- "idownloadblog.com", +- "castorama.fr", +- "sudouest.fr", +- "payscale.com", +- "serebii.net", +- "storypick.com", +- "jobkorea.co.kr", +- "gowildcasino.com", +- "hmetro.com.my", +- "parimatch.com", +- "51pinwei.com", +- "globalnews.ca", +- "mercadopago.com", +- "sixrevisions.com", +- "saisoncard.co.jp", +- "gov.kz", +- "gossip-tv.gr", +- "zbozi.cz", +- "aliorbank.pl", +- "huanqiuauto.com", +- "okaz.com.sa", +- "cplusplus.com", +- "mochimedia.com", +- "google.sn", +- "jquery-plugins.net", +- "peoplesmart.com", +- "mmafighting.com", +- "ponpare.jp", +- "porsche.com", +- "charter.com", +- "scrabblefinder.com", +- "unpcn.com", +- "loveaholics.com", +- "geocities.co.jp", +- "ladbrokes.com", +- "52che.com", +- "swansonvitamins.com", +- "sweetwater.com", +- "ali213.net", +- "savenkeep.com", +- "hotair.com", +- "orgasmatrix.com", +- "runrun.es", +- "filezilla-project.org", +- "looti.net", +- "pagesix.com", +- "twentytwowords.com", +- "gingersoftware.com", +- "youxiduo.com", +- "isimtescil.net", +- "rui.jp", +- "d1g.com", +- "2dbook.com", +- "zigzig.ir", +- "123telugu.com", +- "wdr.de", +- "hankyung.com", +- "pr.com", +- "search.ch", +- "iranproud.com", +- "raaga.com", +- "alt1040.com", +- "okpay.com", +- "recordchina.co.jp", +- "dreamincode.net", +- "bendibao.com", +- "creativelive.com", +- "socialoomph.com", +- "cssdeck.com", +- "taxactonline.com", +- "pb.com", +- "fnac.es", +- "ucsd.edu", +- "tmart.com", +- "whorush.com", +- "spicejet.com", +- "socialadr.com", +- "tutorialzine.com", +- "christianmingle.com", +- "torrentleech.org", +- "statefarm.com", +- "orkut.com", +- "whoscored.com", +- "truthaboutonlinesluts.com", +- "32red.com", +- "wp-themes.com", +- "adpost.com", +- "cnr.cn", +- "180upload.com", +- "snagajob.com", +- "textbroker.com", +- "freshome.com", +- "talkgold.com", +- "dudamobile.com", +- "weblancer.net", +- "newone.org", +- "nacion.com", +- "takepart.com", +- "voici.fr", +- "gizmodo.jp", +- "viki.com", +- "symbaloo.com", +- "topface.com", +- "businessdictionary.com", +- "adtech.info", +- "elandroidelibre.com", +- "fux.com", +- "21-sun.com", +- "cpmfx.com", +- "siemens.com", +- "edmodo.com", +- "notitarde.com", +- "babypips.com", +- "silkroad.com", +- "onextrapixel.com", +- "notdoppler.com", +- "walmart.ca", +- "marvel.com", +- "groupon.fr", +- "us1.com", +- "bunte.de", +- "findlaw.com", +- "topito.com", +- "carrefour.fr", +- "aawsat.com", +- "super.ae", +- "kicktipp.de", +- "simplyrecipes.com", +- "i-mobile.co.jp", +- "podrobnosti.ua", +- "snn.ir", +- "successfactors.com", +- "paixie.net", +- "wiwo.de", +- "glowgaze.com", +- "mapsofworld.com", +- "limetorrents.com", +- "plarium.com", +- "tvi.ua", +- "corel.com", +- "adhitprofits.com", +- "findthecompany.com", +- "noticiasaldiayalahora.co", +- "160by2.com", +- "jobberman.com", +- "rus.ec", +- "fujitsu.com", +- "ladepeche.fr", +- "pravda.sk", +- "wwtdd.com", +- "b9dm.com", +- "marathonbet.com", +- "sexlunch.com", +- "komputronik.pl", +- "gutenberg.org", +- "dizo.com.cn", +- "comunio.de", +- "naked.com", +- "gamesradar.com", +- "moneysupermarket.com", +- "cheaptickets.com", +- "assembla.com", +- "timesonline.co.uk", +- "mckinsey.com", +- "ebook3000.com", +- "videoblocks.com", +- "ruseller.com", +- "pideo.net", +- "joomlacode.org", +- "pciconcursos.com.br", +- "channelnewsasia.com", +- "cnnturk.com", +- "consultant.ru", +- "michigan.gov", +- "manoto1.com", +- "10010.com", +- "wholefoodsmarket.com", +- "globalgrind.com", +- "pichak.net", +- "morpakampus.com", +- "crazydomains.com.au", +- "uptodown.com", +- "polygon.com", +- "raspberrypi.org", +- "atmarkit.co.jp", +- "heftig.co", +- "informationweek.com", +- "trendhunter.com", +- "state.ny.us", +- "pornpros.com", +- "tnt.com", +- "sportal.bg", +- "spritzinc.com", +- "theladders.com", +- "lulu.com", +- "applesfera.com", +- "qoo10.jp", +- "notebookreview.com", +- "startertv.fr", +- "healthkart.com", +- "imgsin.com", +- "mp3olimp.net", +- "readms.com", +- "casadellibro.com", +- "nalog.ru", +- "4gamer.net", +- "jquery4u.com", +- "betfred.com", +- "3dwwwgame.com", +- "appleinsider.com", +- "dailystar.co.uk", +- "swalif.com", +- "hushmail.com", +- "worldtimebuddy.com", +- "sportschau.de", +- "mediatraffic.com", +- "gismeteo.ua", +- "record.com.mx", +- "putnik1.livejournal.com", +- "nextbigwhat.com", +- "vinescope.com", +- "jarchi.ir", +- "yidio.com", +- "dunyanews.tv", +- "hangseng.com", +- "interpark.com", +- "scholastic.com", +- "penny-arcade.com", +- "geilundlive.com", +- "budbi.com", +- "stop55.com", +- "jaidefinichon.com", +- "smartsheet.com", +- "vector.me", +- "farecompare.com", +- "vodafone.com.eg", +- "craftsy.com", +- "theresumator.com", +- "downloadab.com", +- "abendzeitung-muenchen.de", +- "dicio.com.br", +- "fobshanghai.com", +- "2dehands.be", +- "thethao247.vn", +- "cams.com", +- "gothamist.com", +- "moneynews.com", +- "zocdoc.com", +- "rol.ro", +- "nic.ar", +- "avenues.info", +- "cleverbridge.com", +- "usajobs.gov", +- "divxstage.eu", +- "jsticket.net", +- "himasoku.com", +- "thrivethemes.com", +- "orientaltrading.com", +- "premiumpress.com", +- "house365.com", +- "drugoi.livejournal.com", +- "monster.co.uk", +- "quickanddirtytips.com", +- "virtuemart.net", +- "huffpost.com", +- "real.com", +- "teacherspayteachers.com", +- "t24.com.tr", +- "zakon.kz", +- "shoppinglifestyle.com", +- "trendmicro.com", +- "surfingbird.ru", +- "cam.ac.uk", +- "navyfederal.org", +- "rateyourmusic.com", +- "bravenet.com", +- "polo.com", +- "cl.ly", +- "nanacast.com", +- "cnfol.com", +- "24option.com", +- "myscienceacademy.org", +- "getsoftfree.com", +- "cba.pl", +- "templateism.com", +- "actudesfinances.org", +- "1.254.254.254", +- "jobtalk.jp", +- "barbie.com", +- "rahnama.com", +- "gigporno.com", +- "buddypress.org", +- "corporationwiki.com", +- "enorth.com.cn", +- "thepioneerwoman.com", +- "cam4ultimate.com", +- "phpclasses.org", +- "uplus.metroer.com/~content", +- "komando.com", +- "iha.com.tr", +- "televisa.com", +- "tmtpost.com", +- "classifiedsgiant.com", +- "sportinglife.com", +- "askul.co.jp", +- "travelagency.travel", +- "jqueryscript.net", +- "rusfolder.com", +- "netcq.net", +- "irangrand.ir", +- "interaztv.com", +- "downvids.net", +- "mongodb.org", +- "nasgo.net", +- "thesitewizard.com", +- "songspk.cc", +- "travelandleisure.com", +- "d-h.st", +- "wasanga.com", +- "cgg.gov.in", +- "silverclix.com", +- "almogaz.com", +- "sexmob.es", +- "mistreci.com", +- "nukistream.com", +- "postaffiliatepro.com", +- "dish.com", +- "ulta.com", +- "worldcat.org", +- "crackle.com", +- "cineblog01.net", +- "parispornmovies.com", +- "avito.ma", +- "nethouse.ru", +- "elfinanciero.com.mx", +- "ab-in-den-urlaub.de", +- "pixeden.com", +- "thetimenow.com", +- "divar.ir", +- "coolrom.com", +- "akbank.com", +- "saturn.de", +- "dstv.com", +- "mttbsystem.com", +- "hujiang.com", +- "bash.im", +- "sextgem.com", +- "subaonet.com", +- "cnsnews.com", +- "informationng.com", +- "utoronto.ca", +- "hetzner.de", +- "vend-o.com", +- "cybozu.com", +- "autotimes.com.cn", +- "5giay.vn", +- "theepochtimes.com", +- "penesalud.com", +- "livenation.com", +- "qoinpro.com", +- "myway.com", +- "safe-swaps.com", +- "elephantjournal.com", +- "curse.com", +- "17zwd.com", +- "hitleap.com", +- "mec.gov.br", +- "freewebcams.com", +- "westelm.com", +- "imagegals.com", +- "streeteasy.com", +- "ekitan.com", +- "git-scm.com", +- "p30day.com", +- "kapaza.be", +- "svoboda.org", +- "google.mg", +- "timesofisrael.com", +- "roodo.com", +- "malwaretips.com", +- "dumpaday.com", +- "dha.com.tr", +- "diary.ru", +- "epa.gov", +- "jonloomer.com", +- "holidaylettings.co.uk", +- "oem.com.mx", +- "oxfordjournals.org", +- "3bmeteo.com", +- "iwebtool.com", +- "yinyuetai.com", +- "ixl.com", +- "rezultati.com", +- "51sole.com", +- "moudamepo.com", +- "macromill.com", +- "nzz.ch", +- "buzznet.com", +- "roku.com", +- "posta.com.tr", +- "letsbonus.com", +- "theoatmeal.com", +- "artofmanliness.com", +- "tubepornkiss.com", +- "aviny.com", +- "sabresonicweb.com", +- "tech-wd.com", +- "qbank.ru", +- "getsatisfaction.com", +- "prokerala.com", +- "ebc.com.br", +- "typiol.com", +- "photo.net", +- "rockpapershotgun.com", +- "netgear.com", +- "mg.co.za", +- "impressrd.jp", +- "jkbk.cn", +- "bakufu.jp", +- "lgmi.com", +- "tnt-online.ru", +- "frequency.com", +- "zip-codes.com", +- "sport.ro", +- "wolfram.com", +- "pgmediaserve.com", +- "icann.org", +- "twistedsifter.com", +- "mopo.de", +- "vogue.co.uk", +- "chatrandom.com", +- "checkpagerank.net", +- "colorzilla.com", +- "autobip.com", +- "laban.vn", +- "pricecheck.co.za", +- "notimex.com.mx", +- "pik.ba", +- "monster.de", +- "google.cd", +- "economia.uol.com.br", +- "vsnl.net.in", +- "futura-sciences.com", +- "appstorm.net", +- "icefilms.info", +- "dicelacancion.com", +- "hypovereinsbank.de", +- "piratestreaming.tv", +- "101domain.com", +- "google.mn", +- "rutgers.edu", +- "behindwoods.com", +- "downloadmaster.ru", +- "smartinsights.com", +- "wiziq.com", +- "ftc.gov", +- "animenewsnetwork.com", +- "tandfonline.com", +- "seagate.com", +- "famitsu.com", +- "onekingslane.com", +- "zalando.fr", +- "convio.com", +- "seochat.com", +- "qq163.com", +- "capital.gr", +- "tamin.ir", +- "phpfreaks.com", +- "cricketcountry.com", +- "ubersuggest.org", +- "ntv.co.jp", +- "olark.com", +- "1001fonts.com", +- "appsgeyser.com", +- "elsiglodetorreon.com.mx", +- "lyricsmint.com", +- "tovima.gr", +- "petco.com", +- "campograndenews.com.br", +- "amadeus.com", +- "tinychat.com", +- "astrology.com", +- "idg.se", +- "nordea.se", +- "gelbeseiten.de", +- "nrc.nl", +- "houseoffraser.co.uk", +- "hepsibahis3.com", +- "empowernetwork.com/almostasecret", +- "phpnuke.org", +- "xfwed.com", +- "gulte.com", +- "msi.com", +- "netfirms.com", +- "ovcanada.com", +- "smzdm.com", +- "wwwhatsnew.com", +- "mydomainadvisor.com", +- "newindianexpress.com", +- "luxtarget.com", +- "evz.ro", +- "otodom.pl", +- "linkin.net", +- "moneysavingmom.com", +- "uploadbaz.com", +- "egyup.com", +- "three.co.uk", +- "co-operativebank.co.uk", +- "redad.ru", +- "ipsosinteractive.com", +- "all-union.com", +- "trustlink.ru", +- "softango.com", +- "toucharcade.com", +- "tv2.dk", +- "thisissouthwales.co.uk", +- "jra.go.jp", +- "alfavita.gr", +- "ibigdan.livejournal.com", +- "gtarcade.com", +- "jc001.cn", +- "microcenter.com", +- "optimizepress.com", +- "beyebe.com", +- "muyzorras.com", +- "expedia.co.uk", +- "volvocars.com", +- "lyd.com.cn", +- "korben.info", +- "disput.az", +- "aeroflot.ru", +- "betanews.com", +- "avangard.ru", +- "wrzko.eu", +- "cakephp.org", +- "majorgeeks.com", +- "dreamteammoney.com", +- "foroactivo.com", +- "ut.ac.ir", +- "eonet.jp", +- "vn-zoom.com", +- "footytube.com", +- "expedia.de", +- "barneys.com", +- "lieyunwang.com", +- "gartner.com", +- "lazada.com.ph", +- "ourtime.com", +- "ohnotheydidnt.livejournal.com", +- "e-rewards.com", +- "updatestar.com", +- "cafef.vn", +- "cookinglight.com", +- "expressdownload.net", +- "shockmansion.com", +- "adserverpub.com", +- "ipko.pl", +- "gsa-online.de", +- "car.gr", +- "cqcounter.com", +- "thenews.com.pk", +- "gnc.com", +- "teambeachbody.com", +- "kobobooks.com", +- "cwan.com", +- "ca.com", +- "list.ly", +- "baijob.com", +- "gunbroker.com", +- "rtl.be", +- "myadvertisingpays.com", +- "mediapost.com", +- "groupalia.com", +- "anquan.org", +- "mixshowblast.com", +- "myscore.ru", +- "bancochile.cl", +- "a2hosting.com", +- "hayneedle.com", +- "myfc.ir", +- "aktifhaber.com", +- "eater.com", +- "anymeeting.com", +- "cylex.de", +- "sayidaty.net", +- "synonym.com", +- "comprendrechoisir.com", +- "prlog.ru", +- "solidtrustpay.com", +- "cinejosh.com", +- "yelp.co.uk", +- "olx.com.ar", +- "dihitt.com", +- "donkeymails.com", +- "chainreactioncycles.com", +- "wearehairy.com", +- "ebuyer.com", +- "bplans.com", +- "ponparemall.com", +- "readthedocs.org", +- "tehparadox.com", +- "source-wave.com", +- "tbs.co.jp", +- "redcoon.de", +- "francetv.fr", +- "freelogoservices.com", +- "ogone.com", +- "jeanmarcmorandini.com", +- "lasexta.com", +- "sponsoredreviews.com", +- "govome.com", +- "vecteezy.com", +- "alhayat.com", +- "cnhubei.com", +- "mumayi.com", +- "webfail.com", +- "eluniverso.com", +- "moddb.com", +- "gaiaonline.com", +- "gordonua.com", +- "liveadexchanger.com", +- "zhe800.com", +- "softonic.com.br", +- "cnyes.com", +- "cumlouder.com", +- "krakow.pl", +- "nullrefer.com", +- "zaluu.com", +- "diretube.com", +- "seattlepi.com", +- "eanswers.com", +- "gostorego.com", +- "play.com", +- "lenskart.com", +- "unblog.fr", +- "chatwork.com", +- "bronto.com", +- "jobisjob.co.in", +- "mercadolibre.com.uy", +- "overdrive.com", +- "runkeeper.com", +- "smartshopping.com", +- "getrichradio.com", +- "grader.com", +- "101greatgoals.com", +- "elbilad.net", +- "kopp-verlag.de", +- "ranksignals.com", +- "trome.pe", +- "jobstreet.com.my", +- "farnell.com", +- "fastmail.fm", +- "faithit.com", +- "blogdohotelurbano.com", +- "sencha.com", +- "daisycon.com", +- "random.org", +- "tportal.hr", +- "rkanr.com", +- "fc2-erodouga.com", +- "youngpornvideos.com", +- "bravoteens.com", +- "mobile.free.fr", +- "mitele.es", +- "edis.at", +- "questionablecontent.net", +- "indiangilma.com", +- "comunio.es", +- "bitnami.com", +- "sliptalk.com", +- "sourceforge.jp", +- "lyoness.net", +- "nespresso.com", +- "ultrafarma.com.br", +- "lik.cl", +- "jsoftj.com", +- "metoffice.gov.uk", +- "androidauthority.com", +- "360safe.com", +- "wikimart.ru", +- "tutu.ru", +- "truetwit.com", +- "xinruijunshi.com", +- "online-sweepstakes.com", +- "singaporeair.com", +- "cwtv.com", +- "politiken.dk", +- "alaan.tv", +- "tuttomercatoweb.com", +- "imagehost123.com", +- "drakensang.com", +- "frenchweb.fr", +- "syosetu.com", +- "zhifang.com", +- "viptube.com", +- "theme123.net", +- "statista.com", +- "51bi.com", +- "clickz.com", +- "kingworldnews.com", +- "qunar.com", +- "pimpandhost.com", +- "pagina12.com.ar", +- "xinmin.cn", +- "kidshealth.org", +- "pics.livejournal.com", +- "kabum.com.br", +- "anandabazar.com", +- "pnu.ac.ir", +- "scene7.com", +- "paperpkads.com", +- "mylikes.com", +- "longtailvideo.com", +- "firmy.cz", +- "bitcoinity.org", +- "inopressa.ru", +- "expat-blog.com", +- "governmentjobs.com", +- "airdroid.com", +- "mid-day.com", +- "frandroid.com", +- "webceo.com", +- "cadenaser.com", +- "minutouno.com", +- "onamae.com", +- "onlinekhabar.com", +- "williams-sonoma.com", +- "freewebsubmission.com", +- "vozforums.com", +- "bigpicture.ru", +- "mymodernmet.com", +- "presseportal.de", +- "licindia.in", +- "ismedia.jp", +- "depor.pe", +- "sing365.com", +- "v2cigs.com", +- "postimage.org", +- "gencat.cat", +- "west263.com", +- "alohatube.com", +- "eenadupratibha.net", +- "terra.com", +- "bri.co.id", +- "silktide.com", +- "anyang.gov.cn", +- "speedanalysis.com", +- "bitcoin.org", +- "toodledo.com", +- "topgear.com", +- "rtvslo.si", +- "hotpads.com", +- "nedsecure.co.za", +- "expedia.ca", +- "thairath.co.th", +- "gizbot.com", +- "naukrigulf.com", +- "guffins.com", +- "twilio.com", +- "avsforum.com", +- "sharpnews.ru", +- "inoreader.com", +- "stgeorge.com.au", +- "shoebuy.com", +- "sbwire.com", +- "bfm.ru", +- "dongtaiwang.com", +- "mandrillapp.com", +- "176.com", +- "olx.com", +- "trustpilot.co.uk", +- "tgju.org", +- "pap.fr", +- "iphonehacks.com", +- "gry-online.pl", +- "mp3xd.com", +- "viabcp.com", +- "bizcommunity.com", +- "chillingeffects.org", +- "thomasnet.com", +- "performersoft.com", +- "paymaster.ru", +- "comdotgame.com", +- "bseindia.com", +- "foodgawker.com", +- "clicktale.com", +- "dot.tk", +- "smbc-comics.com", +- "vvmembers.co", +- "c-sharpcorner.com", +- "acdcads.com", +- "goldporntube.com", +- "abakus-internet-marketing.de", +- "babbel.com", +- "fzg360.com", +- "99inf.com", +- "cduniverse.com", +- "autobild.de", +- "tvrage.com", +- "phoenix.edu", +- "hurriyetemlak.com", +- "va.gov", +- "maxmind.com", +- "lifehacker.jp", +- "nola.com", +- "niroensani.ir", +- "ihotelier.com", +- "mianbao.com", +- "powerball.com", +- "express.com", +- "freshdesignweb.com", +- "o2.co.uk", +- "utusan.com.my", +- "overclockers.ru", +- "fsiblog.com", +- "launchpad.net", +- "prizee.com", +- "alalam.ir", +- "imtalk.org", +- "vavel.com", +- "nyc.ny.us", +- "youmob.com", +- "dailythanthi.com", +- "ksu.edu.sa", +- "nlayer.net", +- "kurier.at", +- "expert-offers.com", +- "marry52.com", +- "cityads.ru", +- "darkorbit.com", +- "cio.com", +- "a9.com", +- "symfony.com", +- "crobo.com", +- "shatel.ir", +- "opposingviews.com", +- "myvoffice.com", +- "vkmag.com", +- "starpulse.com", +- "bls.gov", +- "lifebettering.com", +- "fanhuan.com", +- "upload7.ir", +- "infoplease.com", +- "suruga-ya.jp", +- "deredactie.be", +- "shangdu.com", +- "portail.free.fr", +- "smartaddons.com", +- "w3layouts.com", +- "wallstreet-online.de", +- "yapo.cl", +- "standard.co.uk", +- "atlas.sk", +- "seowizard.ru", +- "currys.co.uk", +- "nova.cz", +- "mygully.com", +- "favstar.fm", +- "themuse.com", +- "yudu.com", +- "urlopener.com", +- "ellentv.com", +- "imgsrc.ru", +- "km.ru", +- "guildwars2.com", +- "google.mu", +- "androidpit.de", +- "mrporter.com", +- "ttt4.com", +- "cbox.ws", +- "hf365.com", +- "1mobile.com", +- "punjabkesari.in", +- "msu.edu", +- "grasscity.com", +- "abduzeedo.com", +- "sublimetext.com", +- "jtb.co.jp", +- "mensxp.com", +- "myheritage.com", +- "onvasortir.com", +- "safeway.com", +- "comicvine.com", +- "cpubenchmark.net", +- "nn.ru", +- "animefreak.tv", +- "angularjs.org", +- "managewp.com", +- "ameli.fr", +- "merrjep.com", +- "christianbook.com", +- "nubiles.net", +- "klmty.net", +- "247sports.com", +- "aramex.com", +- "tubent.com", +- "cognitiveseo.com", +- "bankpasargad.com", +- "pingler.com", +- "compareja.com.br", +- "surveyzrewardcenter.eu", +- "allyes.com", +- "graaam.com", +- "poriborton.com", +- "seslisozluk.net", +- "shopyourway.com", +- "awd.ru", +- "wa.gov.au", +- "slrclub.com", +- "apollo.lv", +- "girls-ly.com", +- "totalfilm.com", +- "cam4.it", +- "gogecapital.com", +- "sketchup.com", +- "muscleandfitness.com", +- "m24.ru", +- "blinklist.com", +- "artisteer.com", +- "nettavisen.no", +- "enjin.com", +- "pc6.com", +- "citrix.com", +- "indgovtjobs.in", +- "phpbb.com", +- "laughingsquid.com", +- "fblife.com", +- "stansberryresearch.com", +- "hugefiles.net", +- "mp3monkey.net", +- "mcdonalds.com", +- "vodafone.co.uk", +- "t-mobile.de", +- "tp-link.com.cn", +- "iflscience.com", +- "nst.com.my", +- "zoom.com.br", +- "dsw.com", +- "tigerair.com", +- "doityourself.com", +- "bongdainfo.com", +- "imacros.net", +- "paperlesspost.com", +- "sprinthost.ru", +- "lovoo.net", +- "kadinlarkulubu.com", +- "championselect.net", +- "jcb.co.jp", +- "miui.com", +- "impots.gouv.fr", +- "linkshop.com.cn", +- "pando.com", +- "ckeditor.com", +- "arabylife.com", +- "ml.com", +- "sheldonsfans.com", +- "freecharge.in", +- "magicmovies.com", +- "laweekly.com", +- "highrisehq.com", +- "tr.gg", +- "vidbull.com", +- "diy.com", +- "yieldtraffic.com", +- "cima4u.com", +- "gendama.jp", +- "netpnb.com", +- "kannaway.com", +- "soft112.com", +- "die-boersenformel.com", +- "movie25.so", +- "footyroom.com", +- "dostor.org", +- "aol.de", +- "desimartini.com", +- "themeko.org", +- "danarimedia.com", +- "toroporno.com", +- "stylemepretty.com", +- "urlm.de", +- "demotivation.me", +- "gentside.com", +- "carfax.com", +- "huzhou.gov.cn", +- "hotline.ua", +- "fullmoneysystem.com", +- "pornomovies.com", +- "fsymbols.com", +- "blog.de", +- "clickpoint.com", +- "tv-asahi.co.jp", +- "flightstats.com", +- "sonico.com", +- "afamily.vn", +- "anadolu.edu.tr", +- "rs-online.com", +- "androidpit.com", +- "a-telecharger.com", +- "wikifeet.com", +- "nix.ru", +- "tvmao.com", +- "groupon.es", +- "hitfix.com", +- "weathernews.jp", +- "dig.do", +- "googledrive.com", +- "fodors.com", +- "melon.com", +- "testflightapp.com", +- "markt.de", +- "mahua.com", +- "sedo.co.uk", +- "tuenti.com", +- "comm100.com", +- "olx.co.id", +- "lefrecce.it", +- "gov.cl", +- "wplift.com", +- "unn.com.ua", +- "arizona.edu", +- "msn.com.cn", +- "k7x.com", +- "techz.vn", +- "jobomas.com", +- "extranetinvestment.com", +- "tengrinews.kz", +- "comicbookmovie.com", +- "4porn.com", +- "rubiconproject.com", +- "gametracker.com", +- "otcmarkets.com", +- "mismarcadores.com", +- "trojmiasto.pl", +- "cleverreach.com", +- "contactform7.com", +- "weloveshopping.com", +- "runnersworld.com", +- "falabella.com", +- "airtelbroadband.in", +- "twistys.com", +- "ebesucher.de", +- "belastingdienst.nl", +- "orlandosentinel.com", +- "th3professional.com", +- "duke.edu", +- "opensubtitles.us", +- "clickme.net", +- "infor.pl", +- "unesco.org", +- "socialfabric.us", +- "ename.net", +- "alternativeto.net", +- "rotahaber.com", +- "johnchow.com", +- "pervclips.com", +- "linkfeed.ru", +- "dtvideo.com", +- "kinoman.tv", +- "siteprice.org", +- "lacuerda.net", +- "amulyam.in", +- "mandghomebusiness.com", +- "infojobs.com.br", +- "hirufm.lk", +- "mybloggertricks.com", +- "athemes.com", +- "moikrug.ru", +- "fybersearch.com", +- "wine-searcher.com", +- "davidicke.com", +- "dotabuff.com", +- "sainsburys.co.uk", +- "ovaustralia.com", +- "updatesoftnow.com", +- "desarrolloweb.com", +- "elaph.com", +- "icc-cricket.com", +- "gaytube.com", +- "di.fm", +- "99wed.com", +- "c-and-a.com", +- "mlxchange.com", +- "realgfporn.com", +- "synxis.com", +- "optymalizacja.com", +- "ibtesama.com", +- "hankooki.com", +- "shiksha.com", +- "anoox.com", +- "seamless.com", +- "stripe.com", +- "ets.org", +- "fresherslive.com", +- "webcoinpay.net", +- "oscommerce.com", +- "gratisprogramas.org", +- "football365.com", +- "mkyong.com", +- "antichat.ru", +- "spamarrest.com", +- "ubc.ca", +- "36kr.com", +- "startv.in", +- "shoutcast.com", +- "heureka.sk", +- "entheosweb.com", +- "51wan.com", +- "madadsmedia.com", +- "parse.com", +- "ngacn.cc", +- "techbargains.com", +- "tvmovie.de", +- "cpmstar.com", +- "torproject.org", +- "residentadvisor.net", +- "genbeta.com", +- "hulu.jp", +- "pluralsight.com", +- "postini.com", +- "zombie.jp", +- "skimlinks.com", +- "liverail.com", +- "phys.org", +- "slashfilm.com", +- "livemaster.ru", +- "idwebgame.com", +- "pho.to", +- "dealfish.co.th", +- "s1979.com", +- "designfloat.com", +- "live365.com", +- "pbase.com", +- "eniro.se", +- "irannaz.com", +- "socialmonkee.com", +- "uidai.gov.in", +- "joomlashine.com", +- "allhyipmon.ru", +- "upbulk.com", +- "diapers.com", +- "flypgs.com", +- "hotmart.com.br", +- "globus-inter.com", +- "airfrance.fr", +- "t3.com", +- "unetepubli.com", +- "yahoo-help.jp", +- "iphones.ru", +- "95559.com.cn", +- "glamsham.com", +- "gophoto.it", +- "statmyweb.com", +- "aftermarket.pl", +- "forumotion.com", +- "iafd.com", +- "hotlog.ru", +- "drclix.com", +- "wawa-mania.ec", +- "nichepursuits.com", +- "imp.free.fr", +- "baofeng.com", +- "binsearch.info", +- "neswangy.net", +- "parperfeito.com.br", +- "theeroticreview.com", +- "sabayacafe.com", +- "maplestage.com", +- "icook.tw", +- "customerhub.net", +- "uid.me", +- "viperchill.com", +- "askfrank.net", +- "juegosjuegos.com", +- "debonairblog.com", +- "coingeneration.com", +- "onetravel.com", +- "slutroulette.com", +- "jetpack.me", +- "embedupload.com", +- "bancodevenezuela.com", +- "mysavingsmedia.net", +- "smallbiztrends.com", +- "emirates247.com", +- "bu.edu", +- "fineco.it", +- "netbarg.com", +- "gatech.edu", +- "zik.ua", +- "peliculascoco.com", +- "hkjc.com", +- "turkiyegazetesi.com.tr", +- "cooperativa.cl", +- "challenges.fr", +- "usingenglish.com", +- "vouchercodes.co.uk", +- "bonprix.de", +- "disneylatino.com", +- "townwork.net", +- "rentanything.com", +- "krypt.com", +- "wral.com", +- "globes.co.il", +- "designtaxi.com", +- "mp-success.com", +- "invisionpower.com", +- "liontravel.com", +- "classicrummy.com", +- "mt.co.kr", +- "inccel.com", +- "santander.cl", +- "afip.gov.ar", +- "yellowpages.com.au", +- "osclass.org", +- "couriermail.com.au", +- "stream.cz", +- "wizaz.pl", +- "linkresearchtools.com", +- "cam4.co.uk", +- "allafrica.com", +- "gezginler.net", +- "free-ebooks.net", +- "hopesandfears.com", +- "ticketmaster.com.mx", +- "ohio.gov", +- "liberoquotidiano.it", +- "neurs.net", +- "forumophilia.com", +- "odnako.org", +- "gamekult.com", +- "vh1.com", +- "zxart.cn", +- "mass.gov", +- "tv-tokyo.co.jp", +- "mundopromocion.com", +- "theme-junkie.com", +- "asu.edu", +- "lalibre.be", +- "pornokopilka.info", +- "fx678.com", +- "netbeans.org", +- "chinabidding.com.cn", +- "lunapic.com", +- "dramafever.com", +- "hbogo.com", +- "torrents.net", +- "woopra.com", +- "justfab.com", +- "fitnessmagazine.com", +- "tripadvisor.com.mx", +- "183.com.cn", +- "adscendmedia.com", +- "geek.com", +- "thepetitionsite.com", +- "skyscanner.ru", +- "morningpost.com.cn", +- "concursolutions.com", +- "camplace.com", +- "smarturl.it", +- "browsershots.org", +- "piktochart.com", +- "elcorreo.com", +- "collegeboard.org", +- "kasikornbank.com", +- "adsoftheworld.com", +- "fakku.net", +- "jpn.org", +- "sahafah.net", +- "rubias19.com", +- "fc2web.com", +- "redsurf.ru", +- "iproperty.com.my", +- "browsersafeguard.com", +- "mmajunkie.com", +- "bangkokbank.com", +- "ovi.com", +- "fap.to", +- "filmygyan.in", +- "edaily.vn", +- "affilorama.com", +- "valuecommerce.ne.jp", +- "softaculous.com", +- "exchanger.ru", +- "html-color-codes.info", +- "hd-xvideos.com", +- "realself.com", +- "geocaching.com", +- "mom.me", +- "stc.com.sa", +- "video-i365.com", +- "umd.edu", +- "jeffbullas.com", +- "kora.com", +- "cyberchimps.com", +- "popupads.ir", +- "chatango.com", +- "gearslutz.com", +- "fout.jp", +- "contactmusic.com", +- "linkcrypt.ws", +- "sophos.com", +- "forum-auto.com", +- "svtplay.se", +- "newsbusters.org", +- "fileswap.com", +- "phpfox.com", +- "denic.de", +- "riverisland.com", +- "encuentra24.com", +- "foxnewsinsider.com", +- "dtdc.com", +- "tayyar.org", +- "thepushbuttonmillionaire.com", +- "brokenlinkcheck.com", +- "ju51.com", +- "stihi.ru", +- "psdgraphics.com", +- "mommyfucktube.com", +- "mangocity.com", +- "routard.com", +- "whicdn.com", +- "socialtriggers.com", +- "e-bookspdf.org", +- "songspk3.in", +- "paginasamarillas.com", +- "webgame.in.th", +- "xxxdessert.com", +- "materiel.net", +- "skillshare.com", +- "tubepleasure.com", +- "paypal.de", +- "yeahmobi.com", +- "torrentz-proxy.com", +- "aircel.com", +- "openask.com", +- "trafficg.com", +- "anthem.com", +- "aleseriale.pl", +- "f-page.ru", +- "hrsmart.com", +- "cbengine.com", +- "startlap.com", +- "spamhaus.org", +- "trovit.com", +- "sporcle.com", +- "xs8.cn", +- "romwe.com", +- "powtoon.com", +- "cybozulive.com", +- "zbiornik.com", +- "cebit.de", +- "flipboard.com", +- "news.am", +- "wm-panel.com", +- "topnews.ru", +- "usp.br", +- "realmadrid.com", +- "fastdist.net", +- "unian.ua", +- "youtube.com/user/PewDiePie", +- "unc.edu", +- "tamu.edu", +- "ip2location.com", +- "americanapparel.net", +- "virtualedge.com", +- "vikatan.com", +- "goodlayers.com", +- "feedblitz.com", +- "dateinasia.com", +- "freepdfconvert.com", +- "iweb.com", +- "lachainemeteo.com", +- "aetna.com", +- "ti.com", +- "gratisjuegos.org", +- "webhostinghub.com", +- "preev.com", +- "holidayiq.com", +- "elpais.com.uy", +- "uchicago.edu", +- "telcel.com", +- "feebbo.com", +- "webhallen.com", +- "dmir.ru", +- "emailmg.ipage.com", +- "hrs.de", +- "propakistani.pk", +- "theme.co", +- "bigpara.com", +- "finishline.com", +- "fardanews.com", +- "nat.gov.tw", +- "stoloto.ru", +- "sermepa.es", +- "radaris.com", +- "softportal.com", +- "turkiye.gov.tr", +- "nnn.ru", +- "e-familynet.com", +- "wenkang.cn", +- "teamworkpm.net", +- "videohelp.com", +- "pixmania.com", +- "games.com", +- "guns.ru", +- "plus28.com", +- "pf.pl", +- "pbworks.com", +- "sedo.de", +- "freedownloadscenter.com", +- "backpackers.com.tw", +- "mycokerewards.com", +- "chinaunix.net", +- "invisionapp.com", +- "wordhippo.com", +- "unitezz.com", +- "yan.vn", +- "sonhoo.com", +- "spielaffe.de", +- "d.pr", +- "technologyreview.com", +- "democraticunderground.com", +- "molotok.ru", +- "watchever.de", +- "wdc.com", +- "torg.com", +- "ivillage.com", +- "portableapps.com", +- "ovh.es", +- "vse.kz", +- "alrajhibank.com.sa", +- "dhl-usa.com", +- "pingan.com", +- "excite.com", +- "cincodias.com", +- "marksdailyapple.com", +- "bter.com", +- "nationaljournal.com", +- "fao.org", +- "oddee.com", +- "digitalriver.com", +- "livescore.in", +- "siilu.com", +- "gofirstrowus.eu", +- "alquds.co.uk", +- "autoevolution.com", +- "zerx.ru", +- "trovit.it", +- "hvylya.org", +- "carters.com", +- "shejis.com", +- "radio-canada.ca", +- "vodafone.es", +- "sky.fm", +- "maturetube.com", +- "virtualtourist.com", +- "line25.com", +- "rzeczpospolita.pl", +- "megacurioso.com.br", +- "beliefnet.com", +- "eklablog.com", +- "hbo.com", +- "bsi.ir", +- "fastweb.it", +- "webrazzi.com", +- "telam.com.ar", +- "downloadming.me", +- "bluefly.com", +- "thewire.com", +- "erotube.org", +- "vt.edu", +- "jsbin.com", +- "ibosocial.com", +- "brides.com.cn", +- "jn.pt", +- "togetter.com", +- "olhardigital.uol.com.br", +- "ebookee.org", +- "socialgamenet.com", +- "romaniatv.net", +- "epweike.com", +- "pronto.com", +- "blog.pl", +- "top81.cn", +- "flagfox.wordpress.com", +- "unionbank.com", +- "visitkorea.or.kr", +- "blogspot.dk", +- "fermasosedi.ru", +- "inmobi.com", +- "abc.com.py", +- "iqoo.me", +- "17k.com", +- "onlineapplicationsdownloads.com", +- "komli.com", +- "tala.ir", +- "videopremium.me", +- "job.ru", +- "sunbiz.org", +- "tw116.com", +- "browserstack.com", +- "youtu.be", +- "yardbarker.com", +- "flvmplayer.com", +- "kulichki.net", +- "gravity.com", +- "levelclix.com", +- "kissanime.com", +- "insightexpressai.com", +- "colorhexa.com", +- "citizensbankonline.com", +- "hjenglish.com", +- "voeazul.com.br", +- "paraskhnio.gr", +- "es.tl", +- "busuu.com", +- "appsumo.com", +- "metacrawler.com", +- "ciku5.com", +- "android-hilfe.de", +- "laterooms.com", +- "google.com.bn", +- "gamefront.com", +- "rev2pub.com", +- "bharatiyamobile.com", +- "publicidees.com", +- "jossandmain.com", +- "babycentre.co.uk", +- "zetabux.com", +- "movieweb.com", +- "timescity.com", +- "dnevnik.ru", +- "nlcafe.hu", +- "magazine3k.com", +- "irancell.ir", +- "kalaydo.de", +- "e5.ru", +- "lecai.com", +- "sbs.com.au", +- "sierratradingpost.com", +- "girlfriendvideos.com", +- "ink361.com", +- "corporate-ir.net", +- "allgameshome.com", +- "povarenok.ru", +- "typo3.org", +- "turbosquid.com", +- "miniurls.co", +- "thinkwithgoogle.com", +- "haber3.com", +- "newsmeback.com", +- "sipse.com", +- "osxdaily.com", +- "9lessons.info", +- "cyclopaedia.net", +- "reallifecam.com", +- "gameblog.fr", +- "colourbox.com", +- "mixedmartialarts.com", +- "prostoporno.net", +- "chanel.com", +- "maxim.com", +- "cam4.es", +- "olx.com.mx", +- "newscientist.com", +- "netcombo.com.br", +- "serienjunkies.org", +- "shablol.com", +- "bnpparibasfortis.be", +- "canada.com", +- "timeslive.co.za", +- "cinematoday.jp", +- "21cineplex.com", +- "bodisparking.com", +- "cruisecritic.com", +- "vertoz.com", +- "glosbe.com", +- "nstarikov.ru", +- "epinions.com", +- "colbertnation.com", +- "marketglory.com", +- "emailmeform.com", +- "angloinfo.com", +- "filfan.com", +- "yougetsignal.com", +- "broker.to", +- "quickbux.net", +- "gottabemobile.com", +- "beyondtherack.com", +- "tripadvisor.ru", +- "jschina.com.cn", +- "registraduria.gov.co", +- "thisoldhouse.com", +- "appcelerator.com", +- "noticias24carabobo.com", +- "skelbiu.lt", +- "ru.wix.com", +- "iransong.com", +- "i-sux.com", +- "telerama.fr", +- "mydala.com", +- "pia.jp", +- "fusebux.com", +- "biquge.com", +- "microworkers.com", +- "onlywire.com", +- "fanbox.com", +- "ambitoweb.com", +- "tripadvisor.com.br", +- "postgresql.org", +- "telenet.be", +- "thegeekstuff.com", +- "primelocation.com", +- "ee.co.uk", +- "phoenixads.co.in", +- "brigitte.de", +- "360kad.com", +- "kathimerini.gr", +- "batoto.net", +- "babebuns.com", +- "webimpresion.com", +- "olx.com.ng", +- "which.co.uk", +- "f5haber.com", +- "cic.fr", +- "talkfusion.com", +- "ctrlq.org", +- "caracol.com.co", +- "wer-weiss-was.de", +- "invisionzone.com", +- "head-fi.org", +- "thingiverse.com", +- "manager-magazin.de", +- "bzwbk.pl", +- "f1news.ru", +- "tweetreach.com", +- "sj998.com", +- "streetdirectory.com", +- "asos.fr", +- "kalahari.com", +- "classiccars.com", +- "bitacoras.com", +- "bravotv.com", +- "beanfun.com", +- "bonappetit.com", +- "fashionara.com", +- "techdirt.com", +- "newlook.com", +- "iyinet.com", +- "mogujie.com", +- "carros.com.br", +- "starfall.com", +- "rp5.ru", +- "pocket-lint.com", +- "homeadvisor.com", +- "webhostbox.net", +- "cameraboys.com", +- "pricerunner.com", +- "worldcarfans.com", +- "meganovosti.net", +- "taxheaven.gr", +- "freewebsitetemplates.com", +- "mr90.ir", +- "cheapflights.co.uk", +- "bankinter.com", +- "euroresidentes.com", +- "bettycrocker.com", +- "filmey.com", +- "sheinside.com", +- "2ememain.be", +- "tu.tv", +- "kugou.com", +- "destructoid.com", +- "todoist.com", +- "karmaloop.com", +- "appadvice.com", +- "html5rocks.com", +- "osdir.com", +- "webisgreat.info", +- "dailyblogtips.com", +- "mca.gov.in", +- "e-estekhdam.com", +- "hlntv.com", +- "proprofs.com", +- "his-j.com", +- "im286.com", +- "mmorpg.com", +- "shooshtime.com", +- "terra.es", +- "lpcloudbox301.com", +- "tubepornstars.com", +- "tableausoftware.com", +- "soccersuck.com", +- "websurf.ru", +- "indiafreestuff.in", +- "pimei.com", +- "colatour.com.tw", +- "fssnet.co.in", +- "maxpark.com", +- "foodandwine.com", +- "apachefriends.org", +- "standardchartered.co.in", +- "waveapps.com", +- "gosong.net", +- "spring.me", +- "weatherbug.com", +- "iw33.com", +- "apserver.net", +- "thenationonlineng.net", +- "tjournal.ru", +- "greatschools.net", +- "3movs.com", +- "61.com", +- "directpaybiz.com", +- "w3snoop.com", +- "jsonline.com", +- "grainger.com", +- "prevention.com", +- "blizzard.com", +- "baseball-reference.com", +- "cjn.cn", +- "fasthosts.co.uk", +- "kym-cdn.com", +- "cuponation.in", +- "cam4.fr", +- "lalawan67.net", +- "videovantage.co", +- "elimparcial.com", +- "edlen24.com", +- "donya-e-eqtesad.com", +- "englishforums.com", +- "dom2.ru", +- "cinepolis.com", +- "healthtap.com", +- "astroawani.com", +- "autosport.com", +- "finalfantasyxiv.com", +- "valueclickmedia.com", +- "vitaminshoppe.com", +- "apartmentguide.com", +- "notjustok.com", +- "gratispeliculas.org", +- "intporn.com", +- "eroticbeauties.net", +- "egloos.com", +- "nujij.nl", +- "godvine.com", +- "punishtube.com", +- "wisegeek.org", +- "somuch.com", +- "taz.de", +- "zetaboards.com", +- "gravityforms.com", +- "telegraf.rs", +- "odn.ne.jp", +- "topeleven.com", +- "peekyou.com", +- "razerzone.com", +- "furaffinity.net", +- "mobikwik.com", +- "eventful.com", +- "sextube.fm", +- "treccani.it", +- "phatograph.com", +- "feedthebot.com", +- "netdoctor.co.uk", +- "collarme.com", +- "reformal.ru", +- "hemnet.se", +- "jacquieetmicheltv.net", +- "9ku.com", +- "kraloyun.com", +- "directadmin.com", +- "bongda.com.vn", +- "ddizi.org", +- "tedata.net", +- "fb.org", +- "pagemodo.com", +- "satu.kz", +- "nodejs.org", +- "tiberiumalliances.com", +- "wallst.com", +- "dezeen.com", +- "rense.com", +- "hawkhost.com", +- "vonage.com", +- "zjol.com.cn", +- "housefun.com.tw", +- "ad1.ru", +- "myredbook.com", +- "rarlab.com", +- "audiopoisk.com", +- "pbebank.com", +- "whocallsme.com", +- "playground.ru", +- "tnr.com", +- "firstdirect.com", +- "xinhua.jp", +- "gmane.org", +- "verseriesynovelas.com", +- "broadwayworld.com", +- "thefrisky.com", +- "rapmls.com", +- "skapiec.pl", +- "wholesale-dress.net", +- "alison.com", +- "n4hr.com", +- "prefiles.com", +- "vtc.vn", +- "coral.co.uk", +- "azyya.com", +- "smithsonianmag.com", +- "ticksy.com", +- "theync.com", +- "pcinpact.com", +- "eventbrite.co.uk", +- "buenosaires.gob.ar", +- "a5cee7.se", +- "bazingamob.com", +- "pp.cc", +- "shortnews.de", +- "responsinator.com", +- "filepost.com", +- "securefreedom.com", +- "notepad-plus-plus.org", +- "thekrazycouponlady.com", +- "apktops.ir", +- "nr2.ru", +- "timinternet.it", +- "man.lv", +- "forexpeacearmy.com", +- "plius.lt", +- "vcp.ir", +- "mysitecost.ru", +- "yourfiledownloader.com", +- "dealguardian.com", +- "sql.ru", +- "laravel.com", +- "shape5.com", +- "visa.com", +- "vocus.com", +- "stackthatmoney.com", +- "pornicom.com", +- "my.tv.sohu.com/user/cc128", +- "urban-rivals.com", +- "robotstxt.org", +- "colorlabsproject.com", +- "mg.gov.br", +- "local.ch", +- "adbooth.net", +- "se.pl", +- "al-akhbar.com", +- "he.net", +- "covoiturage.fr", +- "sakshieducation.com", +- "thisdaylive.com", +- "thestudentroom.co.uk", +- "pzy.be", +- "designyoutrust.com", +- "forbes.ua", +- "fandongxi.com", +- "expertreviews.co.uk", +- "dream-demo.com", +- "barchart.com", +- "ht.ly", +- "burbuja.info", +- "edgecastcdn.net", +- "amazinglytimedphotos.com", +- "value-domain.com", +- "shareaholic.com", +- "promptfile.com", +- "voetbalzone.nl", +- "ziare.com", +- "trafficbroker.com", +- "coolsport.tv", +- "vanguardia.com.mx", +- "makeshop.jp", +- "mobilism.org", +- "rebelmouse.com", +- "brisbanetimes.com.au", +- "publimetro.com.mx", +- "coolkora.com", +- "realsparrow.com", +- "honda.co.jp", +- "dealcatcher.com", +- "sinoptik.ua", +- "lefeng.com", +- "mamaclub.com", +- "bezuzyteczna.pl", +- "smn.gov.ar", +- "manhub.com", +- "pcgameshardware.de", +- "shipstation.com", +- "zive.cz", +- "disneystore.com", +- "despegar.com.mx", +- "addictivetips.com", +- "path.com", +- "pathofexile.com", +- "seitenreport.de", +- "pardot.com", +- "decathlon.fr", +- "flvrunner.com", +- "xat.com", +- "matchendirect.fr", +- "roem.ru", +- "wat.tv", +- "edline.net", +- "znds.com", +- "northwestern.edu", +- "friendscout24.de", +- "movoto.com", +- "dengiprosto.info", +- "dlisted.com", +- "sports.fr", +- "maxifoot.fr", +- "hubspot.net", +- "natalie.mu", +- "tabloidpulsa.co.id", +- "polki.pl", +- "gamasutra.com", +- "matomeantena.com", +- "adwords-community.com", +- "gallup.com", +- "redtubenacional.com", +- "mangastream.com", +- "zulutrade.com", +- "wunderlist.com", +- "taste.com.au", +- "myhosting.com", +- "totalbeauty.com", +- "8pic.ir", +- "sltrib.com", +- "88db.com", +- "minikoyuncu.com", +- "net4.in", +- "nuevoloquo.com", +- "cago365.com", +- "afip.gob.ar", +- "keep2share.cc", +- "kw.com", +- "terra.com.pe", +- "profi-forex.org", +- "filecloud.io", +- "peliculas4.com", +- "mysitemyway.com", +- "ilmattino.it", +- "geizhals.de", +- "sheershanews.com", +- "whatwpthemeisthat.com", +- "teknosa.com", +- "myshopping.com.au", +- "teamskeet.com", +- "gandalfporn.com", +- "2670.com", +- "peoplefinders.com", +- "elo7.com.br", +- "sofoot.com", +- "uhaul.com", +- "sagepay.com", +- "unb.br", +- "jhu.edu", +- "barrons.com", +- "hasznaltauto.hu", +- "winfxstrategy.com", +- "spamcop.net", +- "az.pl", +- "op.fi", +- "istruzione.it", +- "eveonline.com", +- "imgnip.com", +- "jjoobb.cn", +- "itesm.mx", +- "wptavern.com", +- "kproxy.com", +- "pulptastic.com", +- "quidco.com", +- "ekantipur.com", +- "joann.com", +- "whattoexpect.com", +- "tomshw.it", +- "internetbookshop.it", +- "followerwonk.com", +- "cisionpoint.com", +- "cint.com", +- "quondos.com", +- "suntimes.com", +- "saveinter.net", +- "eiga.com", +- "jdzj.com", +- "goldprice.org", +- "websitemagazine.com", +- "051jk.com", +- "inweb24.com", +- "gamgos.ae", +- "elog-ch.com", +- "trovit.com.mx", +- "webnode.cz", +- "ethnos.gr", +- "oodle.com", +- "subtitulos.es", +- "gameinformer.com", +- "9to5mac.com", +- "youwatch.org", +- "ibps.in", +- "biggerpockets.com", +- "sport24.co.za", +- "my.tv.sohu.com/user/cc133", +- "capsulecrm.com", +- "fuett.mx", +- "poznan.pl", +- "melateiran.com", +- "divxtotal.com", +- "aftabir.com", +- "cyberlink.com", +- "ulozto.cz", +- "jetswap.com", +- "premium.wix.com", +- "eprize.com", +- "huntington.com", +- "careerlink.vn", +- "allhyipmonitors.com", +- "autorambler.ru", +- "jamieoliver.com", +- "minube.com", +- "credomatic.com", +- "oddschecker.com", +- "listia.com", +- "mrrebates.com", +- "8684.cn", +- "kabam.com", +- "tripit.com", +- "gry.pl", +- "ecvv.com", +- "utanbaby.com", +- "lavoixdunord.fr", +- "just-eat.co.uk", +- "go-for-files.com", +- "afpbb.com", +- "mybb.com", +- "madmoizelle.com", +- "sensacine.com", +- "jtl-software.de", +- "worldtimeserver.com", +- "sunmaker.com", +- "marieforleo.com", +- "123sdfsdfsdfsd.ru", +- "duga.jp", +- "avery.com", +- "tvguide.co.uk", +- "salliemae.com", +- "zap.com.br", +- "my.tv.sohu.com/user/cc112", +- "bookmark4you.com", +- "twodollarclick.com", +- "encontreinarede.com", +- "joomshaper.com", +- "marinetraffic.com", +- "feedermatrix.com", +- "nowvideo.at", +- "millenium.org", +- "newalbumreleases.net", +- "frankkern.com", +- "onlineconversion.com", +- "ahlalhdeeth.com", +- "mediawiki.org", +- "xseo.in", +- "generation-nt.com", +- "naftemporiki.gr", +- "hardforum.com", +- "hornbunny.com", +- "my.tv.sohu.com/user/cc124", +- "housing.com", +- "vogue.es", +- "safemls.net", +- "cuisineaz.com", +- "estekhtam.com", +- "coqnu.com", +- "despegar.com.ar", +- "fedoraproject.org", +- "france2.fr", +- "autovit.ro", +- "tradetang.com", +- "levelupgames.uol.com.br", +- "dnforum.com", +- "homebank.kz", +- "carnival.com", +- "hzycsj.com", +- "army.mil", +- "bootsnipp.com", +- "istockimg.com", +- "po-kaki-to.com", +- "qiushibaike.com", +- "tsb.co.uk", +- "gzmama.com", +- "aitnews.com", +- "tripwiremagazine.com", +- "torrenty.org", +- "djangoproject.com", +- "chelseafc.com", +- "gamesgames.com", +- "herold.at", +- "baur.de", +- "kauppalehti.fi", +- "nrelate.com", +- "clickwebinar.com", +- "entropay.com", +- "gridserver.com", +- "virginia.gov", +- "tuan800.com", +- "trueactivist.com", +- "caras.uol.com.br", +- "fontawesome.io", +- "haodou.com", +- "reshareworthy.com", +- "royalcaribbean.com", +- "crakrevenue.com", +- "motika.com.mk", +- "xovi.de", +- "deutsche-startups.de", +- "inven.co.kr", +- "atrapalo.com", +- "ictv.ua", +- "muji.net", +- "kingplayer.com", +- "adworkmedia.com", +- "xjtu.edu.cn", +- "thenounproject.com", +- "professionali.ru", +- "xizhi.com", +- "boo-box.com", +- "customink.com", +- "groupon.my", +- "spartoo.com", +- "bannersdontwork.com", +- "ncore.cc", +- "reklama5.mk", +- "macrojuegos.com", +- "zenhabits.net", +- "te3p.com", +- "utah.gov", +- "telesurtv.net", +- "101.ru", +- "5yi.com", +- "lide.cz", +- "ancestry.co.uk", +- "sana.sy", +- "siteslike.com", +- "vg247.com", +- "tyzhden.ua", +- "ncsu.edu", +- "apherald.com", +- "taaza.com", +- "traffic-delivery.com", +- "uuyoyo.com", +- "hwupgrade.it", +- "game-debate.com", +- "jetpack.wordpress.com", +- "anycodes.com", +- "femina.hu", +- "zattoo.com", +- "acm.org", +- "comenity.net", +- "tarot.com", +- "azadliq.org", +- "advertiserdigital.com", +- "osym.gov.tr", +- "empornium.me", +- "netzero.net", +- "myfico.com", +- "nolix.ru", +- "cnwnews.com", +- "springpad.com", +- "ahangestan.in", +- "localbitcoins.com", +- "nikkei.co.jp", +- "youlikehits.com", +- "boyfriendtv.com", +- "wampserver.com", +- "elnorte.com", +- "codeschool.com", +- "si.edu", +- "nosis.com", +- "downloadhelper.net", +- "global-free-classified-ads.com", +- "flagmantube.com", +- "elnuevodiario.com.ni", +- "handelsbanken.se", +- "sverigesradio.se", +- "femjoy.com", +- "444.hu", +- "calcalist.co.il", +- "asiatech.ir", +- "tv.nu", +- "installmac.com", +- "programmableweb.com", +- "fotki.com", +- "vidivodo.com", +- "websquash.com", +- "selfgrowth.com", +- "wehkamp.nl", +- "amawebs.com", +- "3dlat.com", +- "comunidades.net", +- "streamin.to", +- "idbi.com", +- "cshtracker.com", +- "cdbaby.com", +- "mycommerce.com", +- "united-domains.de", +- "tradingview.com", +- "niniweblog.com", +- "avn.info.ve", +- "apa.tv", +- "pinnaclesports.com", +- "adafruit.com", +- "ipower.com", +- "lebuteur.com", +- "utah.edu", +- "mobeoffice.com", +- "lingualeo.com", +- "fuub.net", +- "tvmongol.com", +- "namasthetelangaana.com", +- "secretsearchenginelabs.com", +- "whowhatwear.com", +- "hiapk.com", +- "torrentz.sx", +- "php.su", +- "sodahead.com", +- "sbb.ch", +- "k12.ca.us", +- "jecontacte.com", +- "thehollywoodgossip.com", +- "pekao24.pl", +- "yourtest-india.com", +- "screwfix.com", +- "humoron.com", +- "yiwugou.com", +- "mulher.uol.com.br", +- "thehackernews.com", +- "shopmania.ro", +- "dlink.com", +- "despegar.com", +- "archlinux.org", +- "nielsen.com", +- "rosnet.ru", +- "appsapk.com", +- "funfarsi.ir", +- "4over.com", +- "subscribe.wordpress.com", +- "lewrockwell.com", +- "portalnet.cl", +- "antenam.info", +- "letribunaldunet.fr", +- "see-tube.com", +- "tureng.com", +- "topcashback.co.uk", +- "contactcars.com", +- "jeux.fr", +- "khan.co.kr", +- "ffffound.com", +- "gmail.com", +- "laprensa.com.ni", +- "jizzhut.com", +- "liilas.com", +- "muare.vn", +- "kting.cn", +- "heteml.jp", +- "genericsteps.com", +- "searchcompletion.com", +- "dwayir.com", +- "dicionarioinformal.com.br", +- "vcita.com", +- "fitsugar.com", +- "kleiderkreisel.de", +- "collective-evolution.com", +- "ethz.ch", +- "sendreach.com", +- "abidjan.net", +- "islamicfinder.org", +- "elong.com", +- "yonhapnews.co.kr", +- "seratnews.ir", +- "stream2watch.me", +- "content-watch.ru", +- "seotechnocrat.com", +- "todaoferta.uol.com.br", +- "toyota.jp", +- "purevid.com", +- "incredimail.com", +- "kia.com", +- "intensedebate.com", +- "kaufmich.com", +- "servis24.cz", +- "brusheezy.com", +- "rtbtraf.com", +- "tejiawang.com", +- "expedia.co.in", +- "food52.com", +- "top-channel.tv", +- "jpnn.com", +- "desitorrents.com", +- "faxingw.cn", +- "crutchfield.com", +- "seneweb.com", +- "usenet.nl", +- "aviasales.ru", +- "nesine.com", +- "appshopper.com", +- "dressupgamesite.com", +- "lowendtalk.com", +- "muslima.com", +- "v-webs.com", +- "linkomanija.net", +- "geniuzz.com", +- "caringbridge.org", +- "gooya.com", +- "dospy.com", +- "siol.net", +- "games.co.id", +- "archiveofourown.org", +- "rocketlawyer.com", +- "free-downloadz.net", +- "pastemagazine.com", +- "invest-system.net", +- "el-ahly.com", +- "todayhumor.co.kr", +- "racingpost.com", +- "stereogum.com", +- "soompi.com", +- "pof.com.br", +- "brainabundance.com", +- "fontpalace.com", +- "canon.jp", +- "eldeforma.com", +- "sacbee.com", +- "jobscore.com", +- "fashionista.com", +- "mywork.vn", +- "thisis50.com", +- "cubadebate.cu", +- "healthguru.com", +- "instatheme.com", +- "apotheken-umschau.de", +- "blizko.ru", +- "tinymce.com", +- "virtualbox.org", +- "tehran.ir", +- "pr.gov.br", +- "mlmleadsystempro.com", +- "resbux.com", +- "komonews.com", +- "childrensplace.com", +- "yoyopress.com", +- "cloudify.cc", +- "24livenewspaper.com", +- "w4.com", +- "islamway.net", +- "fantagazzetta.com", +- "imgspice.com", +- "bovada.lv", +- "payback.de", +- "peb.pl", +- "hotnigerianjobs.com", +- "dev7studios.com", +- "tejaratbank.net", +- "takuhai.jp", +- "travelmath.com", +- "cultofmac.com", +- "wakeupnow.com", +- "insidefacebook.com", +- "mediamarkt.es", +- "500wan.com", +- "rumah123.com", +- "contentmarketinginstitute.com", +- "ed.ac.uk", +- "phimvang.com", +- "womansday.com", +- "lookatme.ru", +- "citizensbank.com", +- "esam.ir", +- "phandroid.com", +- "canadiantire.ca", +- "serienjunkies.de", +- "bbspink.com", +- "yaranehkala.ir", +- "vesti.bg", +- "el-carabobeno.com", +- "smarty.net", +- "6tie.com", +- "antpedia.com", +- "p-world.co.jp", +- "camelcamelcamel.com", +- "sudu.cn", +- "priberam.pt", +- "infoworld.com", +- "myrecipes.com", +- "metrodeal.com", +- "widgetbox.com", +- "krone.at", +- "outfox.tv", +- "mymp4.in", +- "685wo.com", +- "sadanduseless.com", +- "cgd.pt", +- "mrmlsmatrix.com", +- "parenting.com", +- "tradepub.com", +- "linkvehicle.com", +- "mobiledia.com", +- "rghost.ru", +- "xxsy.net", +- "goanimate.com", +- "pikacn.com", +- "metropcs.com", +- "byu.edu", +- "bitelia.com", +- "designscrazed.com", +- "wpde.org", +- "paheal.net", +- "nulled.cc", +- "hmv.co.jp", +- "openx.com", +- "hyundai.com", +- "vvvdj.com", +- "reason.com", +- "livesports.pl", +- "polskieradio.pl", +- "oszone.net", +- "chinhphu.vn", +- "performancehorizon.com", +- "internetretailer.com", +- "skoob.com.br", +- "mediaworld.it", +- "imgrind.com", +- "bancopopular.es", +- "seogadget.ru", +- "m6.fr", +- "rongbay.com", +- "niazpardaz.com", +- "rewity.com", +- "ssense.com", +- "sky-fire.com", +- "flibusta.net", +- "eat24hours.com", +- "lotto.pl", +- "cnw.com.cn", +- "takvim.com.tr", +- "englishtown.com", +- "letudiant.fr", +- "peliculasmas.com", +- "askme.com", +- "linksmanagement.com", +- "webseoanalytics.com", +- "presse-citron.net", +- "eldiariodeamerica.com", +- "instantshift.com", +- "ampxchange.com", +- "xe.gr", +- "experts-exchange.com", +- "sportcategory.com", +- "sharecash.org", +- "linksys.com", +- "yninfo.com", +- "onlinelic.in", +- "aflamneek.com", +- "22.cn", +- "ubuntu-fr.org", +- "cjs.com.cn", +- "mp3clan.com", +- "grani.ru", +- "zen-cart.com", +- "shippingchina.com", +- "jsfor.net", +- "wanadoo.es", +- "zurker.com", +- "chotot.vn", +- "masaladesi.com", +- "insight.ly", +- "trivago.de", +- "neue-sexpartner.com", +- "boe.es", +- "military.com", +- "moonbasa.com", +- "langlaoda.com", +- "tnooz.com", +- "zacks.com", +- "liverpool.com.mx", +- "internic.net", +- "ecuavisa.com", +- "autonews.ru", +- "mcafeesecure.com", +- "peopleclick.com", +- "madthumbs.com", +- "hot-live-chat.com", +- "sugarcrm.com", +- "notonthehighstreet.com", +- "linio.com.co", +- "smartbrief.com", +- "auto-motor-und-sport.de", +- "kyivpost.com", +- "instantteleseminar.com", +- "dillards.com", +- "5i5j.com", +- "runtastic.com", +- "danawa.com", +- "ladunliadi.blogspot.com", +- "getnews.jp", +- "romedic.ro", +- "rodfile.com", +- "instyle.com", +- "swoodoo.com", +- "bannersnack.com", +- "evolife.cn", +- "ktonanovenkogo.ru", +- "office.com", +- "zamalekfans.com", +- "magiran.com", +- "ithome.com", +- "ktrmr.com", +- "spoonful.com", +- "olleh.com", +- "bgr.in", +- "industrialthemes.com", +- "adbkm.com", +- "tsa-algerie.com", +- "bloggang.com", +- "mojang.com", +- "geoiptool.com", +- "autocarindia.com", +- "ajansspor.com", +- "onmeda.de", +- "midwayusa.com", +- "alicdn.com", +- "sportdog.gr", +- "ideeli.com", +- "haspa.de", +- "gladbux.com", +- "porn-star.com", +- "experiandirect.com", +- "yicheshi.com", +- "acervoamador.com", +- "designwall.com", +- "balkanweb.com", +- "response.jp", +- "nettoos.com", +- "beruby.com", +- "manageyourloans.com", +- "kidstaff.com.ua", +- "indeed.co.za", +- "monoprice.com", +- "chsi.com.cn", +- "boorsekala.com", +- "mstaml.com", +- "trafficvance.com", +- "tatatele.in", +- "startbootstrap.com", +- "graphicburger.com", +- "ad-vid-webs.com", +- "jp.dk", +- "one.co.il", +- "athensvoice.gr", +- "payu2blog.com", +- "epidemz.net", +- "dondominio.com", +- "doviz.com", +- "disquscdn.com", +- "work.ua", +- "vsemayki.ru", +- "ikyu.com", +- "songlyrics.com", +- "onlinebank.com", +- "thebump.com", +- "travian.com.tr", +- "java2s.com", +- "twittmate.com", +- "ignou.ac.in", +- "relink.us", +- "4738.com", +- "printvenue.com", +- "tekstowo.pl", +- "natro.com", +- "dengi-tut.info", +- "freeservers.com", +- "inbound.org", +- "free-press-release.com", +- "mydirtyhobby.com", +- "gamefly.com", +- "overclockers.co.uk", +- "eci.nic.in", +- "196.1.211.6", +- "versus.com", +- "batdongsan.com.vn", +- "vrisko.gr", +- "albayan.ae", +- "trendcounter.com", +- "500.com", +- "pagomiscuentas.com", +- "wankoz.com", +- "duote.com", +- "javascript.ru", +- "chevrolet.com", +- "coach.com", +- "decidatriunfar.net", +- "rememberthemilk.com", +- "virginmobileusa.com", +- "google.com.jm", +- "ucm.es", +- "ninja.co.jp", +- "rqzao.com", +- "periodistadigital.com", +- "heritage.org", +- "momtubesex.xxx", +- "vocabulary.com", +- "kupujemprodajem.com", +- "e-cigarette-forum.com", +- "paxum.com", +- "ilpost.it", +- "abercrombie.com", +- "pearsonmylabandmastering.com", +- "echoecho.com", +- "expedia.co.jp", +- "ticketfly.com", +- "colostate.edu", +- "sjtu.edu.cn", +- "seobudget.ru", +- "gigabyte.com", +- "gsmspain.com", +- "misr5.com", +- "enterfactory.com", +- "ciao.de", +- "wuv.de", +- "dagospia.com", +- "slashgear.com", +- "urdupoint.com", +- "themepunch.com", +- "travian.com", +- "discuz.com", +- "pixroute.com", +- "otzovik.com", +- "ubergizmo.com", +- "edreams.fr", +- "internet-positif.org", +- "asmcentral.com", +- "copadomundo.uol.com.br", +- "adjal.com", +- "gotomypc.com", +- "partycity.com", +- "leggo.it", +- "blogosfere.it", +- "teamcoco.com", +- "pricedealsindia.com", +- "glennbeck.com", +- "allyou.com", +- "china.org.cn", +- "xitek.com", +- "photoshopessentials.com", +- "infopraca.pl", +- "boardingarea.com", +- "geni.com", +- "rotaban.ru", +- "foxtab.com", +- "sadistic.pl", +- "socialbro.com", +- "tradesparq.com", +- "itp.ne.jp", +- "swefilmer.com", +- "jobsite.co.uk", +- "topwar.ru", +- "yemeksepeti.com", +- "tokfm.pl", +- "businessinsider.com.au", +- "moe.gov.eg", +- "swedbank.lt", +- "jxgdw.com", +- "bayern.de", +- "alistapart.com", +- "bebinin.com", +- "annunci69.it", +- "plimus.com", +- "cuevana2.tv", +- "viamichelin.fr", +- "whatsmydns.net", +- "tarad.com", +- "hostgator.com.br", +- "hasbro.com", +- "hi-chic.com", +- "driverscollection.com", +- "onetad.com", +- "game2.com.cn", +- "elitepvpers.com", +- "tvuol.uol.com.br", +- "caclubindia.com", +- "diariocorreo.pe", +- "c-rewards.com", +- "business.gov.au", +- "chooseauto.com.cn", +- "timetrade.com", +- "alternate.de", +- "syracuse.com", +- "advanceautoparts.com", +- "shopware.de", +- "newpct.com", +- "proranktracker.com", +- "cex.io", +- "thebot.net", +- "tradekorea.com", +- "legifrance.gouv.fr", +- "cpan.org", +- "rightel.ir", +- "247wallst.com", +- "goldentowns.com", +- "bankifsccode.com", +- "color-hex.com", +- "consumerist.com", +- "juegosdiarios.com", +- "on24.com", +- "stockfreeimages.com", +- "m4.cn", +- "sponsoredtweets.com", +- "open.ac.uk", +- "bilyoner.com", +- "lexisnexis.com", +- "gsu.edu", +- "popscreen.com", +- "stiftung-warentest.de", +- "education.com", +- "leckerficken.de", +- "hostinger.ru", +- "staples.ca", +- "greenpeace.org", +- "mes-meilleurs-films.fr", +- "delish.com", +- "register.it", +- "idiva.com", +- "static.squarespace.com", +- "ololo.fm", +- "basketball-reference.com", +- "tro-ma-ktiko.blogspot.gr", +- "arabianbusiness.com", +- "avianca.com", +- "watchuseek.com", +- "6play.fr", +- "kora-online.tv", +- "armagedomfilmes.biz", +- "531314.com", +- "craigslist.co.uk", +- "inchallah.com", +- "bongdaso.com", +- "toprankblog.com", +- "k12.com", +- "itimes.com", +- "html.net", +- "utsandiego.com", +- "gyakorikerdesek.hu", +- "viddyhddownload.com", +- "wannonce.com", +- "qudong.com", +- "ibicn.com", +- "w3resource.com", +- "socialsecurity.gov", +- "tvn.pl", +- "momsexclipz.com", +- "fstoppers.com", +- "kafeteria.pl", +- "boulanger.fr", +- "guj.nic.in", +- "divaina.com", +- "desktopnexus.com", +- "topseda.ir", +- "payumoney.com", +- "klicktel.de", +- "foxtv.es", +- "cuatro.com", +- "publix.com", +- "astrosage.com", +- "kompass.com", +- "web-hosting.com", +- "nus.edu.sg", +- "jamiiforums.com", +- "lancers.jp", +- "peixeurbano.com.br", +- "buysub.com", +- "yp.com", +- "enstage.com", +- "6eat.com", +- "1ent.com.cn", +- "unionpaysecure.com", +- "pcgames.de", +- "ccidcom.com", +- "lavenir.net", +- "novaposhta.ua", +- "hotpornshow.com", +- "telebank.ru", +- "avaz.ba", +- "doit.com.cn", +- "setlinks.ru", +- "zagat.com", +- "sportmaster.ru", +- "utarget.ru", +- "lingualeo.ru", +- "compucalitv.com", +- "anastasiadate.com", +- "webmaster-rank.info", +- "fastcoexist.com", +- "lavasoft.com", +- "ppvguru.com", +- "greatist.com", +- "knack.be", +- "wowwiki.com", +- "ilcorsaronero.info", +- "jword.jp", +- "750g.com", +- "pantipmarket.com", +- "top.de", +- "photofunia.com", +- "dryicons.com", +- "alweeam.com.sa", +- "dnfight.com", +- "wpolityce.pl", +- "vimeocdn.com", +- "visit-x.net", +- "takungpao.com", +- "perfectworld.eu", +- "kat.ph", +- "hefei.cc", +- "cmse.ru", +- "virginia.edu", +- "fudan.edu.cn", +- "sethgodin.typepad.com", +- "caracaschronicles.com", +- "18qt.com", +- "be2.com.br", +- "rakuten.tw", +- "bukkit.org", +- "miss-no1.com", +- "nts.org.pk", +- "ulozto.net", +- "mixpanel.com", +- "glavred.info", +- "vui.vn", +- "mindspark.com", +- "worldmarket.com", +- "walmart.com.mx", +- "deperu.com", +- "taxact.com", +- "m5zn.com", +- "navy.mil", +- "hibapress.com", +- "cpasbien.com", +- "interjet.com.mx", +- "llbean.com", +- "kenrockwell.com", +- "japan-guide.com", +- "financialpost.com", +- "rankingsinstitute.com", +- "master-x.com", +- "pandawill.com", +- "marketingweek.co.uk", +- "freeforums.org", +- "ysear.ch", +- "pokerstars.com", +- "wired.co.uk", +- "amino.dk", +- "rapidcrush.com", +- "vivanuncios.com", +- "blogsvertise.com", +- "cwb.gov.tw", +- "piter.tv", +- "gistmania.com", +- "topdocumentaryfilms.com", +- "shoghlanty.com", +- "bankmillennium.pl", +- "burberry.com", +- "youporngay.com", +- "webresourcesdepot.com", +- "beachbody.com", +- "asstr.org", +- "pwc.com", +- "competitor.com", +- "rss2search.com", +- "vocuspr.com", +- "behindthename.com", +- "moniker.com", +- "jayde.com", +- "opensuse.org", +- "poemhunter.com", +- "toranoana.jp", +- "interaksyon.com", +- "aeon.co.jp", +- "gungho.jp", +- "fgov.be", +- "xpg.uol.com.br", +- "logic-immo.com", +- "worldsex.com", +- "watchonlineseries.eu", +- "google.co.mz", +- "discas.net", +- "chmail.ir", +- "consumercomplaints.in", +- "allstate.com", +- "twelveskip.com", +- "ibibo.com", +- "noelshack.com", +- "bonprix.ru", +- "directupload.net", +- "equipobimlatino.com", +- "weather2umbrella.com", +- "aibang.com", +- "blog.wordpress.com", +- "turner.com", +- "mediapart.fr", +- "bloog.pl", +- "monotaro.com", +- "online.net", +- "bodmillenium.com", +- "distancesfrom.com", +- "naosalvo.com.br", +- "ap7am.com", +- "focus.ua", +- "cokeandpopcorn.ch", +- "qwant.com", +- "megaplan.ru", +- "sinhvienit.net", +- "dream-marriage.com", +- "voicefive.com", +- "forex.com.cn", +- "xabbs.com", +- "netmums.com", +- "tuxboard.com", +- "cs-cart.com", +- "bitcoin.it", +- "boblil.com", +- "nirsoft.net", +- "neopets.com", +- "spin.com", +- "costco.ca", +- "mirraw.com", +- "ara.cat", +- "klamm.de", +- "glam.com", +- "guenstiger.de", +- "citruspay.com", +- "dnslink.com", +- "guyism.com", +- "shopotam.ru", +- "tim.it", +- "3suisses.fr", +- "gooroops.com", +- "kau.edu.sa", +- "ukbusinessforums.co.uk", +- "gree.jp", +- "komikid.com", +- "redakcja.pl", +- "qpic.cn", +- "voyeurweb.com", +- "mathworks.com", +- "monster.fr", +- "seniat.gob.ve", +- "computrabajo.com.co", +- "xilu.com", +- "madrid.org", +- "ostraining.com", +- "bharian.com.my", +- "telegram.org", +- "sumofus.org", +- "whosdatedwho.com", +- "moreofit.com", +- "meetic.it", +- "femina.mk", +- "itworld.com", +- "indiaglitz.com", +- "cheatcc.com", +- "filmfanatic.com", +- "the-bux.net", +- "very.co.uk", +- "fetishshrine.com", +- "speakingtree.in", +- "iu.edu", +- "modern.az", +- "tak.ru", +- "internetmarketingninjas.com", +- "example.com", +- "sportgeza.hu", +- "wrestlezone.com", +- "jameda.de", +- "caikuu.com", +- "gioco.it", +- "yourtv.com.au", +- "euro.com.pl", +- "anz.co.nz", +- "daft.ie", +- "tirerack.com", +- "vivareal.com.br", +- "definebabe.com", +- "ittefaq.com.bd", +- "lastfm.es", +- "zocalo.com.mx", +- "dpd.de", +- "somethingawful.com", +- "virgin.com", +- "shtyle.fm", +- "viralforest.com", +- "dntrck.com", +- "its-mo.com", +- "q.cc", +- "kinghost.net", +- "elpais.com.co", +- "joomlaspanish.org", +- "sopitas.com", +- "wallbase.cc", +- "cpalead.com", +- "torrentfunk.com", +- "bizcom.com.ru", +- "quizony.com", +- "rcgroups.com", +- "spring.io", +- "kuaidi100.com", +- "xatakandroid.com", +- "mlstatic.com", +- "borsaat.com", +- "jagobd.com", +- "cosmiq.de", +- "crucial.com", +- "cdstm.cn", +- "betclic.fr", +- "telewebion.com", +- "exhentai.org", +- "gnezdo.ru", +- "cebupacificair.com", +- "fusionmls.com", +- "shafaf.ir", +- "ticketmaster.co.uk", +- "adslzone.net", +- "k8.cn", +- "recipdonor.com", +- "in.gov", +- "mforos.com", +- "asscj.com", +- "linkconnector.com", +- "ohfreesex.com", +- "cntraveler.com", +- "scambioetico.org", +- "ladenzeile.de", +- "ntn24.com", +- "beyazperde.com", +- "motherearthnews.com", +- "yupptv.com", +- "220tube.com", +- "fizzle.co", +- "lakii.com", +- "deutsche-wirtschafts-nachrichten.de", +- "saaid.net", +- "bimlatino.com", +- "verisign.com", +- "funpatogh.com", +- "matadornetwork.com", +- "seatguru.com", +- "lululemon.com", +- "uzise.com", +- "networkworld.com", +- "hottube.me", +- "jobsdb.com.hk", +- "life.hu", +- "bonusvid.com", +- "incometaxindiaefiling.gov.in", +- "ey.com", +- "alraimedia.com", +- "allposters.com", +- "authorityroi.com", +- "bmwusa.com", +- "ebaystatic.com", +- "entertainmentcrave.com", +- "ehow.com.br", +- "prisonplanet.com", +- "elnashra.com", +- "email.cz", +- "yes123.com.tw", +- "uitzendinggemist.nl", +- "mindtools.com", +- "atv.com.tr", +- "shoes.net.cn", +- "joomlaportal.de", +- "themoneyconverter.com", +- "meteomedia.com", +- "bankaustria.at", +- "advertise.com", +- "trafficswarm.com", +- "aztecaporno.com", +- "fourseasons.com", +- "movie-blog.org", +- "govdelivery.com", +- "didigames.com", +- "invideo.biz", +- "linux.org.ru", +- "omelete.uol.com.br", +- "babybus.cn", +- "oursogo.com", +- "ero-an.com", +- "mediafax.ro", +- "football.ua", +- "sii.cl", +- "dreamamateurs.com", +- "cheaperthandirt.com", +- "iplocation.net", +- "insideview.com", +- "hihe.vn", +- "stop-sex.com", +- "fubiz.net", +- "url.org", +- "greenmangaming.com", +- "pornup.me", +- "indofeed.com", +- "forumhouse.ru", +- "restaurant.com", +- "key.com", +- "windstream.net", +- "brightedge.com", +- "foreignpolicy.com", +- "noticiasdatv.uol.com.br", +- "logopond.com", +- "datemule.com", +- "webrootanywhere.com", +- "stomp.com.sg", +- "trthaber.com", +- "bitterstrawberry.com", +- "turbo.az", +- "kbs.co.kr", +- "joblo.com", +- "seatimes.com.vn", +- "kuwait.tt", +- "258.com", +- "kp.ua", +- "moviesmobile.net", +- "flamingtext.com", +- "youngt.com", +- "etradenow.cn", +- "copart.com", +- "tuanweihui.com", +- "zinkwaphd.com", +- "adsl.free.fr", +- "infomaniak.ch", +- "re-direcciona.me", +- "mejorenvo.com", +- "instantservice.com", +- "harpersbazaar.com", +- "colorado.edu", +- "belboon.com", +- "telelistas.net", +- "photofans.cn", +- "51seer.com", +- "danjur.com", +- "wunderweib.de", +- "extratorrentlive.com", +- "serpfox.com", +- "androidkade.com", +- "raja.ir", +- "tampabay.com", +- "ser-mujer.org", +- "imasters.com.br", +- "coachfactory.com", +- "mojopages.com", +- "makezine.com", +- "forexschoolonline.com", +- "bochk.com", +- "siamsport.co.th", +- "mdpr.jp", +- "serialssolutions.com", +- "videosexarchive.com", +- "enlnks.com", +- "cision.com", +- "scratchinginfo.com", +- "skidrowgames.net", +- "optimizely.com", +- "video2brain.com", +- "ariva.de", +- "audiomack.com", +- "pimproll.com", +- "house.gov", +- "acs.org", +- "pijamasurf.com", +- "autoc-one.jp", +- "southcn.com", +- "vesti.az", +- "300mbfilms.com", +- "speedmystream.com", +- "wooservers.com", +- "siteliner.com", +- "tinmoi.vn", +- "extremepornvideos.com", +- "cqsq.com", +- "hello-today.com", +- "turkcealtyazi.org", +- "tvyo.com", +- "dealmoon.com", +- "openenglish.com", +- "golfchannel.com", +- "irancloob.com", +- "ebs.in", +- "portalcorreio.uol.com.br", +- "beemp3s.org", +- "condenast.com", +- "mtwebcenters.com.tw", +- "hatelabo.jp", +- "pathci.net", +- "mamsy.ru", +- "noticiasdelmundo.org", +- "guru3d.com", +- "logomaker.com", +- "adhitz.com", +- "swiki.jp", +- "turnitin.com", +- "patoghu.com", +- "carnaval.uol.com.br", +- "cancer.org", +- "clickprime8.com", +- "fahrinfo-berlin.de", +- "unisender.com", +- "flashkhor.com", +- "goodfon.ru", +- "ethiotube.net", +- "cunbang.com", +- "ti-da.net", +- "1phads.com", +- "bien.hu", +- "home77.com", +- "mbabycare.com", +- "vudu.com", +- "fantasy8.com", +- "landrover.com", +- "opencartforum.ru", +- "antena3.ro", +- "getapp.com", +- "torlock.com", +- "wind.it", +- "expatads.com", +- "bloglines.com", +- "sexytube.me", +- "frontier.com", +- "asandownload.com", +- "groupon.pl", +- "storesonlinepro.com", +- "brands4friends.de", +- "infogr.am", +- "webeffector.ru", +- "google.com.mm", +- "ppchero.com", +- "privacystar.com", +- "ocregister.com", +- "liex.ru", +- "kopatheme.com", +- "toggl.com", +- "raywenderlich.com", +- "hecha.cn", +- "vpls.net", +- "manpianyi.com", +- "1881.no", +- "scbeasy.com", +- "plex.tv", +- "selfridges.com", +- "anumex.com", +- "postplanner.com", +- "thisiscolossal.com", +- "you-will-date.com", +- "idealist.org", +- "emarketer.com", +- "anibis.ch", +- "dansmovies.com", +- "footballitarin.com", +- "fragrantica.com", +- "10minutemail.com", +- "ntu.edu.tw", +- "clasicooo.com", +- "onsugar.com", +- "vr-zone.com", +- "walkerplus.com", +- "easymobilerecharge.com", +- "cz001.com.cn", +- "sportsseoul.com", +- "inazumanews2.com", +- "marketingdirecto.com", +- "chartboost.com", +- "unblocked.co", +- "rhymezone.com", +- "portalinmobiliario.com", +- "afrointroductions.com", +- "transunion.com", +- "panorama.it", +- "powershow.com", +- "avval.ir", +- "onlinemeetingnow.com", +- "xoom.com", +- "wnbc.com", +- "tlen.pl", +- "jetairways.com", +- "vtb24.ru", +- "offcn.com", +- "crx7601.com", +- "adverts.ie", +- "kasserver.com", +- "minhavida.com.br", +- "jkpj.com", +- "123contactform.com", +- "imgtiger.com", +- "folha.com.br", +- "npcgo.com", +- "semprot.com", +- "moonfruit.com", +- "jizzbell.com", +- "online-stopwatch.com", +- "allhiphop.com", +- "hackaday.com", +- "digitalplayground.com", +- "careers24.com", +- "cwq.com", +- "wondershare.com", +- "filesend.to", +- "puromarketing.com", +- "workopolis.com", +- "mudainodocument.com", +- "home.ne.jp", +- "shorte.st", +- "tanea.gr", +- "sporza.be", +- "vgorode.ua", +- "google.co.zm", +- "argumentua.com", +- "3m.com", +- "komputerswiat.pl", +- "bongdaplus.vn", +- "supersonicads.com", +- "soundclick.com", +- "lollipop-network.com", +- "lpcloudsvr304.com", +- "313.cn", +- "rtl2.de", +- "ts.cn", +- "mglradio.com", +- "diynetwork.com", +- "komikcaps.net", +- "all-that-is-interesting.com", +- "ultipro.com", +- "frombar.com", +- "sitedeals.nl", +- "codingforums.com", +- "kansascity.com", +- "twtrland.com", +- "cengage.com", +- "lolspotsarticles.com", +- "jackthreads.com", +- "jobstreet.com.sg", +- "diffen.com", +- "eme2000.com", +- "superbru.com", +- "droid-life.com", +- "itb-berlin.de", +- "estibot.com", +- "yourepeat.com", +- "112.ua", +- "70e.com", +- "grid.mk", +- "cromaretail.com", +- "jobstreet.com.ph", +- "gloadmarket.com", +- "gemius.com", +- "huuto.net", +- "vogue.it", +- "divxonline.info", +- "mytoys.de", +- "cashnhits.com", +- "minkchan.com", +- "talabat.com", +- "helpareporter.com", +- "grandascent.com", +- "catalunyacaixa.com", +- "sparwelt.de", +- "tvboxnow.com", +- "imagecurl.org", +- "coocan.jp", +- "eatingwell.com", +- "truelife.com", +- "binaryoptionsbrands.com", +- "foxsportsla.com", +- "jjshouse.com", +- "makaan.com", +- "yamaha.com", +- "activerain.com", +- "excelforum.com", +- "mobinnet.ir", +- "kasikornbankgroup.com", +- "googleplex.com", +- "medianama.com", +- "fullsail.edu", +- "makeupandbeauty.com", +- "marketwired.com", +- "beachbodycoach.com", +- "taloussanomat.fi", +- "youngliving.us", +- "dana.ir", +- "adsgostar.com", +- "esquire.com.cn", +- "meyerweb.com", +- "positivemed.com", +- "harvestapp.com", +- "tim.com.br", +- "sumorobo.net", +- "zbigz.com", +- "schulferien.org", +- "quzhao.com", +- "tsinghua.edu.cn", +- "vogue.com", +- "ecrater.com", +- "internetbs.net", +- "oper.ru", +- "kingstone.com.tw", +- "olympic.org", +- "code.org", +- "wp.tv", +- "adchakra.net", +- "passarela.com.br", +- "damn.com", +- "spn.com.cn", +- "sacitaslan.com", +- "uplod.ir", +- "kununu.com", +- "englishclub.com", +- "ibood.com", +- "buzzfed.com", +- "peopledaily.com.cn", +- "vivastreet.it", +- "adshostnet.com", +- "npmjs.org", +- "lovethatsex.com", +- "garena.tw", +- "hq-sex-tube.com", +- "tvsubtitles.net", +- "trademarkia.com", +- "96down.com", +- "morhipo.com", +- "chuguoqu.com", +- "free-css.com", +- "getsecuredfiles.com", +- "justia.com", +- "paypal-community.com", +- "wezoner.com", +- "google-analytics.com", +- "outsideonline.com", +- "simplymeasured.com", +- "wattsupwiththat.com", +- "vancl.com", +- "leadership.ng", +- "plaisio.gr", +- "fastcocreate.com", +- "fewo-direkt.de", +- "dedecms.com", +- "bostonherald.com", +- "elmundo.com.ve", +- "idhostinger.com", +- "animaljam.com", +- "infoq.com", +- "exler.ru", +- "leprosorium.ru", +- "avis.com", +- "ulusalpost.com", +- "namnak.com", +- "goindigo.in", +- "activeboard.com", +- "fatsecret.com", +- "4umf.com", +- "porn-w.org", +- "sarkariexam.co.in", +- "patagonia.com", +- "3u5.net", +- "roshd.ir", +- "netechangisme.com", +- "ojogo.pt", +- "ujipin.com", +- "topuniversities.com", +- "consequenceofsound.net", +- "no-ip.biz", +- "webdesignerwall.com", +- "fin24.com", +- "openculture.com", +- "pbh2.com", +- "dota2.com", +- "secureupload.eu", +- "alfajertv.com", +- "canlidizihdtv.com", +- "muffingroup.com", +- "imageforum.com", +- "paris.fr", +- "kaufda.de", +- "pelis24.com", +- "ixian.cn", +- "ebenpagan.com", +- "sportsauthority.com", +- "wish.com", +- "ganeshaspeaks.com", +- "meritnation.com", +- "ijie.com", +- "vodafone.com.tr", +- "trovit.es", +- "farsisubtitle.com", +- "musawvir.com", +- "resellerratings.com", +- "soyentrepreneur.com", +- "samakal.net", +- "dietnavi.com", +- "55tuan.com", +- "elcomercio.com", +- "hereisthecity.com", +- "buienradar.nl", +- "arenabg.com", +- "indiansexstories.net", +- "slideboom.com", +- "findsection.net", +- "rankrecon.com", +- "e-radio.gr", +- "cnn.co.jp", +- "gucci.com", +- "natura.net", +- "googlesyndication.com", +- "advancedwebranking.com", +- "lib.ru", +- "sfora.pl", +- "uci.edu", +- "haaretz.co.il", +- "ing.be", +- "yokboylebirsey.com.tr", +- "myfact.tv", +- "yenibiris.com", +- "stuff.tv", +- "dn.pt", +- "whydontyoutrythis.com", +- "nediyor.com", +- "worldoftanks.asia", +- "megamillions.com", +- "elemanonline.net", +- "computrabajo.com.pe", +- "arxiv.org", +- "livescore.tv", +- "aintitcool.com", +- "girlschannel.net", +- "madbid.com", +- "tadawul.com.sa", +- "liqpay.com", +- "softonic.jp", +- "alhilal.com", +- "bizpowa.com", +- "thatguywiththeglasses.com", +- "yemeneconomist.com", +- "pazar3.mk", +- "repai.com", +- "1jux.net", +- "solvusoft.com", +- "yotpo.com", +- "cuantocabron.com", +- "ba.gov.br", +- "arin.net", +- "loginza.ru", +- "homebank.ro", +- "0755car.com", +- "carscoops.com", +- "antarvasna.com", +- "tizag.com", +- "offerpop.com", +- "techmeme.com", +- "ipress.ua", +- "emuparadise.me", +- "sexvidx.com", +- "whatseek.com", +- "become.co.jp", +- "snapfish.com", +- "gsis.gr", +- "speedyshare.com", +- "uncrate.com", +- "doda.jp", +- "straighttalk.com", +- "rsjoomla.com", +- "vozpopuli.com", +- "gotprint.net", +- "finansbank.com.tr", +- "chinatrust.com.tw", +- "stratoserver.net", +- "icnetwork.co.uk", +- "getpopcornti.me", +- "pornper.com", +- "3dmgame.com", +- "squirt.org", +- "mbusa.com", +- "katespade.com", +- "skat.dk", +- "radiko.jp", +- "dexonline.ro", +- "bicaps.net", +- "bitsoma.com", +- "brasil247.com", +- "alittlemarket.com", +- "bd-pratidin.com", +- "amorincontro.com", +- "bigxvideos.com", +- "nissan.co.jp", +- "incomediary.com", +- "theranking.com", +- "el7l.co", +- "webcamtoy.com", +- "steamgifts.com", +- "miles-and-more.com", +- "szonline.net", +- "blocked-website.com", +- "kaztorka.org", +- "avforums.com", +- "indulgy.com", +- "extendcp.co.uk", +- "yonkis.com", +- "ad1111.com", +- "unionbankph.com", +- "job.com", +- "samanepay.com", +- "aceona.com", +- "kar.nic.in", +- "tipico.com", +- "sa.ae", +- "froma.com", +- "songza.com", +- "calciomercato.com", +- "besaba.com", +- "x-rates.com", +- "arsys.es", +- "sisal.it", +- "amateur.tv", +- "designyourway.net", +- "alpha.gr", +- "nimble.com", +- "livefreefun.com", +- "wipo.int", +- "webssearches.com", +- "vodjk.com", +- "91tiger.com", +- "swisscom.com", +- "tuvaro.com", +- "parsonline.net", +- "uolhost.com.br", +- "cnwest.com", +- "roksa.pl", +- "socialmention.com", +- "unibytes.com", +- "screamingfrog.co.uk", +- "owncloud.org", +- "jacquielawson.com", +- "openclipart.org", +- "zimbra.com", +- "poczta-polska.pl", +- "hayah.cc", +- "ringtonematcher.com", +- "emai.com", +- "wealink.com", +- "celebzen.com", +- "pichost.me", +- "rediffmail.com", +- "dinos.co.jp", +- "netvasco.com.br", +- "meilele.com", +- "career.ru", +- "signupgenius.com", +- "screencast-o-matic.com", +- "nav.no", +- "reactiongifs.com", +- "italki.com", +- "mo.gov", +- "bandsintown.com", +- "elwatan.com", +- "jdate.com", +- "quiente.net", +- "skynet.be", +- "googlekeywordtool.com", +- "nubilefilms.com", +- "memedeportes.com", +- "rewardingzonez.com", +- "litmus.com", +- "iyaxin.com", +- "collegeconfidential.com", +- "semperplugins.com", +- "sofort.com", +- "ineedhits.com", +- "live24.gr", +- "acronymfinder.com", +- "jobui.com", +- "9show.com", +- "thedirty.com", +- "tsutaya.co.jp", +- "9787.com", +- "brighthouse.com", +- "boxingscene.com", +- "indeed.com.br", +- "morazzia.com", +- "privatejobshub.blogspot.in", +- "searchenginepeople.com", +- "pozdravok.ru", +- "watchstore.com.cn", +- "rts.ch", +- "pluska.sk", +- "villagevoice.com", +- "sprintrade.com", +- "conversionxl.com", +- "evsuite.com", +- "bci.cl", +- "lampsplus.com", +- "gossipcop.com", +- "valuecommerce.com", +- "zalora.co.id", +- "fastshop.com.br", +- "hockeysfuture.com", +- "bootply.com", +- "chinavasion.com", +- "menards.com", +- "kinobar.net", +- "tokyodisneyresort.jp", +- "knownhost.com", +- "ozbargain.com.au", +- "olx.com.ve", +- "sgk.gov.tr", +- "berliner-sparkasse.de", +- "bancogalicia.com.ar", +- "joomla-master.org", +- "augsburger-allgemeine.de", +- "kroger.com", +- "pulse.ng", +- "putlocker.com", +- "jrtj.com", +- "tapuz.co.il", +- "madhyamam.com", +- "donews.com", +- "showhaber.com", +- "allxnxx.com", +- "uned.es", +- "adsharebux.com", +- "d-addicts.com", +- "banki.ir", +- "levi.com", +- "e97527f0.se", +- "entertainmentwise.com", +- "xvideos-field.com", +- "naver.net", +- "urbia.de", +- "fashionsfriend.com", +- "emuch.net", +- "yelp.fr", +- "metatube.com", +- "sina.com.hk", +- "omb100.com", +- "grameenphone.com", +- "stylebook.de", +- "funny-games.biz", +- "googlewebmastercentral.blogspot.com", +- "vogella.com", +- "surveymonkey.net", +- "forex4you.org", +- "mex.tl", +- "online-fish-games.com", +- "millenniumbcp.pt", +- "fileom.com", +- "friendorfollow.com", +- "downloads.nl", +- "typekit.com", +- "gongkong.com", +- "iqoption.com", +- "tori.fi", +- "smartsource.com", +- "1616.net", +- "1shoppingcart.com", +- "novosti.rs", +- "yofond.com", +- "idokep.hu", +- "motor.ru", +- "xbiao.com", +- "colorcombos.com", +- "pway.cn", +- "egynews.net", +- "elshaab.org", +- "telus.com", +- "olx.com.co", +- "cctvcj.com", +- "kpopstarz.com", +- "razorsocial.com", +- "ncrypt.in", +- "zonetheme.com", +- "gumroad.com", +- "e-shop.gr", +- "kugli.com", +- "levif.be", +- "bookfi.org", +- "globalresearch.ca", +- "sas.com", +- "cloudaccess.net", +- "uplooder.net", +- "exposedwebcams.com", +- "1prime.ru", +- "webappers.com", +- "crocko.com", +- "remax.com", +- "ikco.com", +- "dinside.no", +- "winbank.gr", +- "mijnwoordenboek.nl", +- "weatherzone.com.au", +- "allday2.com", +- "sunat.gob.pe", +- "getit.in", +- "entrance-exam.net", +- "i2ya.com", +- "tlife.gr", +- "qyer.com", +- "calibre-ebook.com", +- "internetcorkboard.com", +- "unitedhyipleague.com", +- "spyrestudios.com", +- "metal-archives.com", +- "aeromexico.com", +- "cv-library.co.uk", +- "bdr1.net", +- "aremo.com.br", +- "blip.tv", +- "afilio.com.br", +- "renewalcoupons.com", +- "proxfree.com", +- "magix.com", +- "jobs.net", +- "souism.com", +- "adtcstrk.com", +- "goodhousekeeping.com", +- "lastfm.ru", +- "sharecare.com", +- "porn.xxx", +- "deathandtaxesmag.com", +- "unocero.com", +- "wer-kennt-wen.de", +- "hotfrog.com", +- "intraship.de", +- "press24.mk", +- "yournewscorner.com", +- "rbc.com", +- "eventure.com", +- "minglebox.com", +- "legendas.tv", +- "drp.su", +- "voicefrom.me", +- "venezuelaaldia.com", +- "cooks.com", +- "numbeo.com", +- "chilehardware.cl", +- "cryptocointalk.com", +- "venusfactor.com", +- "recruitmentcareer.in", +- "larazon.es", +- "sptechs.com", +- "asx.com.au", +- "ahlife.com", +- "st001.com", +- "actudesfinances.info", +- "talkarcades.com", +- "nitori-net.jp", +- "chinahr.com", +- "websitetestlink.com", +- "hypem.com", +- "demorgen.be", +- "sharefile.com", +- "prensalibre.com", +- "eldia.com.ar", +- "billiger.de", +- "3docean.net", +- "streamsend.com", +- "tuaw.com", +- "portafolio.co", +- "trivago.com", +- "olxpix.com", +- "geotrust.com", +- "torrentgun.net", +- "enha.kr", +- "pcastuces.com", +- "t.cn", +- "dimsemenov.com", +- "cam4.nl", +- "basspro.com", +- "macupdate.com", +- "strawpoll.me", +- "elintransigente.com", +- "homeaway.co.uk", +- "my.ecwid.com", +- "graphpaperpress.com", +- "architonic.com", +- "flowplayer.org", +- "syshl.com", +- "18schoolgirlz.com" +- }); +- +- return urls; ++std::vector const& urls_large_data() { ++ static const std::vector hosts{"127.0.0.1", "127.0.0.1", "127.0.0.1"}; ++ return hosts; + } +--- upstream/http/client/crawl/urls_large_data.hpp ++++ browser/http/client/crawl/urls_large_data.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -12,7 +29,6 @@ + + #include + +-std::vector const& +-urls_large_data(); ++std::vector const& urls_large_data(); + + #endif +--- upstream/http/client/methods/http_client_methods.cpp ++++ browser/http/client/methods/http_client_methods.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,27 +33,24 @@ + + //[example_http_client_methods + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from +- ++using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request +-void do_get(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_get(beast::browser::http_byte_stream& stream, ++ http::request& req, beast::flat_buffer buffer, ++ http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); +@@ -43,11 +58,9 @@ + } + + // perform a head request +-void do_head(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_head(beast::browser::http_byte_stream& stream, ++ http::request& req, beast::flat_buffer buffer, ++ http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); +@@ -68,106 +81,88 @@ + res = p.release(); + } + +- + // perform a patch request +-void do_patch(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_patch(beast::browser::http_byte_stream& stream, ++ http::request& req, beast::flat_buffer buffer, ++ http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // perform a put request +-void do_put(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_put(beast::browser::http_byte_stream& stream, ++ http::request& req, beast::flat_buffer buffer, ++ http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; +- req.prepare_payload(); // set content-length based on the body ++ req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); + } + + // perform a post request +-void do_post(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_post(beast::browser::http_byte_stream& stream, ++ http::request& req, beast::flat_buffer buffer, ++ http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // perform a delete request +-void do_delete(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_delete(beast::browser::http_byte_stream& stream, ++ http::request& req, beast::flat_buffer buffer, ++ http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // Performs an HTTP request against httpbin.cpp.al and prints request & response +-int main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 2) +- { +- std::cerr << +- "Usage: http-client-method \n" << +- "Example:\n" << +- " http-client-method get\n" << +- " http-client-method post\n"; ++ if (argc != 2) { ++ std::cerr << "Usage: http-client-method \n" ++ << "Example:\n" ++ << " http-client-method get\n" ++ << " http-client-method post\n"; + return EXIT_FAILURE; + } + +- for (char * c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) + *c = static_cast(std::tolower(*c)); + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); +- beast::tcp_stream stream(ioc); ++ webcpp::asio::ip::tcp::resolver resolver(ioc); ++ beast::tcp_stream transport(ioc); ++ beast::browser::http_byte_stream stream(transport); + + // Look up the domain name +- auto const results = resolver.resolve("httpbin.cpp.al", "http"); ++ auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup +- stream.connect(results); +- ++ transport.connect(results); + + // Set up an HTTP GET request message + http::request req; +- req.set(http::field::host, "httpbin.cpp.al"); +- req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); +- ++ req.set(http::field::host, webcpp_fixture::host()); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; +@@ -187,35 +182,29 @@ + do_post(stream, req, buffer, res); + else if (method == "delete") + do_delete(stream, req, buffer, res); +- else +- { ++ else { + std::cerr << "Unknown method: " << method << std::endl; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" +- << req << std::endl; +- ++ std::cout << "Request send:\n-----------------------------\n" << req << std::endl; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" +- << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ transport.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -223,3 +212,28 @@ + } + + //] ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ for (const auto* method : {"get", "head", "post", "put", "patch", "delete"}) { ++ std::vector storage{"http-client-methods", method}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("200 OK") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-methods: passed\n"; ++ return 0; ++} +--- upstream/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ browser/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,36 +31,31 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include + #include + #include +-#include ++#include + #include + #include ++#include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = net::ssl; // from +-using tcp = net::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = webcpp::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-sync-ssl []\n" << +- "Example:\n" << +- " http-client-sync-ssl www.example.com 443 /\n" << +- " http-client-sync-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-sync-ssl []\n" ++ << "Example:\n" ++ << " http-client-sync-ssl www.example.com 443 /\n" ++ << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -51,28 +64,23 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx(ssl::context::tlsv12_client); ++ ssl::context ctx(ssl::context::tls_client); + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + +- // These objects perform our I/O +- tcp::resolver resolver(ioc); +- ssl::stream stream(ioc, ctx); ++ // These objects perform our I/O ++ webcpp::asio::ip::tcp::resolver resolver(ioc); ++ beast::ssl_stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host)) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); +- } ++ beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); +@@ -89,7 +97,6 @@ + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); +- req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); +@@ -127,13 +134,36 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (bool(ec)) + throw beast::system_error{ec}; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-sync-ssl", "127.0.0.1", port, "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-sync-ssl: passed\n"; ++ return 0; ++} +--- upstream/http/client/sync/http_client_sync.cpp ++++ browser/http/client/sync/http_client_sync.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,33 +32,30 @@ + + //[example_http_client + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-sync []\n" << +- "Example:\n" << +- " http-client-sync www.example.com 80 /\n" << +- " http-client-sync www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-sync []\n" ++ << "Example:\n" ++ << " http-client-sync www.example.com 80 /\n" ++ << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -50,10 +64,10 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +@@ -65,7 +79,6 @@ + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); +- req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); +@@ -89,13 +102,11 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -103,3 +114,28 @@ + } + + //] ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"http-client-sync", "127.0.0.1", port, "/http"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application http-client-sync: passed\n"; ++ return 0; ++} +--- upstream/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,76 +32,54 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include +-#include ++#include ++#include ++ + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = webcpp::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; +- websocket::stream> ws_; ++class session : public std::enable_shared_from_this { ++ webcpp::asio::ip::tcp::resolver resolver_; ++ websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- session(net::strand ex, ssl::context& ctx) +- : resolver_(ex) +- , ws_(ex, ctx) +- { +- } ++ session(net::strand ex, ssl::context& ctx) ++ : resolver_(ex), ws_(ex, ctx) {} ++ + public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. +- explicit +- session(ssl::context& ctx) +- : session(net::make_strand(net::system_executor{}), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; +- std::cerr << ec.message() << "\n"; +- return; +- } ++ beast::set_server_name(ws_.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); +@@ -93,19 +90,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -113,16 +102,12 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -136,15 +121,11 @@ + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_ssl_handshake, +- shared_from_this())); +- } +- +- void +- on_ssl_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); ++ } ++ ++ void on_ssl_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -152,79 +133,48 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-ssl"); +- })); ++ /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -236,38 +186,61 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int application_main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async-ssl \n" << +- "Example:\n" << +- " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async-ssl \n" ++ << "Example:\n" ++ << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + +- ++ webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +- ssl::context ctx{ssl::context::tlsv12_client}; ++ ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // Launch the asynchronous operation +- std::make_shared(ctx)->run(host, port, text); ++ std::make_shared(ioc, ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. +- net::query(net::system_executor(), net::execution::context).join(); ++ ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"websocket-client-async-ssl-system-executor", "127.0.0.1", ++ port, "Beast fixture echo"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application websocket-client-async-ssl-system-executor: passed\n"; ++ return 0; ++} +--- upstream/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,68 +32,47 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include +-#include ++#include ++#include ++ + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = webcpp::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; +- websocket::stream> ws_; ++class session : public std::enable_shared_from_this { ++ webcpp::asio::ip::tcp::resolver resolver_; ++ websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc, ssl::context& ctx) +- : resolver_(net::make_strand(ioc)) +- , ws_(net::make_strand(ioc), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; +- std::cerr << ec.message() << "\n"; +- return; +- } ++ beast::set_server_name(ws_.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); +@@ -85,19 +83,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -105,38 +95,30 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +- ++ + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); +- ++ + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_ssl_handshake, +- shared_from_this())); +- } +- +- void +- on_ssl_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); ++ } ++ ++ void on_ssl_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -144,79 +126,48 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-ssl"); +- })); ++ /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -228,15 +179,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int application_main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async-ssl \n" << +- "Example:\n" << +- " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async-ssl \n" ++ << "Example:\n" ++ << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -244,23 +192,49 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ssl::context::tlsv12_client}; ++ ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"websocket-client-async-ssl", "127.0.0.1", port, ++ "Beast fixture echo"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application websocket-client-async-ssl: passed\n"; ++ return 0; ++} +--- upstream/websocket/client/async/websocket_client_async.cpp ++++ browser/websocket/client/async/websocket_client_async.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,34 +31,31 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; +@@ -48,39 +63,22 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc) +- : resolver_(net::make_strand(ioc)) +- , ws_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) ++ : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout for the operation +@@ -88,16 +86,12 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Turn off the timeout on the tcp_stream, because +@@ -105,18 +99,10 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async"); +- })); ++ /* Browser owns handshake User-Agent. */ + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -125,64 +111,41 @@ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); +- ++ + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -194,15 +157,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int application_main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async \n" << +- "Example:\n" << +- " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async \n" ++ << "Example:\n" ++ << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -210,14 +170,40 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"websocket-client-async", "127.0.0.1", port, ++ "Beast fixture echo"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application websocket-client-async: passed\n"; ++ return 0; ++} +--- upstream/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ browser/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -16,8 +34,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -25,27 +43,25 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; ++namespace net = boost::asio; + + // Sends a WebSocket message and prints the response +-net::awaitable +-do_session(std::string host, std::string port, std::string text) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string text) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = websocket::stream{ executor }; ++ auto resolver = webcpp::asio::ip::tcp::resolver{executor}; ++ auto stream = websocket::stream{executor}; + + // Look up the domain name +- auto const results = co_await resolver.async_resolve(host, port); ++ auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); ++ auto ep = co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -57,33 +73,25 @@ + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket +- stream.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::client)); ++ stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- stream.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set( +- http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake +- co_await stream.async_handshake(host, "/"); ++ co_await stream.async_handshake(host, "/", net::use_awaitable); + + // Send the message +- co_await stream.async_write(net::buffer(text)); ++ co_await stream.async_write(net::buffer(text), net::use_awaitable); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer +- co_await stream.async_read(buffer); ++ co_await stream.async_read(buffer, net::use_awaitable); + + // Close the WebSocket connection +- co_await stream.async_close(websocket::close_code::normal); ++ co_await stream.async_close(websocket::close_code::normal, net::use_awaitable); + + // If we get here then the connection is closed gracefully + +@@ -93,18 +101,13 @@ + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr +- << "Usage: websocket-client-awaitable \n" +- << "Example:\n" +- << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-awaitable \n" ++ << "Example:\n" ++ << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -112,24 +115,18 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, text), +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -138,11 +135,35 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int application_main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } + + #endif ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"websocket-client-awaitable", "127.0.0.1", port, ++ "Beast fixture echo"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application websocket-client-awaitable: passed\n"; ++ return 0; ++} +--- upstream/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,72 +32,61 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include ++#include + +-#include +-#include +-#include + #include + #include +-#include + #include + #include + #include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = webcpp::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-sync-ssl \n" << +- "Example:\n" << +- " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-sync-ssl \n" ++ << "Example:\n" ++ << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const port = argv[2]; ++ auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ssl::context::tlsv12_client}; ++ ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification +- load_root_certificates(ctx); ++ // Browser trust store owns TLS authorities. + + // These objects perform our I/O +- tcp::resolver resolver{ioc}; +- websocket::stream> ws{ioc, ctx}; ++ webcpp::asio::ip::tcp::resolver resolver{ioc}; ++ websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(beast::get_lowest_layer(ws), results); ++ auto ep = beast::get_lowest_layer(ws).connect(results); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); +- } ++ beast::set_server_name(ws.next_layer(), host.c_str()).value(); + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); +@@ -92,13 +100,7 @@ + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws.handshake(host, "/"); +@@ -119,11 +121,35 @@ + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("beastSecurePort").as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"websocket-client-sync-ssl", "127.0.0.1", port, ++ "Beast fixture echo"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application websocket-client-sync-ssl: passed\n"; ++ return 0; ++} +--- upstream/websocket/client/sync/websocket_client_sync.cpp ++++ browser/websocket/client/sync/websocket_client_sync.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,50 +33,46 @@ + + //[example_websocket_client + +-#include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int application_main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-sync \n" << +- "Example:\n" << +- " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-sync \n" ++ << "Example:\n" ++ << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const port = argv[2]; ++ auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver{ioc}; +- websocket::stream ws{ioc}; ++ webcpp::asio::ip::tcp::resolver resolver{ioc}; ++ websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(ws.next_layer(), results); ++ auto ep = ws.next_layer().connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -66,13 +80,7 @@ + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws.handshake(host, "/"); +@@ -93,9 +101,7 @@ + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -103,3 +109,29 @@ + } + + //] ++ ++#include ++#include ++#include ++ ++int main() { ++ const auto port = emscripten::val::global("location")["port"].as(); ++ setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1); ++ setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1); ++ { ++ std::vector storage{"websocket-client-sync", "127.0.0.1", port, ++ "Beast fixture echo"}; ++ std::vector arguments; ++ for (auto& value : storage) ++ arguments.push_back(value.data()); ++ std::ostringstream output; ++ auto* original = std::cout.rdbuf(output.rdbuf()); ++ const auto result = application_main(static_cast(arguments.size()), arguments.data()); ++ std::cout.rdbuf(original); ++ std::cout << output.str(); ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ return 1; ++ } ++ std::cout << "application websocket-client-sync: passed\n"; ++ return 0; ++} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..f2c97b0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,291 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + beast::ssl_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream_, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (static_cast(ec)) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "http-client-async-ssl-system-executor", + "localhost", + port, + "/http", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-async-ssl-system-executor: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..384180d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,281 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + beast::ssl_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream_, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (static_cast(ec)) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-async-ssl", "localhost", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-async-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..e5c051e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/async/http_client_async.cpp @@ -0,0 +1,227 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-async", "127.0.0.1", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-async: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..f68e309 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,227 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = webcpp::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::ssl_stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client, net::use_awaitable); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req, net::use_awaitable); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple(net::use_awaitable)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && static_cast(ec)) { + throw boost::system::system_error(ec, "shutdown"); + } +} + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-awaitable-ssl", "localhost", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-awaitable-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..838a5b9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,186 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results, net::use_awaitable); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req, net::use_awaitable); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-awaitable", "127.0.0.1", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-awaitable: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/body/json_body.hpp new file mode 100644 index 0000000..72165e5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/body/json_body.hpp @@ -0,0 +1,120 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(webcpp::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(webcpp::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/body/json_client.cpp new file mode 100644 index 0000000..7cee5fd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/body/json_client.cpp @@ -0,0 +1,111 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "json_body.hpp" + +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using webcpp::asio::ip::tcp; // from + +namespace { +int application_main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + return 0; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"json_client"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) { + return 1; + } + } + std::cout << "application json_client: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..bcbc525 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/http_crawl.cpp @@ -0,0 +1,341 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + webcpp::asio::ip::tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, webcpp::asio::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. + for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); + } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-crawl", "2"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Success : 3") == std::string::npos) { + return 1; + } + } + std::cout << "application http-crawl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..3abd545 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"127.0.0.1", "127.0.0.1", "127.0.0.1"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..1cca132 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..ebac4d5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/methods/http_client_methods.cpp @@ -0,0 +1,253 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using webcpp::asio::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream transport(ioc); + beast::browser::http_byte_stream stream(transport); + + // Look up the domain name + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + transport.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + transport.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + for (const auto* method : {"get", "head", "post", "put", "patch", "delete"}) { + std::vector storage{"http-client-methods", method}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("200 OK") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-methods: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..db0085d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,182 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tls_client); + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::ssl_stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + stream.shutdown(ec); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (static_cast(ec)) { + throw beast::system_error{ec}; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-sync-ssl", "localhost", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-sync-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..0cff7ff --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/http/client/sync/http_client_sync.cpp @@ -0,0 +1,154 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-sync", "127.0.0.1", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-sync: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/mapping.json new file mode 100644 index 0000000..cd29957 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/mapping.json @@ -0,0 +1,29 @@ +{ + "applications": [ + "http-client-async", + "http-client-async-ssl", + "http-client-async-ssl-system-executor", + "http-client-awaitable", + "http-client-awaitable-ssl", + "json_client", + "http-crawl", + "http-client-methods", + "http-client-sync", + "http-client-sync-ssl", + "websocket-client-async", + "websocket-client-async-ssl", + "websocket-client-async-ssl-system-executor", + "websocket-client-awaitable", + "websocket-client-sync", + "websocket-client-sync-ssl" + ], + "adaptations": [ + "Browser owns DNS, HTTP framing, WebSocket wire protocol and TLS trust.", + "TLS fixture trusts an ephemeral CA only in a fresh Chromium profile.", + "No certificate exception is used; untrusted CA and trusted wrong-host rejection controls accompany HTTPS/WSS exchanges.", + "Guest CA lists, TLS version pinning, and handshake User-Agent removed.", + "System executor and crawler threads use explicit io_context scheduling.", + "Awaitable clients retain co_await with explicit use_awaitable tokens.", + "Driver injects the local browser endpoint and validates response output." + ] +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..19cf053 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,297 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(ws_.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-async-ssl-system-executor", + "localhost", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-async-ssl-system-executor: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..c917ba3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,289 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(ws_.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-async-ssl", + "localhost", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-async-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..e6fbf07 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,254 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-async", + "127.0.0.1", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-async: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..f2c31b8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,185 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = + co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/", net::use_awaitable); + + // Send the message + co_await stream.async_write(net::buffer(text), net::use_awaitable); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer, net::use_awaitable); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal, net::use_awaitable); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-awaitable", + "127.0.0.1", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-awaitable: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..05a5d24 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,172 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).connect(results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(ws.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-sync-ssl", + "localhost", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-sync-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..e01fe28 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/browser/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,154 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = ws.next_layer().connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-sync", + "127.0.0.1", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-sync: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/close_observation.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/close_observation.hpp new file mode 100644 index 0000000..ec6cb91 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/close_observation.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_APPLICATION_CLOSE_OBSERVATION_HPP +#define WEBCPP_BEAST_APPLICATION_CLOSE_OBSERVATION_HPP + +#include +#include +#include +#include + +namespace webcpp_fixture { +// Publish only after the protocol engine has reported its normal closed state. +inline void observe_normal_close() { + const auto* path = std::getenv("WEBCPP_BEAST_FIXTURE_CLOSED"); + if (path == nullptr) { + return; + } + const auto temporary = std::string(path) + ".tmp"; + { + std::ofstream output(temporary); + output << "closed\n"; + output.flush(); + if (!output) { + std::abort(); + } + } + if (std::rename(temporary.c_str(), path) != 0) { + std::abort(); + } +} +} // namespace webcpp_fixture + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/failure.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/failure.hpp new file mode 100644 index 0000000..2ff20c4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/failure.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_APPLICATION_FAILURE_HPP +#define WEBCPP_BEAST_APPLICATION_FAILURE_HPP +#include +#include +#include +#include + +namespace webcpp_fixture { +// Exception-off application counterparts stop at a formerly throwing failure site. +[[noreturn]] inline void fail_stop() { + static_cast( + std::fputs("application failure: exception-off fail-stop counterpart\n", stderr)); + std::abort(); +} + +template +[[nodiscard]] auto resolve(Resolver& resolver, std::string_view host, std::string_view port) { + boost::system::error_code error; + auto results = resolver.resolve(host, port, error); + if (error) { + fail_stop(); + } + return results; +} +} // namespace webcpp_fixture +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/fixture.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/fixture.hpp new file mode 100644 index 0000000..da8c016 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/fixture.hpp @@ -0,0 +1,50 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_APPLICATION_FIXTURE_HPP +#define WEBCPP_BEAST_APPLICATION_FIXTURE_HPP + +#include +#include +#include +#include +#include +#include + +namespace webcpp_fixture { +[[nodiscard]] inline const char* host() { + const auto* value = std::getenv("WEBCPP_BEAST_FIXTURE_HOST"); + return value != nullptr ? value : "localhost"; +} + +[[nodiscard]] inline const char* port() { + const auto* value = std::getenv("WEBCPP_BEAST_FIXTURE_PORT"); + return value != nullptr ? value : "8080"; +} + +[[nodiscard]] inline int integer(const char* text) { + int value = 0; + const auto* end = text + std::strlen(text); + const auto result = std::from_chars(text, end, value); + if (result.ec != std::errc{} || result.ptr != end) { + static_cast(std::fputs("application fixture: invalid integer argument\n", stderr)); + std::abort(); + } + return value; +} + +[[nodiscard]] inline unsigned short port_number() { + const auto value = integer(port()); + if (value < 1 || std::cmp_greater(value, std::numeric_limits::max())) { + static_cast( + std::fputs("application fixture: port is outside the valid range\n", stderr)); + std::abort(); + } + return static_cast(value); +} +} // namespace webcpp_fixture + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/fixture_resolver.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/fixture_resolver.hpp new file mode 100644 index 0000000..c9ad7c6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/fixture_resolver.hpp @@ -0,0 +1,86 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_APPLICATION_FIXTURE_RESOLVER_HPP +#define WEBCPP_BEAST_APPLICATION_FIXTURE_RESOLVER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace webcpp_fixture { +// The application's DNS dependency is explicit: this fixture only resolves its local peer. +// It does not claim WASI provides an asynchronous DNS worker or a system executor. +class resolver { +public: + using executor_type = boost::asio::any_io_executor; + using results_type = boost::asio::ip::basic_resolver_results; + + explicit resolver(executor_type executor) : executor_(std::move(executor)) {} + + explicit resolver(webcpp::asio::io_context& context) : resolver(context.get_executor()) {} + + [[nodiscard]] executor_type get_executor() const { return executor_; } + + static void cancel() {} + + static results_type resolve(std::string_view host, std::string_view port, + boost::system::error_code& ec) { + if (host != "localhost" && host != "127.0.0.1") { + ec = boost::asio::error::host_not_found; + return {}; + } + unsigned value = 0; + for (const char digit : port) { + if (digit < '0' || digit > '9' || value > 6553) { + ec = boost::asio::error::service_not_found; + return {}; + } + value = (value * 10) + static_cast(digit - '0'); + } + if (port.empty() || value > 65535) { + ec = boost::asio::error::service_not_found; + return {}; + } + ec.clear(); + return results_type::create( + {boost::asio::ip::address_v4::loopback(), static_cast(value)}, + std::string(host), std::string(port)); + } + + static results_type resolve(std::string_view host, std::string_view port) { + boost::system::error_code ec; + auto result = resolve(host, port, ec); + if (ec) { + boost::throw_exception(boost::system::system_error(ec)); + } + return result; + } + + template > + auto async_resolve(std::string_view host, std::string_view port, Token&& token = {}) { + return boost::asio::async_initiate( + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [this](auto handler, std::string name, std::string service) { + boost::system::error_code ec; + auto result = resolve(name, service, ec); + boost::asio::post(executor_, + boost::asio::append(std::move(handler), ec, std::move(result))); + }, + token, std::string(host), std::string(port)); + } + +private: + executor_type executor_; +}; +} // namespace webcpp_fixture +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/README.md b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/README.md new file mode 100644 index 0000000..9d8ba1d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/README.md @@ -0,0 +1,43 @@ +# Host HTTP client counterparts + +The host owns HTTP transport, DNS and TLS. These counterparts preserve request and +response semantics through the host API; they do not claim unchanged socket scheduling. +The mapping records each adaptation. The separate `test/applications/host-tls` lane +measures actual HTTPS trust and the documentation client's host-owned mutual TLS. + +The crawler uses the upstream `crawl_report`, counters, status histogram and report +formatting, extracted directly by `tools/prepare_host_clients.py`. Two asynchronous +workers retain the original get-next, complete, aggregate and repeat flow. A single +`wasi::http_context` serializes reporting and advances both host exchanges without +operating-system threads. Worker and message state remain alive through completion. + +Each incoming request body supplies one `authority /absolute-path` pair per line. +The component validates the entire input before starting work, accepts at most 32 +entries of at most 2048 characters, limits each response to 64 KiB, and gives every +exchange a five-second deadline. The result is the original text crawl report plus +`X-Crawl-Completed` and `X-Crawl-Workers` headers. + +The host API combines DNS, connect, request write and response read into one exchange. +A failed exchange increments the report's `Read` counter; the original separate +`Timer`, `Resolve`, `Connect` and `Write` counters remain zero and are unmeasured. +This is an explicit transport-phase adaptation. Non-200 HTTP statuses are successful +reads and enter the status histogram, as in the upstream crawler. A failed exchange +continues to the next target instead of terminating the crawl. + +The bounded test owns two loopback HTTP peers and supplies six distinct authority/path +pairs. A synchronization barrier requires two requests to be active simultaneously. +The peer responses yield two 200s, one 201, one 404, one 503 and one truncated body. +The driver verifies five successful reads, one read failure, all six destinations +exactly once, and continued work after the failure. A second request containing 33 +entries must return 400 without contacting either peer. + +Run the four ABI/exception profiles with configured SDK 34 and Wasmtime 50: + +```sh +b2 toolset=clang-wasip2,clang-wasip3 exception-handling=on,off \ + libs/beast/test/applications/host-clients//http-crawl +``` + +`WASMTIME` overrides the runtime executable; otherwise the driver uses `wasmtime` on +`PATH`. The driver bounds readiness and HTTP waits, then stops the component process, +closes both peers and joins their workers. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/doc-ssl-client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/doc-ssl-client.cpp new file mode 100644 index 0000000..eb7a578 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/doc-ssl-client.cpp @@ -0,0 +1,62 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-local.cpp new file mode 100644 index 0000000..f0a46d2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-local.cpp @@ -0,0 +1,69 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-ssl-system-executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-ssl-system-executor.cpp new file mode 100644 index 0000000..0fbd5a9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-ssl-system-executor.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-ssl.cpp new file mode 100644 index 0000000..edf75fa --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async-ssl.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async.cpp new file mode 100644 index 0000000..b65feea --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-async.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-awaitable-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-awaitable-ssl.cpp new file mode 100644 index 0000000..9acf779 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-awaitable-ssl.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-awaitable.cpp new file mode 100644 index 0000000..9acf779 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-awaitable.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-coro-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-coro-ssl.cpp new file mode 100644 index 0000000..83667ea --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-coro-ssl.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-coro.cpp new file mode 100644 index 0000000..6850578 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-coro.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-methods.cpp new file mode 100644 index 0000000..89b1acd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-methods.cpp @@ -0,0 +1,93 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + const std::array methods = { + http::verb::get, http::verb::head, http::verb::post, + http::verb::put, http::verb::patch, http::verb::delete_, + }; + for (const auto method : methods) { + http::request request{method, "/fixture", 11}; + request.set(http::field::host, authority); + if (method == http::verb::post) { + request.body() = "Some random post data"; + } + if (method == http::verb::put) { + request.body() = "Some random put data"; + } + if (method == http::verb::delete_) { + request.body() = "Some random delete data"; + } + if (method == http::verb::patch) { + request.body() = "Some random patch data"; + } + request.prepare_payload(); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok) { + return failure(error); + } + if (method != http::verb::head && !request.body().empty() && + response.body() != request.body()) { + return failure(error); + } + ++completed; + } + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-sync-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-sync-ssl.cpp new file mode 100644 index 0000000..b9a3b0e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-sync-ssl.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-sync.cpp new file mode 100644 index 0000000..8367bc4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-client-sync.cpp @@ -0,0 +1,70 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\n") { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-crawl.cpp new file mode 100644 index 0000000..ebff1d2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/http-crawl.cpp @@ -0,0 +1,229 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace wasi = beast::wasi; + +namespace { +struct crawl_target { + std::string authority; + std::string path; +}; + +// This structure aggregates statistics on all the sites +class crawl_report { + wasi::http_context& context_; + std::size_t index_ = 0; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + crawl_report(wasi::http_context& context, const std::vector& hosts) + : context_(context), hosts_(hosts) {} + + // Run an aggregation function on the serialized host queue. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + context_.get_executor().post( + [this, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }, + std::allocator{}); + } + + // Returns the next host to check + crawl_target const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return &hosts_[n]; + } + + [[nodiscard]] std::size_t completed() const { return count_; } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Retain the upstream worker's get-next, complete, aggregate and repeat algorithm. +// Host HTTP combines resolution, connect, write and read into one asynchronous exchange. +class worker : public std::enable_shared_from_this { + crawl_report& report_; + wasi::http_context& context_; + std::optional connection_; + http::request req_; + http::response res_; + +public: + worker(crawl_report& report, wasi::http_context& context) : report_(report), context_(context) { + req_.version(11); + req_.method(http::verb::get); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + void run() { do_get_host(); } + + void do_get_host() { + const auto* host = report_.get_host(); + if (host == nullptr) { + return; + } + req_.target(host->path); + req_.set(http::field::host, host->authority); + connection_.emplace("http", host->authority); + res_ = {}; + wasi::transfer_options options; + options.body_limit = 65536; + options.expires_after(5000000000); + wasi::async_perform( + context_, *connection_, req_, res_, + [self = shared_from_this()](boost::system::error_code ec, std::size_t) { + self->on_read(ec); + }, + options); + } + + void on_read(boost::system::error_code ec) { + if (ec) { + // The host does not expose individual socket phases. An unsuccessful complete + // exchange increments Read; the other upstream phase counters remain unmeasured. + report_.aggregate([](crawl_report& report) { ++report.read_failures; }); + } else { + const auto code = res_.result_int(); + report_.aggregate([code](crawl_report& report) { + ++report.success; + ++report.status_codes[code]; + }); + } + connection_.reset(); + do_get_host(); + } +}; + +http::response invalid_targets() { + http::response response{http::status::bad_request, 11}; + response.body() = "Expected 1 to 32 lines containing an authority and an absolute path"; + response.prepare_payload(); + return response; +} + +http::response handle(const http::request& incoming) { + std::vector hosts; + std::istringstream input(incoming.body()); + std::string line; + while (std::getline(input, line)) { + const auto split = line.find(' '); + if (hosts.size() == 32 || split == std::string::npos || split == 0 || + split + 1 >= line.size() || line[split + 1] != '/' || line.size() > 2048) { + return invalid_targets(); + } + hosts.push_back({.authority = line.substr(0, split), .path = line.substr(split + 1)}); + } + if (hosts.empty()) { + return invalid_targets(); + } + wasi::http_context context; + crawl_report report(context, hosts); + // Two bounded asynchronous workers share one serialized host readiness/reporting queue. + // This preserves overlapping requests without claiming operating-system worker threads. + for (unsigned index = 0; index < 2; ++index) { + std::make_shared(report, context)->run(); + } + context.run(); + std::ostringstream output; + output << report; + http::response response{http::status::ok, 11}; + response.set("X-Crawl-Completed", std::to_string(report.completed())); + response.set("X-Crawl-Workers", "2"); + response.body() = output.str(); + response.prepare_payload(); + return response; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/json_body.hpp new file mode 100644 index 0000000..d62ec9d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/json_body.hpp @@ -0,0 +1,112 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(boost::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(boost::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/json_client.cpp new file mode 100644 index 0000000..9525b65 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/json_client.cpp @@ -0,0 +1,58 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include "json_body.hpp" + +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = + scheme_field.empty() ? "http" : std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; + + http::request request{http::verb::post, "/post", 11}; + request.set(http::field::host, authority); + request.set(http::field::content_type, "application/json"); + request.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + request.prepare_payload(); + request.chunked(false); // Host owns framing for the original unsized JSON Body. + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || response.body() != request.body()) { + return failure(error); + } + ++completed; + + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/mapping.json new file mode 100644 index 0000000..76d8468 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-clients/mapping.json @@ -0,0 +1,25 @@ +{ + "applications": [ + "doc-ssl-client", + "http-client-async", + "http-client-async-local", + "http-client-async-ssl", + "http-client-async-ssl-system-executor", + "http-client-awaitable", + "http-client-awaitable-ssl", + "json_client", + "http-client-coro", + "http-client-coro-ssl", + "http-crawl", + "http-client-methods", + "http-client-sync", + "http-client-sync-ssl" + ], + "adaptations": [ + "Incoming host invocation replaces command-line launch.", + "Host HTTP perform replaces original socket scheduling and HTTP framing.", + "GET, six methods and JSON Body retained. Crawler preserves the upstream report and two asynchronous get-next/complete/aggregate workers over up to 32 distinct controlled authority/path pairs. Host HTTP combines transport phases; complete exchange failures increment Read, while the separate socket phase counters are unmeasured.", + "TLS/Unix transport become host-owned; the base fixture measures HTTP payloads. Separate configured-host HTTPS fixtures verify CA trust, hostname rejection, and the documentation client's mutual TLS.", + "Stackful source compatibility remains blocked without Boost.Context." + ] +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/doc-ssl-server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/doc-ssl-server.cpp new file mode 100644 index 0000000..582a7ee --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/doc-ssl-server.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/host-extra/prepare.py. Do not edit. + +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { + +// The embedding host must authenticate clients before invoking this handler. +// The test's TLS frontend enforces mutual TLS and rejects missing identities. +#ifndef WEBCPP_BEAST_HOST_MTLS_CONFIRMED +#error "This counterpart requires a host configured to enforce mutual TLS" +#endif +http::response handle(const http::request& /*unused*/) { + http::response res; + res.body() = "Hello!"; + + res.prepare_payload(); + return res; +} +} // namespace +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/doc-ssl-server.diff b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/doc-ssl-server.diff new file mode 100644 index 0000000..233c58c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/doc-ssl-server.diff @@ -0,0 +1,161 @@ +--- upstream/doc/ssl/server.cpp ++++ host-extra/doc-ssl-server.cpp +@@ -1,3 +1,11 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/host-extra/prepare.py. Do not edit. ++ + // + // Copyright (c) 2025 Mohammad Nejati + // +@@ -7,127 +15,28 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include +-#include +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++namespace beast = webcpp::beast; ++namespace http = beast::http; + +-#include ++namespace { + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) +- +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = net::ssl; +- +-void +-print_exception(std::exception_ptr eptr) +-{ +- if(eptr) +- { +- try +- { +- std::rethrow_exception(eptr); +- } +- catch(std::exception& e) +- { +- std::cerr << e.what() << std::endl; +- } +- } +-} +- +-net::awaitable +-handle_session(ssl::stream stream) +-{ +- // Perform the SSL handshake +- co_await stream.async_handshake(ssl::stream_base::server); +- +- // Read and discard a request +- beast::flat_buffer buf; +- http::request req; +- co_await http::async_read(stream, buf, req); +- +- // Write the response ++// The embedding host must authenticate clients before invoking this handler. ++// The test's TLS frontend enforces mutual TLS and rejects missing identities. ++#ifndef WEBCPP_BEAST_HOST_MTLS_CONFIRMED ++#error "This counterpart requires a host configured to enforce mutual TLS" ++#endif ++http::response handle(const http::request& /*unused*/) { + http::response res; + res.body() = "Hello!"; +- co_await http::async_write(stream, res); + +- // Gracefully shutdown the SSL stream +- auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) +- throw boost::system::system_error(ec); ++ res.prepare_payload(); ++ return res; + } +- +-net::awaitable +-acceptor(ssl::context& ctx) +-{ +- auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{ {}, 8080 }; +- net::ip::tcp::acceptor acceptor{ executor, endpoint }; +- +- for(;;) +- { +- net::co_spawn( +- executor, +- handle_session({ co_await acceptor.async_accept(), ctx }), +- print_exception); +- } +-} +- +-int +-main() +-{ +- try +- { +- // The io_context is required for all I/O +- net::io_context ioc; +- +- // The SSL context is required, and holds certificates, +- // configurations and session related data +- ssl::context ctx{ ssl::context::sslv23 }; +- +- // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ +- ctx.set_options( +- ssl::context::no_sslv2 | ssl::context::default_workarounds | +- ssl::context::single_dh_use); +- +- // Comment this line to disable client certificate request. +- ctx.set_verify_mode( +- ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); +- +- // The client's certificate will be verified against this +- // certificate authority. +- ctx.load_verify_file("ca.crt"); +- +- // In a real application, the passphrase would be read from +- // a secure place, such as a key vault. +- ctx.set_password_callback([](auto, auto) { return "123456"; }); +- +- // Server certificate and private key. +- ctx.use_certificate_chain_file("server.crt"); +- ctx.use_private_key_file("server.key", ssl::context::pem); +- +- // DH parameters for DHE-based cipher suites +- ctx.use_tmp_dh_file("dh4096.pem"); +- +- net::co_spawn(ioc, acceptor(ctx), print_exception); +- +- ioc.run(); +- } +- catch(std::exception& e) +- { +- std::cerr << e.what() << std::endl; +- } +-} +- +-#else +- +-int +-main(int, char*[]) +-{ +- std::printf("awaitables require C++20\n"); +- return EXIT_FAILURE; +-} +- +-#endif ++} // namespace ++WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-fast.cpp new file mode 100644 index 0000000..f29ee3f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-fast.cpp @@ -0,0 +1,187 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/host-extra/prepare.py. Do not edit. + +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +using application_response = + std::variant, http::response>; + +class http_worker { + std::optional> string_response_; + std::optional> file_response_; + std::string doc_root_ = "."; + +public: + void process_request(http::request const& req) { + // NOLINTNEXTLINE(readability-trivial-switch): preserve upstream method dispatch + switch (req.method()) { + case http::verb::get: send_file(req.target()); break; + + default: + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + break; + } + } + + void send_bad_response(http::status status, std::string const& error) { + string_response_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple()); + + string_response_->result(status); + + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + } + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open(full_path.c_str(), beast::file_mode::read, ec); + if (ec) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + file_response_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple()); + + file_response_->result(http::status::ok); + + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + } + + application_response release() { + if (file_response_) { + return std::move(*file_response_); + } + // NOLINTNEXTLINE(bugprone-unchecked-optional-access): process_request selects one response + return std::move(*string_response_); + } +}; + +application_response handle(const http::request& request) { + http_worker worker; + worker.process_request(request); + return worker.release(); +} +} // namespace +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-fast.diff b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-fast.diff new file mode 100644 index 0000000..9c123f5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-fast.diff @@ -0,0 +1,472 @@ +--- upstream/http/server/fast/http_server_fast.cpp ++++ host-extra/http-server-fast.cpp +@@ -1,3 +1,11 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/host-extra/prepare.py. Do not edit. ++ + // + // Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) + // +@@ -13,339 +21,167 @@ + // + //------------------------------------------------------------------------------ + +-#include "fields_alloc.hpp" ++#include ++#include ++#include ++#include ++#include ++#include ++namespace beast = webcpp::beast; ++namespace http = beast::http; + +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from +- +-// Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++namespace { ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) { ++ return "text/html"; ++ } ++ if (iequals(ext, ".html")) { ++ return "text/html"; ++ } ++ if (iequals(ext, ".php")) { ++ return "text/html"; ++ } ++ if (iequals(ext, ".css")) { ++ return "text/css"; ++ } ++ if (iequals(ext, ".txt")) { ++ return "text/plain"; ++ } ++ if (iequals(ext, ".js")) { ++ return "application/javascript"; ++ } ++ if (iequals(ext, ".json")) { ++ return "application/json"; ++ } ++ if (iequals(ext, ".xml")) { ++ return "application/xml"; ++ } ++ if (iequals(ext, ".swf")) { ++ return "application/x-shockwave-flash"; ++ } ++ if (iequals(ext, ".flv")) { ++ return "video/x-flv"; ++ } ++ if (iequals(ext, ".png")) { ++ return "image/png"; ++ } ++ if (iequals(ext, ".jpe")) { ++ return "image/jpeg"; ++ } ++ if (iequals(ext, ".jpeg")) { ++ return "image/jpeg"; ++ } ++ if (iequals(ext, ".jpg")) { ++ return "image/jpeg"; ++ } ++ if (iequals(ext, ".gif")) { ++ return "image/gif"; ++ } ++ if (iequals(ext, ".bmp")) { ++ return "image/bmp"; ++ } ++ if (iequals(ext, ".ico")) { ++ return "image/vnd.microsoft.icon"; ++ } ++ if (iequals(ext, ".tiff")) { ++ return "image/tiff"; ++ } ++ if (iequals(ext, ".tif")) { ++ return "image/tiff"; ++ } ++ if (iequals(ext, ".svg")) { ++ return "image/svg+xml"; ++ } ++ if (iequals(ext, ".svgz")) { ++ return "image/svg+xml"; ++ } + return "application/text"; + } + +-class http_worker +-{ ++using application_response = ++ std::variant, http::response>; ++ ++class http_worker { ++ std::optional> string_response_; ++ std::optional> file_response_; ++ std::string doc_root_ = "."; ++ + public: +- http_worker(http_worker const&) = delete; +- http_worker& operator=(http_worker const&) = delete; ++ void process_request(http::request const& req) { ++ // NOLINTNEXTLINE(readability-trivial-switch): preserve upstream method dispatch ++ switch (req.method()) { ++ case http::verb::get: send_file(req.target()); break; + +- http_worker(tcp::acceptor& acceptor, const std::string& doc_root) : +- acceptor_(acceptor), +- doc_root_(doc_root) +- { +- } +- +- void start() +- { +- accept(); +- check_deadline(); +- } +- +-private: +- using alloc_t = fields_alloc; +- //using request_body_t = http::basic_dynamic_body>; +- using request_body_t = http::string_body; +- +- // The acceptor used to listen for incoming connections. +- tcp::acceptor& acceptor_; +- +- // The path to the root of the document directory. +- std::string doc_root_; +- +- // The socket for the currently connected client. +- tcp::socket socket_{acceptor_.get_executor()}; +- +- // The buffer for performing reads +- beast::flat_static_buffer<8192> buffer_; +- +- // The allocator used for the fields in the request and reply. +- alloc_t alloc_{8192}; +- +- // The parser for reading the requests +- boost::optional> parser_; +- +- // The timer putting a time limit on requests. +- net::steady_timer request_deadline_{ +- acceptor_.get_executor(), (std::chrono::steady_clock::time_point::max)()}; +- +- // The string-based response message. +- boost::optional>> string_response_; +- +- // The string-based response serializer. +- boost::optional>> string_serializer_; +- +- // The file-based response message. +- boost::optional>> file_response_; +- +- // The file-based response serializer. +- boost::optional>> file_serializer_; +- +- void accept() +- { +- // Clean up any previous connection. +- beast::error_code ec; +- socket_.close(ec); +- buffer_.consume(buffer_.size()); +- +- acceptor_.async_accept( +- socket_, +- [this](beast::error_code ec) +- { +- if (ec) +- { +- accept(); +- } +- else +- { +- // Request must be fully processed within 60 seconds. +- request_deadline_.expires_after( +- std::chrono::seconds(60)); +- +- read_request(); +- } +- }); +- } +- +- void read_request() +- { +- // On each read the parser needs to be destroyed and +- // recreated. We store it in a boost::optional to +- // achieve that. +- // +- // Arguments passed to the parser constructor are +- // forwarded to the message object. A single argument +- // is forwarded to the body constructor. +- // +- // We construct the dynamic body with a 1MB limit +- // to prevent vulnerability to buffer attacks. +- // +- parser_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); +- +- http::async_read( +- socket_, +- buffer_, +- *parser_, +- [this](beast::error_code ec, std::size_t) +- { +- if (ec) +- accept(); +- else +- process_request(parser_->get()); +- }); +- } +- +- void process_request(http::request> const& req) +- { +- switch (req.method()) +- { +- case http::verb::get: +- send_file(req.target()); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; ++ default: ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); ++ break; + } + } + +- void send_bad_response( +- http::status status, +- std::string const& error) +- { +- string_response_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); ++ void send_bad_response(http::status status, std::string const& error) { ++ string_response_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple()); + + string_response_->result(status); +- string_response_->keep_alive(false); ++ + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); +- +- string_serializer_.emplace(*string_response_); +- +- http::async_write( +- socket_, +- *string_serializer_, +- [this](beast::error_code ec, std::size_t) +- { +- socket_.shutdown(tcp::socket::shutdown_send, ec); +- string_serializer_.reset(); +- string_response_.reset(); +- accept(); +- }); + } + +- void send_file(beast::string_view target) +- { ++ void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) +- { +- send_bad_response( +- http::status::not_found, +- "File not found\r\n"); ++ if (target.empty() || target[0] != '/' || target.contains("..")) { ++ send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; +- full_path.append( +- target.data(), +- target.size()); ++ full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; +- file.open( +- full_path.c_str(), +- beast::file_mode::read, +- ec); +- if(ec) +- { +- send_bad_response( +- http::status::not_found, +- "File not found\r\n"); ++ file.open(full_path.c_str(), beast::file_mode::read, ec); ++ if (ec) { ++ send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + +- file_response_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); ++ file_response_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple()); + + file_response_->result(http::status::ok); +- file_response_->keep_alive(false); ++ + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); +- +- file_serializer_.emplace(*file_response_); +- +- http::async_write( +- socket_, +- *file_serializer_, +- [this](beast::error_code ec, std::size_t) +- { +- socket_.shutdown(tcp::socket::shutdown_send, ec); +- file_serializer_.reset(); +- file_response_.reset(); +- accept(); +- }); + } + +- void check_deadline() +- { +- // The deadline may have moved, so check it has really passed. +- if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) +- { +- // Close socket to cancel any outstanding operation. +- socket_.close(); +- +- // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at( +- (std::chrono::steady_clock::time_point::max)()); ++ application_response release() { ++ if (file_response_) { ++ return std::move(*file_response_); + } +- +- request_deadline_.async_wait( +- [this](beast::error_code) +- { +- check_deadline(); +- }); ++ // NOLINTNEXTLINE(bugprone-unchecked-optional-access): process_request selects one response ++ return std::move(*string_response_); + } + }; + +-int main(int argc, char* argv[]) +-{ +- try +- { +- // Check command line arguments. +- if (argc != 6) +- { +- std::cerr << "Usage: http_server_fast
{spin|block}\n"; +- std::cerr << " For IPv4, try:\n"; +- std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; +- std::cerr << " For IPv6, try:\n"; +- std::cerr << " http_server_fast 0::0 80 . 100 block\n"; +- return EXIT_FAILURE; +- } +- +- auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- std::string doc_root = argv[3]; +- int num_workers = std::atoi(argv[4]); +- bool spin = (std::strcmp(argv[5], "spin") == 0); +- +- net::io_context ioc{1}; +- tcp::acceptor acceptor{ioc, {address, port}}; +- +- std::list workers; +- for (int i = 0; i < num_workers; ++i) +- { +- workers.emplace_back(acceptor, doc_root); +- workers.back().start(); +- } +- +- if (spin) +- for (;;) ioc.poll(); +- else +- ioc.run(); +- } +- catch (const std::exception& e) +- { +- std::cerr << "Error: " << e.what() << std::endl; +- return EXIT_FAILURE; +- } ++application_response handle(const http::request& request) { ++ http_worker worker; ++ worker.process_request(request); ++ return worker.release(); + } ++} // namespace ++WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-small.cpp new file mode 100644 index 0000000..9407399 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-small.cpp @@ -0,0 +1,115 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/host-extra/prepare.py. Do not edit. + +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; + +namespace { +namespace my_program_state { +std::size_t request_count() { + static std::size_t count = 0; + return ++count; +} + +std::time_t now() { + return std::time(nullptr); +} +} // namespace my_program_state + +class http_connection { + http::request request_; + http::response response_; + +public: + explicit http_connection(http::request request) + : request_(std::move(request)) {} + + void process_request() { + response_.version(request_.version()); + + // NOLINTNEXTLINE(readability-trivial-switch): preserve upstream method dispatch + switch (request_.method()) { + case http::verb::get: + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + break; + + default: + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + break; + } + + response_.prepare_payload(); + } + + void create_response() { + if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + http::response release() { return std::move(response_); } +}; + +http::response handle(http::request request) { + http_connection connection(std::move(request)); + connection.process_request(); + return connection.release(); +} +} // namespace +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-small.diff b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-small.diff new file mode 100644 index 0000000..aa7f0c5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/http-server-small.diff @@ -0,0 +1,327 @@ +--- upstream/http/server/small/http_server_small.cpp ++++ host-extra/http-server-small.cpp +@@ -1,3 +1,11 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/host-extra/prepare.py. Do not edit. ++ + // + // Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) + // +@@ -13,239 +21,95 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include +-#include +-#include +-#include + #include +-#include +-#include ++#include + #include ++#include ++#include ++#include ++namespace beast = webcpp::beast; ++namespace http = beast::http; + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace { ++namespace my_program_state { ++std::size_t request_count() { ++ static std::size_t count = 0; ++ return ++count; ++} + +-namespace my_program_state +-{ +- std::size_t +- request_count() +- { +- static std::size_t count = 0; +- return ++count; ++std::time_t now() { ++ return std::time(nullptr); ++} ++} // namespace my_program_state ++ ++class http_connection { ++ http::request request_; ++ http::response response_; ++ ++public: ++ explicit http_connection(http::request request) ++ : request_(std::move(request)) {} ++ ++ void process_request() { ++ response_.version(request_.version()); ++ ++ // NOLINTNEXTLINE(readability-trivial-switch): preserve upstream method dispatch ++ switch (request_.method()) { ++ case http::verb::get: ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ break; ++ ++ default: ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; ++ break; ++ } ++ ++ response_.prepare_payload(); + } + +- std::time_t +- now() +- { +- return std::time(0); +- } +-} +- +-class http_connection : public std::enable_shared_from_this +-{ +-public: +- http_connection(tcp::socket socket) +- : socket_(std::move(socket)) +- { +- } +- +- // Initiate the asynchronous operations associated with the connection. +- void +- start() +- { +- read_request(); +- check_deadline(); +- } +- +-private: +- // The socket for the currently connected client. +- tcp::socket socket_; +- +- // The buffer for performing reads. +- beast::flat_buffer buffer_{8192}; +- +- // The request message. +- http::request request_; +- +- // The response message. +- http::response response_; +- +- // The timer for putting a deadline on connection processing. +- net::steady_timer deadline_{ +- socket_.get_executor(), std::chrono::seconds(60)}; +- +- // Asynchronously receive a complete request message. +- void +- read_request() +- { +- auto self = shared_from_this(); +- +- http::async_read( +- socket_, +- buffer_, +- request_, +- [self](beast::error_code ec, +- std::size_t bytes_transferred) +- { +- boost::ignore_unused(bytes_transferred); +- if(!ec) +- self->process_request(); +- }); +- } +- +- // Determine what needs to be done with the request message. +- void +- process_request() +- { +- response_.version(request_.version()); +- response_.keep_alive(false); +- +- switch(request_.method()) +- { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" +- << std::string(request_.method_string()) +- << "'"; +- break; +- } +- +- write_response(); +- } +- +- // Construct a response message based on the program state. +- void +- create_response() +- { +- if(request_.target() == "/count") +- { ++ void create_response() { ++ if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" +- << "Request count\n" +- << "\n" +- << "

Request count

\n" +- << "

There have been " +- << my_program_state::request_count() +- << " requests so far.

\n" +- << "\n" +- << "\n"; +- } +- else if(request_.target() == "/time") +- { ++ << "Request count\n" ++ << "\n" ++ << "

Request count

\n" ++ << "

There have been " << my_program_state::request_count() ++ << " requests so far.

\n" ++ << "\n" ++ << "\n"; ++ } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); +- beast::ostream(response_.body()) +- << "\n" +- << "Current time\n" +- << "\n" +- << "

Current time

\n" +- << "

The current time is " +- << my_program_state::now() +- << " seconds since the epoch.

\n" +- << "\n" +- << "\n"; +- } +- else +- { ++ beast::ostream(response_.body()) << "\n" ++ << "Current time\n" ++ << "\n" ++ << "

Current time

\n" ++ << "

The current time is " << my_program_state::now() ++ << " seconds since the epoch.

\n" ++ << "\n" ++ << "\n"; ++ } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + +- // Asynchronously transmit the response message. +- void +- write_response() +- { +- auto self = shared_from_this(); +- +- response_.content_length(response_.body().size()); +- +- http::async_write( +- socket_, +- response_, +- [self](beast::error_code ec, std::size_t) +- { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); +- self->deadline_.cancel(); +- }); +- } +- +- // Check whether we have spent enough time on this connection. +- void +- check_deadline() +- { +- auto self = shared_from_this(); +- +- deadline_.async_wait( +- [self](beast::error_code ec) +- { +- if(!ec) +- { +- // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); +- } +- }); +- } ++ http::response release() { return std::move(response_); } + }; + +-// "Loop" forever accepting new connections. +-void +-http_server(tcp::acceptor& acceptor, tcp::socket& socket) +-{ +- acceptor.async_accept(socket, +- [&](beast::error_code ec) +- { +- if(!ec) +- std::make_shared(std::move(socket))->start(); +- http_server(acceptor, socket); +- }); ++http::response handle(http::request request) { ++ http_connection connection(std::move(request)); ++ connection.process_request(); ++ return connection.release(); + } +- +-int +-main(int argc, char* argv[]) +-{ +- try +- { +- // Check command line arguments. +- if(argc != 3) +- { +- std::cerr << "Usage: " << argv[0] << "
\n"; +- std::cerr << " For IPv4, try:\n"; +- std::cerr << " receiver 0.0.0.0 80\n"; +- std::cerr << " For IPv6, try:\n"; +- std::cerr << " receiver 0::0 80\n"; +- return EXIT_FAILURE; +- } +- +- auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- +- net::io_context ioc{1}; +- +- tcp::acceptor acceptor{ioc, {address, port}}; +- tcp::socket socket{ioc}; +- http_server(acceptor, socket); +- +- ioc.run(); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error: " << e.what() << std::endl; +- return EXIT_FAILURE; +- } +-} ++} // namespace ++WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/mapping.json new file mode 100644 index 0000000..214b2c7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/mapping.json @@ -0,0 +1,25 @@ +{ + "applications": [ + { + "id": "http-server-fast", + "upstream": "http/server/fast/http_server_fast.cpp", + "source": "http-server-fast.cpp" + }, + { + "id": "http-server-small", + "upstream": "http/server/small/http_server_small.cpp", + "source": "http-server-small.cpp" + }, + { + "id": "doc-ssl-server", + "upstream": "doc/ssl/server.cpp", + "source": "doc-ssl-server.cpp" + } + ], + "adaptations": [ + "The host owns connection acceptance, framing, persistence and TLS.", + "Fast retains GET-only path/error/file logic; host fields use the default allocator.", + "Small retains /count and /time; counter lifetime is the host component instance.", + "The TLS example requires an explicit host mutual-TLS capability assertion." + ] +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/prepare.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/prepare.py new file mode 100644 index 0000000..31c40b1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host-extra/prepare.py @@ -0,0 +1,176 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Extract the remaining upstream HTTP handlers for host-owned transport.""" + +import argparse +import difflib +import json +from pathlib import Path +import subprocess + +HERE = Path(__file__).resolve().parent +UPSTREAM = HERE.parents[1] / "upstream" +NOTICE = """// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/host-extra/prepare.py. Do not edit. + +""" +PREFIX = """#include +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace { +""" + + +def block(source: str, marker: str) -> str: + start = source.index(marker) + opening = source.index("{", start) + level, end = 1, opening + 1 + while level: + level += (source[end] == "{") - (source[end] == "}") + end += 1 + return source[start:end] + + +def fast(source: str) -> str: + mime = block(source, "beast::string_view\nmime_type") + process = block(source, "void process_request(") + process = process.replace("request_body_t, http::basic_fields", "http::string_body") + process = process.replace("switch (req.method())", + "// NOLINTNEXTLINE(readability-trivial-switch): preserve upstream " + "method dispatch\n switch (req.method())") + methods = [] + for name, serializer in (("send_bad_response", "string"), ("send_file", "file")): + method = block(source, "void " + name + "(") + method = method[:method.index(serializer + "_serializer_.emplace")] + "}\n" + method = method.replace("std::make_tuple(alloc_)", "std::make_tuple()") + method = method.replace(serializer + "_response_->keep_alive(false);", "") + method = method.replace('target.find("..") != std::string::npos', 'target.contains("..")') + methods.append(method) + return PREFIX + mime + """ +using application_response = std::variant, + http::response>; +class http_worker { + std::optional> string_response_; + std::optional> file_response_; + std::string doc_root_ = "."; +public: +""" + process + "\n" + "\n".join(methods) + """ + application_response release() { + if (file_response_) { return std::move(*file_response_); } + // NOLINTNEXTLINE(bugprone-unchecked-optional-access): process_request selects one response + return std::move(*string_response_); + } +}; +application_response handle(const http::request& request) { + http_worker worker; + worker.process_request(request); + return worker.release(); +} +} // namespace +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +""" + + +def small(source: str) -> str: + state = block(source, "namespace my_program_state") + state = state.replace("std::time(0)", "std::time(nullptr)") + process = block(source, "void\n process_request()") + process = process.replace("response_.keep_alive(false);", "") + process = process.replace("write_response();", "response_.prepare_payload();") + process = process.replace("switch(request_.method())", "switch (request_.method())") + process = process.replace("switch (request_.method())", + "// NOLINTNEXTLINE(readability-trivial-switch): preserve upstream " + "method dispatch\n switch (request_.method())") + create = block(source, "void\n create_response()") + return PREFIX + state + """ +class http_connection { + http::request request_; + http::response response_; +public: + explicit http_connection(http::request request) + : request_(std::move(request)) {} +""" + process + "\n" + create + """ + http::response release() { return std::move(response_); } +}; +http::response handle(http::request request) { + http_connection connection(std::move(request)); + connection.process_request(); + return connection.release(); +} +} // namespace +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +""" + + +def tls_server(source: str) -> str: + start = source.index("http::response res;") + response = source[start:source.index("co_await http::async_write", start)] + return PREFIX + """ +// The embedding host must authenticate clients before invoking this handler. +// The test's TLS frontend enforces mutual TLS and rejects missing identities. +#ifndef WEBCPP_BEAST_HOST_MTLS_CONFIRMED +#error "This counterpart requires a host configured to enforce mutual TLS" +#endif +http::response handle(const http::request& /*unused*/) { +""" + response + """ + res.prepare_payload(); + return res; +} +} // namespace +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +""" + + +SOURCES = { + "http-server-fast": ("http/server/fast/http_server_fast.cpp", fast), + "http-server-small": ("http/server/small/http_server_small.cpp", small), + "doc-ssl-server": ("doc/ssl/server.cpp", tls_server), +} + + +def generate(formatter: str) -> None: + mapping = [] + for name, (relative, transform) in SOURCES.items(): + source = (UPSTREAM / relative).read_text() + notice = source[:source.index("#include")] + text = NOTICE + notice + transform(source) + path = HERE / (name + ".cpp") + result = subprocess.run([formatter, f"--assume-filename={path}", + "--style={BasedOnStyle: InheritParentConfig, InsertBraces: true}"], + input=text, + text=True, capture_output=True, check=True) + if not path.exists() or path.read_text() != result.stdout: + path.write_text(result.stdout) + difference = "".join(difflib.unified_diff( + source.splitlines(True), result.stdout.splitlines(True), + fromfile="upstream/" + relative, tofile="host-extra/" + path.name)) + (HERE / (name + ".diff")).write_text(difference) + mapping.append({"id": name, "upstream": relative, "source": path.name}) + (HERE / "mapping.json").write_text(json.dumps({ + "applications": mapping, + "adaptations": [ + "The host owns connection acceptance, framing, persistence and TLS.", + "Fast retains GET-only path/error/file logic; host fields use the default allocator.", + "Small retains /count and /time; counter lifetime is the host component instance.", + "The TLS example requires an explicit host mutual-TLS capability assertion." + ]}, indent=2) + "\n") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--clang-format", required=True) + generate(parser.parse_args().clang_format) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server-flex-awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server-flex-awaitable.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server-flex-awaitable.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server-flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server-flex.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server-flex.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/advanced-server.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async-local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async-local.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async-local.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async-ssl.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async-ssl.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-async.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-awaitable.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-awaitable.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-coro-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-coro-ssl.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-coro-ssl.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-coro.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-coro.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-flex.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-flex.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-stackless-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-stackless-ssl.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-stackless-ssl.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-stackless.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-stackless.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-sync-ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-sync-ssl.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-sync-ssl.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-sync.cpp new file mode 100644 index 0000000..eb5f932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/http-server-sync.cpp @@ -0,0 +1,225 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + + return res; +} + +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/mapping.json new file mode 100644 index 0000000..62d0a8a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/host/mapping.json @@ -0,0 +1,19 @@ +{ + "applications": [ + "advanced-server", + "advanced-server-flex", + "advanced-server-flex-awaitable", + "http-server-async", + "http-server-async-local", + "http-server-async-ssl", + "http-server-awaitable", + "http-server-coro", + "http-server-coro-ssl", + "http-server-flex", + "http-server-stackless", + "http-server-stackless-ssl", + "http-server-sync", + "http-server-sync-ssl" + ], + "adaptation": "Original mime_type, path_cat and handle_request; message_generator replaced by std::variant; host owns persistence and server entrypoint." +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/manifest.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/manifest.json new file mode 100644 index 0000000..940e4a7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/manifest.json @@ -0,0 +1,1066 @@ +{ + "schema": 1, + "upstream": { + "repository": "https://github.com/boostorg/beast", + "tag": "boost-1.92.0", + "commit": "7c1e061f91e2ef542217b76286c314d006c0c8fc", + "sha256": { + "CMakeLists.txt": "070c5efabeab51b1d5b25c69c55afa4fb72d56d6743529cde0bcc85165bed995", + "Jamfile": "d02ebb503b9d7c161b3ec3c7f77eed1269ef6c1828991ba2e6945c29b418c28c", + "LICENSE_1_0.txt": "c9bff75738922193e67fa726fa225535870d2aa1059f91452c411736284ad566", + "advanced/CMakeLists.txt": "f4dc5153a8e05f96203d9df442d3aec75adfbf4ac7a61b09a051c7caa4b0ddfe", + "advanced/Jamfile": "ac1cc37d7feef12153110dcd2257c5690c55c37f4ced763577cca0ef9c630bfb", + "advanced/server/CMakeLists.txt": "abbd30741cfdee278bafbc631372aded32b73604c74bb482f748424f87d0f34a", + "advanced/server/Jamfile": "4074fd02df4e6e014a1691118e848ba3e17215cb96501c1dfb93fceeff20a9b4", + "advanced/server/advanced_server.cpp": "b8551a0401513926775fa9a4fb586c31b1c35d6bdbbeab133acd76dcef6417c1", + "advanced/server-flex/CMakeLists.txt": "4d0dde1af2c5ae1f53b6de7b1e877568869af94f9c59dff81bdeeaae53d59c65", + "advanced/server-flex/Jamfile": "6da2ee2ab44cbea73228f2f5e25253d278350467dd04ab940b4057bea1e31fd9", + "advanced/server-flex/advanced_server_flex.cpp": "3cdadec03c231d96b32138121fcaaa91058f946b145efab5fdbd257a658e586f", + "advanced/server-flex-awaitable/CMakeLists.txt": "743190da13fe67d4af3091a6572dcd63a80ecd9b06f357e28948e0551a820acb", + "advanced/server-flex-awaitable/Jamfile": "0f2ddb70faae3ab9d0d4f4cb8273e801e9b99937f76b18abce2c88f1622a39ca", + "advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp": "0916159386ccbaad071ab35d551be64cbc85e36b10fcd61552689222827d7772", + "common/root_certificates.hpp": "8cde8d4eeff7cf1aebbc5dd6446f777e9a9b96b21252939994eb7cf99d11197f", + "common/server_certificate.hpp": "38da7e73494f7cdfe9e4852b3475a06a2748403fea2a5d555833f6a1c2766c7e", + "doc/CMakeLists.txt": "5ed94b7c2c534b958cf23731b2a9833b257b08473beed38ef4b50add58d2cdcb", + "doc/Jamfile": "487488cdb5268d8747af40870aa78ea97a5344104d69105ba63278d99926fd16", + "doc/http_examples.hpp": "745cd03f963d0e548a06401f94ed9994133b0928536ac91292283b1ab4bc59ff", + "doc/ssl/CMakeLists.txt": "4b6e9c3a619fd7200dd0fa791bbadc62f74f05c17e770207e5904620ae93a402", + "doc/ssl/Jamfile": "1b8b84a99cd009eabbe86bfc70d73eeb6c412006c5ef8efd2509360b7c443ba3", + "doc/ssl/client.cpp": "910605f3980b2a8ee48f9d9609315340e9ff7c99e3a521cdc8f2dcda230dc641", + "doc/ssl/server.cpp": "3680895ad66c553faa0d0427261f12c47f8b44990556d12e91bfe58b837b20bc", + "echo-op/CMakeLists.txt": "188de9bec2e436c6861461f376a6644706345105f1e7cc1e628e860f0a55882c", + "echo-op/Jamfile": "c7f8ca15e9aff1eb1a0c3ae96af64fac281fe607716245972e7274b374a47ea3", + "echo-op/echo_op.cpp": "e01a3157d3bfb8b09b104546fa3a3895daacab5d4a859adf1d3f5a36a22d5be8", + "http/CMakeLists.txt": "f5f9e4155b210f4db27471241df5b91bf927e9ffd338eeaf29a76fa95020c279", + "http/Jamfile": "865cb1dfb1c6840e465f6a4d4b9a499f563b4d286e5582d81f81bcc47e3c9e78", + "http/client/CMakeLists.txt": "652343e1537af9631f7da56921060aa6b985c6e278be6c10db83a0d19f1e1468", + "http/client/Jamfile": "c0b56ccbf53187fd16775c1b6134c1359ee19231ec5aba789fcca4e1de01ec78", + "http/client/async/CMakeLists.txt": "125aad15c8631d0acf758484993ff24a322720a713ecdb9ae302103451492c75", + "http/client/async/Jamfile": "dab57a5fcfa8a3048be7b19723ed77e7c2ebfa0217eb4e12c0dd0577c549667b", + "http/client/async/http_client_async.cpp": "816f89467516608d32223d1002e3be8be5c5a216f94a63153b3a39721c30c69b", + "http/client/async-local/CMakeLists.txt": "56010ac64696f288281ac853b5d4d932b9b6530cb242bbe75980ada78de030cf", + "http/client/async-local/Jamfile": "8c29cc9480554c10ae45c55919debac414a8a1b86be8e7c2d001746881a224c5", + "http/client/async-local/http_client_async_local.cpp": "5817e41c77c0201e00940c65811aa67b8e700d87f334fc514149705e194effba", + "http/client/async-ssl/CMakeLists.txt": "d50c27b1eafcf7dd3c3bccf1ab1a5621fc5a08913101256e4a26ca351081036a", + "http/client/async-ssl/Jamfile": "3b843f2a0dbe21ffc54f81d3dc6052110501ba04ff0bff31bf794f6a837e3b78", + "http/client/async-ssl/http_client_async_ssl.cpp": "3a6d13f9fec8f3947cbb0a760eebb97a92ac668553ba127f5b8e6c339fe3793d", + "http/client/async-ssl-system-executor/CMakeLists.txt": "c4fb1bb25e2728b11f71cc5c9ee3e27bffff098ff20f77fb296a9eebaae8a246", + "http/client/async-ssl-system-executor/Jamfile": "cce33422fb6356f2d01c26131aceb0b923bfb04303631508889a02209d41bd2a", + "http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp": "5e6adcee1bd3e12a82a93d5ee8a75ec2cce9cf10fe77a0deabe270cfa6707b39", + "http/client/awaitable/CMakeLists.txt": "0b52172cab0f8e84a6ecc71eaa32811755a42b0859441b6a944763e1e96e5bb0", + "http/client/awaitable/Jamfile": "33e5a061e769e27da28e559d3e21aa1ebf9b9f5420df51af47c000daf8fb9730", + "http/client/awaitable/http_client_awaitable.cpp": "76b5b6bfc44480b6804e02908b0f25a4f2abb810386ea40818c288bf2d79a6f1", + "http/client/awaitable-ssl/CMakeLists.txt": "6a96f55e49ef5ee21ab0bdaca2eb957baf76e9f22ebebb80d05efe7eccc64b87", + "http/client/awaitable-ssl/Jamfile": "f0aa009d4f9835fd9852f36bb3d4d8b12de62e259094745c27e64a9d37db9c3d", + "http/client/awaitable-ssl/http_client_awaitable_ssl.cpp": "1908532b161ff89663c36abdc15f38861d5c66aa14cfc01b352d4a9a911a3c02", + "http/client/body/CMakeLists.txt": "58b0bf38be34614c78d893879f331ec64afdf73ba6dec3d9a649888e91e04988", + "http/client/body/Jamfile": "3434784a22d67916d11fccc0057a9ce8c739b10d57deb3d82713ec842adb4ab5", + "http/client/body/json_body.hpp": "2e3ecabdabd268fa6923e7d64fc16201d320ae44cf4aca75cc14931ced273339", + "http/client/body/json_client.cpp": "a210c17676556d6c6cc3ddcc749de298524a8c41248ff25db36b930a6e6f4af8", + "http/client/coro/CMakeLists.txt": "e8933439e23a8f3296126bd1bf92b5fa90ccae0600d5629922c99bdb18e19c5f", + "http/client/coro/Jamfile": "8ab6e8cbd290343ba63a88fc9e3dfd4320e0924e7edeeb7b04d897fe48f3d17c", + "http/client/coro/http_client_coro.cpp": "b85b19fe93ea3fd20b17c732d688d4a317667cd641cd68ef7440cda8b683096d", + "http/client/coro-ssl/CMakeLists.txt": "3ddc2c400b84be7e7c4a57d242a15024f8dfc5ef7729f9ef8b56a18c22ed9610", + "http/client/coro-ssl/Jamfile": "275b19e8a0d7a7a7f81510cf96046e4ac49759b05e648d07a008110083c4800b", + "http/client/coro-ssl/http_client_coro_ssl.cpp": "0015284bc663851a3e47386ece94529ab3dc480c65f7394c5a70b529102ec506", + "http/client/crawl/CMakeLists.txt": "d15b141e08efc2e3579921c80c7e631335601c78cf6fd80062eee15bb357f1de", + "http/client/crawl/Jamfile": "6b938d6e63095608684678a19244db02cbaec157a37ea08760814884075327a1", + "http/client/crawl/http_crawl.cpp": "3e86324bf49cbffd4a98bde64a21c0d8a4a3cb4fc34e3dce678f0c4e599b4424", + "http/client/crawl/urls_large_data.cpp": "a9c315c2208246012763299130aae078df3a33739b19c26ae276a3e5fdb1ef50", + "http/client/crawl/urls_large_data.hpp": "e6c6495f5a419875f547ac16693be6b6fcc2c134aa9a26931a1428a28912eee5", + "http/client/methods/CMakeLists.txt": "7aa4c2fa358958089e39921cd30d91bfabc6c91c3b5732d03aa82435211611b7", + "http/client/methods/Jamfile": "4029b4b85b5ec4b7f2b46278423757054c0c3965da1f14b2424fa8a7ee8ed874", + "http/client/methods/http_client_methods.cpp": "ab47deeed0cae45178ef75da1da3bae724b198d4d06b5b60b13df519690c1e04", + "http/client/sync/CMakeLists.txt": "0d79f46099d1cd687b23933161aed1cc4810a367234d7527bb1c39f18231dd46", + "http/client/sync/Jamfile": "e336ceff1a9af38af3777d6cc1c4049817d8c2fe791b4ee99aaf925e01689df7", + "http/client/sync/http_client_sync.cpp": "5b68cb9b6f615024d8a8819e4bc2b692b69e79416cccbeb0dcaac1c01567b620", + "http/client/sync-ssl/CMakeLists.txt": "114940b97c54d12ae4d7a42b667a5a2ad779d8fbf82edc258f58dc8ebc8b5f92", + "http/client/sync-ssl/Jamfile": "b21f4c2c81ed2dd181c7e9593d7ebf414fe9446273911d298e51336b610e924b", + "http/client/sync-ssl/http_client_sync_ssl.cpp": "7d7069120db34a88ead11609a4a651cce3e679c48ce0365440b411cfb4be915b", + "http/server/CMakeLists.txt": "e64a7e654b2e13d8ac71376b58048010a4a0afe7f672b6e7179f188e237c4ffd", + "http/server/Jamfile": "47d65c2686cf25c00792dc344082ba5f1ddd43fd45b146cf1f09a76d6d2a4215", + "http/server/async/CMakeLists.txt": "3c5075595025810339228e4f7e252d4c8d3da5a65e664d86beba3a92191587d6", + "http/server/async/Jamfile": "cf11c95209cb18e382eef72b95ec98dcbae5653c3c4837127325fb5c4aaaefa4", + "http/server/async/http_server_async.cpp": "53ab7acfc3811774a8c426ff9b5f61ad6ae6a123c578540bb8d71c25858f4fe6", + "http/server/async-local/CMakeLists.txt": "9aac26dce633426bd33212f372b68d33a0ed63c52641a65fc087eb70ea396e82", + "http/server/async-local/Jamfile": "4aecf93e2feded958b6b7d00e077d4e05383497d4267658f9391345cf3a3b449", + "http/server/async-local/http_server_async_local.cpp": "e139d39a73dd5eb332f48dee35763bfca9fc5a44b04c453ea34281e3ba06e508", + "http/server/async-ssl/CMakeLists.txt": "3ebb5d9b031037672534e6c81d29a75b11b87c5ee99d7617ba72056ee388558f", + "http/server/async-ssl/Jamfile": "40a127f2657d9b2336d42dcc28a9965add14c02f2a6ebe1b0e0c35b6b616675f", + "http/server/async-ssl/http_server_async_ssl.cpp": "b8a2eb08500ae28628e5a2854c1aba94580877bebb6f7bae1558244e69382897", + "http/server/awaitable/CMakeLists.txt": "069ce8c32802b71c67378b1fb1cf37926bceb2f344e651284d37fe4027a6b407", + "http/server/awaitable/Jamfile": "01ffa4e1fef1b7faf6582c1b65441668c0df4da22957e8ec43ce99bf7cb75548", + "http/server/awaitable/http_server_awaitable.cpp": "3d092ed8c558faa234f2e8625179d8a11fbc95979891b9d694e3b4bc0d202d33", + "http/server/coro/CMakeLists.txt": "67eb72cc74a9dab4926da992ddbbb60305c777b5341a757858952854d032f070", + "http/server/coro/Jamfile": "396703d272b70f03ed4f3fda7fdf30633d09553fff95e248b4280838fb42e04a", + "http/server/coro/http_server_coro.cpp": "0d4fac745d0e490fe694c84faeb8fb5354a8347480d3320b26aed7794edb0f0f", + "http/server/coro-ssl/CMakeLists.txt": "2e7360a6977750501ee1e1025e616ac77cd87597ed43b6c095230077cdaab5f3", + "http/server/coro-ssl/Jamfile": "6121cda0d3cf48956b9bee8205da0abe5c99efe2efca19bbc76adcce308e9312", + "http/server/coro-ssl/http_server_coro_ssl.cpp": "ef5bd717a8ef8418d25b201738ae8c351b9d5f8ca424f2e39d7eb65b777b3cbc", + "http/server/fast/CMakeLists.txt": "635e9c2ac8a3907706a023eee7bb0a87088b3a2c5e2e637613a0771c6a01a5df", + "http/server/fast/Jamfile": "1b6b0cffaea08e1fd1de1b955695abfed7252f90501f701378ceba107207f806", + "http/server/fast/fields_alloc.hpp": "dff083804efa396f0f990db55eac8f075b2704259330ce889afdcb3ce4c93712", + "http/server/fast/http_server_fast.cpp": "33f30c472d0114c50cc04506a8eca32cceed24ba0dc578d0f573a09ae3097809", + "http/server/flex/CMakeLists.txt": "e03415cae519ad52c82b4fb4744e1a89d7e8fbb1f4358a06413dfbd8262a916f", + "http/server/flex/Jamfile": "f2bea3c4d6585c8b0115d945cbd575f49444535868b5af9d5c22b10ff975da39", + "http/server/flex/http_server_flex.cpp": "b80c1fed1ec189d0ae08eb9c9b19646e35fc692f27b89435185de3f31f6c312a", + "http/server/small/CMakeLists.txt": "07d50fc2d6ac48f02cb96838c441c25f186bb5878e447fe03f08df24e81df764", + "http/server/small/Jamfile": "affa46bc123ff0ebfde08b4e433d4a3445a4e78d151703e1a03ca1d60f337c07", + "http/server/small/http_server_small.cpp": "9e105862c5deb57abee9a037aa446e6ac19a2b2e0a26afa6619bbbbdb2ecf788", + "http/server/stackless/CMakeLists.txt": "467fb59b915556219778704eef164ac79fe2c39603fa33f3fc133250b8723406", + "http/server/stackless/Jamfile": "80b732ea9f2733d6be359acb8a1fa955aed3edcbcd5685d9c97d9b9f523e2368", + "http/server/stackless/http_server_stackless.cpp": "11c956e807f83d6d7a15d3b041dbf82f4e2c272aba000295ed40ff8a737ae033", + "http/server/stackless-ssl/CMakeLists.txt": "2279c445737ff679c8047bef244abbd0498fc8df6c0584152296ce61b5658136", + "http/server/stackless-ssl/Jamfile": "f040195b26b742152d5113500cbdabc1726f2a6442238acbeef13ac0cd3634f1", + "http/server/stackless-ssl/http_server_stackless_ssl.cpp": "84da30c85fcd2dd62c1789e102b3b5c6c8f8fdf33e047d4cee7bd8cd6821276a", + "http/server/sync/CMakeLists.txt": "3e32497df9d4d20bd7390a2d72d8bbae61f1d8771b654631ae6359584d3b2a2c", + "http/server/sync/Jamfile": "14a066f850234bda2fb7a9260bdbbb039d06738672bbfb40713546567d6a6b54", + "http/server/sync/http_server_sync.cpp": "15939682a95af5d212d073dc1caaa077b0fe3966feeac0c248a1bebae76d7d58", + "http/server/sync-ssl/CMakeLists.txt": "c4eb1a91eaf200affb2dc0f97607720f69a4bf48a7695e3e134555e44fc272ec", + "http/server/sync-ssl/Jamfile": "51e4d78465f56ae1c705adcb39ad854398c240b8cdefffcfb7768ec6e1ae9dfe", + "http/server/sync-ssl/http_server_sync_ssl.cpp": "64e2bac9d7780a43839acaa9632fe9b7a5907497e7aa00c01cea0dc45af7ca7b", + "websocket/CMakeLists.txt": "f5f9e4155b210f4db27471241df5b91bf927e9ffd338eeaf29a76fa95020c279", + "websocket/Jamfile": "865cb1dfb1c6840e465f6a4d4b9a499f563b4d286e5582d81f81bcc47e3c9e78", + "websocket/client/CMakeLists.txt": "f824e9d8cd7ea985e2ebcd67300d7b575cb87e69b2c5ed83ae4cae9d790a3666", + "websocket/client/Jamfile": "1bcd841f8bd5f9aded3865605657d7d2e357c4d43a721e719359262745c2e6f9", + "websocket/client/async/CMakeLists.txt": "17fa4c8c516984507c32fe1287e9a2f043debf7ad9cd1e7bb4ec9928ca9077ad", + "websocket/client/async/Jamfile": "4657921f7cdf7c14f5861dcd1a10f43a430efdc5304f40f9eb9f6162b5015d48", + "websocket/client/async/websocket_client_async.cpp": "49e4c78f9512adf7fb21835e3bd9948efb8406c8c917bef2a4f5f9797c057d52", + "websocket/client/async-local/CMakeLists.txt": "7c1d20f8c130dcb974c70c53fca9036450d22e200ab2817024a1f9c0067c7c87", + "websocket/client/async-local/Jamfile": "d110e5ea88b614dd03707c44f59fbee90b721afbe302106a5459252e5983e311", + "websocket/client/async-local/websocket_client_async_local.cpp": "df9eacfbc9df03a34fcb1b4139f7b6c480e377ceb86f97ecd323d1f7825d55a8", + "websocket/client/async-ssl/CMakeLists.txt": "3d80f629a776d249d49c09b28518b8430789cc17e62692086d9eae272f819c73", + "websocket/client/async-ssl/Jamfile": "978d0512e88af97baf792ac76803b020cbe7f81991a342e726a27f3109b74f80", + "websocket/client/async-ssl/websocket_client_async_ssl.cpp": "4098df4a5fb6f4d6294cff1547d5823e0f2f3faf1f55975500e39014b822b7b9", + "websocket/client/async-ssl-system-executor/CMakeLists.txt": "356ea1d55ef6f17bd071616e941bebdb5193dbd4617c0677cf62395c126fe1d0", + "websocket/client/async-ssl-system-executor/Jamfile": "27ebe6127b420b562356801dad8bb24c67f1d543eeb360041e4230c146b92d1d", + "websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp": "20ab08f7820871e36456fe5760abeb5ad5cb0949529864cab93b12544754d91d", + "websocket/client/awaitable/CMakeLists.txt": "49f2563596b65d291870c354d3189905447c622d08d91b362df3c4d4829c96bb", + "websocket/client/awaitable/Jamfile": "630a0082ad6740602c5ab467d1cb3a14e2712947fcf66882f8b2bfcc06bce24c", + "websocket/client/awaitable/websocket_client_awaitable.cpp": "1643f654a9faf1c89467929f638bdf5bedacebfd20047059dff90847df95c411", + "websocket/client/coro/CMakeLists.txt": "64218162f612ee8ac2dabb86bb0c9939f542bf3ed4b654c07190471028795645", + "websocket/client/coro/Jamfile": "f067e9bad4e23697498a19f7a5de0b543cac530353cc10e603b3912deececeea", + "websocket/client/coro/websocket_client_coro.cpp": "fa03f7796b92b847082a3861c6e4c58918597cd73e6fa8346f5d3aa9542a4f4c", + "websocket/client/coro-ssl/CMakeLists.txt": "61fc82090d3825779d25c9459a874b6318a0b26ac18e946d218261b0a73775af", + "websocket/client/coro-ssl/Jamfile": "6f3c047324935b7a43ed8c1bdc10f9cde1a3361c495fb3f9049bf67bad7170a4", + "websocket/client/coro-ssl/websocket_client_coro_ssl.cpp": "e9813be3865b1113821636aa66b8eabc0c86c752e4094e6ab953a25bb4b07a0e", + "websocket/client/sync/CMakeLists.txt": "f33351c1e71db39065f08db467750ae26751c517a94f8233b369444f7ff5b1a9", + "websocket/client/sync/Jamfile": "fda4b6cf09e12364f2e50729d8d7cc64dbdd48553f0e94fd7bd8071411fa380d", + "websocket/client/sync/websocket_client_sync.cpp": "f41a2e80c5d4423337fc29d307edd7b254f8ef02d46482c1e5e7802a35319fee", + "websocket/client/sync-ssl/CMakeLists.txt": "3ea7e324e06aa7858b8ed547a46eb8384fffd7df5dc2fc37d61d6fc6ca0048a3", + "websocket/client/sync-ssl/Jamfile": "f782bdbb460b6aff841f30de0db261812e6fd93de19e3f0372b0cb42bc389503", + "websocket/client/sync-ssl/websocket_client_sync_ssl.cpp": "665b91b089855d64bf028eaddab9cb313df1a77ec0fe8a6459a6694c7873b67d", + "websocket/server/CMakeLists.txt": "a06ed3a01b09ca42327fd56ebc636886109fe5d7fed4f300618d6371add7e9f0", + "websocket/server/Jamfile": "180966f1942b47ecfcbda6ceac8084c855825651dfa3cffd415809af647a3dcd", + "websocket/server/async/CMakeLists.txt": "fbd316f7b8d47ba2bd88e88709f662860e75318c2a1958ba59a2c8400700ed62", + "websocket/server/async/Jamfile": "af4b7dde9e8d4a3b8463cee6c0c1d886c6036c2bf97e7797bf07c24a59a4a17f", + "websocket/server/async/websocket_server_async.cpp": "7c8353425941717ed7339935d857e7face75f0cfc0db743618ac1732ad45f1ab", + "websocket/server/async-local/CMakeLists.txt": "c07b4420b116b709e0691081ae0cd3cd486f213b6c7ff5931c70cf2b97ff792a", + "websocket/server/async-local/Jamfile": "fd3cd75e5d3181df0873eac6e01611bb06abb74605e068a77ffc62fc4d8d4d34", + "websocket/server/async-local/websocket_server_async_local.cpp": "fee7d38ca2c50934b2a188ec94a3f56e70a9bb114cf2a66dcb2149bd15ee9e84", + "websocket/server/async-ssl/CMakeLists.txt": "01b6b14c6726237899cdbb2e008fa33ea2afe7655b1c1ab44b97fc0f2ae28a16", + "websocket/server/async-ssl/Jamfile": "96fa37a5495763aa15e214eeffa3147f3cdb3b9168f25f510ed7946a6d43f34d", + "websocket/server/async-ssl/websocket_server_async_ssl.cpp": "88bc72fb879de2daf27ae4a052958f0c6cfa9de5ebab0342cc934bf250c009db", + "websocket/server/awaitable/CMakeLists.txt": "b1ee3cd77d0c85bd5161effabd9fa6f851eb690bbd49c8cfd248e83828e20c33", + "websocket/server/awaitable/Jamfile": "100a3bdb37c5d0e31d57ee369670f8baffa296a47338d48ee8742e2fa5ac4662", + "websocket/server/awaitable/websocket_server_awaitable.cpp": "d12e2e3633195e68a579996f6b77a0214d2e3a1fa2ff23c5b78b8274cd032f3c", + "websocket/server/chat-multi/CMakeLists.txt": "d49cd8a02e32f9648fa349498e844921199e1d1e8f89ec3612019916eb42cb9f", + "websocket/server/chat-multi/Jamfile": "6f1eed1800889b3669ad1a90784254ad65212591eda6a8b6034d68f2f2286716", + "websocket/server/chat-multi/beast.hpp": "613bd070ac645e514baaee813f54da5d3336583ec9d529ee0a1e7993c11e504f", + "websocket/server/chat-multi/chat_client.html": "105de4fce2f4c36c99edc872da0195617fec8dbd0c378435f055053244638a4b", + "websocket/server/chat-multi/http_session.cpp": "93e31131bf2b516158f61b1b3d7a87e363a3c086833314ea342022721e8dd20d", + "websocket/server/chat-multi/http_session.hpp": "19ff07949b7b85ee59c9a9517bb9032a737d63d012d5fd395ec06865174db932", + "websocket/server/chat-multi/listener.cpp": "58e6501890380dd734c69f9a39dfdcd264a276a5f1dc0135a2f55214c7950f01", + "websocket/server/chat-multi/listener.hpp": "4bb3f9dc51cee198660d1cc9d27b9cdfe763d1e6b98e21c4f3760f786d7b5478", + "websocket/server/chat-multi/main.cpp": "23742e3af586286404eb7670b7e21dc4ba1327c56c787b1e4f8f5fd441dcafe9", + "websocket/server/chat-multi/net.hpp": "4e2b0d03747ae82b6b594b6e6e5ad65fb7eccae9498451d7486be5d795ccac95", + "websocket/server/chat-multi/shared_state.cpp": "2757f7f63ef9499e433b668018415a6bfecfa015e89aeb1f8af8a03180d9421a", + "websocket/server/chat-multi/shared_state.hpp": "0936355348c3de0bdb46efb62e2cd917ead27bbf890626874d3061ba83635c9d", + "websocket/server/chat-multi/websocket_session.cpp": "d827e36b5b5a67168047e67a6ba027fbaf621231863c88e9cd47f1766a2b544f", + "websocket/server/chat-multi/websocket_session.hpp": "8a76f8e05a0f3a4467ec0a217728372ed699429f427211989f0ea271544b68ec", + "websocket/server/coro/CMakeLists.txt": "7facc531e9a695f1bbe22f910fa9f121fb2463c6ee1734f9874c6f41da4e87cc", + "websocket/server/coro/Jamfile": "b71a6aaa0401a2c6fce85e980e42f588718dc04bf9fef64923027f68d4d6bf73", + "websocket/server/coro/websocket_server_coro.cpp": "4cb6d60d4d708d5f69b3d435484f0004110ca79afa1b9313bd6ac38e0b64b882", + "websocket/server/coro-ssl/CMakeLists.txt": "cd664c67895fe1057fc9196f276adcd342ca4ac329b85b48d01fb9cca94a3c49", + "websocket/server/coro-ssl/Jamfile": "38665d8930139aadd256dfd5c296d8cb2a787dbcebc6af67c8fa8e320cbfc948", + "websocket/server/coro-ssl/websocket_server_coro_ssl.cpp": "6a0ef064a530c3254a30e357bac478584303b2b52dd07397d14b72293c1cb3b2", + "websocket/server/fast/CMakeLists.txt": "d3f9755218a506a88979fe4670fc9668715e3823db5689a1b8b4c83ea10e588e", + "websocket/server/fast/Jamfile": "f19b81810b70d5d563fad4b1f020aa95c92341ed4532c593c321a14987c2f4c7", + "websocket/server/fast/websocket_server_fast.cpp": "6335605dfe73c7b1fe4a6511c22ea896023e3bf4bffc13af1b4290255cca2608", + "websocket/server/stackless/CMakeLists.txt": "242acbde310c209293d5a51822280af254dd431ae30f76d47f8dbfb9415b85d4", + "websocket/server/stackless/Jamfile": "068169891cb6bb046eafc9d1945f287fe6fc655a9785b66cd0f365d9fd06ca44", + "websocket/server/stackless/websocket_server_stackless.cpp": "632b1cef70872b4a88ef305435b5efdd5182f66b40d90267dfa47f235e876fad", + "websocket/server/stackless-ssl/CMakeLists.txt": "9244f023a23b8be92d0a8d0afce5b3c90ea78fe5e2563776a0460c79fd4dc782", + "websocket/server/stackless-ssl/Jamfile": "e130faf6e121a31803a16bcb507b9edfcea7b998c405b3922ab854f68cddf2bf", + "websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp": "e332b0648c2c20f1c68d0c2514c0b7042bfbc030b72909f7eb1cb651e4366902", + "websocket/server/sync/CMakeLists.txt": "798d7a5439023141bb53aaaef9224b21700cad19918eceb2148bce46c12e7752", + "websocket/server/sync/Jamfile": "c95496c3cbe95d2d396b9e4f45bca95fe04b962801ca7a8905255f07d2370e89", + "websocket/server/sync/websocket_server_sync.cpp": "45465d151483066a4d05c196ab771f50dca417f26d583d616f037748ece78af0", + "websocket/server/sync-ssl/CMakeLists.txt": "07c8e03c87cb12c92ebb021913bbd12aa36587727ea8929b052762bad7f21b7e", + "websocket/server/sync-ssl/Jamfile": "8033e6eb7fa7bae5dd04c7cf00158827fde48077beac46b34048a51150589d65", + "websocket/server/sync-ssl/websocket_server_sync_ssl.cpp": "657dc21e4dd33778767281a50a2ea761c60d0cf6365d6cd29f456fcbef81c454" + } + }, + "applications": [ + { + "id": "advanced-server", + "path": "advanced/server", + "cmake_target": "advanced-server", + "sources": [ + "advanced/server/advanced_server.cpp" + ], + "entrypoint": "advanced/server/advanced_server.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "signals", + "threads" + ] + }, + { + "id": "advanced-server-flex", + "path": "advanced/server-flex", + "cmake_target": "advanced-server-flex", + "sources": [ + "advanced/server-flex/advanced_server_flex.cpp" + ], + "entrypoint": "advanced/server-flex/advanced_server_flex.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "signals", + "threads" + ] + }, + { + "id": "advanced-server-flex-awaitable", + "path": "advanced/server-flex-awaitable", + "cmake_target": "advanced-server-flex-awaitable", + "sources": [ + "advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp" + ], + "entrypoint": "advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "awaitable", + "signals", + "threads" + ] + }, + { + "id": "doc-ssl-client", + "path": "doc/ssl", + "cmake_target": "doc-ssl-client", + "sources": [ + "doc/ssl/client.cpp" + ], + "entrypoint": "doc/ssl/client.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "awaitable" + ] + }, + { + "id": "doc-ssl-server", + "path": "doc/ssl", + "cmake_target": "doc-ssl-server", + "sources": [ + "doc/ssl/server.cpp" + ], + "entrypoint": "doc/ssl/server.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "awaitable" + ] + }, + { + "id": "echo-op", + "path": "echo-op", + "cmake_target": "echo-op", + "sources": [ + "echo-op/echo_op.cpp" + ], + "entrypoint": "echo-op/echo_op.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [] + }, + { + "id": "http-client-async", + "path": "http/client/async", + "cmake_target": "http-client-async", + "sources": [ + "http/client/async/http_client_async.cpp" + ], + "entrypoint": "http/client/async/http_client_async.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "http-client-async-local", + "path": "http/client/async-local", + "cmake_target": "http-client-async-local", + "sources": [ + "http/client/async-local/http_client_async_local.cpp" + ], + "entrypoint": "http/client/async-local/http_client_async_local.cpp", + "tls": false, + "stackful": false, + "local_socket": true, + "server": false, + "dependencies": [ + "local-socket" + ] + }, + { + "id": "http-client-async-ssl", + "path": "http/client/async-ssl", + "cmake_target": "http-client-async-ssl", + "sources": [ + "http/client/async-ssl/http_client_async_ssl.cpp" + ], + "entrypoint": "http/client/async-ssl/http_client_async_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "http-client-async-ssl-system-executor", + "path": "http/client/async-ssl-system-executor", + "cmake_target": "http-client-async-ssl-system-executor", + "sources": [ + "http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp" + ], + "entrypoint": "http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "system-executor" + ] + }, + { + "id": "http-client-awaitable", + "path": "http/client/awaitable", + "cmake_target": "http-client-awaitable", + "sources": [ + "http/client/awaitable/http_client_awaitable.cpp" + ], + "entrypoint": "http/client/awaitable/http_client_awaitable.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "awaitable" + ] + }, + { + "id": "http-client-awaitable-ssl", + "path": "http/client/awaitable-ssl", + "cmake_target": "http-client-awaitable-ssl", + "sources": [ + "http/client/awaitable-ssl/http_client_awaitable_ssl.cpp" + ], + "entrypoint": "http/client/awaitable-ssl/http_client_awaitable_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "awaitable" + ] + }, + { + "id": "json_client", + "path": "http/client/body", + "cmake_target": "http-client-json", + "sources": [ + "http/client/body/json_client.cpp" + ], + "entrypoint": "http/client/body/json_client.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "http-client-coro", + "path": "http/client/coro", + "cmake_target": "http-client-coro", + "sources": [ + "http/client/coro/http_client_coro.cpp" + ], + "entrypoint": "http/client/coro/http_client_coro.cpp", + "tls": false, + "stackful": true, + "local_socket": false, + "server": false, + "dependencies": [ + "stackful" + ] + }, + { + "id": "http-client-coro-ssl", + "path": "http/client/coro-ssl", + "cmake_target": "http-client-coro-ssl", + "sources": [ + "http/client/coro-ssl/http_client_coro_ssl.cpp" + ], + "entrypoint": "http/client/coro-ssl/http_client_coro_ssl.cpp", + "tls": true, + "stackful": true, + "local_socket": false, + "server": false, + "dependencies": [ + "stackful" + ] + }, + { + "id": "http-crawl", + "path": "http/client/crawl", + "cmake_target": "http-crawl", + "sources": [ + "http/client/crawl/http_crawl.cpp", + "http/client/crawl/urls_large_data.cpp" + ], + "entrypoint": "http/client/crawl/http_crawl.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-client-methods", + "path": "http/client/methods", + "cmake_target": "http-client-methods", + "sources": [ + "http/client/methods/http_client_methods.cpp" + ], + "entrypoint": "http/client/methods/http_client_methods.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "http-client-sync", + "path": "http/client/sync", + "cmake_target": "http-client-sync", + "sources": [ + "http/client/sync/http_client_sync.cpp" + ], + "entrypoint": "http/client/sync/http_client_sync.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "http-client-sync-ssl", + "path": "http/client/sync-ssl", + "cmake_target": "http-client-sync-ssl", + "sources": [ + "http/client/sync-ssl/http_client_sync_ssl.cpp" + ], + "entrypoint": "http/client/sync-ssl/http_client_sync_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "http-server-async", + "path": "http/server/async", + "cmake_target": "http-server-async", + "sources": [ + "http/server/async/http_server_async.cpp" + ], + "entrypoint": "http/server/async/http_server_async.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-server-async-local", + "path": "http/server/async-local", + "cmake_target": "http-server-async-local", + "sources": [ + "http/server/async-local/http_server_async_local.cpp" + ], + "entrypoint": "http/server/async-local/http_server_async_local.cpp", + "tls": false, + "stackful": false, + "local_socket": true, + "server": true, + "dependencies": [ + "local-socket", + "threads" + ] + }, + { + "id": "http-server-async-ssl", + "path": "http/server/async-ssl", + "cmake_target": "http-server-async-ssl", + "sources": [ + "http/server/async-ssl/http_server_async_ssl.cpp" + ], + "entrypoint": "http/server/async-ssl/http_server_async_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-server-awaitable", + "path": "http/server/awaitable", + "cmake_target": "http-server-awaitable", + "sources": [ + "http/server/awaitable/http_server_awaitable.cpp" + ], + "entrypoint": "http/server/awaitable/http_server_awaitable.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "awaitable", + "threads" + ] + }, + { + "id": "http-server-coro", + "path": "http/server/coro", + "cmake_target": "http-server-coro", + "sources": [ + "http/server/coro/http_server_coro.cpp" + ], + "entrypoint": "http/server/coro/http_server_coro.cpp", + "tls": false, + "stackful": true, + "local_socket": false, + "server": true, + "dependencies": [ + "stackful", + "threads" + ] + }, + { + "id": "http-server-coro-ssl", + "path": "http/server/coro-ssl", + "cmake_target": "http-server-coro-ssl", + "sources": [ + "http/server/coro-ssl/http_server_coro_ssl.cpp" + ], + "entrypoint": "http/server/coro-ssl/http_server_coro_ssl.cpp", + "tls": true, + "stackful": true, + "local_socket": false, + "server": true, + "dependencies": [ + "stackful", + "threads" + ] + }, + { + "id": "http-server-fast", + "path": "http/server/fast", + "cmake_target": "http-server-fast", + "sources": [ + "http/server/fast/http_server_fast.cpp" + ], + "entrypoint": "http/server/fast/http_server_fast.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [] + }, + { + "id": "http-server-flex", + "path": "http/server/flex", + "cmake_target": "http-server-flex", + "sources": [ + "http/server/flex/http_server_flex.cpp" + ], + "entrypoint": "http/server/flex/http_server_flex.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-server-small", + "path": "http/server/small", + "cmake_target": "http-server-small", + "sources": [ + "http/server/small/http_server_small.cpp" + ], + "entrypoint": "http/server/small/http_server_small.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [] + }, + { + "id": "http-server-stackless", + "path": "http/server/stackless", + "cmake_target": "http-server-stackless", + "sources": [ + "http/server/stackless/http_server_stackless.cpp" + ], + "entrypoint": "http/server/stackless/http_server_stackless.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-server-stackless-ssl", + "path": "http/server/stackless-ssl", + "cmake_target": "http-server-stackless-ssl", + "sources": [ + "http/server/stackless-ssl/http_server_stackless_ssl.cpp" + ], + "entrypoint": "http/server/stackless-ssl/http_server_stackless_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-server-sync", + "path": "http/server/sync", + "cmake_target": "http-server-sync", + "sources": [ + "http/server/sync/http_server_sync.cpp" + ], + "entrypoint": "http/server/sync/http_server_sync.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "http-server-sync-ssl", + "path": "http/server/sync-ssl", + "cmake_target": "http-server-sync-ssl", + "sources": [ + "http/server/sync-ssl/http_server_sync_ssl.cpp" + ], + "entrypoint": "http/server/sync-ssl/http_server_sync_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "websocket-client-async", + "path": "websocket/client/async", + "cmake_target": "websocket-client-async", + "sources": [ + "websocket/client/async/websocket_client_async.cpp" + ], + "entrypoint": "websocket/client/async/websocket_client_async.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "websocket-client-async-local", + "path": "websocket/client/async-local", + "cmake_target": "websocket-client-async-local", + "sources": [ + "websocket/client/async-local/websocket_client_async_local.cpp" + ], + "entrypoint": "websocket/client/async-local/websocket_client_async_local.cpp", + "tls": false, + "stackful": false, + "local_socket": true, + "server": false, + "dependencies": [ + "local-socket" + ] + }, + { + "id": "websocket-client-async-ssl", + "path": "websocket/client/async-ssl", + "cmake_target": "websocket-client-async-ssl", + "sources": [ + "websocket/client/async-ssl/websocket_client_async_ssl.cpp" + ], + "entrypoint": "websocket/client/async-ssl/websocket_client_async_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "websocket-client-async-ssl-system-executor", + "path": "websocket/client/async-ssl-system-executor", + "cmake_target": "websocket-client-async-ssl-system-executor", + "sources": [ + "websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp" + ], + "entrypoint": "websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "system-executor" + ] + }, + { + "id": "websocket-client-awaitable", + "path": "websocket/client/awaitable", + "cmake_target": "websocket-client-awaitable", + "sources": [ + "websocket/client/awaitable/websocket_client_awaitable.cpp" + ], + "entrypoint": "websocket/client/awaitable/websocket_client_awaitable.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [ + "awaitable" + ] + }, + { + "id": "websocket-client-coro", + "path": "websocket/client/coro", + "cmake_target": "websocket-client-coro", + "sources": [ + "websocket/client/coro/websocket_client_coro.cpp" + ], + "entrypoint": "websocket/client/coro/websocket_client_coro.cpp", + "tls": false, + "stackful": true, + "local_socket": false, + "server": false, + "dependencies": [ + "stackful" + ] + }, + { + "id": "websocket-client-coro-ssl", + "path": "websocket/client/coro-ssl", + "cmake_target": "websocket-client-coro-ssl", + "sources": [ + "websocket/client/coro-ssl/websocket_client_coro_ssl.cpp" + ], + "entrypoint": "websocket/client/coro-ssl/websocket_client_coro_ssl.cpp", + "tls": true, + "stackful": true, + "local_socket": false, + "server": false, + "dependencies": [ + "stackful" + ] + }, + { + "id": "websocket-client-sync", + "path": "websocket/client/sync", + "cmake_target": "websocket-client-sync", + "sources": [ + "websocket/client/sync/websocket_client_sync.cpp" + ], + "entrypoint": "websocket/client/sync/websocket_client_sync.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "websocket-client-sync-ssl", + "path": "websocket/client/sync-ssl", + "cmake_target": "websocket-client-sync-ssl", + "sources": [ + "websocket/client/sync-ssl/websocket_client_sync_ssl.cpp" + ], + "entrypoint": "websocket/client/sync-ssl/websocket_client_sync_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": false, + "dependencies": [] + }, + { + "id": "websocket-server-async", + "path": "websocket/server/async", + "cmake_target": "websocket-server-async", + "sources": [ + "websocket/server/async/websocket_server_async.cpp" + ], + "entrypoint": "websocket/server/async/websocket_server_async.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "websocket-server-async-local", + "path": "websocket/server/async-local", + "cmake_target": "websocket-server-async-local", + "sources": [ + "websocket/server/async-local/websocket_server_async_local.cpp" + ], + "entrypoint": "websocket/server/async-local/websocket_server_async_local.cpp", + "tls": false, + "stackful": false, + "local_socket": true, + "server": true, + "dependencies": [ + "local-socket", + "threads" + ] + }, + { + "id": "websocket-server-async-ssl", + "path": "websocket/server/async-ssl", + "cmake_target": "websocket-server-async-ssl", + "sources": [ + "websocket/server/async-ssl/websocket_server_async_ssl.cpp" + ], + "entrypoint": "websocket/server/async-ssl/websocket_server_async_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "websocket-server-awaitable", + "path": "websocket/server/awaitable", + "cmake_target": "websocket-server-awaitable", + "sources": [ + "websocket/server/awaitable/websocket_server_awaitable.cpp" + ], + "entrypoint": "websocket/server/awaitable/websocket_server_awaitable.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "awaitable", + "threads" + ] + }, + { + "id": "websocket-chat-multi", + "path": "websocket/server/chat-multi", + "cmake_target": "websocket-chat-multi", + "sources": [ + "websocket/server/chat-multi/http_session.cpp", + "websocket/server/chat-multi/listener.cpp", + "websocket/server/chat-multi/main.cpp", + "websocket/server/chat-multi/shared_state.cpp", + "websocket/server/chat-multi/websocket_session.cpp" + ], + "entrypoint": "websocket/server/chat-multi/main.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "signals", + "threads" + ] + }, + { + "id": "websocket-server-coro", + "path": "websocket/server/coro", + "cmake_target": "websocket-server-coro", + "sources": [ + "websocket/server/coro/websocket_server_coro.cpp" + ], + "entrypoint": "websocket/server/coro/websocket_server_coro.cpp", + "tls": false, + "stackful": true, + "local_socket": false, + "server": true, + "dependencies": [ + "stackful", + "threads" + ] + }, + { + "id": "websocket-server-coro-ssl", + "path": "websocket/server/coro-ssl", + "cmake_target": "websocket-server-coro-ssl", + "sources": [ + "websocket/server/coro-ssl/websocket_server_coro_ssl.cpp" + ], + "entrypoint": "websocket/server/coro-ssl/websocket_server_coro_ssl.cpp", + "tls": true, + "stackful": true, + "local_socket": false, + "server": true, + "dependencies": [ + "stackful", + "threads" + ] + }, + { + "id": "websocket-server-fast", + "path": "websocket/server/fast", + "cmake_target": "websocket-server-fast", + "sources": [ + "websocket/server/fast/websocket_server_fast.cpp" + ], + "entrypoint": "websocket/server/fast/websocket_server_fast.cpp", + "tls": false, + "stackful": true, + "local_socket": false, + "server": true, + "dependencies": [ + "stackful", + "threads" + ] + }, + { + "id": "websocket-server-stackless", + "path": "websocket/server/stackless", + "cmake_target": "websocket-server-stackless", + "sources": [ + "websocket/server/stackless/websocket_server_stackless.cpp" + ], + "entrypoint": "websocket/server/stackless/websocket_server_stackless.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "websocket-server-stackless-ssl", + "path": "websocket/server/stackless-ssl", + "cmake_target": "websocket-server-stackless-ssl", + "sources": [ + "websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp" + ], + "entrypoint": "websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "websocket-server-sync", + "path": "websocket/server/sync", + "cmake_target": "websocket-server-sync", + "sources": [ + "websocket/server/sync/websocket_server_sync.cpp" + ], + "entrypoint": "websocket/server/sync/websocket_server_sync.cpp", + "tls": false, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + }, + { + "id": "websocket-server-sync-ssl", + "path": "websocket/server/sync-ssl", + "cmake_target": "websocket-server-sync-ssl", + "sources": [ + "websocket/server/sync-ssl/websocket_server_sync_ssl.cpp" + ], + "entrypoint": "websocket/server/sync-ssl/websocket_server_sync_ssl.cpp", + "tls": true, + "stackful": false, + "local_socket": false, + "server": true, + "dependencies": [ + "threads" + ] + } + ], + "support": { + "documentation_snippets": "doc/http_examples.hpp", + "tls": [ + "common/root_certificates.hpp", + "common/server_certificate.hpp" + ], + "json": "http/client/body/json_body.hpp", + "chat_html": "websocket/server/chat-multi/chat_client.html", + "crawler": [ + "http/client/crawl/urls_large_data.hpp", + "http/client/crawl/urls_large_data.cpp" + ], + "allocator": "http/server/fast/fields_alloc.hpp" + }, + "normalization": { + "http": "Compare status, application headers and decoded body. Keep raw output; ignore Date, Server and transport framing only.", + "websocket": "Compare text/binary mode, payload bytes and close outcome.", + "crawler": "Ignore elapsed wall time only; compare all counters/status buckets." + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..0be86b0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,298 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + beast::ssl_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream_, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (static_cast(ec)) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "http-client-async-ssl-system-executor", + "localhost", + port, + "/http", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-async-ssl-system-executor: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..1d7718d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,288 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + beast::ssl_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream_, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (static_cast(ec)) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-async-ssl", "localhost", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-async-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..5e1d6f1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/async/http_client_async.cpp @@ -0,0 +1,228 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-async", "127.0.0.1", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-async: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..d67b78d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,231 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = webcpp::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::ssl_stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client, net::use_awaitable); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req, net::use_awaitable); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple(net::use_awaitable)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && static_cast(ec)) { + webcpp_fixture::fail_stop(); + } +} + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-awaitable-ssl", "localhost", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-awaitable-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..7141d2b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,184 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results, net::use_awaitable); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req, net::use_awaitable); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-awaitable", "127.0.0.1", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-awaitable: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/body/json_body.hpp new file mode 100644 index 0000000..2bfab8b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/body/json_body.hpp @@ -0,0 +1,121 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(webcpp::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(webcpp::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/body/json_client.cpp new file mode 100644 index 0000000..5e8d08d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/body/json_client.cpp @@ -0,0 +1,112 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "json_body.hpp" + +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using webcpp::asio::ip::tcp; // from + +namespace { +int application_main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = webcpp_fixture::resolve(resolver, host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + return 0; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"json_client"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) { + return 1; + } + } + std::cout << "application json_client: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..19079e8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/http_crawl.cpp @@ -0,0 +1,342 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + webcpp::asio::ip::tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, webcpp::asio::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. + for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); + } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-crawl", "2"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Success : 3") == std::string::npos) { + return 1; + } + } + std::cout << "application http-crawl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..969d6db --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,25 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"127.0.0.1", "127.0.0.1", "127.0.0.1"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..b0ad468 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..3776676 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/methods/http_client_methods.cpp @@ -0,0 +1,252 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using webcpp::asio::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream transport(ioc); + beast::browser::http_byte_stream stream(transport); + + // Look up the domain name + auto const results = + webcpp_fixture::resolve(resolver, webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + transport.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + transport.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully + } + return EXIT_SUCCESS; +} + +//] + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + for (const auto* method : {"get", "head", "post", "put", "patch", "delete"}) { + std::vector storage{"http-client-methods", method}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("200 OK") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-methods: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..67dcfbc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,186 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tls_client); + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::ssl_stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = webcpp_fixture::resolve(resolver, host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + stream.shutdown(ec); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (static_cast(ec)) { + webcpp_fixture::fail_stop(); + } + } + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-sync-ssl", "localhost", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-sync-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..ea74716 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/http/client/sync/http_client_sync.cpp @@ -0,0 +1,152 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = webcpp_fixture::resolve(resolver, host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully + } + return EXIT_SUCCESS; +} + +//] + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{"http-client-sync", "127.0.0.1", port, "/http"}; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; + } + } + std::cout << "application http-client-sync: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..caad897 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,304 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(ws_.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-async-ssl-system-executor", + "localhost", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-async-ssl-system-executor: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..eb4fe28 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,296 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(ws_.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-async-ssl", + "localhost", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-async-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..b6dccbd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,255 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp::asio::ip::tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-async", + "127.0.0.1", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-async: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..a04ee4e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,183 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port, net::use_awaitable); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = + co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/", net::use_awaitable); + + // Send the message + co_await stream.async_write(net::buffer(text), net::use_awaitable); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer, net::use_awaitable); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal, net::use_awaitable); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-awaitable", + "127.0.0.1", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-awaitable: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..96099b2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,176 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = webcpp::asio::ssl; // from +using webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tls_client}; + + // Verify the remote server's certificate + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); + if (verify_error) { + webcpp_fixture::fail_stop(); + } + } + + // This holds the root certificate used for verification + // Browser trust store owns TLS authorities. + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = webcpp_fixture::resolve(resolver, host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).connect(results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + beast::set_server_name(ws.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; +} + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("beastSecurePort").as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "localhost", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-sync-ssl", + "localhost", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-sync-ssl: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..a73cace --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-browser/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,152 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +// from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +namespace { +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int application_main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + webcpp::asio::ip::tcp::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = webcpp_fixture::resolve(resolver, host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = ws.next_layer().connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + /* Browser owns handshake User-Agent. */ + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; +} + +//] + +} // namespace + +#include +#include +#include + +int main() { + const auto port = emscripten::val::global("location")["port"].as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", "127.0.0.1", 1) != 0) { + return 1; + } + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) { + return 1; + } + { + std::vector storage{ + "websocket-client-sync", + "127.0.0.1", + port, + "Beast fixture echo", + }; + std::vector arguments; + arguments.reserve(storage.size()); + for (auto& value : storage) { + arguments.push_back(value.data()); + } + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; + } + } + std::cout << "application websocket-client-sync: passed\n"; + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp new file mode 100644 index 0000000..eb15c16 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp @@ -0,0 +1,663 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +using executor_type = net::strand; +using stream_type = beast::tcp_stream::rebind_executor::other; +using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +/** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. +*/ +class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit task_group(net::any_io_executor exec) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; + task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + + @note `completion_token` must have an associated executor that matches + the one the child task runs on (e.g. via `net::bind_executor`). This is + because `emit`() can run on a different thread than the task, and + `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template + auto adapt(CompletionToken&& completion_token) { + auto const lg = std::scoped_lock{mtx_}; + auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: + remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + + ~remover() { + if (tg_) { + auto const lg = std::scoped_lock{tg_->mtx_}; + if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); + } + } + } + }; + + return net::bind_cancellation_slot( + cs->slot(), + net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's + handler, if any. + + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { + auto const lg = std::scoped_lock{mtx_}; + for (auto& cs : css_) { + cs.emit(type); + } + } + + /** Starts an asynchronous wait on the task_group. + + The completion handler will be called when: + + - All the child tasks completed. + - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion + handler must be: + @code + void handler( + boost::system::error_code const& error // result of operation + ); + @endcode + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template > + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( + // The apparent recursion crosses an asynchronous completion boundary. + // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { + if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); + } + + if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; + } + + { + auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + + if (!std::exchange(scheduled, true)) { + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); + } + + self.complete(ec); + }, + completion_token, cv_); + } +}; + +template +net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { + auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + + while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; + } + + if (ec) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + ws.text(ws.got_text()); + co_await ws.async_write(buffer.data()); + + // Clear the buffer + buffer.consume(buffer.size()); + } + + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +template +net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + + if (ec == http::error::end_of_stream) { + co_return; + } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + + co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); + if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } + + co_await beast::async_write(stream, std::move(res)); + } +} + +net::awaitable detect_session(stream_type stream, ssl::context& ctx, + beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), + net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be + // inherited by all child coroutines. + co_await net::this_coro::throw_if_cancelled(false); + + stream.expires_after(std::chrono::seconds(30)); + + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + + auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + + if (!ssl_stream.lowest_layer().is_open()) { + co_return; + } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } + } else { + co_await run_session(stream, buffer, doc_root); + + if (!stream.socket().is_open()) { + co_return; + } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +} + +net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + + if (ec == net::error::operation_aborted) { + co_return; + } + + if (ec) { + webcpp_fixture::fail_stop(); + } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }))); + } +} + +net::awaitable handle_signals(task_group& task_group) { + auto const executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto sig = co_await signal_set.async_wait(); + + if (sig == SIGINT) { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( + net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); + + if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); + co_await task_group.async_wait(); + } + + std::cout << "Child tasks completed.\n"; + } else // SIGTERM + { + net::query(executor.get_inner_executor(), net::execution::context).stop(); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }))); + + // Create and launch a signal handler coroutine + net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server-flex/advanced_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server-flex/advanced_server_flex.cpp new file mode 100644 index 0000000..d7926d4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server-flex/advanced_server_flex.cpp @@ -0,0 +1,875 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class websocket_session { + websocket_session() = default; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( + websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, + derived().shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, + derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), + beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } + +public: + // Start the asynchronous operation + template + void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; + +public: + // Create the session + explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; + +public: + // Create the ssl_websocket_session + explicit ssl_websocket_session(ssl::stream&& stream) + : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream>& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +template +void make_websocket_session(beast::tcp_stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +template +void make_websocket_session(ssl::stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +protected: + beast::flat_buffer buffer; + +public: + // Construct the session +private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, + derived().shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream)) {} + + // Start the session + void run() { this->do_read(); } + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Called by the base class + beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the http_session + ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream), ctx) {} + + // Start the session + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( + ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Called by the base class + ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + +private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + explicit detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); + } + + void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( + stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(std::move(stream_), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector http_session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" + << "Example:\n" + << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&](beast::error_code const&, int) { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server/advanced_server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server/advanced_server.cpp new file mode 100644 index 0000000..bf2ed20 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/advanced/server/advanced_server.cpp @@ -0,0 +1,630 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, + shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection +class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +public: + // Take ownership of the socket + http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) { + static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + +private: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read(stream_, buffer_, *parser_, + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + std::make_shared(stream_.release_socket()) + ->do_accept(parser_->release()); + return; + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(acceptor_.get_executor(), + beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the http session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" + << "Example:\n" + << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&](beast::error_code const&, int) { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/common/root_certificates.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/common/root_certificates.hpp new file mode 100644 index 0000000..f210458 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/common/root_certificates.hpp @@ -0,0 +1,3983 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP + +#include +#include + +/* + PLEASE READ + + These root certificates here are included just to make the + SSL client examples work. They are NOT intended to be + illustrative of best-practices for performing TLS certificate + verification. + + A REAL program which needs to verify the authenticity of a + server IP address resolved from a given DNS name needs to + consult the operating system specific certificate store + to validate the chain of signatures, compare the domain name + properly against the domain name in the certificate, check + the certificate revocation list, and probably do some other + things. + + ALL of these operations are entirely outside the scope of + both Boost.Beast and Boost.Asio. + + See (work in progress): + https://github.com/djarek/certify + + tl;dr: root_certificates.hpp should not be used in production code +*/ + +namespace ssl = boost::asio::ssl; // from + +namespace detail { + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(ctx.load_verify_file(path, ec)); + return; + } + + std::string cert = + "# ACCVRAIZ1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" + "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" + "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ\n" + "BgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwHUEtJQUNDVjENMAsGA1UECgwEQUND\n" + "VjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCb\n" + "qau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gMjmoY\n" + "HtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWo\n" + "G2ioPej0RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpA\n" + "lHPrzg5XPAOBOp0KoVdDaaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a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1W8rB2Vt2lh8kORdOag0wok\n" + "RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" + "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Actalis Authentication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" + "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" + "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv\n" + "UTufClrJwkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX\n" + "4ay8IMKx4INRimlNAJZaby/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9\n" + "KK3giq0itFZljoZUj5NDKd45RnijMCO6zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/\n" + "gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1fYVEiVRvjRuPjPdA1Yprb\n" + "rxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2oxgkg4YQ\n" + "51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8geb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kn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU\n" + "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" + "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Commercial\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" + "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" + "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL\n" + "MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1\n" + "yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr\n" + "VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/\n" + "nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG\n" + "XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj\n" + "vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt\n" + "Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g\n" + "N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" + "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Networking\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBOZXR3b3JraW5nMB4XDTEwMDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SEHi3y\n" + "YJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbua\n" + "kCNrmreIdIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRL\n" + "QESxG9fhwoXA3hA/Pe24/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp\n" + "6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG\n" + "yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i\n" + "QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfO\n" + "tDIuUFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzu\n" + "QY0x2+c06lkh1QF612S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZ\n" + "Lgo/bNjR9eUJtGxUAArgFU2HdW23WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4u\n" + "olu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9/ZFvgrG+CJPbFEfxojfHRZ48\n" + "x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVz\n" + "dCBQcmVtaXVtMB4XDTEwMDEyOTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkG\n" + "A1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1U\n" + "cnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxBLf\n" + "qV/+Qd3d9Z+K4/as4Tx4mr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mS2NuB2OosSw/WDQ\n" + "MKSOyARiqcTtNd56l+0OOF6SL5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc\n" + "0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK+4w1IX2COPKpVJEZNZOUbWo6xbLQ\n" + "u4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF\n" + "u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH\n" + "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" + "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" + "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" + "KeC2uAloGRwYQw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" + "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" + "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" + "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" + "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" + "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" + "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" + "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" + "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" + "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK\n" + "gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ\n" + "W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg\n" + "1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQ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R8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+\n" + "fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n" + "n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Atos TrustedRoot 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE\n" + "AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG\n" + "EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAM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RsPCHe6ed\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Autoridad de Certificacion Firmaprofesional CIF A62634068\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UE\n" + "BhMCRVMxQjBABgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1h\n" + "cHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEy\n" + "MzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIwQAYDVQQDDDlBdXRvcmlkYWQgZGUg\n" + "Q2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBBNjI2MzQwNjgwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDDUtd9\n" + "thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQM\n" + "cas9UX4PB99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefG\n" + "L9ItWY16Ck6WaVICqjaY7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15i\n" + "NA9wBj4gGFrO93IbJWyTdBSTo3OxDqqHECNZXyAFGUftaI6SEspd/NYrspI8IM/h\n" + "X68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyIplD9amML9ZMWGxmPsu2b\n" + "m8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctXMbScyJCy\n" + "Z/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirja\n" + "EbsXLZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/T\n" + "KI8xW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I8nkvof/uZS2+F0g\n" + "StRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTDKCOM/icz\n" + "Q0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQB\n" + "jLMi6Et8Vcad+qMUu2WFbm5PEn4KPJ2V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Baltimore CyberTrust Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" + "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" + "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" + "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" + "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" + "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" + "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" + "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" + "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" + "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" + "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" + "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" + "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" + "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" + "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" + "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" + "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" + "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" + "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" + "BQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1g1Lr\n" + "6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPV\n" + "L4O2fuPn9Z6rYPnT8Z2SdIrkHJasW4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oIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us\n" + "H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ\n" + "I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7\n" + "5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" + "3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" + "Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 3 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" + "BQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRHsJ8Y\n" + "ZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3E\n" + "N3coTRiR5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9\n" + "tznDDgFHmV0ST9tD+leh7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vK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MsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz6MkE\n" + "kbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41\n" + "3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD\n" + "u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq\n" + "4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CA Disig Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV\n" + "BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu\n" + "MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy\n" + "MDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sxEzARBgNVBAcTCkJyYXRpc2xhdmEx\n" + "EzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERpc2lnIFJvb3QgUjIw\n" + "ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbCw3Oe\n" + "NcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNH\n" + "PWSb6WiaxswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3I\n" + "x2ymrdMxp7zo5eFm1tL7A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbe\n" + "QTg06ov80egEFGEtQX6sx3dOy1FU+16SGBsEWmjGycT6txOgmLcRK7fWV8x8nhfR\n" + "yyX+hk4kLlYMeE2eAR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+ "G5gPcFw0sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3Os\n" + "zMOl6W8KjptlwlCFtaOgUxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8x\n" + "L4ysEr3vQCj8KWefshNPZiTEUxnpHikV7+ZtsH8tZ/3zbBt1RqPlShfppNcL\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CFCA EV ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD\n" + "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx\n" + "MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j\n" + "aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJP\n" + "T1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnVBU03\n" + "sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpL\n" + "TIpTUnrD7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5\n" + "/ZOkVIBMUtRSqy5J35DNuF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp\n" + "7hZZLDRJGqgG16iI0gNyejLi6mhNbiyWZXvKWfry4t3uMCz7zEasxGPrb382KzRz\n" + "EpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7xzbh72fROdOXW3NiGUgt\n" + "hxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+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OaHIz16eGWRGENoXkbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+Z\n" + "AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ\n" + "5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB\n" + "gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV\n" + "BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw\n" + "MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl\n" + "YXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01P\n" + "RE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3\n" + "UcEbVASY06m/weaKXTuH+7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI\n" + "2GqGd0S7WWaXUF601CxwRM/aN5VCaTwwxHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8\n" + "Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV4EajcNxo2f8ESIl33rXp\n" + "+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA1KGzqSX+\n" + "DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5O\n" + "nKVIrLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW\n" + "/zAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6g\n" + "PKA6hjhodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9u\n" + "QXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAPpiem/Yb6dc5t3iuHXIY\n" + "SdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CPOGEIqB6BCsAv\n" + "IC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/\n" + "RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4\n" + "zJVSk/BwJVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd\n" + "BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB\n" + "ZQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" + "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" + "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" + "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" + "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" + "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" + "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" + "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB\n" + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU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GMA8GA1UdEwEB\n" + "/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl\n" + "wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM\n" + "4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV\n" + "2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna\n" + "FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ\n" + "CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK\n" + "boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke\n" + "jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL\n" + "S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb\n" + "QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl\n" + "0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB\n" + "NVOFBkpdn627G190\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNV\n" + "BAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4X\n" + "DTA3MDYyOTE1MTMwNVoXDTI3MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQ\n" + "BgNV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v/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw\n" + "WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw\n" + "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + "MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x\n" + "MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD\n" + "VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX\n" + "BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" + "ggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sO\n" + "ty3tRQgXstmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9M\n" + "CiBtnyN6tMbaLOQdLNyzKNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPu\n" + "I9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8JXrJhFwLrN1CTivngqIkicuQstDuI7pm\n" + "TLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16XdG+RCYyKfHx9WzMfgIh\n" + "C59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq4NYKpkDf\n" + "ePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3Yz\n" + "IoejwpKGbvlw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k1\n" + "gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS6Cvu5zHbugRqh5jnxV/v\n" + "faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63\n" + "Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh\n" + "jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw\n" + "3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM\n" + "MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D\n" + "ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBU\n" + "cnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIyMTIwNzM3WhcNMjkxMjMxMTIwNzM3\n" + "WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMg\n" + "Uy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSIw\n" + "IAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0B\n" + "AQEFAAOCAQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rH\n" + "UV+rpDKmYYe2bg+G0jACl/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LM\n" + "TXPb865Px1bVWqeWifrzq2jUI4ZZJ88JJ7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVU\n" + "BBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4fOQtf/WsX+sWn7Et0brM\n" + "kUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0cvW0QM8x\n" + "AcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNV\n" + "HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15y\n" + "sHhE49wcrwn9I0j6vSrEuVUEtRCjjSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfL\n" + "I9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1mS1FhIrlQgnXdAIv94nYmem8\n" + "J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5ajZt3hrvJBW8qY\n" + "VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI\n" + "03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCB\n" + "gDELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMu\n" + "QS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIG\n" + "A1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y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B0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMC\n" + "AQYwDQYJKoZIhvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQ\n" + "F/xlhMcQSZDe28cmk4gmb3DWAl45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTf\n" + "CVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuAL55MYIR4PSFk1vtBHxgP58l1cb29\n" + "XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMoclm2q8KMZiYcdywm\n" + "djWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tMpkT/\n" + "WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jb\n" + "AoJnwTnbw3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksq\n" + "P/ujmv5zMnHCnsZy4YpoJ/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Ko\n" + "b7a6bINDd82Kkhehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnj\n" + "XALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P\n" + "5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbi\n" + "DrW5viSP\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Chambers of Commerce Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmN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pSB7+R5KBWIBpih1YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MD\n" + "xvbxrN8y8NmBGuScvfaAFPDRLLmF9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QG\n" + "tjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcKzBIKinmwPQN/aUv0NCB9szTq\n" + "jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De\n" + "fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg\n" + "OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ\n" + "d0jQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Comodo AAA Services root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb\n" + "MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow\n" + "GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj\n" + "YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM\n" + "GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" + "ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua\n" + "BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe\n" + "3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4\n" + "YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR\n" + "rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm\n" + "ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU\n" + "oBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20v\n" + "QUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29t\n" + "b2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUF\n" + "AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q\n" + "GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz\n" + "Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2\n" + "G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi\n" + "l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3\n" + "smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Cybertrust Global Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDoTCCAomgAwI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ogp24CJJ8iYGd7ix1yCcUx\n" + "XOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2hO0j9n0Hq0V+09+zv+mKts2o\n" + "omcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+TX3EJIrduPuoc\n" + "A06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW\n" + "WL1WMRJOEcgh4LMRkWXbtKaIOM5V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\n" + "ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM\n" + "HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03\n" + "UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42\n" + "tSHKXzlABF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9R\n" + "ySPocq60vFYJfxLLHLGvKZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsM\n" + "lFqVlNpQmvH/pStmMaTJOKDfHR+4CS7zp+hnUquVH+BGPtikw8paxTGA6Eian5Rp\n" + "/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUCAwEAAaOCARowggEWMA8G\n" + "A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ4PGEMA4G\n" + "A1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVj\n" + "dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUy\n" + "MENBJTIwMiUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRl\n" + "cmV2b2NhdGlvbmxpc3QwQ6BBoD+GPWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3Js\n" + "L2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAwOS5jcmwwDQYJKoZIhvcNAQEL\n" + "BQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm2H6NMLVwMeni\n" + "acfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0\n" + "o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K\n" + "zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8\n" + "PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y\n" + "Johw1+qRzT65ysCQblrGXnRl11z+o+I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 EV 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBID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UiO8aEXUHL7P+PPoeUSbrh/Yp\n" + "3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05\n" + "nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNF\n" + "CSuGdXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na\n" + "xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX\n" + "KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DST Root CA X3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" + "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" + "DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" + "PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" + "Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + "AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" + "rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" + "OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" + "xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" + "7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" + "aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" + "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" + "SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" + "ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" + "AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" + "R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" + "JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" + "Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c\n" + "JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP\n" + "mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+\n" + "wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4\n" + "VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/\n" + "AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB\n" + "AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW\n" + "BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun\n" + "pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC\n" + "dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf\n" + "fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm\n" + "NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx\n" + "H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe\n" + "+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/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lmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAWhsI6yLETcDbYz+70CjTVW0z9\n" + "B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv\n" + "ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo\n" + "IhNzbM8m9Yop5w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg\n" + "RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq\n" + "hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf\n" + "Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q\n" + "RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD\n" + "AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY\n" + "JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv\n" + "6pZjamVFkpUBtA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" + "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" + "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" + "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" + "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" + "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" + "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" + "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" + "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" + "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n" + "MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI\n" + "2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx\n" + "1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ\n" + "q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz\n" + "tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ\n" + "vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP\n" + "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV\n" + "5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY\n" + "1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4\n" + "NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG\n" + "Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91\n" + "8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe\n" + "pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl\n" + "MrY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe\n" + "Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw\n" + "EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x\n" + "IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF\n" + "K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG\n" + "fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO\n" + "Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd\n" + "BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx\n" + "AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/\n" + "oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8\n" + "sycX\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert High Assurance EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n" + "ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n" + "LmRpZ2ljZX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n" + "\n"; + cert += + "# DigiCert Trusted Root G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3Qg\n" + "RzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBiMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3y\n" + "ithZwuEppz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1If\n" + "xp4VpX6+n6lXFllVcq9ok3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDV\n" + "ySAdYyktzuxeTsiT+CFhmzTrBcZe7FsavOvJz82sNEBfsXpm7nfISKhmV1efVFiO\n" + "DCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGYQJB5w3jHtrHEtWoYOAMQ\n" + "jdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6MUSaM0C/\n" + "CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCi\n" + "EhtmmnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADM\n" + "fRyVw4/3IbKyEbe7f/LVjHAsQWCqsWMYRJUadmJ+9oCw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ATE-----\n" + "\n"; + cert += + "# E-Tugra Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNV\n" + "BAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBC\n" + "aWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNV\n" + "BAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQDDB9FLVR1\n" + "Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMwNTEyMDk0OFoXDTIz\n" + "MDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+\n" + "BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhp\n" + "em1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN\n" + "ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4vU/kwVRHoViVF56C/UY\n" + "B4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vdhQd2h8y/L5VMzH2nPbxH\n" + "D5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5KCKpbknSF\n" + "Q9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEo\n" + "q1+gElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3D\n" + "k14opz8n8Y4e0ypQBaNV2cvnOVPAmJ6MVGK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3oS7AwaboMMPOhy\n" + "Rp/7SNVel+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOS\n" + "Agu+TGbrIP65y7WZf+a2E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xl\n" + "nJ2lYJU6Un/10asIbvPuW/mIPX64b24D5EI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EE Certification Centre Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1\n" + "MQswCQYDVQQGEwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1\n" + "czEoMCYGA1UEAwwfRUUgQ2VydGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYG\n" + "CSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIwMTAxMDMwMTAxMDMwWhgPMjAzMDEy\n" + "MTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlBUyBTZXJ0aWZpdHNl\n" + "ZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRyZSBS\n" + "b290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEB\n" + "AQUAA4IBDwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUy\n" + "euuOF0+W2Ap7kaJjbMeMTC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvO\n" + "bntl8jixwKIy72KyaOBhU8E2lf/slLo2rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIw\n" + "WFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw93X2PaRka9ZP585ArQ/d\n" + "MtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtNP2MbRMNE\n" + "1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYD\n" + "VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/\n" + "zQas8fElyalL1BSZMEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYB\n" + "BQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEF\n" + "BQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+RjxY6hUFaTlrg4wCQiZrxTFGGV\n" + "v9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqMlIpPnTX/dqQG\n" + "E5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u\n" + "uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIW\n" + "iAYLtqZLICjU3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/v\n" + "GVCJYMzpJJUPwssd8m92kMfMdcGWxZ0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust.net Premium 2048 Secure Server CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML\n" + "RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp\n" + "bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5\n" + "IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp\n" + "ZmljYXRpb24gQ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89vqbllRrDtRnDvV5b\n" + "u/8j72gZyxKTJ1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+\n" + "bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er\n" + "fF6adulZkMV8gzURZVE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\n" + "Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\n" + "KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\n" + "cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw\n" + "NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw\n" + "NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy\n" + "ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV\n" + "BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ\n" + "KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo\n" + "Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4\n" + "4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9\n" + "KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI\n" + "rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi\n" + "94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB\n" + "sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi\n" + "gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo\n" + "kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE\n" + "vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t\n" + "O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua\n" + "AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP\n" + "9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/\n" + "eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\n" + "0vdXcDazv/wor3ElhVsT/h5/WrQ8\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - EC1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG\n" + "A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3\n" + "d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu\n" + "dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq\n" + "RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy\n" + "MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD\n" + "VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0\n" + "L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g\n" + "Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD\n" + "ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi\n" + "A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt\n" + "ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH\n" + "Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O\n" + "BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC\n" + "R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX\n" + "hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G2\n" + "-----B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2jZRjJKRxAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAP\n" + "BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN\n" + "BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/\n" + "jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ\n" + "Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v\n" + "1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R\n" + "nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH\n" + "VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAw\n" + "gb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL\n" + "Ex9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykg\n" + "MjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMjAw\n" + "BgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEc0\n" + "MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3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DgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg\n" + "p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZm\n" + "DRd9FBUb1Ov9H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5\n" + "COmSdI31R9KrO9b7eGZONn356ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ry\n" + "L3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd+PwyvzeG5LuOmCd+uh8W4XAR8gPf\n" + "JWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQHtZa37dG/OaG+svg\n" + "IHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBDF8Io\n" + "2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV\n" + "09tL7ECQ8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQ\n" + "XR4EzzffHqhmsYzmIGrv/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrq\n" + "T8p+ck0LcIymSLumoRT2+1hEmRSuqguTaaApJUqlyyvdimYHFngVV3Eb7PVHhPOe\n" + "MTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAw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yHuY3UjKcC9FhHb8owbZEKTV1\n" + "d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6Z\n" + "XPYfcX3v73svfuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZR\n" + "gyFmxhE+885H7pwoHyXa/6xmld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3\n" + "d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9bgsiG1eGZbYwE8na6SfZu6W0eX6Dv\n" + "J4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq4BjFbkerQUIpm/Zg\n" + "DdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWErtXvM\n" + "+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyy\n" + "F62ARPBopY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9\n" + "SQ98POyDGCBDTtWTurQ0sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdws\n" + "E3PYJ/HQcu51OyLemGhmW/HGY0dVHLqlCFF1pkgl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg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1qPKzEUURout\n" + "736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2A\n" + "DDL24CejQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBTB8Sa6oC2uhYHP0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFuk\n" + "fCPAlaUs3L6JbyO5o91lAFJekazInXJ0glMLfalAvWhgxeG4VDvBNhcl2MG9AjEA\n" + "njWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOaKaqW04MjyaR7YbPMAuhd\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu\n" + "hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/l\n" + "xKvRHYqjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBSATNbrdP9JNqPV2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0\n" + "CMRw3J5QdCHojXohw0+WbhXRIjVhLfoIN+4Zba3bssx9BzT1YBkstTTZbyACMANx\n" + "sbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11xzPKwTdb+mciUqXWi4w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Global CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\n" + "YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG\n" + "EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg\n" + "R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9\n" + "9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq\n" + "fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\n" + "iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\n" + "1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\n" + "bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\n" + "MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\n" + "ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\n" + "uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\n" + "Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\n" + "tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\n" + "PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n" + "hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n" + "5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY\n" + "MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo\n" + "R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx\n" + "MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK\n" + "Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9\n" + "AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA\n" + "ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0\n" + "7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W\n" + "kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI\n" + "mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1\n" + "6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl\n" + "4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K\n" + "oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj\n" + "UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU\n" + "AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL\n" + "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj\n" + "KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2\n" + "MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV\n" + "BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw\n" + "NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV\n" + "BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH\n" + "MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL\n" + "So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal\n" + "tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG\n" + "CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT\n" + "qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz\n" + "rD6ogRLQy7rQkgu2npaqBA+K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB\n" + "mDELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsT\n" + "MChjKSAyMDA4IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s\n" + "eTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhv\n" + "cml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIzNTk1OVowg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IFyqCXDFdRootD4abdNlF+9RAsXqqaC2G\n" + "spki4cErx5z481+oghLrGREt\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE\n" + "BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0\n" + "IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV\n" + "VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8\n" + "cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT\n" + "QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh\n" + "F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v\n" + "c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w\n" + "mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd\n" + "VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX\n" + "teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ\n" + "f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0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BEGIN CERTIFICATE-----\n" + "MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ\n" + "FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F\n" + "uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX\n" + "kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs\n" + "ewv4n4Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc\n" + "8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke\n" + "hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI\n" + "KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg\n" + "515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO\n" + "xwy8p2Fp8fc74SrL+SvzZpA3\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\n" + "A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\n" + "b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw\n" + "MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\n" + "YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT\n" + "aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ\n" + "jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp\n" + "xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp\n" + "1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG\n" + "snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ\n" + "U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8\n" + "9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E\n" + "BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B\n" + "AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz\n" + "yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE\n" + "38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP\n" + "AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\n" + "DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\n" + "HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcN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vRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7\n" + "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\n" + "MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\n" + "RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\n" + "gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\n" + "KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\n" + "QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\n" + "XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\n" + "LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\n" + "RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\n" + "jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n" + "6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\n" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\n" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\n" + "WD9f\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R6\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg\n" + "MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh\n" + "bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQx\n" + "MjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjET\n" + "MBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCAiIwDQYJ\n" + "KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQssgrRI\n" + "xutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1k\n" + "ZguSgMpE3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxD\n" + "aNc9PIrFsmbVkJq3MQbFvuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJw\n" + "Ln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cPu9czc8FB10jZp\n" + "nOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs\n" + "pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v\n" + "JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R\n" + "8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4\n" + "5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Global Chambersign Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD\n" + "aGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMxNDBaFw0zODA3MzEx\n" + "MjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3Vy\n" + "cmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAG\n" + "A1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAl\n" + "BgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZI\n" + "hvcNAQEBBQADggIPADCCAgoCggIBAMDfVtPkOpt2RbQT2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kEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiC\n" + "CQDJzdPp1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCow\n" + "KAYIKwYBBQUHAgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZI\n" + "hvcNAQEFBQADggIBAICIf3DekijZBZRG/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZ\n" + "UohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6ReAJ3spED8IXDneRRXoz\n" + "X1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/sdZ7LoR/x\n" + "fxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVz\n" + "a2Mg9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yyd\n" + "Yhz2rXzdpjEetrHHfoUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMd\n" + "SqlapskD7+3056huirRXhOukP9DuqqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9O\n" + "AP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETrP3iZ8ntxPjzxmKfFGBI/5rso\n" + "M0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVqc5iJWzouE4ge\n" + "v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z\n" + "09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQsw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ADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy\n" + "OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P\n" + "TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ\n" + "HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER\n" + "dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf\n" + "ReYNnyicsbkqWletNw+vHX/bvZ8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" + "EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp\n" + "ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz\n" + "NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH\n" + "EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE\n" + "AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw\n" + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD\n" + "E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH\n" + "/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy\n" + "DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh\n" + "GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR\n" + "tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA\n" + "AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE\n" + "FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX\n" + "WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu\n" + "9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr\n" + "gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo\n" + "2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n" + "LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n" + "4uJEvlz36hz1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions ECC RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN\n" + "BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl\n" + "bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv\n" + "b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ\n" + "BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj\n" + "YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5\n" + "MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0\n" + "dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg\n" + "QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa\n" + "jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC\n" + "MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi\n" + "C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep\n" + "lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof\n" + "TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1Ix\n" + "RDBCBgNVBAoTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAwP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6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8\n" + "TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7\n" + "dIsXRSZMFpGD/md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8Acys\n" + "Nnq/onN694/BtZqhFLKPM58N7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXI\n" + "l7WdmplNsDz4SgCbZN2fOUvRJ9e4\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix\n" + "DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k\n" + "IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT\n" + "N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9v\n" + "dENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAxMTIxWjCBpjELMAkG\n" + "A1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNh\n" + "ZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkx\n" + "QDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgUm9vdENBIDIwMTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" + "AQDC+Kk/G4n8PDwEXT2QNrCROnk8ZlrvbTkBSRq0t89/TSNTt5A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rv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/ea\n" + "j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh\n" + "X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ\n" + "l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf\n" + "bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4\n" + "pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK\n" + "e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0\n" + "vm9qp/UsQu0yrbYhnr68\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsx\n" + "FjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3Qg\n" + "Um9vdCBDQSAxMB4XDTAzMDUxNTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkG\n" + "A1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdr\n" + "b25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1ApzQ\n" + "jVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEn\n" + "PzlTCeqrauh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjh\n" + "ZY4bXSNmO7ilMlHIhqqhqZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9\n" + "nnV0ttgCXjqQesBCNnLsak3c78QA3xMYV18meMjWCnl3v/evt3a5pQuEF10Q6m/h\n" + "q5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNVHRMBAf8ECDAGAQH/AgED\n" + "MA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7ih9legYsC\n" + "mEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI3\n" + "7piol7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clB\n" + "oiMBdDhViw+5LmeiIAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJs\n" + "EhTkYY2sEJCehFC78JZvRZ+K88psT/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpO\n" + "fMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilTc4afU9hDDl3WY4JxHYB0yvbi\n" + "AmvZWg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL\n" + "BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ\n" + "SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n\n" + "a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5\n" + "NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAY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oZIhvcNAQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG\n" + "7BJ8dNVI0lkUmcDrudHr9EgwW62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCk\n" + "MpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWldy8joRTnU+kLBEUx3XZL7av9YROXr\n" + "gZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov+BS5gLNdTaqX4fnk\n" + "GMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDceqFS\n" + "3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJm\n" + "Ozj/2ZQw9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+\n" + "l6mc1X5VTMbeRRAc6uk7nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6c\n" + "JfTzPV4e0hz5sy229zdcxsshTrD3mUcYhcErulWuBurQB7Lcq9CClnXO0lD+mefP\n" + "L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa\n" + "LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG\n" + "mpv0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ISRG Root X1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" + "WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGE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n" + "ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ\n" + "3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK\n" + "NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5\n" + "ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n" + "TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n" + "jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n" + "oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n" + "4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n" + "mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" + "emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Commercial Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu\n" + "VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw\n" + "MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw\n" + "JQYDVQQDEx5JZGVuVHJ1c3QgQ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M+x8uwt\n" + "LRvM7Kqas6pgghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93\n" + "nAbowacYXVKV7cndJZ5t+qntozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3\n" + "+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmVYjzlVYA211QC//G5Xc7UI2/YRYRK\n" + "W2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUXfeu+h1sXIFRRk0pT\n" + "AwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/rokTLq\n" + "l1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG\n" + "4iZZRHUe2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZ\n" + "mUlO+KWA2yUPHGNiiskzZ2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A\n" + "7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7RcGzM7vRX+Bi6hG6H\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Public Sector Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu\n" + "VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN\n" + "MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0\n" + "MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAo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DKQGXSc3z1i9kKlT/YPyNtGtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8G\n" + "lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW\n" + "mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df\n" + "WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5\n" + "+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ\n" + "tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA\n" + "GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv\n" + "8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Izenpe.com\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4\n" + "MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6\n" + "ZW5wZS5jb20wHhcNMDcxMjEzMTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYD\n" + "VQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5j\n" + "b20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ03rKDx6sp4boFmVq\n" + "scIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAKClaO\n" + "xdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6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SnxIOvVFfLMMjlF4rJUT3sb9fbgakEyrkgPH7UIBzg/YsfqikuFgba56\n" + "awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8qhT/AQKM6WfxZSzwo\n" + "JNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Csg1lw\n" + "LDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCT\n" + "VyvehQP5aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGk\n" + "LhObNA5me0mrZJfQRsN5nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJb\n" + "UjWumDqtujWTI6cfSN01RpiyEGjkpTHCClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/\n" + "QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZoQ0iy2+tzJOeRf1SktoA+\n" + "naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1ZWrOZyGls\n" + "QyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# LuxTrust Global Root 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL\n" + "BQAwRjELMAkGA1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNV\n" + "BAMMFkx1eFRydXN0IEdsb2JhbCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUw\n" + "MzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEWMBQGA1UECgwNTHV4VHJ1c3QgUy5B\n" + "LjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCCAiIwDQ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1uecEsh9QNcH7X9njJCwROxLHOk3D+sFTAMs2ZMGQXvw/l4jP9\n" + "BzZAcg4atmpZ1gDlaCDdLnINH2pkMSCEfUmmWjfrRcmF9dTHF5kH5ptV5AzoqbTO\n" + "jFu1EVzPig4N1qx3gf4ynCSecs5U89BvolbW7MM3LGVYvlcAGvI1+ut7MV3CwRI9\n" + "loGIlonBWVx65n9wNOeD4rHh4bhY79SV5GCc8JaXcozrhAIuZY+kt9J/Z93I055c\n" + "qqmkoCUUBpvsT34tC38ddfEz2O3OuHVtPlu5mB0xDVbYQw8wkbIEa91WvpWAVWe+\n" + "2M2D2RjuLg+GLZKecBPs3lHJQ3gCpU3I+V/EkVhGFndadKpAvAefMLmx9xIX3eP/\n" + "JEAdemrRTxgKqpAd60Ae36EeRJIQmvKN4dFLRp7oRUKX6kWZ8+xm1QL68qZKJKre\n" + "zrnK+T+Tb/mjuuqlPpmt/f97mfVl7vBZKGfXkJWkE4SphMHozs51k2MavDzq1WQf\n" + "LSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc7kGUnF4ZLvhFSZl0kbAEb+MEWrGrKqv+\n" + "x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6\n" + "oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Microsec e-Szigno Root CA 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\n" + "VQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0\n" + "ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0G\n" + "CSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTAeFw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775\n" + "tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c\n" + "2Pm2G2JwCz02yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5t\n" + "HMN1Rq41Bab2XD0h7lbwyYIiLXpUq3DDfSJlgnCW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# NetLock Arany (Class Gold) Főtanúsítvány\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG\n" + "EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3\n" + "MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl\n" + "cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR\n" + "dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgxMjA2MTUwODIxWjCB\n" + "pzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxOZXRM\n" + "b2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlm\n" + "aWNhdGlvbiBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNz\n" + "IEdvbGQpIEbFkXRhbsO6c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAxCRec75LbRTDofTjl5Bu0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrT\n" + "lF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw/HpYzY6b7cNGbIRwXdrz\n" + "AZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAkH3B5r9s5\n" + "VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRG\n" + "ILdwfzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2\n" + "BJtr+UBdADTHLpl1neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAG\n" + "AQH/AgEEMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2M\n" + "U9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwWqZw8UQCgwBEIBaeZ5m8BiFRh\n" + "bvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTtaYtOUZcTh5m2C\n" + "+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC\n" + "bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2F\n" + "uLjbvrW5KfnaNwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2\n" + "XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Network Solutions Certificate Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi\n" + "MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu\n" + "MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp\n" + "dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswC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+ "wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN\n" + "pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GA CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCB\n" + "ijELMAkGA1UEBhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHly\n" + "aWdodCAoYykgMjAwNTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl\n" + "ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQSBDQTAeFw0w\n" + "NTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYDVQQGEwJDSDEQMA4G\n" + "A1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIwIAYD\n" + "VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBX\n" + "SVNlS2V5IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAy0+zAJs9Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxR\n" + "VVuuk+g3/ytr6dTqvirdqFEr12bDYVxgAsj1znJ7O7jyTmUIms2kahnBAbtzptf2\n" + "w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbDd50kc3vkDIzh2TbhmYsF\n" + "mQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ/yxViJGg\n" + "4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t9\n" + "4B3RLoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYw\n" + "DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQw\n" + "EAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOx\n" + "SPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vImMMkQyh2I+3QZH4VFvbBsUfk2\n" + "ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4+vg1YFkCExh8\n" + "vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa\n" + "hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZi\n" + "Fj4A4xylNoEYokxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ\n" + "/L7fCg0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GB CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBt\n" + "MQswCQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUg\n" + "Rm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9i\n" + "YWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAwMzJaFw0zOTEyMDExNTEwMzFaMG0x\n" + "CzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBG\n" + "b3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh\n" + "bCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3\n" + "HEokKtaXscriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGx\n" + "WuR51jIjK+FTzJlFXHtPrby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX\n" + "1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNk\n" + "u7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4oQnc/nSMbsrY9gBQHTC5P\n" + "99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvgGUpuuy9r\n" + "M2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw\n" + "AwEB/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUB\n" + "BAMCAQAwDQYJKoZIhvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrgh\n" + "cViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5\n" + "gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3ZwLWoo4rO\n" + "ZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" + "aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic\n" + "Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GC CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICaTCCAe+gAwI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wdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFy\n" + "ZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh\n" + "Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYI\n" + "KwYBBQUHAgEWFmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3T\n" + "KbkGGew5Oanwl4Rqy+/fMIGuBgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rq\n" + "y+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1p\n" + "dGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD\n" + "VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL\n" + "MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk\n" + "fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8\n" + "7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R\n" + "cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y\n" + "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n" + "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n" + "SnQ2+Q==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 1 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIUeFhfLq0sGU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duebPRq34wGmAOt\n" + "zCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB\n" + "BjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZIhvcNAQELBQAD\n" + "ggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC\n" + "MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2\n" + "cDMT/uFPpiN3GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUN\n" + "qXsCHKnQO18LwIE6PWThv6ctTr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5\n" + "YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP+V04ikkwj+3x6xn0dxoxGE1nVGwv\n" + "b2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh3jRJjehZrJ3ydlo2\n" + "8hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fawx/k\n" + "NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj\n" + "ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp\n" + "q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt\n" + "nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl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RtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGUa6FJpEcwRTEL\n" + "MAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT\n" + "ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2f\n" + "BluornFdLwUvZ+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzn\n" + "g/iN/Ae42l9NLmeyhP3ZRPx3UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2Bl\n" + "fF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodmVjB3pjd4M1IQWK4/YY7yarHvGH5K\n" + "WWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK+JDSV6IZUaUtl0Ha\n" + "B0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrWIozc\n" + "hLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPR\n" + "TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD\n" + "mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z\n" + "ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y\n" + "4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza\n" + "8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZ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0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB\n" + "BjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZIhvcNAQELBQAD\n" + "ggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66\n" + "AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RC\n" + "roijQ1h5fq7KpVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0Ga\n" + "W/ZZGYjeVYg3UQt4XAoeo0L9x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4n\n" + "lv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgzdWqTHBLmYF5vHX/JHyPLhGGfHoJE\n" + "+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6XU/IyAgkwo1jwDQHV\n" + "csaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+NwmNtd\n" + "dbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg\n" + "KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM\n" + "HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4\n" + "WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1Zh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4b0j\n" + "Wy10QJLZYxkNc91pvGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeT\n" + "mJlglFwjz1onl14LBQaTNx47aTbrqZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK\n" + "4SVhM7JZG+Ju1zdXtg2pEto=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00\n" + "MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286IxSR\n" + "/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNu\n" + "FoM7pmRLMon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXR\n" + "U7Ox7sWTaYI+FrUoRqHe6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+c\n" + "ra1AdHkrAj80//ogaX3T7mH1urPnMNA3I4ZyYUUpSFlob3emLoG+B01vr87ERROR\n" + "FHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3UVDmrJqMz6nWB2i3ND0/k\n" + "A9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f75li59w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6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/\n" + "ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx\n" + "NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv\n" + "bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49\n" + "AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA\n" + "VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku\n" + "WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP\n" + "MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX\n" + "5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ\n" + "ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg\n" + "h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority RSA R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNV\n" + "BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UE\n" + "CgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMB4XDTE3MDUzMTE4MTQzN1oXDTQy\n" + "MDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4G\n" + "A1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQD\n" + "DC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvq\n" + "M0fNTPl9fb69LT3w23jhhqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssuf\n" + "OePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7wcXHswxzpY6IXFJ3vG2fThVUCAtZJycxa\n" + "4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTOZw+oz12WGQvE43LrrdF9\n" + "HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+B6KjBSYR\n" + "aZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcA\n" + "b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reRrwU7ZcegbLHNYhLDkBvjJc40vG93drEQ\n" + "w/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi\n" + "S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07\n" + "mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0\n" + "aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz\n" + "WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0\n" + "b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS\n" + "b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB\n" + "BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI\n" + "7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg\n" + "CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD\n" + "VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T\n" + "kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+\n" + "gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority RSA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz\n" + "OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv\n" + "bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2R\n" + "xFdHaxh3a3by/ZPkPQ/CFp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aX\n" + "qhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcC\n" + "C52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/geoeOy3ZExqysdBP+lSgQ3\n" + "6YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5H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H5db5\n" + "BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwiieDhZNRnvDF5YTy7ykHN\n" + "XGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD\n" + "AgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsF\n" + "AAOCAQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw\n" + "8PRBEew/R40/cof5O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOG\n" + "nXkZ7/e7DDWQw4rtTw/1zBLZpD67oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCP\n" + "oky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul4+vJhaAlIDf7js4MNIThPIGy\n" + "d05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6+/NNIxuZMzSg\n" + "LvWpCz/UXeHPhJ/iGcJfitYgHuNztw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureSign RootCA11\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDEr\n" + "MCkGA1UEChMiSmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoG\n" + "A1UEAxMTU2VjdXJlU2lnbiBSb290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0\n" + "MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSswKQYDVQQKEyJKYXBhbiBDZXJ0aWZp\n" + "Y2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1cmVTaWduIFJvb3RD\n" + "QTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvLTJsz\n" + "i1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8\n" + "h9uuywGOwvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOV\n" + "MdrAG/LuYpmGYz+/3ZMqg6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9\n" + "UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rPO7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni\n" + "8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitAbpSACW22s293bzUIUPsC\n" + "h8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZXt94wDgYD\n" + "VR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB\n" + "AKChOBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xm\n" + "KbabfSVSSUOrTC4rbnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQ\n" + "X5Ucv+2rIrVls4W6ng+4reV6G4pQOh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWr\n" + "QbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01y8hSyn+B/tlr0/cR7SXf+Of5\n" + "pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061lgeLKBObjBmN\n" + "QSdJQO7e5iNEOdyhIta6A/I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureTrust CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI\n" + "MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9y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R0PBAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCsw\n" + "KaAnoCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsG\n" + "AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L\n" + "URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO\n" + "H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm\n" + "I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY\n" + "iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc\n" + "f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication RootCA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl\n" + "MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe\n" + "U2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoX\n" + "DTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRy\n" + "dXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3VyaXR5IENvbW11bmlj\n" + "YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV\n" + "OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr\n" + "zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM\n" + "VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ\n" + "hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO\n" + "ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw\n" + "awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs\n" + "OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF\n" + "coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc\n" + "okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8\n" + "t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy\n" + "1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/\n" + "SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY\n" + "MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t\n" + "dW5pY2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/zOLjw9XARYvz6buyXAiFL39vmwLAw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Sonera Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP\n" + "MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx\n" + "MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV\n" + "BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o\n" + "Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt\n" + "5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s\n" + "3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej\n" + "vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu\n" + "8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw\n" + "DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG\n" + "MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil\n" + "zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/\n" + "3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD\n" + "FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6\n" + "Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2\n" + "ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gRVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0y\n" + "MjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIg\n" + "TmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRlcmxhbmRlbiBFViBS\n" + "b290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkkSzrS\n" + "M4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nC\n" + "UiY4iKTWO0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3d\n" + "Z//BYY1jTw+bbRcwJu+r0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46p\n" + "rfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13l\n" + "pJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gVXJrm0w912fxBmJc+qiXb\n" + "j5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/U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eG9QgkRQP2YGiqtDhFZKDyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8\n" + "FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGyeUN51q1veieQA6TqJIc/2b3Z6fJfUEkc\n" + "7uzXLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloX\n" + "DTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMCTkwxHjAcBgNVBAoMFVN0YWF0IGRl\n" + "ciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5lZGVybGFuZGVuIFJv\n" + "b3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4yolQP\n" + "cPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WW\n" + "IkYFsO2tx1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqX\n" + "xz8ecAgwoNzFs21v0IJyEavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFy\n" + "KJLZWyNtZrVtB0LrpjPOktvA9mxjeM3KTj215VKb8b475lRgsGYeCasH/lSJEULR\n" + "9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUurmkVLoR9BvUhTFXFkC4az\n" + "5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU51nus6+N8\n" + "6U78dULI7ViVDAZCopz35HCz33Jv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sjdj3BP1lB0/\n" + "QFH1T/U67cjF68IeHRaVesd+QnGTbksVtzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM\n" + "94B7IWcnMFk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Services Root Certificate Authority - G2\n" + "-----BE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ZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI\n" + "bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB\n" + "ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z\n" + "qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n" + "iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n" + "0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n" + "sSi6\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Gold CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n" + "BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln\n" + "biBHb2xkIENBIC0gRzIwHhcNMDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBF\n" + "MQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMR8wHQYDVQQDExZT\n" + "d2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC\n" + "CgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUqt2/8\n" + "76LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+\n" + "bbqBHH5CjCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c\n" + "6bM8K8vzARO/Ws/BtQpgvd21mWRTuK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"GPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxpmo/a\n" + "77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC\n" + "hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3\n" + "92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp\n" + "Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w\n" + "ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt\n" + "Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Silver CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE\n" + "BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWdu\n" + "IFNpbHZlciBDQSAtIEcyMB4XDTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0Nlow\n" + "RzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMY\n" + "U3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A\n" + "MIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644N0Mv\n" + "Fz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7br\n" + "YT7QbNHm+/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73J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ixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx/uNncqCxv1yL5PqZ\n" + "IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8\n" + "aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X\n" + "em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR\n" + "dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/\n" + "OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+\n" + "hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy\n" + "tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgxMDAxMTA0MDE0WhcNMzMxMDAxMjM1\n" + "OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy\n" + "aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50\n" + "ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0G\n" + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUd\n" + "AqSzm1nzHoqvNK38DcLZSBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiC\n" + "FoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/FvudocP05l03Sx5iRUKrERLMjfTlH6VJi\n" + "1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx9702cu+fjOlbpSD8DT6Iavq\n" + "jnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGVWOHAD3bZ\n" + "wI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGj\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/\n" + "WSA2AHmgoCJrjNXyYdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhy\n" + "NsZt+U2e+iKo4YFWz827n+qrkRk4r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPAC\n" + "uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw\n" + "IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6\n" + "g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN\n" + "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" + "BSeOE6Fuwg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApB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n5z2r3Ex3XsFpSzTucpH9sry9uetuUg/vBa3wW30\n" + "6gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT\n" + "91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml\n" + "e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p\n" + "TpPDpFQUWw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx\n" + "GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp\n" + "bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w\n" + "KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0\n" + "BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRpZmlrYXNpIC0gU3Vy\n" + "dW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYDVQQG\n" + "EwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXll\n" + "IEJpbGltc2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklU\n" + "QUsxLTArBgNVBAsTJEthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBT\n" + "TTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11IFNNIFNTTCBLb2sgU2VydGlmaWthc2kg\n" + "LSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr3UwM6q7\n" + "a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y86Ij5iySr\n" + "LqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INr\n" + "N3wcwv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2X\n" + "YacQuFWQfw4tJzh03+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/\n" + "iSIzL+aFCr2lqBs23tPcLG07xxO9WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4f\n" + "AJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQUZT/HiobGPN08VFw1+DrtUgxH\n" + "V8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh\n" + "AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPf\n" + "IPP54+M638yclNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4\n" + "lzwDGrpDxpa5RXI4s6ehlj2Re37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c\n" + "8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0jq5Rm+K37DwhuJi1/FwcJsoz7UMCf\n" + "lo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcx\n" + "EjAQBgNVBAoTCVRBSVdBTi1DQ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wDwYDVR0TAQH/BAUwAwEB\n" + "/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6gcFGn90xHNcgL\n" + "1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn\n" + "LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WF\n" + "H6vPNOw/KP4M8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNo\n" + "RI2T9GRwoD2dKAXDOXC4Ynsg/eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+\n" + "nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlglPx4mI88k1HtQJAH32RjJMtOcQWh\n" + "15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryPA9gK8kxkRr05YuWW\n" + "6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3mi4TW\n" + "nsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5j\n" + "wa19hAM8EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWz\n" + "aGHQRiapIVJpLesux+t3zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmy\n" + "KwbQBM0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES\n" + "MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU\n" + "V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz\n" + "Wh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hrw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Taiwan GRCA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/\n" + "MQswCQYDVQQGEwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5MB4XDTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1ow\n" + "PzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dvdmVybm1lbnQgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\n" + "AJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qNw8XR\n" + "IePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1q\n" + "gQdW8or5BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKy\n" + "yhwOeYHWtXBiCAEuTk8O1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAts\n" + "F/tnyMKtsc2AtJfcdgEWFelq16TheEfOhtX7MfP6Mb40qij7cEwdScevLJ1tZqa2\n" + "jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wovJ5pGfaENda1UhhXcSTvx\n" + "ls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7Q3hub/FC\n" + "VGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHK\n" + "YS1tB6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoH\n" + "EgKXTiCQ8P8NHuJBO9NAOueNXdpm5AK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" + "arMCpgKIv7NHfirZ1fpoeDVNAgMBAAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYD\n" + "VR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qWDNXr+nuqF+gTEjANBgkqhkiG\n" + "9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNmzqjMDfz1mgbl\n" + "dxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx\n" + "0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1Tj\n" + "TQpgcmLNkQfWpb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBed\n" + "Y2gea+zDTYa4EzAvXUYNR0PVG6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7\n" + "Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpcc41teyWRyu5FrgZLAMzTsVlQ2jqI\n" + "OylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOTJsjrDNYmiLbAJM+7\n" + "vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2qReW\n" + "t88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcn\n" + "HL/EVlP6Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVx\n" + "SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor ECA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1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BVwm8nHc2Fv\n" + "civUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u/ukZMjgDfxT2\n" + "AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F\n" + "hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50\n" + "soIipX1TH0XsJ5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BI\n" + "WJZpTdwHjFGTot+fDz2LYLSCjaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1Wi\n" + "tJ/X5g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U\n" + "cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29y\n" + "IFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkxMjMxMTcyMzE2WjCB\n" + "pDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFuYW1h\n" + "IENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUG\n" + "A1UECwweVHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZU\n" + "cnVzdENvciBSb290Q2VydCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A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2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp\n" + "5KeXRKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu\n" + "1uwJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Trustis FPS Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBF\n" + "MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQL\n" + "ExNUcnVzdGlzIEZQUyBSb290IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTEx\n" + "MzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNVBAoTD1RydXN0aXMgTGltaXRlZDEc\n" + "MBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQAD\n" + "ggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQRUN+\n" + "AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihH\n" + "iTHcDnlkH5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjj\n" + "vSkCqPoc4Vu5g6hBSLwacY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA\n" + "0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zto3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlB\n" + "OrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEAAaNTMFEwDwYDVR0TAQH/\n" + "BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAdBgNVHQ4E\n" + "FgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01\n" + "GX2cGE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmW\n" + "zaD+vkAMXBJV+JOCyinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP4\n" + "1BIy+Q7DsdwyhEQsb8tGD+pmQQ9P8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZE\n" + "f1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHVl/9D7S3B2l0pKoU/rGXuhg8F\n" + "jZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYliB6XzCGcKQEN\n" + "ZetX2fNXlrtIzYE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Extended Validation Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBF\n" + "eHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMx\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNV\n" + "BAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrsiWog\n" + "D4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvS\n" + "sPGP2KxFRv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aop\n" + "O2z6+I9tTcg1367r3CTueUWnhbYFiN6IXSV8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j\n" + "2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwiGpWO\n" + "vpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2C\n" + "xR9GUeOcGMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx\n" + "cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM\n" + "fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Global G2 Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH\n" + "bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0x\n" + "CzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlUcnVzdDEbMBkGA1UEAwwSVUNBIEds\n" + "b2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxeYr\n" + "b3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmToni9\n" + "kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzm\n" + "VHqUwCoV8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/R\n" + "VogvGjqNO7uCEeBHANBSh6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDc\n" + "C/Vkw85DvG1xudLeJ1uK6NjGruFZfc8oLTW4lVYa8bJYS7cSN8h8s+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MRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI\n" + "+Vg7RE+xygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGy\n" + "YiGqhkCyLmTTX8jjfhFnRR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bX\n" + "UB+K+wb1whnw0A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + "VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo\n" + "I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng\n" + "o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G\n" + "A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB\n" + "zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW\n" + "RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB\n" + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw\n" + "MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV\n" + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU\n" + "aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B\n" + "3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY\n" + "tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/\n" + "Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1d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diyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/\n" + "qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB\n" + "VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB\n" + "L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n" + "jjxDah2nGN59PRbxYvnKkKj9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjELMAkG\n" + "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJp\n" + "U2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwg\n" + "SW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2ln\n" + "biBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5\n" + "IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8Utpkmw4tXNherJI9/gHm\n" + "GUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGzrl0Bp3ve\n" + "fLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUw\n" + "AwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJ\n" + "aW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYj\n" + "aHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMW\n" + "kf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMDA2gAMGUCMGYhDBgmYFo4e1ZC\n" + "4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIxAJw9SDkjOVga\n" + "FRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\n" + "ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5I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AQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE\n" + "p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y\n" + "5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Universal Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB\n" + "vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MTgwNgYDVQQDEy9W\n" + "ZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJVUzEX\n" + "MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0\n" + "IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9y\n" + "IGF1dGhvcml6ZWQgdXNlIG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZl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Ofc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3\n" + "7M2CYfE45k+XmCpajQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Verisign Class 3 Public Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw\n" + "CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl\n" + "cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu\n" + "LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT\n" + "aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp\n" + "dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD\n" + "VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT\n" + "aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ\n" + "bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu\n" + "IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg\n" + "LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b\n" + "N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t\n" + "KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu\n" + "kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm\n" + "CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ\n" + "Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu\n" + "imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te\n" + "2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe\n" + "DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC\n" + "/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p\n" + "F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt\n" + "TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# XRamp Global CA Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB\n" + "gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk\n" + "MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY\n" + "UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx\n" + "NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3\n" + "dy54cmFtcHNlY3VyaXR5LmNvb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XHGPurt+HBvbaoAPIbzp26a3QPSy\n" + "i6mx5O+aGtA9aZnuqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ\n" + "O+7ETPTsJ3xCwnR8gooJybQDJbw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# certSIGN ROOT CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYT\n" + "AlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBD\n" + "QTAeFw0wNjA3MDQxNzIwMDRaFw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJP\n" + "MREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTCC\n" + "ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7IJUqOtdu0KBuqV5Do\n" + "0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHHrfAQ\n" + "UySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5d\n" + "RdY4zTW2ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQ\n" + "OA7+j0xbm0bqQfWwCHTD0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwv\n" + "JoIQ4uNllAoEwF73XVv4EOLQunpL+943AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08C\n" + "AwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAcYwHQYDVR0O\n" + "BBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IBAQA+0hyJ\n" + "LjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecY\n" + "MnQ8SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ\n" + "44gx+FkagQnIl6Z0x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6I\n" + "Jd1hJyMctTEHBDa0GpC9oHRxUIltvBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNw\n" + "i/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7NzTogVZ96edhBiIL5VaZVDADlN\n" + "9u6wWk5JRFRYX0KD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ePKI Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe\n" + "MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0\n" + "ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMxMjdaMF4xCzAJBgNVBAYTAlRXMSMw\n" + "IQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEqMCgGA1UECwwhZVBL\n" + "SSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEF\n" + "AAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAH\n" + "SyZbCUNsIZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAh\n" + "ijHyl3SJCRImHJ7K2RKilTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3X\n" + "DZoTM1PRYfl61dd4s5oz9wCGzh1NlDivqOx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rGNm6\n" + "5ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUB\n" + "o2M3IUxExJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS\n" + "/jQ6fbjpKdx2qcgw+BRxgMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z\n" + "Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE\n" + "W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D\n" + "hNQ+IIX3Sj0rnP0qCglN6oH4EZw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - C3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG\n" + "EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx\n" + "IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND\n" + "IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci\n" + "MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti\n" + "sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O\n" + "BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\n" + "Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c\n" + "3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J\n" + "0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n" + "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n" + "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n" + "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n" + "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n" + "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n" + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n" + "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n" + "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n" + "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n" + "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n" + "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n" + "+JbNR6iC8hZVdyR+EhCVBCyj\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - C1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkG\n" + "A1UEBhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEg\n" + "SW5jMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNpZ24gUm9v\n" + "dCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+upufGZ\n" + "BczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZ\n" + "HdPIWoU/Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH\n" + "3DspVpNqs8FqOp099cGXOFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvH\n" + "GPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4VI5b2P/AgNBbeCsbEBEV5f6f9vtKppa+c\n" + "xSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleoomslMuoaJuvimUnzYnu3Yy1\n" + "aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+XJGFehiq\n" + "TbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87\n" + "/kOXSTKZEhVb3xEp/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4\n" + "kqNPEjE2NuLe/gDEo2APJ62gsIq1NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrG\n" + "YQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT\n" + "+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo\n" + "WXzhriKi4gp6D/piq1JM4fHfyr6DDUI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - G1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD\n" + "VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU\n" + "ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH\n" + "MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO\n" + "MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv\n" + "Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN\n" + "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz\n" + "f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO\n" + "8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq\n" + "d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM\n" + "tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt\n" + "Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB\n" + "o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD\n" + "AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x\n" + "PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM\n" + "wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d\n" + "GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH\n" + "6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby\n" + "RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx\n" + "iN66zB+Afko=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB\n" + "qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV\n" + "BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAw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G89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/\n" + "LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7\n" + "jVaMaA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp\n" + "IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi\n" + "BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw\n" + "MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh\n" + "d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig\n" + "YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v\n" + "dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/\n" + "BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6\n" + "papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K\n" + "DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3\n" + "KMqh9HneteY4sPBlcIx/A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GbY2SS9\n" + "9irY7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2S\n" + "zhkGcuYMXDhpxwTWvGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUk\n" + "OQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" + "HQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJKoZIhvcNAQELBQADggEBABpA\n" + "2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweKA3rD6z8KLFIW\n" + "oCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu\n" + "t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7c\n" + "KUGRIjxpp7sC8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fM\n" + "m7v/OeZWYdMKp8RcTGB7BXcmer/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZu\n" + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + + static_cast( + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); + if (ec) { + return; + } +} + +} // namespace detail + +// Load the root certificates into an ssl::context + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); +} + +inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); + if (ec) { + webcpp_fixture::fail_stop(); + } +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/common/server_certificate.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/common/server_certificate.hpp new file mode 100644 index 0000000..af78066 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/common/server_certificate.hpp @@ -0,0 +1,139 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP + +#include +#include +#include +#include + +/* Load a signed certificate into the ssl context, and configure + the context for use with a server. + + For this to work with the browser or operating system, it is + necessary to import the "Beast Test CA" certificate into + the local certificate store, browser, or operating system + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. +*/ +inline void load_server_certificate(boost::asio::ssl::context& ctx) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { + ctx.use_certificate_chain_file(path); + ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), + boost::asio::ssl::context::pem); + return; + } + + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 + openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj + "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = + "-----BEGIN CERTIFICATE-----\n" + "MIIDlTCCAn2gAwIBAgIUOLxr3q7Wd/pto1+2MsW4fdRheCIwDQYJKoZ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EmrcQNdz/KIxJj/fRB3j9GM4lkdaIju47V998Z619E/6pt7GWcAySm1faPB0X4fL\n" + "FJ6iYR2r/kJLoppPqL0EE49uwyYQ1dKhXS2hk+IIfA9mBn8eAFb/0435A2fXutds\n" + "qhvwIOmAObCzcoKkz3sChbk4ToUTqbC0TmFAXI5Upz1wnADzjpbJrpegCA3pmvhT\n" + "7356drqnCGY9\n" + "-----END CERTIFICATE-----\n"; + + std::string const key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz0GwgnxSBhygx\n" + "BdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOTLppr5MKxqQHEpYdyDYGD1noBoz4T\n" + "iIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05P41c2F9pBEnUwUxIUG1Cb6AN0cZW\n" + "F/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATmWm9SJc2lsjWptbyIN6hFXLYPXTwn\n" + "YzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7rV+AiGTxUU35V0AzpJlmvct5aJV/\n" + "5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4lIzJ8yxzOzSStBPxvdrOobSSNlRZ\n" + "IlE7gnyNAgMBAAECggEAY0RorQmldGx9D7M+XYOPjsWLs1px0cXFwGA20kCgVEp1\n" + "kleBeHt93JqJsTKwOzN2tswl9/ZrnIPWPUpcbBlB40ggjzQk5k4jBY50Nk2jsxuV\n" + "9A9qzrP7AoqhAYTQjZe42SMtbkPZhEeOyvCqxBAi6csLhcv4eB4+In0kQo7dfvLs\n" + "Xu/3WhSsuAWqdD9EGnhD3n+hVTtgiasRe9318/3R9DzP+IokoQGOtXm+1dsfP0mV\n" + "8XGzQHBpUtJNn0yi6SC4kGEQuKkX33zORlSnZgT5VBLofNgra0THd7x3atOx1lbr\n" + "V0QizvCdBa6j6FwhOQwW8UwgOCnUbWXl/Xn4OaofMQKBgQDdRXSMyys7qUMe4SYM\n" + "Mdawj+rjv0Hg98/xORuXKEISh2snJGKEwV7L0vCn468n+sM19z62Axz+lvOUH8Qr\n" + "hLkBNqJvtIP+b0ljRjem78K4a4qIqUlpejpRLw6a/+44L76pMJXrYg3zdBfwzfwu\n" + "b9NXdwHzWoNuj4v36teGP6xOUwKBgQDQCT52XX96NseNC6HeK5BgWYYjjxmhksHi\n" + "stjzPJKySWXZqJpHfXI8qpOd0Sd1FHB+q1s3hand9c+Rxs762OXlqA9Q4i+4qEYZ\n" + "qhyRkTsl+2BhgzxmoqGd5gsVT7KV8XqtuHWLmetNEi+7+mGSFf2iNFnonKlvT1JX\n" + "4OQZC7ntnwKBgH/ORFmmaFxXkfteFLnqd5UYK5ZMvGKTALrWP4d5q2BEc7HyJC2F\n" + "+5lDR9nRezRedS7QlppPBgpPanXeO1LfoHSA+CYJYEwwP3Vl83Mq/Y/EHgp9rXeN\n" + "L+4AfjEtLo2pljjnZVDGHETIg6OFdunjkXDtvmSvnUbZBwG11bMnSAEdAoGBAKFw\n" + "qwJb6FNFM3JnNoQctnuuvYPWxwM1yjRMqkOIHCczAlD4oFEeLoqZrNhpuP8Ij4wd\n" + "GjpqBbpzyVLNP043B6FC3C/edz4Lh+resjDczVPaUZ8aosLbLiREoxE0udfWf2dU\n" + "oBNnrMwwcs6jrRga7Kr1iVgUSwBQRAxiP2CYUv7tAoGBAKdPdekPNP/rCnHkKIkj\n" + "o13pr+LJ8t+15vVzZNHwPHUWiYXFhG8Ivx7rqLQSPGcuPhNss3bg1RJiZAUvF6fd\n" + "e6QS4EZM9dhhlO2FmPQCJMrRVDXaV+9TcJZXCbclQnzzBus9pwZZyw4Anxo0vmir\n" + "nOMOU6XI4lO9Xge/QDEN4Y2R\n" + "-----END PRIVATE KEY-----\n"; + + std::string const dh = + "-----BEGIN DH PARAMETERS-----\n" + "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" + "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" + "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" + "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; + + ctx.set_password_callback( + [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + + ctx.set_options(boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + + ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + + ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), + boost::asio::ssl::context::file_format::pem); + + ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/http_examples.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/http_examples.hpp new file mode 100644 index 0000000..2095a30 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/http_examples.hpp @@ -0,0 +1,950 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include + +/* This file contains the functions and classes found in the documentation + + They are compiled and run as part of the unit tests, so you can copy + the code and use it in your own projects as a starting point for + building a network application. +*/ + +// The documentation assumes the webcpp::beast::http namespace + +namespace boost::beast::http { + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_http_send_expect_100_continue + +/** Send a request with Expect: 100-continue + + This function will send a request with the Expect: 100-continue + field by first sending the header, then waiting for a successful + response from the server before continuing to send the body. If + a non-successful server response is received, the function + returns immediately. + + @param stream The remote HTTP server stream. + + @param buffer The buffer used for reading. + + @param req The request to send. This function modifies the object: + the Expect header field is inserted into the message if it does + not already exist, and set to "100-continue". + + @param ec Set to the error, if any occurred. +*/ +template +void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, + request>& req, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); + + // Create the serializer + request_serializer> sr{req}; + + // Send just the header + write_header(stream, sr, ec); + if (ec) { + return; + } + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); + if (ec) { + return; + } + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; + } + } + + // Server is OK with the request, send the body + write(stream, sr, ec); +} + +//] + +//[example_http_receive_expect_100_continue + +/** Receive a request, handling Expect: 100-continue if present. + + This function will read a request from the specified stream. + If the request contains the Expect: 100-continue field, a + status response will be delivered. + + @param stream The remote HTTP client stream. + + @param buffer The buffer used for reading. + + @param ec Set to the error, if any occurred. +*/ +template +void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); + if (ec) { + return; + } + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); + if (ec) { + return; + } + } + + // Read the rest of the message. + // + read(stream, buffer, parser, ec); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Send Child Process Output +// +//------------------------------------------------------------------------------ + +//[example_http_send_cgi_response + +/** Send the output of a child process as an HTTP response. + + The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. + + @param input A stream to read the child process output from. + + @param output A stream to write the HTTP response to. + + @param ec Set to the error, if any occurred. +*/ +template +void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. + response res; + + res.result(status::ok); + res.version(11); + res.set(field::server, "Beast"); + res.set(field::transfer_encoding, "chunked"); + + // No data yet, but we set more = true to indicate + // that it might be coming later. Otherwise the + // serializer::is_done would return true right after + // sending the header. + res.body().data = nullptr; + res.body().more = true; + + // Create the serializer. + response_serializer sr{res}; + + // Send the header immediately. + write_header(output, sr, ec); + if (ec) { + return; + } + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process + std::array buffer{}; + auto bytes_transferred = input.read_some(boost::asio::buffer(buffer), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer + res.body().data = nullptr; + + // `false` means no more data is coming + res.body().more = false; + } else { + if (ec) { + return; + } + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming + res.body().data = buffer.data(); + res.body().size = bytes_transferred; + res.body().more = true; + } + + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. + if (ec == error::need_buffer) { + ec = {}; + continue; + } + if (ec) { + return; + } + } while (!sr.is_done()); +} + +//] + +//-------------------------------------------------------------------------- +// +// Example: HEAD Request +// +//-------------------------------------------------------------------------- + +//[example_http_do_head_response + +/** Handle a HEAD request for a resource. + */ +template +void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; + + // Read the request + request req; + read(stream, buffer, req, ec); + if (ec) { + return; + } + + // Set up the response, starting with the common fields + response res; + res.version(11); + res.set(field::server, "test"); + + // Now handle request-specific fields + switch (req.method()) { + case verb::head: + case verb::get: { + // A HEAD request is handled by delivering the same + // set of headers that would be sent for a GET request, + // including the Content-Length, except for the body. + res.result(status::ok); + res.content_length(payload.size()); + + // For GET requests, we include the body + if (req.method() == verb::get) { + // We deliver the same payload for GET requests + // regardless of the target. A real server might + // deliver a file based on the target. + res.body() = payload; + } + break; + } + + default: { + // We return responses indicating an error if + // we do not recognize the request method. + res.result(status::bad_request); + res.set(field::content_type, "text/plain"); + res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; + res.prepare_payload(); + break; + } + } + + // Send the response + write(stream, res, ec); + if (ec) { + return; + } +} + +//] + +//[example_http_do_head_request + +/** Send a HEAD request for a resource. + + This function submits a HEAD request for the specified resource + and returns the response. + + @param res The response. This is an output parameter. + + @param stream The synchronous stream to use. + + @param buffer The buffer to use. + + @param target The request target. + + @param ec Set to the error, if any occurred. + + @throws std::invalid_argument if target is empty. +*/ +template +response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, + error_code& ec) { + // Do some type checking to be a good citizen + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. + if (target.empty()) { + webcpp_fixture::fail_stop(); + } + + // Build the HEAD request for the target + request req; + req.version(11); + req.method(verb::head); + req.target(target); + req.set(field::user_agent, "test"); + + // A client MUST send a Host header field in all HTTP/1.1 request messages. + // https://tools.ietf.org/html/rfc7230#section-5.4 + req.set(field::host, "localhost"); + + // Now send it + write(stream, req, ec); + if (ec) { + return {}; + } + + // Create a parser to read the response. + // We use the `empty_body` type since + // a response to a HEAD request MUST NOT + // include a body. + response_parser p; + + // Inform the parser that there will be no body. + p.skip(true); + + // Read the message. Even though fields like + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); + if (ec) { + return {}; + } + + // Transfer ownership of the response to the caller. + return p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: HTTP Relay +// +//------------------------------------------------------------------------------ + +//[example_http_relay + +/** Relay an HTTP message. + + This function efficiently relays an HTTP message from a downstream + client to an upstream server, or from an upstream server to a + downstream client. After the message header is read from the input, + a user provided transformation function is invoked which may change + the contents of the header before forwarding to the output. This may + be used to adjust fields such as Server, or proxy fields. + + @param output The stream to write to. + + @param input The stream to read from. + + @param buffer The buffer to use for the input. + + @param transform The header transformation to apply. The function will + be called with this signature: + @code + template + void transform(message< + isRequest, Body, Fields>&, // The message to transform + error_code&); // Set to the error, if any + @endcode + + @param ec Set to the error if any occurred. + + @tparam isRequest `true` to relay a request. + + @tparam Fields The type of fields to use for the message. +*/ +template +void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, + Transform&& transform) { + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + std::array buf{}; + + // Create a parser with a buffer body to read from the input. + parser p; + + // Create a serializer from the message contained in the parser. + serializer sr{p.get()}; + + // Read just the header from the input + read_header(input, buffer, p, ec); + if (ec) { + return; + } + + // Apply the caller's header transformation + transform(p.get(), ec); + if (ec) { + return; + } + + // Send the transformed message to the output + write_header(output, sr, ec); + if (ec) { + return; + } + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf.data(); + p.get().body().size = buf.size(); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) { + ec = {}; + } + if (ec) { + return; + } + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = buf.size() - p.get().body().size; + p.get().body().data = buf.data(); + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } + + // Write everything in the buffer (which might be empty) + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) { + ec = {}; + } + if (ec) { + return; + } + } while (!p.is_done() && !sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Serialize to std::ostream +// +//------------------------------------------------------------------------------ + +//[example_http_write_ostream + +// The detail namespace means "not public" +namespace detail { + +// This helper is needed for C++11. +// When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +template +class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + +public: + write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer + template + void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + + // Keep a running total of how much we wrote + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence + for (auto it = boost::asio::buffer_sequence_begin(buffers); + it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream + if (buffer.size() > + static_cast(std::numeric_limits::max())) { + ec = make_error_code(errc::value_too_large); + return; + } + os_.write(reinterpret_cast(buffer.data()), + static_cast(buffer.size())); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } + + // Adjust our running total + bytes_transferred += buffer_size(buffer); + } + + // Inform the serializer of the amount we consumed + sr_.consume(bytes_transferred); + } +}; + +} // namespace detail + +/** Write a message to a `std::ostream`. + + This function writes the serialized representation of the + HTTP/1 message to the sream. + + @param os The `std::ostream` to write to. + + @param msg The message to serialize. + + @param ec Set to the error, if any occurred. +*/ +template +void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; + do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); + if (ec) { + return; + } + } while (!sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Parse from std::istream +// +//------------------------------------------------------------------------------ + +//[example_http_read_istream + +/** Read a message from a `std::istream`. + + This function attempts to parse a complete HTTP/1 message from the stream. + + @param is The `std::istream` to read from. + + @param buffer The buffer to use. + + @param msg The message to store the result. + + @param ec Set to the error, if any occurred. +*/ +template +void read_istream(std::istream& is, basic_flat_buffer& buffer, + message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are + // forwarded to the message constructor. Here, we use + // a move construction in case the caller has constructed + // their message in a non-default way. + // + parser p{std::move(msg)}; + + do { + // Extract whatever characters are presently available in the istream + if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream + buffer.commit( + static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); + } else if (buffer.size() == 0) { + // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream + if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + + // Try to get more from the istream. This might block. + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. + if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; + } + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); + if (ec) { + return; + } + break; + } + } + + // Write the data to the parser + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. + if (ec == error::need_more) { + ec = {}; + } + if (ec) { + return; + } + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); + } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Deferred Body Type +// +//------------------------------------------------------------------------------ + +//[example_http_defer_body + +/** Handle a form POST request, choosing a body type depending on the Content-Type. + + This reads a request from the input stream. If the method is POST, and + the Content-Type is "application/x-www-form-urlencoded " or + "multipart/form-data", a `string_body` is used to receive and store + the message body. Otherwise, a `dynamic_body` is used to store the message + body. After the request is received, the handler will be invoked with the + request. + + @param stream The stream to read from. + + @param buffer The buffer to use for reading. + + @param handler The handler to invoke when the request is complete. + The handler must be invokable with this signature: + @code + template + void handler(request&& req); + @endcode + + @throws system_error Thrown on failure. +*/ +template +void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + + // Read just the header. Otherwise, the empty_body + // would generate an error if body octets were received. + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb + if (req0.get().method() == verb::post && + (req0.get()[field::content_type] == "application/x-www-form-urlencoded" || + req0.get()[field::content_type] == "multipart/form-data")) { + request_parser req{std::move(req0)}; + read(stream, buffer, req); + handler(req.release()); + } else { + request_parser req{std::move(req0)}; + read(stream, buffer, req); + handler(req.release()); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Incremental Read +// +//------------------------------------------------------------------------------ + +//[example_incremental_read + +/* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. +*/ +template +void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); + if (ec) { + return; + } + while (!p.is_done()) { + std::array buf{}; + p.get().body().data = buf.data(); + p.get().body().size = buf.size(); + read(stream, buffer, p, ec); + if (ec == error::need_buffer) { + ec = {}; + } + if (ec) { + return; + } + os.write(buf.data(), static_cast(buf.size() - p.get().body().size)); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Read large response body +// +//------------------------------------------------------------------------------ + +//[example_read_large_response_body + +/* This function uses custom size limit of the resposne body. + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. +*/ +template +std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, + message>& msg, + std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); + if (ec) { + return bytes_transferred; + } + msg = p.release(); + return bytes_transferred; +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_chunk_parsing + +/** Read a message with a chunked body and print the chunks and extensions + */ +template +void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); + if (ec) { + return; + } + + // This container will hold the extensions for each chunk + chunk_extensions ce; + + // This string will hold the body of each chunk + std::string chunk; + + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = + [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk + string_view extensions, // The raw chunk-extensions string. Already validated. + error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); + if (ev) { + return; + } + + // See if the chunk is too big + if (size > std::numeric_limits::max()) { + ev = error::body_limit; + return; + } + + // Make sure we have enough storage, and + // reset the container for the upcoming chunk + chunk.reserve(static_cast(size)); + chunk.clear(); + }; + + // Set the callback. The function requires a non-const reference so we + // use a local variable, since temporaries can only bind to const refs. + p.on_chunk_header(header_cb); + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. + auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk + string_view body, // A buffer holding chunk body data + error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. + if (remain == body.size()) { + ec = error::end_of_chunk; + } + + // Append this piece to our container + chunk.append(body.data(), body.size()); + + // The return value informs the parser of how much of the body we + // consumed. We will indicate that we consumed everything passed in. + return body.size(); + }; + p.on_chunk_body(body_cb); + + while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); + if (!ec) { + continue; + } + if (ec != error::end_of_chunk) { + return; + } + ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; + if (!extension.second.empty()) { + os << " = " << extension.second << '\n' << std::flush; + } else { + os << '\n' << std::flush; + } + } + + // Now print the chunk body + os << "Chunk Body: " << chunk << '\n' << std::flush; + } + + // Get a reference to the parsed message, this is for convenience + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it + for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << '\n' << std::flush; + continue; + } + os << it->name() << ": " << it->value() << '\n' << std::flush; + } +} + +//] + +} // namespace boost::beast::http diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/ssl/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/ssl/client.cpp new file mode 100644 index 0000000..823a1b6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/ssl/client.cpp @@ -0,0 +1,134 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + { + webcpp_fixture::fail_stop(); + } + } +} + +net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) + if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { + webcpp_fixture::fail_stop(); + } + + // Set a callback to verify that the hostname in the server + // certificate matches the expected value + stream.set_verify_callback(ssl::host_name_verification("localhost")); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request + http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); + + // Read the response + beast::flat_buffer buf; + http::response res; + co_await http::async_read(stream, buf, res); + + // Print the response body + std::cout << res.body(); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +} // namespace + +int main() { + { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful + ctx.set_verify_mode(ssl::verify_peer); + + // The servers's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Client certificate and private key (if server request for). + ctx.use_certificate_chain_file("client.crt"); + ctx.use_private_key_file("client.key", ssl::context::pem); + + net::co_spawn(ioc, request(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/ssl/server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/ssl/server.cpp new file mode 100644 index 0000000..fc19ff2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/doc/ssl/server.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + { + webcpp_fixture::fail_stop(); + } + } +} + +net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + + // Read and discard a request + beast::flat_buffer buf; + http::request req; + co_await http::async_read(stream, buf, req); + + // Write the response + http::response res; + res.body() = "Hello!"; + co_await http::async_write(stream, res); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +net::awaitable acceptor(ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), + print_exception); + } +} + +} // namespace + +int main() { + { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. + // Asio exposes the OpenSSL verification bitmask as signed integer constants. + // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Server certificate and private key. + ctx.use_certificate_chain_file("server.crt"); + ctx.use_private_key_file("server.key", ssl::context::pem); + + // DH parameters for DHE-based cipher suites + ctx.use_tmp_dh_file("dh4096.pem"); + + net::co_spawn(ioc, acceptor(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/echo-op/echo_op.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/echo-op/echo_op.cpp new file mode 100644 index 0000000..a2ce491 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/echo-op/echo_op.cpp @@ -0,0 +1,394 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; +namespace beast = webcpp::beast; + +//[example_core_echo_op_1 + +namespace { +template +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] + -> net::async_result, void(beast::error_code)>::return_type; + +//------------------------------------------------------------------------------ + +//[example_core_echo_op_2 + +/** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending + in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + + - A line was read in and written back on the stream + + - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` + and `async_write_some` function. The program must ensure that no + other reads or writes are performed until this operation completes. + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the + first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the + requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is + responsible for ensuring that the lifetime of this object is + extended least until the completion handler is invoked. + + @param token The handler to be called when the operation completes. + The implementation takes ownership of the handler by performing a decay-copy. + The handler must be invocable with this signature: + @code + void handler( + beast::error_code error // Result of operation. + ); + @endcode + + Regardless of whether the asynchronous operation completes immediately or + not, the handler will not be invoked from within this function. Invocation + of the handler will be performed in a manner equivalent to using + `net::post`. +*/ +template +// Upstream documentation repeats the initiating signature before its implementation. +// NOLINTNEXTLINE(readability-redundant-declaration) +// Each documentation snippet presents the complete public declaration. +// NOLINTNEXTLINE(readability-redundant-declaration) +auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ + CompletionToken&& token) + -> net::async_result*/ + std::decay_t, + void(beast::error_code) /*< The completion handler signature goes here >*/ + >::return_type; +//] + +//[example_core_echo_op_3 + +template +class echo_op; + +// This example uses the Asio's stackless "fauxroutines", implemented +// using a macro-based solution. It makes the code easier to write and +// easier to read. This include file defines the necessary macros and types. +#include + +// Read a line and echo it back +// +template +// The retained stackless coroutine expands each yield into nested resume branches. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +// Stackless coroutine macros generate the branches in this operation. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + -> net::async_result, + void(beast::error_code)>::return_type /*< The completion handler + signature goes here >*/ +{ + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. + static_assert(beast::is_async_stream::value, + "AsyncStream type requirements not met"); + static_assert(net::is_dynamic_buffer::value, + "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, + // and creates the `async_result` object which becomes the + // return value of this initiating function. + + net::async_completion init(token); + + // The helper macro BOOST_ASIO_HANDLER_TYPE converts the completion + // token type into a concrete handler type of the correct signature. + + using handler_type = BOOST_ASIO_HANDLER_TYPE(CompletionToken, void(beast::error_code)); + + // The class template `async_base` holds the caller's completion + // handler for us, and provides all of the boilerplate for forwarding + // the associated allocator and associated executor from the caller's + // handler to our operation. It also maintains a `net::executor_work_guard` + // for the executor associated with the stream. This work guard is + // inexpensive, and prevents the execution context from running out + // of work. It is usually necessary although rarely it can be skipped + // depending on the operation (this echo example needs it because it + // performs more than one asynchronous operation in a row). + // We declare this type alias to make the code easier to read. + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ + beast::executor_type /*< The type of executor used by the stream to dispatch + asynchronous operations >*/ + >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + + // Upstream combines coroutine state and shared lifetime as independent mixins. + // NOLINTNEXTLINE(misc-multiple-inheritance) + // Asio operation state combines completion ownership with coroutine resume state. + // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream; + DynamicBuffer& buffer; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( + std::move( + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , + stream(stream), + buffer(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our + // asynchronous control flow. + (*this)({}, 0, false); + } + + // If a newline is present in the buffer sequence, this function returns + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + + static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + + auto const begin = + net::buffers_iterator::begin(buffers); + auto const end = + net::buffers_iterator::end(buffers); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + const auto result = std::find(begin, end, '\n'); + + if (result == end) { + return 0; // not found + } + + return result + 1 - begin; + } + + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + // Resume labels generated by the stackless coroutine form one state machine. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + + reenter(*this) { + for (;;) { + // Stackless resume labels require this local to be assigned after resumption. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + // Resume labels cannot cross an initialized local; it is assigned before use. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer.data()); + + // If we don't have the newline, then read more + if (pos == 0) { + // Stackless resume labels require this local to be assigned after + // resumption. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + // Resume labels cannot cross an initialized local; it is assigned before + // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, + buffer.capacity() - buffer.size()), + std::min(65536, // and over 65536 is too much. + buffer.max_size() - buffer.size())); + + // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + + yield stream.async_read_some(buffer.prepare(bytes_to_read), + std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. + + // Move the bytes read from the writable area to the + // readable area. + + buffer.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. + if (ec) { + break; + } + + // Keep looping until we get the newline + continue; + } + + // We have our newline, so send the first `pos` bytes of the + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + + yield net::async_write(stream, beast::buffers_prefix(pos, buffer.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, + // and the `reenter` statement above will cause control to jump + // to the following line. The variable `pos` is no longer valid + // (remember that we returned from the function using `yield` above) + // but we can use `bytes_transferred` to know how much of the buffer + // to consume. With "real" coroutines this will be easier and more + // natural. + + buffer.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. + + break; + } + + // When a composed operation completes immediately, it must not + // directly invoke the completion handler otherwise it could + // lead to unfairness, starvation, or stack overflow. Therefore, + // if cont == false (meaning, that the call stack still includes + // the frame of the initiating function) then we need to use + // `net::post` to cause us to be called again after the initiating + // function. The function `async_base::invoke` takes care of + // calling the final completion handler, using post if the + // first argument is false, otherwise invoking it directly. + + this->complete(cont, ec); + } + } + }; + + // Create the composed operation and launch it. This is a constructor + // call followed by invocation of operator(). We use BOOST_ASIO_HANDLER_TYPE + // to convert the completion token into the correct handler type, + // allowing user-defined specializations of the async_result template + // to be used. + + echo_op(stream, buffer, std::move(init.completion_handler)); + + // This hook lets the caller see a return value when appropriate. + // For example this might return std::future if + // CompletionToken is net::use_future, or this might + // return an error code if CompletionToken specifies a coroutine. + + return init.result.get(); +} + +// Including this file undefines the macros used by the stackless fauxroutines. +#include + +//] + +struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { + if (ec) { + std::cerr << ": " << ec.message() << '\n'; + } + } +}; + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" + << "Example:\n" + << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; + endpoint_type const ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); + acceptor.listen(); + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); + ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-local/http_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-local/http_client_async_local.cpp new file mode 100644 index 0000000..bc59e52 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-local/http_client_async_local.cpp @@ -0,0 +1,184 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* target, + int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, std::string{host} + ":" + port); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { + std::cerr << "Usage: http-client-async-local []\n" + << "Example:\n" + << " http-client-async-local /tmp/http.sock localhost 80 /\n" + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + const auto* const host = argv[2]; + const auto* const port = argv[3]; + const auto* const target = argv[4]; + int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..9995baf --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,255 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor()), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..9f7026c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,252 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..1f54524 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/async/http_client_async.cpp @@ -0,0 +1,195 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..6638b17 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,195 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include "common/root_certificates.hpp" + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + webcpp_fixture::fail_stop(); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..98c689d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,152 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/body/json_body.hpp new file mode 100644 index 0000000..19ff218 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/body/json_body.hpp @@ -0,0 +1,120 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(webcpp::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(webcpp::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/body/json_client.cpp new file mode 100644 index 0000000..3a57b02 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/body/json_client.cpp @@ -0,0 +1,76 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "json_body.hpp" + +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/coro-ssl/http_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/coro-ssl/http_client_coro_ssl.cpp new file mode 100644 index 0000000..1e24957 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -0,0 +1,207 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, ssl::context& ctx, + net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res << std::endl; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream.async_shutdown(yield[ec]); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro-ssl []\n" + << "Example:\n" + << " http-client-coro-ssl www.example.com 443 /\n" + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/coro/http_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/coro/http_client_coro.cpp new file mode 100644 index 0000000..4fc12b5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/coro/http_client_coro.cpp @@ -0,0 +1,159 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro []\n" + << "Example:\n" + << " http-client-coro www.example.com 80 /\n" + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..7cb28c7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/http_crawl.cpp @@ -0,0 +1,341 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, webcpp::asio::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Create and launch the worker threads. + std::vector workers; + workers.reserve(threads + 1); + for (int i = 0; i < threads; ++i) { + // Each worker will eventually add some data to the aggregated + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto reporting_work = + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); + + workers.emplace_back([&report, reporting_work] { + // We use a separate io_context for each worker because + // the asio resolver simulates asynchronous operation using + // a dedicated worker thread per io_context, and we want to + // do a lot of name resolutions in parallel. + webcpp::asio::io_context ioc; + std::make_shared(report, ioc)->run(); + ioc.run(); // lint-run: drives the application's network operations + }); + } + + // Add another thread to run the main io_context which + // is used to aggregate the statistics + workers.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + + // Now block until all threads exit + for (auto& worker : workers) { + worker.join(); + } + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..742928a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..0d55720 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..2b5d0d0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/methods/http_client_methods.cpp @@ -0,0 +1,211 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..6a7fea1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,149 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { + webcpp_fixture::fail_stop(); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..96451a7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/client/sync/http_client_sync.cpp @@ -0,0 +1,117 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async-local/http_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async-local/http_server_async_local.cpp new file mode 100644 index 0000000..021a2fa --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async-local/http_server_async_local.cpp @@ -0,0 +1,446 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-async-local \n" + << "Example:\n" + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async-ssl/http_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async-ssl/http_server_async_ssl.cpp new file mode 100644 index 0000000..cdcf6f7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async-ssl/http_server_async_ssl.cpp @@ -0,0 +1,534 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + void on_run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + do_read(); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" + << "Example:\n" + << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async/http_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async/http_server_async.cpp new file mode 100644 index 0000000..3dfb361 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/async/http_server_async.cpp @@ -0,0 +1,468 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" + << "Example:\n" + << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/awaitable/http_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/awaitable/http_server_awaitable.cpp new file mode 100644 index 0000000..6105689 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/awaitable/http_server_awaitable.cpp @@ -0,0 +1,360 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +// Handles an HTTP server connection +net::awaitable do_session(beast::tcp_stream stream, + std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + co_await http::async_read(stream, buffer, req); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have + // dropped the connection already. +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" + << "Example:\n" + << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/coro-ssl/http_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/coro-ssl/http_server_coro_ssl.cpp new file mode 100644 index 0000000..12e98b3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -0,0 +1,403 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) + return "text/html"; + if (iequals(ext, ".html")) + return "text/html"; + if (iequals(ext, ".php")) + return "text/html"; + if (iequals(ext, ".css")) + return "text/css"; + if (iequals(ext, ".txt")) + return "text/plain"; + if (iequals(ext, ".js")) + return "application/javascript"; + if (iequals(ext, ".json")) + return "application/json"; + if (iequals(ext, ".xml")) + return "application/xml"; + if (iequals(ext, ".swf")) + return "application/x-shockwave-flash"; + if (iequals(ext, ".flv")) + return "video/x-flv"; + if (iequals(ext, ".png")) + return "image/png"; + if (iequals(ext, ".jpe")) + return "image/jpeg"; + if (iequals(ext, ".jpeg")) + return "image/jpeg"; + if (iequals(ext, ".jpg")) + return "image/jpeg"; + if (iequals(ext, ".gif")) + return "image/gif"; + if (iequals(ext, ".bmp")) + return "image/bmp"; + if (iequals(ext, ".ico")) + return "image/vnd.microsoft.icon"; + if (iequals(ext, ".tiff")) + return "image/tiff"; + if (iequals(ext, ".tif")) + return "image/tiff"; + if (iequals(ext, ".svg")) + return "image/svg+xml"; + if (iequals(ext, ".svgz")) + return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(ssl::stream& stream, + std::shared_ptr const& doc_root, net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) + break; + if (ec) + return fail(ec, "read"); + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + + if (ec) + return fail(ec, "write"); + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); + if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" + << "Example:\n" + << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/coro/http_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/coro/http_server_coro.cpp new file mode 100644 index 0000000..4f72585 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/coro/http_server_coro.cpp @@ -0,0 +1,360 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) + return "text/html"; + if (iequals(ext, ".html")) + return "text/html"; + if (iequals(ext, ".php")) + return "text/html"; + if (iequals(ext, ".css")) + return "text/css"; + if (iequals(ext, ".txt")) + return "text/plain"; + if (iequals(ext, ".js")) + return "application/javascript"; + if (iequals(ext, ".json")) + return "application/json"; + if (iequals(ext, ".xml")) + return "application/xml"; + if (iequals(ext, ".swf")) + return "application/x-shockwave-flash"; + if (iequals(ext, ".flv")) + return "video/x-flv"; + if (iequals(ext, ".png")) + return "image/png"; + if (iequals(ext, ".jpe")) + return "image/jpeg"; + if (iequals(ext, ".jpeg")) + return "image/jpeg"; + if (iequals(ext, ".jpg")) + return "image/jpeg"; + if (iequals(ext, ".gif")) + return "image/gif"; + if (iequals(ext, ".bmp")) + return "image/bmp"; + if (iequals(ext, ".ico")) + return "image/vnd.microsoft.icon"; + if (iequals(ext, ".tiff")) + return "image/tiff"; + if (iequals(ext, ".tif")) + return "image/tiff"; + if (iequals(ext, ".svg")) + return "image/svg+xml"; + if (iequals(ext, ".svgz")) + return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, + net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) + break; + if (ec) + return fail(ec, "read"); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + + if (ec) + return fail(ec, "write"); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn(acceptor.get_executor(), + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" + << "Example:\n" + << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/fast/fields_alloc.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/fast/fields_alloc.hpp new file mode 100644 index 0000000..3419542 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/fast/fields_alloc.hpp @@ -0,0 +1,168 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP +#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP + +#include +#include +#include +#include + +namespace detail { + +class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + + char* end() { return reinterpret_cast(this + 1) + size_; } + + explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} + +public: + static static_pool& construct(std::size_t size) { + auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + + static static_pool& share(static_pool& pool) { + ++pool.refs_; + return pool; + } + + void destroy() { + if ((--refs_) != 0u) { + return; + } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { + auto* last = p_ + n; + if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + } + ++count_; + auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { + if ((--count_) != 0u) { + return; + } + p_ = reinterpret_cast(this + 1); + } +}; + +} // namespace detail + +/** A non-thread-safe allocator optimized for @ref basic_fields. + + This allocator obtains memory from a pre-allocated memory block + of a given size. It does nothing in deallocate until all + previously allocated blocks are deallocated, upon which it + resets the internal memory block for re-use. + + To use this allocator declare an instance persistent to the + connection or session, and construct with the block size. + A good rule of thumb is 20% more than the maximum allowed + header size. For example if the application only allows up + to an 8,000 byte header, the block size could be 9,600. + + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. +*/ +template +struct fields_alloc { + detail::static_pool* pool; + +public: + using value_type = T; + using is_always_equal = std::false_type; + using pointer = T*; + using reference = T&; + using const_pointer = T const*; + using const_reference = T const&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template + struct rebind { + using other = fields_alloc; + }; + +#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) + // Workaround for g++ + // basic_string assumes that allocators are default-constructible + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 + fields_alloc() = default; +#endif + + explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + + fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template + explicit fields_alloc(fields_alloc const& other) + : pool(&detail::static_pool::share(*other.pool)) {} + + ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { + return static_cast(pool->alloc(n * sizeof(T))); + } + + void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template + void construct(U* ptr, Args&&... args) { + ::new (static_cast(ptr)) U(std::forward(args)...); + } + + template + void destroy(U* ptr) { + ptr->~U(); + } +#endif + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool == &rhs.pool_; + } + + template + friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { + return !(lhs == rhs); + } +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/fast/http_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/fast/http_server_fast.cpp new file mode 100644 index 0000000..271d6d0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/fast/http_server_fast.cpp @@ -0,0 +1,358 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include "fields_alloc.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +class http_worker { +public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + + // Retain the upstream borrowing constructor contract in this reference counterpart. + // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + + void start() { + accept(); + check_deadline(); + } + +private: + using alloc_t = fields_alloc; + // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. + tcp::acceptor& acceptor_; + + // The path to the root of the document directory. + std::string doc_root_; + + // The socket for the currently connected client. + tcp::socket socket_{acceptor_.get_executor()}; + + // The buffer for performing reads + beast::flat_static_buffer<8192> buffer_; + + // The allocator used for the fields in the request and reply. + alloc_t alloc_{8192}; + + // The parser for reading the requests + boost::optional> parser_; + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), + std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> + string_response_; + + // The string-based response serializer. + boost::optional>> + string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. + boost::optional>> + file_serializer_; + + void accept() { + // Clean up any previous connection. + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { + if (ec) { + accept(); + } else { + // Request must be fully processed within 60 seconds. + request_deadline_.expires_after(std::chrono::seconds(60)); + + read_request(); + } + }); + } + + void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. + // + // Arguments passed to the parser constructor are + // forwarded to the message object. A single argument + // is forwarded to the body constructor. + // + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { + if (ec) { + accept(); + } else { + process_request(parser_->get()); + } + }); + } + + void process_request(http::request> const& req) { + if (req.method() == http::verb::get) { + send_file(req.target()); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + + void send_bad_response(http::status status, std::string const& error) { + string_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); + }); + } + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open(full_path.c_str(), beast::file_mode::read, ec); + if (ec) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + file_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); + }); + } + + void check_deadline() { + // The deadline may have moved, so check it has really passed. + if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. + request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 6) { + std::cerr << "Usage: http_server_fast
" + "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " http_server_fast 0::0 80 . 100 block\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + std::string const doc_root = argv[3]; + int const num_workers = webcpp_fixture::integer(argv[4]); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; + for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) { + for (;;) { + ioc.poll(); + } + } else { + ioc.run(); // lint-run: drives the application's network operations + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/flex/http_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/flex/http_server_flex.cpp new file mode 100644 index 0000000..076965e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/flex/http_server_flex.cpp @@ -0,0 +1,636 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP flex server (plain and SSL), asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; + +protected: + beast::flat_buffer buffer; + +public: + // Take ownership of the buffer +private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), + beast::bind_front_handler(&session::on_write, + derived().shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Read another request + do_read(); + } + + friend Derived; +}; + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_session(tcp::socket&& socket, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the session + ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( + ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake + async_detect_ssl(stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" + << "Example:\n" + << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/small/http_server_small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/small/http_server_small.cpp new file mode 100644 index 0000000..511e4b5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/small/http_server_small.cpp @@ -0,0 +1,221 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +namespace { +namespace my_program_state { +std::size_t request_count() { + static std::size_t count = 0; + return ++count; +} + +std::time_t now() { + return std::time(nullptr); +} +} // namespace my_program_state + +class http_connection : public std::enable_shared_from_this { +public: + explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { + read_request(); + check_deadline(); + } + +private: + // The socket for the currently connected client. + tcp::socket socket_; + + // The buffer for performing reads. + beast::flat_buffer buffer_{8192}; + + // The request message. + http::request request_; + + // The response message. + http::response response_; + + // The timer for putting a deadline on connection processing. + net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. + void read_request() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + if (!ec) { + self->process_request(); + } + }); + } + + // Determine what needs to be done with the request message. + void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + + if (request_.method() == http::verb::get) { + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); + } + + // Construct a response message based on the program state. + void create_response() { + if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + // Asynchronously transmit the response message. + void write_response() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.close(ec)); + } + }); + } +}; + +// "Loop" forever accepting new connections. +void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { + if (!ec) { + std::make_shared(std::move(socket))->start(); + } + http_server(acceptor, socket); + }); +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + + ioc.run(); // lint-run: drives the application's network operations + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/stackless-ssl/http_server_stackless_ssl.cpp new file mode 100644 index 0000000..4cb4f76 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -0,0 +1,545 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + yield stream_.async_shutdown( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + ctx_(ctx), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" + << "Example:\n" + << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/stackless/http_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/stackless/http_server_stackless.cpp new file mode 100644 index 0000000..816e51f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/stackless/http_server_stackless.cpp @@ -0,0 +1,482 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" + << "Example:\n" + << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/sync-ssl/http_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/sync-ssl/http_server_sync_ssl.cpp new file mode 100644 index 0000000..c1b5369 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -0,0 +1,377 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.handshake(ssl::stream_base::server, ec)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Perform the SSL shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync-ssl
\n" + << "Example:\n" + << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} + .detach(); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/sync/http_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/sync/http_server_sync.cpp new file mode 100644 index 0000000..abe4627 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/http/server/sync/http_server_sync.cpp @@ -0,0 +1,344 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync
\n" + << "Example:\n" + << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-local/websocket_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-local/websocket_client_async_local.cpp new file mode 100644 index 0000000..49e062c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-local/websocket_client_async_local.cpp @@ -0,0 +1,198 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; + + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr + << "Usage: websocket-client-async-local \n" + << "Example:\n" + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + const auto* const host = argv[2]; + const auto* const port = argv[3]; + const auto* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..c8bff59 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,263 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor{}), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..ab86e69 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,259 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..92b94ac --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,217 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); + })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..3c2f122 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,146 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); + + // Send the message + co_await stream.async_write(net::buffer(text)); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp new file mode 100644 index 0000000..7615d0e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -0,0 +1,197 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + return fail(ec, "connect"); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro-ssl \n" + << "Example:\n" + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/coro/websocket_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/coro/websocket_client_coro.cpp new file mode 100644 index 0000000..55f0a6d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/coro/websocket_client_coro.cpp @@ -0,0 +1,164 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro \n" + << "Example:\n" + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..b73de02 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,134 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + webcpp_fixture::fail_stop(); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..e466a80 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,112 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async-local/websocket_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async-local/websocket_server_async_local.cpp new file mode 100644 index 0000000..cdd6950 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async-local/websocket_server_async_local.cpp @@ -0,0 +1,235 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; + } + // Create the session and run it + std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-async-local \n" + << "Example:\n" + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async-ssl/websocket_server_async_ssl.cpp new file mode 100644 index 0000000..f8f6f98 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -0,0 +1,292 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async/websocket_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async/websocket_server_async.cpp new file mode 100644 index 0000000..e6eb729 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/async/websocket_server_async.cpp @@ -0,0 +1,257 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" + << "Example:\n" + << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/awaitable/websocket_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/awaitable/websocket_server_awaitable.cpp new file mode 100644 index 0000000..1f4161d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/awaitable/websocket_server_awaitable.cpp @@ -0,0 +1,157 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Echoes back all received WebSocket messages +namespace { +net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + co_await stream.async_accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed) { + co_return; + } + + if (ec) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + stream.text(stream.got_text()); + co_await stream.async_write(buffer.data()); + } +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" + << "Example:\n" + << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/beast.hpp new file mode 100644 index 0000000..1e7ec46 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/beast.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/http_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/http_session.cpp new file mode 100644 index 0000000..27686e2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/http_session.cpp @@ -0,0 +1,337 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include +#include "http_session.hpp" +#include "websocket_session.hpp" + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +} // namespace + +http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +void http_session::run() { + do_read(); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, parser_->get(), + beast::bind_front_handler(&http_session::on_read, shared_from_this())); +} + +void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + boost::make_shared(stream_.release_socket(), state_) + ->run(parser_->release()); + return; + } + + // Handle request + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response + beast::async_write(stream_, std::move(msg), + [self, keep_alive](beast::error_code ec, std::size_t bytes) { + self->on_write(ec, bytes, keep_alive); + }); +} + +void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Read another request + do_read(); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/http_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/http_session.hpp new file mode 100644 index 0000000..74da296 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/http_session.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +#include +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +/** Represents an established HTTP connection + */ +class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + + struct send_lambda; + + void fail(beast::error_code ec, char const* what); + void do_read(); + void on_read(beast::error_code ec, std::size_t /*unused*/); + void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + +public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/listener.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/listener.cpp new file mode 100644 index 0000000..e62dbde --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/listener.cpp @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "http_session.hpp" +#include "listener.hpp" + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } +} + +void listener::run() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handle a connection +void listener::on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); + } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/listener.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/listener.hpp new file mode 100644 index 0000000..172a454 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/listener.hpp @@ -0,0 +1,56 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" + +// Forward declaration +class shared_state; + +// Accepts incoming connections and launches the sessions +class listener : public boost::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec, tcp::socket socket); + +public: + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/main.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/main.cpp new file mode 100644 index 0000000..4ce5d9f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/main.cpp @@ -0,0 +1,97 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +//------------------------------------------------------------------------------ +/* + WebSocket chat server, multi-threaded + + This implements a multi-user chat room using WebSocket. The + `io_context` runs on any number of threads, specified at + the command line. + +*/ +//------------------------------------------------------------------------------ + +#include "listener.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" + << "Example:\n" + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto* doc_root = argv[3]; + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Create and launch a listening port + boost::make_shared(ioc, tcp::endpoint{address, port}, + boost::make_shared(doc_root)) + ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&ioc](boost::system::error_code const&, int) { + // Stop the io_context. This will cause run() + // to return immediately, eventually destroying the + // io_context and any remaining handlers in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/net.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/net.hpp new file mode 100644 index 0000000..b3acfe9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/net.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +#include + +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/shared_state.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/shared_state.cpp new file mode 100644 index 0000000..3315c9c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/shared_state.cpp @@ -0,0 +1,69 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "shared_state.hpp" +#include "websocket_session.hpp" + +shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + +void shared_state::join(websocket_session* session) { + std::scoped_lock const lock(mutex_); + sessions_.insert(session); +} + +void shared_state::leave(websocket_session* session) { + std::scoped_lock const lock(mutex_); + sessions_.erase(session); +} + +// Broadcast a message to all websocket client sessions +void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + + // Make a local list of all the weak pointers representing + // the sessions, so we can do the actual sending without + // holding the mutex: + std::vector> v; + { + std::scoped_lock const lock(mutex_); + v.reserve(sessions_.size()); + for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); + } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. + for (auto const& wp : v) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + if (const auto sp = wp.lock()) { + sp->send(ss); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/shared_state.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/shared_state.hpp new file mode 100644 index 0000000..898c90d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/shared_state.hpp @@ -0,0 +1,60 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP + +#include +#include +#include +#include +#include + +// Forward declaration +class websocket_session; + +// Represents the shared server state +class shared_state { + std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; + + // Keep a list of all the connected clients + std::unordered_set sessions_; + +public: + explicit shared_state(std::string doc_root); + + [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); + void send(std::string message); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/websocket_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/websocket_session.cpp new file mode 100644 index 0000000..6af339b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/websocket_session.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "websocket_session.hpp" + +websocket_session::websocket_session(tcp::socket&& socket, + boost::shared_ptr const& state) + : ws_(std::move(socket)), state_(state) {} + +websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); +} + +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these + if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Read another message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + + net::post(ws_.get_executor(), + beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); +} + +void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? + if (queue_.size() > 1) { + return; + } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); +} + +void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any + if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/websocket_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/websocket_session.hpp new file mode 100644 index 0000000..4673db5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/chat-multi/websocket_session.hpp @@ -0,0 +1,89 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// Forward declaration +class shared_state; + +/** Represents an active WebSocket connection to the server + */ +class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; + std::vector> queue_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); + +public: + websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + + template + void run(http::request> req); + + // Send a message + void send(boost::shared_ptr const& ss); + +private: + void on_send(boost::shared_ptr const& ss); +}; + +template +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); + })); + + // Accept the websocket handshake + ws_.async_accept(req, + beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp new file mode 100644 index 0000000..f5fc7de --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -0,0 +1,211 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void do_session(websocket::stream>& ws, net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) + return fail(ec, "accept"); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) + break; + + if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) + return fail(ec, "write"); + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" + << "Example:\n" + << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/coro/websocket_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/coro/websocket_server_coro.cpp new file mode 100644 index 0000000..ed910f7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/coro/websocket_server_coro.cpp @@ -0,0 +1,186 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) + return fail(ec, "accept"); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) + break; + + if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) + return fail(ec, "write"); + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" + << "Example:\n" + << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + boost::asio::spawn( + ioc, + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/fast/websocket_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/fast/websocket_server_fast.cpp new file mode 100644 index 0000000..d5fb270 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/fast/websocket_server_fast.cpp @@ -0,0 +1,397 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, fast +// +//------------------------------------------------------------------------------ + +/* This server contains the following ports: + + Synchronous + Asynchronous + Coroutine + + This program is optimized for the Autobahn|Testsuite + benchmarking and WebSocket compliants testing program. + + See: + https://github.com/crossbario/autobahn-testsuite +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); +} + +// Adjust settings on the stream +template +void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + + websocket::permessage_deflate pmd; + pmd.client_enable = true; + pmd.server_enable = true; + pmd.compLevel = 3; + ws.set_option(pmd); + + ws.auto_fragment(false); + + // Autobahn|Testsuite needs this + ws.read_message_max(64 * 1024 * 1024); +} + +//------------------------------------------------------------------------------ + +void do_sync_session(websocket::stream& ws) { + beast::error_code ec; + + setup_stream(ws); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Sync"); + })); + + ws.accept(ec); + if (ec) + return fail(ec, "accept"); + + for (;;) { + beast::flat_buffer buffer; + + ws.read(buffer, ec); + if (ec == websocket::error::closed) + break; + if (ec) + return fail(ec, "read"); + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); + if (ec) + return fail(ec, "write"); + } +} + +void do_sync_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) { + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; + for (;;) { + tcp::socket socket{ioc}; + + acceptor.accept(socket, ec); + if (ec) + return fail(ec, "accept"); + + std::thread( + std::bind(&do_sync_session, websocket::stream(std::move(socket)))) + .detach(); + } +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation + void run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&async_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed + if (ec == websocket::error::closed) + return; + + if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&async_session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +// Accepts incoming connections and launches the sessions +class async_listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen(net::socket_base::max_listen_connections, ec); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); + })); + + ws.async_accept(yield[ec]); + if (ec) + return fail(ec, "accept"); + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); + if (ec == websocket::error::closed) + break; + if (ec) + return fail(ec, "read"); + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) + return fail(ec, "write"); + } +} + +void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); + } +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" + << "Example:\n" + " websocket-server-fast 0.0.0.0 8080 1\n" + " Connect to:\n" + " starting-port+0 for synchronous,\n" + " starting-port+1 for asynchronous,\n" + " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create sync port + std::thread( + beast::bind_front_handler(&do_sync_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 0u)})) + .detach(); + + // Create async port + std::make_shared(ioc, + tcp::endpoint{address, static_cast(port + 1u)}) + ->run(); + + // Create coro port + boost::asio::spawn(ioc, + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), + boost::asio::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp new file mode 100644 index 0000000..cf12752 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -0,0 +1,311 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless-ssl"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/stackless/websocket_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/stackless/websocket_server_stackless.cpp new file mode 100644 index 0000000..b8d4ac2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/stackless/websocket_server_stackless.cpp @@ -0,0 +1,277 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" + << "Example:\n" + << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp new file mode 100644 index 0000000..58a8d4b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -0,0 +1,138 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "close_observation.hpp" +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket, ssl::context& ctx) { + { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + beast::error_code read_error; + ws.read(buffer, read_error); + if (read_error == websocket::error::closed) { + webcpp_fixture::observe_normal_close(); + return; + } + if (read_error) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync-ssl
\n" + << "Example:\n" + << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread(&do_session, std::move(socket), std::ref(ctx)).detach(); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/sync/websocket_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/sync/websocket_server_sync.cpp new file mode 100644 index 0000000..76cabdc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-native/websocket/server/sync/websocket_server_sync.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "close_observation.hpp" +#include "failure.hpp" +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket) { + { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + beast::error_code read_error; + ws.read(buffer, read_error); + if (read_error == websocket::error::closed) { + webcpp_fixture::observe_normal_close(); + return; + } + if (read_error) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync
\n" + << "Example:\n" + << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread(&do_session, std::move(socket)).detach(); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp new file mode 100644 index 0000000..05807c3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp @@ -0,0 +1,661 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +using executor_type = net::strand; +using stream_type = beast::tcp_stream::rebind_executor::other; +using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +/** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. +*/ +class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit task_group(net::any_io_executor exec) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; + task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + + @note `completion_token` must have an associated executor that matches + the one the child task runs on (e.g. via `net::bind_executor`). This is + because `emit`() can run on a different thread than the task, and + `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template + auto adapt(CompletionToken&& completion_token) { + auto const lg = std::scoped_lock{mtx_}; + auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: + remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + + ~remover() { + if (tg_) { + auto const lg = std::scoped_lock{tg_->mtx_}; + if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); + } + } + } + }; + + return net::bind_cancellation_slot( + cs->slot(), + net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's + handler, if any. + + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { + auto const lg = std::scoped_lock{mtx_}; + for (auto& cs : css_) { + cs.emit(type); + } + } + + /** Starts an asynchronous wait on the task_group. + + The completion handler will be called when: + + - All the child tasks completed. + - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion + handler must be: + @code + void handler( + boost::system::error_code const& error // result of operation + ); + @endcode + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template > + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( + // The apparent recursion crosses an asynchronous completion boundary. + // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { + if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); + } + + if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; + } + + { + auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + + if (!std::exchange(scheduled, true)) { + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); + } + + self.complete(ec); + }, + completion_token, cv_); + } +}; + +template +net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { + auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + + while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; + } + + if (ec) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + ws.text(ws.got_text()); + co_await ws.async_write(buffer.data()); + + // Clear the buffer + buffer.consume(buffer.size()); + } + + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +template +net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + + if (ec == http::error::end_of_stream) { + co_return; + } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + + co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); + if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } + + co_await beast::async_write(stream, std::move(res)); + } +} + +net::awaitable detect_session(stream_type stream, ssl::context& ctx, + beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), + net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be + // inherited by all child coroutines. + co_await net::this_coro::throw_if_cancelled(false); + + stream.expires_after(std::chrono::seconds(30)); + + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + + auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + + if (!ssl_stream.lowest_layer().is_open()) { + co_return; + } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } + } else { + co_await run_session(stream, buffer, doc_root); + + if (!stream.socket().is_open()) { + co_return; + } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +} + +net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + + if (ec == net::error::operation_aborted) { + co_return; + } + + if (ec) { + webcpp_fixture::fail_stop(); + } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }))); + } +} + +net::awaitable handle_signals(task_group& task_group) { + auto const executor = co_await net::this_coro::executor; + auto deadline = net::steady_timer{executor}; + deadline.expires_after(std::chrono::seconds(4)); + + co_await deadline.async_wait(); + + { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( + net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); + + if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); + co_await task_group.async_wait(); + } + + std::cout << "Child tasks completed.\n"; + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }))); + + // Create and launch a signal handler coroutine + net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server-flex/advanced_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server-flex/advanced_server_flex.cpp new file mode 100644 index 0000000..2e0ff3d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server-flex/advanced_server_flex.cpp @@ -0,0 +1,859 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class websocket_session { + websocket_session() = default; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( + websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, + derived().shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, + derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), + beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } + +public: + // Start the asynchronous operation + template + void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; + +public: + // Create the session + explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; + +public: + // Create the ssl_websocket_session + explicit ssl_websocket_session(ssl::stream&& stream) + : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream>& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +template +void make_websocket_session(beast::tcp_stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +template +void make_websocket_session(ssl::stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +protected: + beast::flat_buffer buffer; + +public: + // Construct the session +private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, + derived().shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream)) {} + + // Start the session + void run() { this->do_read(); } + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Called by the base class + beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the http_session + ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream), ctx) {} + + // Start the session + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( + ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Called by the base class + ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + +private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + explicit detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); + } + + void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( + stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(std::move(stream_), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector http_session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" + << "Example:\n" + << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server/advanced_server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server/advanced_server.cpp new file mode 100644 index 0000000..2d549f5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/advanced/server/advanced_server.cpp @@ -0,0 +1,614 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server +// +//------------------------------------------------------------------------------ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, + shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection +class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +public: + // Take ownership of the socket + http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) { + static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + +private: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read(stream_, buffer_, *parser_, + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + std::make_shared(stream_.release_socket()) + ->do_accept(parser_->release()); + return; + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(acceptor_.get_executor(), + beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the http session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" + << "Example:\n" + << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/common/root_certificates.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/common/root_certificates.hpp new file mode 100644 index 0000000..af6048d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/common/root_certificates.hpp @@ -0,0 +1,3984 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP + +#include +#include + +/* + PLEASE READ + + These root certificates here are included just to make the + SSL client examples work. They are NOT intended to be + illustrative of best-practices for performing TLS certificate + verification. + + A REAL program which needs to verify the authenticity of a + server IP address resolved from a given DNS name needs to + consult the operating system specific certificate store + to validate the chain of signatures, compare the domain name + properly against the domain name in the certificate, check + the certificate revocation list, and probably do some other + things. + + ALL of these operations are entirely outside the scope of + both Boost.Beast and Boost.Asio. + + See (work in progress): + https://github.com/djarek/certify + + tl;dr: root_certificates.hpp should not be used in production code +*/ + +namespace ssl = boost::asio::ssl; // from + +namespace detail { + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(ctx.load_verify_file(path, ec)); + return; + } + + std::string cert = + "# ACCVRAIZ1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" + "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" +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yIpMNOmqOFGYM\n" + "LVN0V2Ue1bLdI4E7pWYjJ2cJj+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf\n" + "77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrTQfv6MooqtyuGC2mDOL7Nii4LcK2N\n" + "JpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW+YJF1DngoABd15jm\n" + "fZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7Ixjp\n" + "6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp\n" + "1txyM/1d8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B\n" + "9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok\n" + "RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" + "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Actalis Authentication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" + "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" + "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWN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bAEzlgqqI0JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDz\n" + "WochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKxK3JCaKygvU5a2hi/a5iB0P2avl4V\n" + "SM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+Xlff1ANATIGk0k9j\n" + "pwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX\n" + "X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok\n" + "fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R\n" + "K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU\n" + "ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU\n" + "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" + "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Commercial\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" + "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" + "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL\n" + "MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1\n" + "yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr\n" + "VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/\n" + "nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG\n" + "XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj\n" + "vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt\n" + "Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g\n" + "N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" + "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Networking\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDB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zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVz\n" + "dCBQcmVtaXVtMB4XDTEwMDEyOTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkG\n" + "A1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1U\n" + "cnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxBLf\n" + "qV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtnBKAQ\n" + "JG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ\n" + "+jjeRFcV5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrS\n" + "s8PhaJyJ+HoAVt70VZVs+7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5\n" + "HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmdGPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d7\n" + "70O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5Rp9EixAqnOEhss/n/fauG\n" + "V+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NIS+LI+H+S\n" + "qHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S\n" + "5u046uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4Ia\n" + "C1nEWTJ3s7xgaVY5/bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TX\n" + "OwF0lkLgAOIua+rF7nKsu7/+6qqo+Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYE\n" + "FJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByvMiPIs0laUZx2\n" + "KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg\n" + "Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B\n" + "8OWycvpEgjNC6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQ\n" + "MKSOyARiqcTtNd56l+0OOF6SL5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc\n" + "0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK+4w1IX2COPKpVJEZNZOUbWo6xbLQ\n" + "u4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF\n" + "u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH\n" + "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" + "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" + "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" + "KeC2uAloGRwYQw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" + "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" + "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" + "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" + "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" + "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" + "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" + "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" + "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" + "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzAN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DVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSwDPBMMPQFWAJI/TPlUq9LhONm\n" + "UjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oAA7CXDpO8Wqj2\n" + "LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY\n" + "+gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS\n" + "k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl\n" + "7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm\n" + "btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl\n" + "urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+\n" + "fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n" + "n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Atos TrustedRoot 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE\n" + "AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG\n" + "EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM\n" + "FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC\n" + "REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp\n" + "Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM\n" + "VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+\n" + "SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ\n" + "4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L\n" + "cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi\n" + "eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV\n" + "HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG\n" + "A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j\n" + "vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP\n" + "DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc\n" + "maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D\n" + "lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv\n" + "KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Autoridad de Certificacion Firmaprofesional CIF A62634068\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UE\n" + "BhMCRVMxQjBABgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1h\n" + "cHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEy\n" + "MzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIwQAYDVQQDDDlBdXRvcmlkYWQgZGUg\n" + "Q2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBBNjI2MzQwNjgwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDDUtd9\n" + "thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQM\n" + "cas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ylMnfX40S2wBEqgLk9\n" + "am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qkR71kMrv2JYSiJ0L1\n" + "ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaPT481\n" + "PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS\n" + "3a/DTg4fJl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5k\n" + "SeTy36LssUzAKh3ntLFlosS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF\n" + "3dvd6qJ2gHN99ZwExEWN57kci57q13XRcrHedUTnQn3iV2t93Jm8PYMo6oCTjcVM\n" + "ZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoRsaS8I8nkvof/uZS2+F0g\n" + "StRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTDKCOM/icz\n" + "Q0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQB\n" + "jLMi6Et8Vcad+qMUu2WFbm5PEn4KPJ2V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Baltimore CyberTrust Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" + "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" + "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" + "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" + "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" + "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" + "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" + "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" + "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" + "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" + "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" + "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" + "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" + "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" + "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" + "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" + "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" + "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" + "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQ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AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMmAd+BikoL1Rpzz\n" + "uvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAU18h\n" + "9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s\n" + "A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3t\n" + "OluwlN5E40EIosHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo\n" + "+fsicdl9sz1Gv7SEr5AcD48Saq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7\n" + "KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYdDnkM/crqJIByw5c/8nerQyIKx+u2\n" + "DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us\n" + "H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ\n" + "I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7\n" + "5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" + "3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" + "Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 3 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3M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wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAACAj\n" + "QTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV\n" + "cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXS\n" + "IGrs/CIBKM+GuIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2\n" + "HJLw5QY33KbmkJs4j1xrG0aGQ0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsa\n" + "O5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8ZORK15FTAaggiG6cX0S5y2CBNOxv\n" + "033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2KSb12tjE8nVhz36u\n" + "dmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz6MkE\n" + "kbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41\n" + "3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD\n" + "u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq\n" + "4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CA Disig Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV\n" + "BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu\n" + "MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy\n" + "MDcxOTA5MTUzMFow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075KMOYKmFM\n" + "tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqf\n" + "GopTpti72TVVsRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkb\n" + "lvdhuDvEK7Z4bLQjb/D907JedR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka\n" + "+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W81k/BfDxujRNt+3vrMNDcTa/F1bal\n" + "TFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjxmHHEt38OFdAlab0i\n" + "nSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01utI3\n" + "gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18Dr\n" + "G5gPcFw0sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3Os\n" + "zMOl6W8KjptlwlCFtaOgUxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8x\n" + "L4ysEr3vQCj8KWefshNPZiTEUxnpHikV7+ZtsH8tZ/3zbBt1RqPlShfppNcL\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CFCA EV ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD\n" + "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx\n" + "MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j\n" + "aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYD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jmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdL\n" + "jOztUmCypAbqTuv0axn96/Ua4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBS\n" + "ESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sGE5uPhnEFtC+NiWYzKXZUmhH4J/qy\n" + "P5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfXBDrDMlI1Dlb4pd19\n" + "xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjnaH9d\n" + "Ci77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN\n" + "5mydLIhyPDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe\n" + "/v5WOaHIz16eGWRGENoXkbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+Z\n" + "AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ\n" + "5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB\n" + "gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV\n" + "BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw\n" + "MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMB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JVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd\n" + "BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB\n" + "ZQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" + "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" + "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" + "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" + "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" + "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" + "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" + "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB\n" + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" + "EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" + "Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh\n" + "dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR\n" + "6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X\n" + "pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC\n" + "9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV\n" + "/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf\n" + "Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gU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3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb\n" + "QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl\n" + "0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB\n" + "NVOFBkpdn627G190\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNV\n" + "BAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4X\n" + "DTA3MDYyOTE1MTMwNVoXDTI3MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQ\n" + "BgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwIQ2VydGlnbmEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7qXOEm7RFHYeGifBZ4\n" + "QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyHGxny\n" + "gQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbw\n" + "zBfsV1/pogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q\n" + "130yGLMLLGq/jj8UEYkgDncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2\n" + "JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKfIrjxwo1p3Po6WAbfAgMBAAGjgbwwgbkw\n" + "DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQtCRZvgHyUtVF9lo53BEw\n" + "ZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJBgNVBAYT\n" + "AkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzj\n" + "AQ/JSP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG\n" + "9w0BAQUFAAOCAQEAhQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8h\n" + "bV6lUmPOEvjvKtpv6zf+EwLHyzs+ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFnc\n" + "fca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1kluPBS1xp81HlDQwY9qcEQCYsuu\n" + "HWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY1gkIl2PlwS6w\n" + "t0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw\n" + "WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw\n" + "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + "MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x\n" + "MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD\n" + "VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX\n" + "BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" + "ggIKAoICAQDN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NybDAxoC+gLYYr\n" + "aHR0cDovL2NybC5kaGlteW90aXMuY29tL2NlcnRpZ25hcm9vdGNhLmNybDANBgkq\n" + "hkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOItOoldaDgvUSILSo3L\n" + "6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxPTGRG\n" + "HVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH6\n" + "0BGM+RFq7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncB\n" + "lA2c5uk5jR+mUYyZDDl34bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdi\n" + "o2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1\n" + "gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS6Cvu5zHbugRqh5jnxV/v\n" + "faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63\n" + "Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh\n" + "jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw\n" + "3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM\n" + "MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D\n" + "ZXJ0dW0gQ2VydGlmaWNhdGlv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ajZt3hrvJBW8qY\n" + "VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI\n" + "03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCB\n" + "gDELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMu\n" + "QS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIG\n" + "A1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29yayBDQSAyMCIYDzIwMTExMDA2MDgz\n" + "OTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQTDEiMCAGA1UEChMZ\n" + "VW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3\n" + "b3JrIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWA\n" + "DGSdhhuWZGc/IjoedQF97/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn\n" + "0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+oCgCXhVqqndwpyeI1B+twTUrWwbNWuKFB\n" + "OJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40bRr5HMNUuctHFY9rnY3lE\n" + "fktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2puTRZCr+E\n" + "S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puchxuO9ozC1+9eB+D4Ko\n" + "b7a6bINDd82Kkhehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnj\n" + "XALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P\n" + "5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbi\n" + "DrW5viSP\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Chambers of Commerce Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xKTAnBgNVBAMTIENoYW1iZXJz\n" + "IG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEyMjk1MFoXDTM4MDcz\n" + "MTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBj\n" + "dXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIw\n" + "EAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEp\n" + "MCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0G\n" + "CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW9\n" + "28sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKAXuFixrYp4YFs8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CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRV\n" + "HSAAMCowKAYIKwYBBQUHAgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20w\n" + "DQYJKoZIhvcNAQEFBQADggIBAJASryI1wqM58C7e6bXpeHxIvj99RZJe6dqxGfwW\n" + "PJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH3qLPaYRgM+gQDROpI9CF\n" + "5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbURWpGqOt1\n" + "glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaH\n" + "FoI6M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2\n" + "pSB7+R5KBWIBpih1YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MD\n" + "xvbxrN8y8NmBGuScvfaAFPDRLLmF9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QG\n" + "tjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcKzBIKinmwPQN/aUv0NCB9szTq\n" + "jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De\n" + "fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg\n" + "OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ\n" + "d0jQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Comodo AAA Services root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb\n" + "MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAw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0BAQUF\n" + "AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q\n" + "GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz\n" + "Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2\n" + "G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi\n" + "l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3\n" + "smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Cybertrust Global Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYG\n" + "A1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2Jh\n" + "bCBSb290MB4XDTA2MTIxNTA4MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UE\n" + "ChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBS\n" + "b290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Mi8vRRQZhP/8NN5\n" + "7CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW0ozS\n" + "J8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2y\n" + "HLtgwEZLAfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iP\n" + "t3sMpTjr3kfb1V05/Iin89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNz\n" + "FtApD0mpSPCzqrdsxacwOUBdrsTiXSZT8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAY\n" + "XSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/\n" + "MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2MDSgMqAw\n" + "hi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3Js\n" + "MB8GA1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQBW7wojoFROlZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMj\n" + "Wqd8BfP9IjsO0QbE2zZMcwSO5bAi5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUx\n" + "XOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2hO0j9n0Hq0V+09+zv+mKts2o\n" + "omcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+TX3EJIrduPuoc\n" + "A06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW\n" + "WL1WMRJOEcgh4LMRkWXbtKaIOM5V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\n" + "ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK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n" + "o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K\n" + "zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8\n" + "PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y\n" + "Johw1+qRzT65ysCQblrGXnRl11z+o+I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 EV 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw\n" + "NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV\n" + "BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAwOTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfSegpn\n" + "ljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM0\n" + "3TP1YtHhzRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6Z\n" + "qQTMFexgaDbtCHu39b+T7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lR\n" + "p75mpoo6Kr3HGrHhFPC+Oh25z1uxav60sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8\n" + "HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure3511H3a6UCAwEAAaOCASQw\n" + "ggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyvcop9Ntea\n" + "HNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFw\n" + "Oi8vZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xh\n" + "c3MlMjAzJTIwQ0ElMjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1E\n" + "RT9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0MEagRKBChkBodHRwOi8vd3d3LmQt\n" + "dHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xhc3NfM19jYV8yX2V2XzIwMDku\n" + "Y3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+PPoeUSbrh/Yp\n" + "3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05\n" + "nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNF\n" + "CSuGdXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na\n" + "xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX\n" + "KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DST Root CA X3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" + "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" + "DkRTVCBSb290IENBIFgzM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-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c\n" + "JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP\n" + "mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+\n" + "wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4\n" + "VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/\n" + "AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB\n" + "AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW\n" + "BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun\n" + "pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC\n" + "dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf\n" + "fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm\n" + "NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx\n" + "H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe\n" + "+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSA\n" + "n61UQbVH35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4Htecc\n" + "biJVMWWXvdMX0h5i89vqbFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9Hp\n" + "EgjAALAcKxHad3A2m67OeYfcgnDmCXRwVWmvo2ifv922ebPynXApVfSr/5Vh88lA\n" + "bx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OPYLfykqGxvYmJHzDNw6Yu\n" + "YjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+RnlTGNAgMB\n" + "AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQW\n" + "BBTOw0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPI\n" + "QW5pJ6d1Ee88hjZv0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I\n" + "0jJmwYrA8y8678Dj1JGG0VDjA9tzd29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4Gni\n" + "lmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAWhsI6yLETcDbYz+70CjTVW0z9\n" + "B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv\n" + "ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo\n" + "IhNzbM8m9Yop5w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg\n" + "RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq\n" + "hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf\n" + "Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q\n" + "RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD\n" + "AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY\n" + "JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv\n" + "6pZjamVFkpUBtA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" + "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" + "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" + "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" + "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" + "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" + "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" + "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" + "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" + "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\n" +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jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91\n" + "8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe\n" + "pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl\n" + "MrY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe\n" + "Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw\n" + "EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x\n" + "IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF\n" + "K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG\n" + "fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO\n" + "Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd\n" + "BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx\n" + "AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/\n" + "oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8\n" + "sycX\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert High Assurance EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n" + "ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n" + "LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug\n" + "RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm\n" + "+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW\n" + "PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM\n" + "xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB\n" + "Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3\n" + "hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg\n" + "EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA\n" + "FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec\n" + "nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z\n" + "eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF\n" + "hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2\n" + "Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe\n" + "vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep\n" + "+OkuE6N36B9K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Trusted Root G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3Qg\n" + "RzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBiMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3y\n" + "ithZwuEppz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyh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JLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iahixTXTBmyUEFxPT9N\n" + "cCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN5r5N\n" + "0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie\n" + "4u1Ki7wb/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI\n" + "r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1\n" + "/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm\n" + "gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# E-Tugra Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNV\n" + "BAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBC\n" + "aWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNV\n" + "BAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQDDB9FLVR1\n" + "Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMwNTEyMDk0OFoXDTIz\n" + "MDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+\n" + "BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhp\n" + "em1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHV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" + "Nzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAKkEh47U6YA5n+KGCR\n" + "HTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jOXKqY\n" + "GwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c\n" + "77NCR807VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3\n" + "+GbHeJAAFS6LrVE1Uweoa2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WK\n" + "vJUawSg5TB9D0pH0clmKuVb8P7Sd2nCcdlqMQ1DujjByTd//SffGqWfZbawCEeI6\n" + "FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEVKV0jq9BgoRJP3vQXzTLl\n" + "yb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gTDx4JnW2P\n" + "AJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpD\n" + "y4Q08ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8d\n" + "NL/+I5c30jn6PQ0GC7TbO6Orb1wdtn7os4I07QZcJA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EC-ACC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB\n" + "8zELMAkGA1UEBhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2Vy\n" + "dGlmaWNhY2lvIChOSUYgUS0wODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1\n" + "YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYDVQQLEyxWZWdld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\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4\n" + "opvpXY0wfwYDVR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBo\n" + "dHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidW\n" + "ZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAwDQYJKoZIhvcN\n" + "AQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJlF7W2u++AVtd0x7Y\n" + "/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNaAl6k\n" + "SBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhy\n" + "Rp/7SNVel+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOS\n" + "Agu+TGbrIP65y7WZf+a2E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xl\n" + "nJ2lYJU6Un/10asIbvPuW/mIPX64b24D5EI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EE Certification Centre Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1\n" + "MQswCQYDVQQGEwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1\n" + "czEoMCYGA1UEAwwfRUUgQ2VydGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYG\n" + "CSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIwMTAxMDMwMTAxMDMwWhgPMjAzMDEy\n" + "MTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQK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"iAYLtqZLICjU3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/v\n" + "GVCJYMzpJJUPwssd8m92kMfMdcGWxZ0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust.net Premium 2048 Secure Server CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML\n" + "RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp\n" + "bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5\n" + "IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0yOTA3\n" + "MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3\n" + "LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp\n" + "YWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG\n" + "A1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU1LqRKGsuqjIAcVFmQq\n" + "K0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOLGp18EzoOH1u3Hs/lJBQe\n" + "sYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSrhRSGlVuX\n" + "MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT\n" + "XTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/\n" + "HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH\n" + "4QIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV\n" + "HQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJKoZIhvcNAQEFBQADggEBADub\n" + "j1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPyT/4xmf3IDExo\n" + "U8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf\n" + "zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5b\n" + "u/8j72gZyxKTJ1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+\n" + "bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er\n" + "fF6adulZkMV8gzURZVE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\n" + "Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\n" + "KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\n" + "cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2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O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua\n" + "AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP\n" + "9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/\n" + "eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\n" + "0vdXcDazv/wor3ElhVsT/h5/WrQ8\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - EC1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG\n" + "A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3\n" + "d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu\n" + "dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq\n" + "RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy\n" + "MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD\n" + "VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0\n" + "L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g\n" + "Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD\n" + "ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi\n" + "A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt\n" + "ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH\n" + "Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O\n" + "BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC\n" + "R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX\n" + "hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50\n" + "cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3Qs\n" + "IEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVz\n" + "dCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwHhcNMDkwNzA3MTcy\n" + "NTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVu\n" + "dHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwt\n" + "dGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0\n" + "aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5IC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + "AoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP/vaCeb9zYQYKpSfYs1/T\n" + "RU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXzHHfV1IWN\n" + "cCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hW\n" + "wcKUs/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1\n" + "U1+cPvQXLOZprE4yTGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0\n" + "jaWvYkxN4FisZDQSA/i2jZRjJKRxAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAP\n" + "BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN\n" + "BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/\n" + "jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ\n" + "Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v\n" + "1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R\n" + "nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH\n" + "VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "M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hVoSFLUmQjAJOgc47Ol\n" + "IQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk\n" + "5F6G+TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuY\n" + "n/PIjhs4ViFqUZPTkcpG2om3PVODLAgfi49T3f+sHw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GDCA TrustAUTH R5 ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UE\n" + "BhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ\n" + "IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0\n" + "MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVowYjELMAkGA1UEBhMCQ04xMjAwBgNV\n" + "BAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8w\n" + "HQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0BAQEF\n" + "AAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJj\n" + "Dp6L3TQsAlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBj\n" + "TnnEt1u9ol2x8kECK62pOqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+u\n" + "KU49tm7srsHwJ5uu4/Ts765/94Y9cnrrpftZTqfrlYwiOXnhLQiPzLyRuEH3FMEj\n" + "qcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ9Cy5WmYqsBebnh52nUpm\n" + "MUHfP/vFBu8btn4aR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RRbxake5TFW/TRQl1brqQ\n" + "XR4EzzffHqhmsYzmIGrv/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrq\n" + "T8p+ck0LcIymSLumoRT2+1hEmRSuqguTaaApJUqlyyvdimYHFngVV3Eb7PVHhPOe\n" + "MTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaM\n" + "f/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vX\n" + "mX7wCl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7\n" + "zUjwTcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0P\n" + "fyblqAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtc\n" + "vfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4\n" + "Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gH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sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdws\n" + "E3PYJ/HQcu51OyLemGhmW/HGY0dVHLqlCFF1pkgl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTukk3Lv\n" + "CvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3Kg\n" + "GjSY6Dlo7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9Bu\n" + "XvAuMC6C/Pq8tBcKSOWIm8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOd\n" + "re7kRXuJVfeKH2JShBKzwkCX44ofR5GmdFrS+LFjKBC4swm4VndAoiaYecb+3yXu\n" + "PuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbuak7MkogwTZq9TwtImoS1\n" + "mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscszcTJGr61K\n" + "8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqj\n" + "x5RWIr9qS34BIbIjM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gkC\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout\n" + "736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2A\n" + "DDL24CejQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBTB8Sa6oC2uhYHP0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFuk\n" + "fCPAlaUs3L6JbyO5o91lAFJekazInXJ0glMLfalAvWhgxeG4VDvBNhcl2MG9AjEA\n" + "njWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOaKaqW04MjyaR7YbPMAuhd\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjQwHhcNM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iLnTjoBbdq\n" + "fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\n" + "iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\n" + "1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\n" + "bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\n" + "MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\n" + "ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\n" + "uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\n" + "Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\n" + "tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\n" + "PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n" + "hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n" + "5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY\n" + "MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo\n" + "R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aW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aYNKxoU\n" + "AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL\n" + "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj\n" + "KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2\n" + "MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV\n" + "BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw\n" + "NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV\n" + "BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH\n" + "MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL\n" + "So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal\n" + "tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG\n" + "CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT\n" + "qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz\n" + "rD6ogRLQy7rQkgu2npaqBA+K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB\n" + "mDELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsT\n" + "MChjKSAyMDA4IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s\n" + "eTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhv\n" + "cml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIzNTk1OVowgZgxCzAJ\n" + "BgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg\n" + "MjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0\n" + "BgNVBAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg\n" + "LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz\n" + "+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5jK/BGvESyiaHAKAxJcCGVn2TAppMSAmUm\n" + "hsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdEc5IiaacDiGydY8hS2pgn\n" + "5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3CIShwiP/W\n" + "JmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exAL\n" + "DmKudlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZC\n" + "huOl1UcCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw\n" + "HQYDVR0OBBYEFMR5yo6hTgMdHNxr2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IB\n" + "AQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9cr5HqQ6XErhK8WTTOd8lNNTB\n" + "zU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbEAp7aDHdlDkQN\n" + "kv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD\n" + "AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUH\n" + "SJsMC8tJP33st/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2G\n" + "spki4cErx5z481+oghLrGREt\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE\n" + "BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0\n" + "IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV\n" + "VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8\n" + "cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tl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UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN\n" + "Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja\n" + "QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW\n" + "koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9\n" + "ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt\n" + "DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm\n" + "bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYD\n" + "VQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1\n" + "c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" + "AQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0DE81\n" + "WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUG\n" + "FF+3Qs17j1hhNNwqCPkuwwGmIkQcTAeC5lvO0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9tx4TuaY\n" + "T1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz\n" + "GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m\n" + "1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV\n" + "OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH\n" + "6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX\n" + "QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ\n" + "FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F\n" + "uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX\n" + "kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs\n" + "ewv4n4Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc\n" + "8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke\n" + "hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI\n" + "KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg\n" + "515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO\n" + "xwy8p2Fp8fc74SrL+SvzZpA3\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA\n" + "-----B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BnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP\n" + "AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\n" + "DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\n" + "HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1\n" + "MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL\n" + "v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8\n" + "eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq\n" + "tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd\n" + "C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa\n" + "zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB\n" + "mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH\n" + "V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n\n" + "bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG\n" + "3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs\n" + "J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO\n" + "291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS\n" + "ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd\n" + "AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7\n" + "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\n" + "MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\n" + "RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\n" + "gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\n" + "KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\n" + "QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\n" + "XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\n" + "LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\n" + "RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\n" + "jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n" + "6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\n" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\n" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\n" + "WD9f\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R6\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg\n" + "MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh\n" + "bFNp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MEGDAWgBSu\n" + "bAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN\n" + "nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGt\n" + "Ixg93eFyRJa0lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr61\n" + "55wsTLxDKZmOMNOsIeDjHfrYBzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLj\n" + "vUYAGm0CuiVdjaExUd1URhxN25mW7xocBFymFe944Hn+Xds+qkxV/ZoVqW/hpvvf\n" + "cDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr3TsTjxKM4kEaSHpz\n" + "oHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB10jZp\n" + "nOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs\n" + "pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v\n" + "JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R\n" + "8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4\n" + "5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Global Chambersign Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEB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yZi99Bffnt0uYlDXA2TopwZ2yUDMd\n" + "SqlapskD7+3056huirRXhOukP9DuqqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9O\n" + "AP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETrP3iZ8ntxPjzxmKfFGBI/5rso\n" + "M0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVqc5iJWzouE4ge\n" + "v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z\n" + "09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh\n" + "MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE\n" + "YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3\n" + "MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo\n" + "ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg\n" + "MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN\n" + "ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA\n" + "PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w\n" + "wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi\n" + "EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY\n" + "avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+\n" + "YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE\n" + "sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h\n" + "/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5\n" + "IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD\n" + "ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy\n" + "OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P\n" + "TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ\n" + "HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER\n" + "dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf\n" + "ReYNnyicsbkqWletNw+vHX/bvZ8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" + "EUdvRGFkZH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YVN8Gb5DKj7Tjo\n" + "2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n" + "LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n" + "4uJEvlz36hz1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions ECC RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN\n" + "BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl\n" + "bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv\n" + "b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ\n" + "BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj\n" + "YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5\n" + "MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0\n" + "dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg\n" + "QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa\n" + "jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC\n" + "MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi\n" + "C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep\n" + "lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof\n" + "TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1Ix\n" + "RDBCBgNVBAoTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1p\n" + "YyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIFJvb3RDQSAyMDExMB4XDTExMTIw\n" + "NjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYTAkdSMUQwQgYDVQQK\n" + "EztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIENl\n" + "cnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBAKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPz\n" + "dYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJ\n" + "fel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa71HFK9+WXesyHgLacEns\n" + "bgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u8yBRQlqD\n" + "75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSP\n" + "FEDH3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNV\n" + "HRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp\n" + "5dgTBCPuQSUwRwYDVR0eBEAwPqA8MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQu\n" + "b3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQub3JnMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVtXdMiKahsog2p\n" + "6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8\n" + "TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7\n" + "dIsXRSZMFpGD/md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8Acys\n" + "Nnq/onN694/BtZqhFLKPM58N7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXI\n" + "l7WdmplNsDz4SgCbZN2fOUvRJ9e4\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix\n" + "DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k\n" + "IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAM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SQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc\n" + "Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNV\n" + "HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVd\n" + "ctA4GGqd83EkVAswDQYJKoZIhvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0I\n" + "XtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+D1hYc2Ryx+hFjtyp8iY/xnmMsVMI\n" + "M4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrMd/K4kPFox/la/vot\n" + "9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+yd+2V\n" + "Z5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/ea\n" + "j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh\n" + "X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ\n" + "l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf\n" + "bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4\n" + "pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK\n" + "e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0\n" + "vm9qp/UsQu0yrbYhnr68\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDMDCCAhigA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RM9IauUiqpO\n" + "fMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilTc4afU9hDDl3WY4JxHYB0yvbi\n" + "AmvZWg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL\n" + "BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ\n" + "SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n\n" + "a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5\n" + "NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtvbmcxEjAQBgNVBAcT\n" + "CUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMXSG9u\n" + "Z2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "AoICAQCziNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFO\n" + "dem1p+/l6TWZ5Mwc50tfjTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mI\n" + "VoBc+L0sPOFMV4i707mV78vH9toxdCim5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV\n" + "9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOesL4jpNrcyCse2m5FHomY\n" + "2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj0mRiikKY\n" + "vLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+Tt\n" + "bNe/JgER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cq9CClnXO0lD+mefP\n" + "L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa\n" + "LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG\n" + "mpv0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ISRG Root X1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" + "WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n" + "ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n" + "MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n" + "h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+\n" + "0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U\n" + "A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW\n" + "T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH\n" + "B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC\n" + "B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv\n" + "KB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c/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" + "emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Commercial Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu\n" + "VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw\n" + "MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw\n" + "JQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ldhNlT\n" + "3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU\n" + "+ehcCuz/mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gp\n" + "S0l4PJNgiCL8mdo2yMKi1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1\n" + "bVoE/c40yiTcdCMbXTMTEl3EASX2MN0CXZ/g1Ue9tOsbobtJSdifWwLziuQkkORi\n" + "T0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl3ZBWzvurpWCdxJ35UrCL\n" + "vYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzyNeVJSQjK\n" + "Vsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZK\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x+QGtVKnO7RcGzM7vRX+Bi6hG6H\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Public Sector Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu\n" + "VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN\n" + "MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0\n" + "MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTyP4o7\n" + "ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGy\n" + "RBb06tD6Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlS\n" + "bdsHyo+1W/CD80/HLaXIrcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF\n" + "/YTLNiCBWS2ab21ISGHKTN9T0a9SvESfqy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R\n" + "3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoSmJxZZoY+rfGwyj4GD3vw\n" + "EUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFnol57plzy\n" + "9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9V\n" + "GxyhLrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ\n" + "2fjXctscvG29ZV/viDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsV\n" + "WaFHVCkugyhfHMKiq3IXAAaOReyL4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gD\n" + "W/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMwDQYJKoZIhvcN\n" + "AQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj\n" + "t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHV\n" + "DRDtfULAj+7AmgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9\n" + "TaDKQGXSc3z1i9kKlT/YPyNtGtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8G\n" + "lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW\n" + "mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df\n" + "WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5\n" + "+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ\n" + "tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA\n" + "GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv\n" + "8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Izenpe.com\n" + "-----BEGIN C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WrOZyGls\n" + "QyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# LuxTrust Global Root 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL\n" + "BQAwRjELMAkGA1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNV\n" + "BAMMFkx1eFRydXN0IEdsb2JhbCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUw\n" + "MzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEWMBQGA1UECgwNTHV4VHJ1c3QgUy5B\n" + "LjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBANeFl78RmOnwYoNMPIf5U2o3C/IPPIfOb9wmKb3F\n" + "ibrJgz337spbxm1Jc7TJRqMbNBM/wYlFV/TZsfs2ZUv7COJIcRHIbjuend+JZTem\n" + "hfY7RBi2xjcwYkSSl2l9QjAk5A0MiWtj3sXh306pFGxT4GHO9hcvHTy95iJMHZP1\n" + "EMShduxq3sVs35a0VkBCwGKSMKEtFZSg0iAGCW5qbeXrt77U8PEVfIvmTroTzEsn\n" + "Xpk8F12PgX8zPU/TPxvsXD/wPEx1bvKm1Z3aLQdjAsZy6ZS8TEmVT4hSyNvoaYL4\n" + "zDRbIvCGp4m9SAptZoFtyMhk+wHh9OHe2Z7d21vUKpkmFRseTJIpgp7VkoGSQXAZ\n" + "96Tlk0u8d2cx3Rz9MXANF5kM+Qw5GSoXtTBxVdUPrljhPS80m8+f9niFwpN6cj5m\n" + "j5wWEWCPnolvZ77gR1o7DJpni89Gxq44o/KnvObWhWszJHAiS8sIm7vI+AIpHb4g\n" + "DEa/a4ebsypmQjVGbKq6rfmY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MEWrGrKqv+\n" + "x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6\n" + "oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Microsec e-Szigno Root CA 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\n" + "VQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0\n" + "ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0G\n" + "CSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTAeFw0wOTA2MTYxMTMwMThaFw0y\n" + "OTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3Qx\n" + "FjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3pp\n" + "Z25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o\n" + "dTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvP\n" + "kd6mJviZpWNwrZuuyjNAfW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tc\n" + "cbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG0IMZfcChEhyVbUr02MelTTMuhTlAdX4U\n" + "fIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKApxn1ntxVUwOXewdI/5n7\n" + "N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm1HxdrtbC\n" + "xkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1\n" + "+rUCAwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G\n" + "A1UdDgQWBBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPM\n" + "Pcu1SCOhGnqmKrs0aDAbBgNVHREEFDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqG\n" + "SIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0olZMEyL/azXm4Q5DwpL7v8u8h\n" + "mLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfXI/OMn74dseGk\n" + "ddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775\n" + "tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c\n" + "2Pm2G2JwCz02yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5t\n" + "HMN1Rq41Bab2XD0h7lbwyYIiLXpUq3DDfSJlgnCW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# NetLock Arany (Class Gold) Főtanúsítvány\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG\n" + "EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3\n" + "MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl\n" + "cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR\n" + "dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhc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/GeufOJ8z2F\n" + "uLjbvrW5KfnaNwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2\n" + "XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Network Solutions Certificate Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi\n" + "MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu\n" + "MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp\n" + "dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJV\n" + "UzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydO\n" + "ZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqG\n" + "SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwz\n" + "c7MEL7xxjOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPP\n" + "OCwGJgl6cvf6UDL4wpPTaaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rl\n" + "mGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXTcrA/vGp97Eh/jcOrqnErU2lBUzS1sLnF\n" + "BgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc/Qzpf14Dl847ABSHJ3A4\n" + "qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMBAAGjgZcw\n" + "gZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIB\n" + "BjAPBgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwu\n" + "bmV0c29sc3NsLmNvbS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3Jp\n" + "dHkuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc8\n" + "6fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q4LqILPxFzBiwmZVRDuwduIj/\n" + "h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/GGUsyfJj4akH\n" + "/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv\n" + "wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN\n" + "pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GA CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCB\n" + "ijELMAkGA1UEBhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHly\n" + "aWdodCAoYykgMjAwNTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl\n" + "ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQSBDQTAeFw0w\n" + "NTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYDVQQGEwJDSDEQMA4G\n" + "A1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ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0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GB CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBt\n" + "MQswCQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUg\n" + "Rm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9i\n" + "YWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAwMzJaFw0zOTEyMDExNTEwMzFaMG0x\n" + "CzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBG\n" + "b3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh\n" + "bCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3\n" + "HEokKtaXscriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGx\n" + "WuR51jIjK+FTzJlFXHtPrby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX\n" + "1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNk\n" + "u7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4oQnc/nSMbsrY9gBQHTC5P\n" + "99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvgGUpuuy9r\n" + "M2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw\n" + "AwEB/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUB\n" + "BAMCAQAwDQYJKoZIhvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrgh\n" + "cViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5\n" + "gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3ZwLWoo4rO\n" + "ZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" + "aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic\n" + "Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GC CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw\n" + "CQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91\n" + "bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwg\n" + "Um9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRaFw00MjA1MDkwOTU4MzNaMG0xCzAJ\n" + "BgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBGb3Vu\n" + "ZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2JhbCBS\n" + "b290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4ni\n" + "eUqjFqdrVCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4W\n" + "p2OQ0jnUsYd4XxiWD1AbNTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8E\n" + "BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7T\n" + "rYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0EAwMDaAAwZQIwJsdpW9zV\n" + "57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtkAjEA2zQg\n" + "Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC\n" + "TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0\n" + "aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0\n" + "aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz\n" + "MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw\n" + "IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR\n" + "dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp\n" + "li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D\n" + "rOpm2RgbaIr1VxqYuvXtdj182d6UajtLF8HVj71lODqV0D1VNk7feVcxKh7YWWVJ\n" + "WCCYfqtffp/p1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EAitQUtf70mpKnGdSk\n" + "fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8\n" + "7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R\n" + "cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y\n" + "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n" + "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n" + "SnQ2+Q==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 1 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00\n" + "MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakEPBtV\n" + "wedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWe\n" + "rNrwU8lmPNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF341\n" + "68Xfuw6cwI2H44g4hWf6Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKO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kooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fawx/k\n" + "NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj\n" + "ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp\n" + "q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt\n" + "nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCa\n" + "GMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6XJxg\n" + "Fyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55J\n" + "WpzmM+Yklvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bB\n" + "rrcCaoF6qUWD4gXmuVbBlDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp\n" + "+ARz8un+XJiM9XOva7R+zdRcAitMOeGylZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1\n" + "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7CUW+v90m/xd2gNNWQjrLhVoQPR\n" + "TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD\n" + "mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z\n" + "ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y\n" + "4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza\n" + "8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00\n" + "MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFhZiFf\n" + "qq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMW\n" + "n4rjyduYNM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ym\n" + "c5GQYaYDFCDy54ejiK2toIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+\n" + "O7q414AB+6XrW7PFXmAqMa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rQ+NwmNtd\n" + "dbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg\n" + "KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM\n" + "HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4\n" + "WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM\n" + "V0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNggDhoB\n" + "4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUr\n" + "H556VOijKTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd\n" + "8lyyBTNvijbO0BNO/79KDDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9Cabwv\n" + "vWhDFlaJKjdhkf2mrk7AyxRllDdLkgbvBNDInIjbC3uBr7E9KsRlOni27tyAsdLT\n" + "mZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n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tSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5Wvv\n" + "oxXqA/4Ti2Tk08HS6IT7SdEQTXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFg\n" + "u/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9DuDcpmvJRPpq3t/O5jrFc/ZSXPsoaP\n" + "0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGibIh6BJpsQBJFxwAYf\n" + "3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmDhPbl\n" + "8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+\n" + "DhcI00iX0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HN\n" + "PlopNLk9hM6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/\n" + "ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx\n" + "NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv\n" + "bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49\n" + "AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA\n" + "VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku\n" + "WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP\n" + "MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX\n" + "5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ\n" + "ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg\n" + "h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority RSA R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNV\n" + "BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UE\n" + "CgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMB4XDTE3MDUzMTE4MTQzN1oXDTQy\n" + "MDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4G\n" + "A1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQD\n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RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5\n" + "Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nxY/hoLVUE0fKNsKTPvDxeH3jnpaAg\n" + "cLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2GguDKBAdRUNf/ktUM\n" + "79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDzOFSz\n" + "/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXt\n" + "ll9ldDz7CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEm\n" + "Kf7GUmG6sXP/wwyc5WxqlD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKK\n" + "QbNmC1r7fSOl8hqw/96bg5Qu0T/fkreRrwU7ZcegbLHNYhLDkBvjJc40vG93drEQ\n" + "w/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi\n" + "S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07\n" + "mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0\n" + "aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz\n" + "WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0\n" + "b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS\n" + "b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB\n" + "BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI\n" + "7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg\n" + "CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD\n" + "VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T\n" + "kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+\n" + "gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority RSA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz\n" + "OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxED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"A1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGV\n" + "cpNxJK1ok1iOMq8bs3AD/CUrdIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBc\n" + "Hadm47GUBwwyOabqG7B52B2ccETjit3E+ZUfijhDPwGFpUenPUayvOUiaPd7nNgs\n" + "PgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAslu1OJD7OAUN5F7kR/\n" + "q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjqerQ0\n" + "cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jr\n" + "a6x+3uxjMxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90I\n" + "H37hVZkLId6Tngr75qNJvTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/Y\n" + "K9f1JmzJBjSWFupwWRoyeXkLtoh/D1JIPb9s2KJELtFOt3JY04kTlf5Eq/jXixtu\n" + "nLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406ywKBjYZC6VWg3dGq2ktuf\n" + "oYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NIWuuA8ShY\n" + "Ic2wBlX7Jz9TkHCpBB5XJ7k=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SZAFIR ROOT CA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQEL\n" + "BQAwUTELMAkGA1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6\n" + "ZW5pb3dhIFMuQS4xGDAWBgNVBAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkw\n" + "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==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureSign RootCA11\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDEr\n" + "MCkGA1UEChMiSmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoG\n" + "A1UEAxMTU2VjdXJlU2lnbiBSb290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0\n" + "MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSswKQYDVQQKEyJKYXBhbiBDZXJ0aWZp\n" + "Y2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1cmVTaWduIFJvb3RD\n" + "QTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvLTJsz\n" + "i1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8\n" + "h9uuywGOwvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOV\n" + "MdrAG/LuYpmGYz+/3ZMqg6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9\n" + "UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rPO7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni\n" + "8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitAbpSACW22s293bzUIUPsC\n" + "h8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZXt94wDgYD\n" + "VR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB\n" + "AKChOBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xm\n" + "KbabfSVSSUOrTC4rbnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQ\n" + "X5Ucv+2rIrVls4W6ng+4reV6G4pQOh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWr\n" + "QbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01y8hSyn+B/tlr0/cR7SXf+Of5\n" + "pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061lgeLKBObjBmN\n" + "QSdJQO7e5iNEOdyhIta6A/I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureTrust CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI\n" + "MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x\n" + "FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz\n" + "MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv\n" + "cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN\n" + "AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz\n" + "Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO\n" + "0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao\n" + "wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj\n" + "7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS\n" + "8kvNU3xHCzaFDmapCJcWNFfBZveA4+1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TIFICATE-----\n" + "\n"; + cert += + "# Security Communication RootCA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl\n" + "MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe\n" + "U2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoX\n" + "DTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRy\n" + "dXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3VyaXR5IENvbW11bmlj\n" + "YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV\n" + "OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr\n" + "zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM\n" + "VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ\n" + "hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO\n" + "ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw\n" + "awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs\n" + "OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF\n" + "coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc\n" + "okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8\n" + "t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy\n" + "1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/\n" + "SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY\n" + "MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t\n" + "dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5\n" + "WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD\n" + "VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8\n" + "9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ\n" + "DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9\n" + "Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N\n" + "QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ\n" + "xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G\n" + "A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T\n" + "AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG\n" + "kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr\n" + "Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5\n" + "Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU\n" + "JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot\n" + "RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Sonera Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP\n" + "MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx\n" + "MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV\n" + "BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o\n" + "Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt\n" + "5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s\n" + "3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej\n" + "vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu\n" + "8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw\n" + "DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG\n" + "MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil\n" + "zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/\n" + "3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD\n" + "FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6\n" + "Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2\n" + "ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gRVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0y\n" + "MjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIg\n" + "TmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZW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fOWBfoqSmuc0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHS\n" + "v4ilf0X8rLiltTMMgsT7B/Zq5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTC\n" + "wPTxGfARKbalGAKb12NMcIxHowNDXLldRqANb/9Zjr7dn3LDWyvfjFvO5QxGbJKy\n" + "CqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tNf1zuacpzEPuKqf2e\n" + "vTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi5Dp6\n" + "Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIa\n" + "Gl6I6lD4WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeL\n" + "eG9QgkRQP2YGiqtDhFZKDyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8\n" + "FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGyeUN51q1veieQA6TqJIc/2b3Z6fJfUEkc\n" + "7uzXLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloX\n" + "DTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMCTkwxHjAcBgNVBAoMFVN0YWF0IGRl\n" + "ciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5lZGVybGFuZGVuIFJv\n" + "b3QgQ0EgLSBHMzCCAiI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n" + "Ipf3YF3qKS9Ysr1YvY2WTxB1v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixp\n" + "gZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA8KCWAg8zxXHzniN9lLf9OtMJgwYh\n" + "/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b8KKaa8MFSu1BYBQw\n" + "0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0rmj1A\n" + "fsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq\n" + "4BZ+Extq1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR\n" + "1VmiiXTTn74eS9fGbbeIJG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/\n" + "QFH1T/U67cjF68IeHRaVesd+QnGTbksVtzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM\n" + "94B7IWcnMFk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Services Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs\n" + "ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5\n" + "MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD\n" + "VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy\n" + "ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy\n" + "dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p\n" + "OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2\n" + "8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K\n" + "Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe\n" + "hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk\n" + "6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw\n" + "DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q\n" + "AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI\n" + "bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB\n" + "ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z\n" + "qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n" + "iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n" + "0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n" + "sSi6\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Gold CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n" + "BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24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" + "lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64OfPAeGZe6Drn\n" + "8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov\n" + "L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe6\n" + "45R88a7A3hfm5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczO\n" + "UYrHUDFu4Up+GC9pWbY9ZIEr44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5\n" + "O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOfMke6UiI0HTJ6CVanfCU2qT1L2sCC\n" + "bwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6mGu6uLftIdxf+u+yv\n" + "GPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxpmo/a\n" + "77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC\n" + "hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3\n" + "92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp\n" + "Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w\n" + "ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt\n" + "Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Silver CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMA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AMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU\n" + "F6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRBtjpbO8tFnb0c\n" + "wpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0\n" + "cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIB\n" + "AHPGgeAn0i0P4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShp\n" + "WJHckRE1qTodvBqlYJ7YH39FkWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9\n" + "xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L3XWgwF15kIwb4FDm3jH+mHtwX6WQ\n" + "2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx/uNncqCxv1yL5PqZ\n" + "IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8\n" + "aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X\n" + "em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR\n" + "dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/\n" + "OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+\n" + "hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy\n" + "tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 2\n" + "-----BEGIN CERTIFICAT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827n+qrkRk4r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPAC\n" + "uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw\n" + "IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6\n" + "g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN\n" + "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" + "BSeOE6Fuwg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgxMDAxMTAyOTU2WhcNMzMxMDAxMjM1\n" + "OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy\n" + "aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50\n" + "ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0G\n" + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN\n" + "8ELg63iIVl6bmlQdTQyK9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/\n" + "RLyTPWGrTs0NvvAgJ1gORH8EGoel15YUNpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4\n" + "hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZFiP0Zf3WHHx+xGwpzJFu5\n" + "ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W0eDrXltM\n" + "EnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGj\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1\n" + "A/d2O2GCahKqGFPrAyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOy\n" + "WL6ukK2YJ5f+AbGwUgC4TeQbIXQbfsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ\n" + "1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzTucpH9sry9uetuUg/vBa3wW30\n" + "6gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT\n" + "91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml\n" + "e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p\n" + "TpPDpFQUWw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx\n" + "GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp\n" + "bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w\n" + "KwYDVQQLEyRLYW11IFNlcnRpZ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zcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5j\n" + "wa19hAM8EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWz\n" + "aGHQRiapIVJpLesux+t3zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmy\n" + "KwbQBM0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES\n" + "MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU\n" + "V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz\n" + "WhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJVEFJV0FO\n" + "LUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + "AQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFE\n" + "AcK0HMMxQhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HH\n" + "K3XLfJ+utdGdIzdjp9xCoi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeX\n" + "RfwZVzsrb+RH9JlF/h3x+JejiB03HFyP4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/z\n" + "rX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1ry+UPizgN7gr8/g+YnzAx\n" + "3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkq\n" + "hkiG9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeC\n" + "MErJk/9q56YAf4lCmtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdls\n" + "XebQ79NqZp4VKIV66IIArB6nCWlWQtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62D\n" + "lhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVYT0bf+215WfKEIlKuD8z7fDvn\n" + "aspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocnyYh0igzyXxfkZ\n" + "YiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Taiwan GRCA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/\n" + "MQswCQYDVQQGEwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5MB4XDTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1ow\n" + "PzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dvdmVybm1lbnQgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\n" + "AJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qNw8XR\n" + "IePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1q\n" + "gQdW8or5BtD3cCJNtLdBuTK4sfCxw5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\n" + "hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6QzDxARvBMB1uUO07+1\n" + "EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+HbkZ6Mm\n" + "nD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WX\n" + "udpVBrkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz\n" + "ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe\n" + "LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl\n" + "pYYsfPQS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TeliaSonera Root CA v1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAw\n" + "NzEUMBIGA1UECgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJv\n" + "b3QgQ0EgdjEwHhcNMDcxMDE4MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYD\n" + "VQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwWVGVsaWFTb25lcmEgUm9vdCBDQSB2\n" + "MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+6yfwIaPzaSZVfp3F\n" + "VRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA3GV1\n" + "7CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+X\n" + "Z75Ljo1kB1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+\n" + "/j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mEDTPwOA\n" + "BoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23xFUfJ3zSCNV2HykVh0A5\n" + "3ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmcp0yJF4Ou\n" + "owReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/\n" + "wZ0+fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZF\n" + "ZtS6mFjBAgMBAAGjYzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAf\n" + "BgNVHSMEGDAWgBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/\n" + "MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAQEABT41XBVwm8nHc2Fv\n" + "civUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u/ukZMjgDfxT2\n" + "AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F\n" + "hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50\n" + "soIipX1TH0XsJ5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BI\n" + "WJZpTdwHjFGTot+fDz2LYLSCjaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1Wi\n" + "tJ/X5g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MC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tPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv2wnL\n" + "/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RX\n" + "CI/hOWB3S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYa\n" + "ZH9bDTMJBzN7Bj8RpFxwPIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW\n" + "2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dvDDqPys/cA8GiCcjl/YBeyGBCARsaU1q7\n" + "N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYURpFHmygk71dSTlxCnKr3\n" + "Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANExdqtvArB\n" + "As8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp\n" + "5KeXRKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu\n" + "1uwJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Trustis FPS Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBF\n" + "MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQL\n" + "ExNUcnVzdGlzIEZQUyBSb290IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTEx\n" + "MzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNVBAoTD1RydXN0aXMgTGltaXRlZDEc\n" + "MBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQAD\n" + "ggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQRUN+\n" + "AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihH\n" + "iTHcDnlkH5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjj\n" + "vSkCqPoc4Vu5g6hBSLwacY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA\n" + "0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zto3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlB\n" + "OrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEAAaNTMFEwDwYDVR0TAQH/\n" + "BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAdBgNVHQ4E\n" + "FgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01\n" + "GX2cGE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmW\n" + "zaD+vkAMXBJV+JOCyinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP4\n" + "1BIy+Q7DsdwyhEQsb8tGD+pmQQ9P8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZE\n" + "f1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHVl/9D7S3B2l0pKoU/rGXuhg8F\n" + "jZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYliB6XzCGcKQEN\n" + "ZetX2fNXlrtIzYE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Extended Validation Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3Q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AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBADaN\n" + "l8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR\n" + "ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQ\n" + "VBcZEhrxH9cMaVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5\n" + "c6sq1WnIeJEmMX3ixzDx/BR4dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp\n" + "4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb+7lsq+KePRXBOy5nAliRn+/4Qh8s\n" + "t2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOWF3sGPjLtx7dCvHaj\n" + "2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwiGpWO\n" + "vpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2C\n" + "xR9GUeOcGMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx\n" + "cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM\n" + "fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Global G2 Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH\n" + "bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDA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ochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5\n" + "1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl\n" + "1qnN3e92mI0ADs0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oU\n" + "b3n09tDh05S60FdRvScFDcH9yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LV\n" + "PtateJLbXDzz2K36uGt/xDYotgIVilQsnLAXc47QN6MUPJiVAAwpBVueSUmxX8fj\n" + "y88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHojhJi6IjMtX9Gl8Cb\n" + "EGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZkbxqg\n" + "DMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI\n" + "+Vg7RE+xygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGy\n" + "YiGqhkCyLmTTX8jjfhFnRR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bX\n" + "UB+K+wb1whnw0A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + "VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo\n" + "I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng\n" + "o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G\n" + "A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB\n" + "zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW\n" + "RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB\n" + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw\n" + "MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgN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QYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPF\n" + "Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO\n" + "VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3\n" + "ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs\n" + "8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR\n" + "iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze\n" + "Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ\n" + "XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/\n" + "qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB\n" + "VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB\n" + "L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n" + "jjxDah2nGN59PRbxYvnKkKj9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln\n" + "biw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ynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\n" + "ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1\n" + "nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex\n" + "t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz\n" + "SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG\n" + "BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+\n" + "rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/\n" + "NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E\n" + "BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH\n" + "BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy\n" + "aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv\n" + "MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE\n" + "p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y\n" + "5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Universal Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB\n" + "vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZ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wBwYFKw4DAhoEFI/l0xqGrI2Oa8PPgGrUSBgs\n" + "exkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud\n" + "DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4\n" + "sAPmLGd75JR3Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+\n" + "seQxIcaBlVZaDrHC1LGmWazxY8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz\n" + "4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTxP/jgdFcrGJ2BtMQo2pSXpXDrrB2+\n" + "BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+PwGZsY6rp2aQW9IHR\n" + "lRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3\n" + "7M2CYfE45k+XmCpajQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Verisign Class 3 Public Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw\n" + "CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl\n" + "cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu\n" + "LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT\n" + "aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp\n" + "dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD\n" +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qrl0Hj0rDKH/v+yv6efHHrfAQ\n" + "UySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5d\n" + "RdY4zTW2ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQ\n" + "OA7+j0xbm0bqQfWwCHTD0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwv\n" + "JoIQ4uNllAoEwF73XVv4EOLQunpL+943AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08C\n" + "AwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAcYwHQYDVR0O\n" + "BBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IBAQA+0hyJ\n" + "LjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecY\n" + "MnQ8SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ\n" + "44gx+FkagQnIl6Z0x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6I\n" + "Jd1hJyMctTEHBDa0GpC9oHRxUIltvBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNw\n" + "i/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7NzTogVZ96edhBiIL5VaZVDADlN\n" + "9u6wWk5JRFRYX0KD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ePKI Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe\n" + "MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0\n" + "ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aW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\n" + "MAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH\n" + "ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGB\n" + "uvl2ICO1J2B01GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6Yl\n" + "PwZpVnPDimZI+ymBV3QGypzqKOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkP\n" + "JXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdVxrsStZf0X4OFunHB2WyBEXYKCrC/\n" + "gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEPNXubrjlpC2JgQCA2\n" + "j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+rGNm6\n" + "5ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUB\n" + "o2M3IUxExJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS\n" + "/jQ6fbjpKdx2qcgw+BRxgMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z\n" + "Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE\n" + "W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D\n" + "hNQ+IIX3Sj0rnP0qCglN6oH4EZw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - C3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG\n" + "EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx\n" + "IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND\n" + "IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci\n" + "MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti\n" + "sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O\n" + "BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\n" + "Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c\n" + "3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J\n" + "0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n" + "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n" + "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n" + "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n" + "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n" + "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n" + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n" + "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n" + "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n" + "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n" + "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n" + "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n" + "+JbNR6iC8hZVdyR+EhCVBCyj\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - C1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkG\n" + "A1UEBhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEg\n" + "SW5jMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNpZ24gUm9v\n" + "dCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+upufGZ\n" + "BczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZ\n" + "HdPIWoU/Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH\n" + "3DspVpNqs8FqOp099cGXOFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvH\n" + "GPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4VI5b2P/AgNBbeCsbEBEV5f6f9vtKppa+c\n" + "xSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleoomslMuoaJuvimUnzYnu3Yy1\n" + "aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+XJGFehiq\n" + "TbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87\n" + "/kOXSTKZEhVb3xEp/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4\n" + "kqNPEjE2NuLe/gDEo2APJ62gsIq1NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrG\n" + "YQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT\n" + "+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo\n" + "WXzhriKi4gp6D/piq1JM4fHfyr6DDUI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - G1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD\n" + "VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU\n" + "ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0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tUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J\n" + "NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA\n" + "MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP\n" + "r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU\n" + "DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz\n" + "YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX\n" + "xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2\n" + "/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/\n" + "LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7\n" + "jVaMaA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp\n" + "IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi\n" + "BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw\n" + "MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh\n" + "d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig\n" + "YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v\n" + "dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/\n" + "BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6\n" + "papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K\n" + "DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3\n" + "KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox\n" + "XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCB\n" + "rjELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNV\n" + "BAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0wODA0MDIwMDAwMDBa\n" + "Fw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhhd3Rl\n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BXcmer/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZu\n" + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + + static_cast( + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); + if (ec) { + return; + } +} + +} // namespace detail + +// Load the root certificates into an ssl::context + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); +} + +inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); + if (ec) { + webcpp_fixture::fail_stop(); + } +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/common/server_certificate.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/common/server_certificate.hpp new file mode 100644 index 0000000..ff0fe0a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/common/server_certificate.hpp @@ -0,0 +1,140 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP + +#include +#include +#include +#include + +/* Load a signed certificate into the ssl context, and configure + the context for use with a server. + + For this to work with the browser or operating system, it is + necessary to import the "Beast Test CA" certificate into + the local certificate store, browser, or operating system + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. +*/ +inline void load_server_certificate(boost::asio::ssl::context& ctx) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { + ctx.use_certificate_chain_file(path); + ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), + boost::asio::ssl::context::pem); + return; + } + + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 + openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj + "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = + "-----BEGIN CERTIFICATE-----\n" + "MIIDlTCCAn2gAwIBAgIUOLxr3q7Wd/pto1+2MsW4fdRheCIwDQYJKoZIhvcNAQEL\n" + "BQAwWjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRQwEgYDVQQHDAtMb3MgQW5n\n" + "ZWxlczEOMAwGA1UECgwFQmVhc3QxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTAe\n" + "Fw0yMTA3MDYwMTQ5MjVaFw00ODExMjEwMTQ5MjVaMFoxCzAJBgNVBAYTAlVTMQsw\n" + "CQYDVQQIDAJDQTEUMBIGA1UEBwwLTG9zIEFuZ2VsZXMxDjAMBgNVBAoMBUJlYXN0\n" + "MRgwFgYDVQQDDA93d3cuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" + "DwAwggEKAoIBAQCz0GwgnxSBhygxBdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOT\n" + "Lppr5MKxqQHEpYdyDYGD1noBoz4TiIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05\n" + "P41c2F9pBEnUwUxIUG1Cb6AN0cZWF/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATm\n" + "Wm9SJc2lsjWptbyIN6hFXLYPXTwnYzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7\n" + "rV+AiGTxUU35V0AzpJlmvct5aJV/5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4\n" + "lIzJ8yxzOzSStBPxvdrOobSSNlRZIlE7gnyNAgMBAAGjUzBRMB0GA1UdDgQWBBR+\n" + "dYtY9zmFSw9GYpEXC1iJKHC0/jAfBgNVHSMEGDAWgBR+dYtY9zmFSw9GYpEXC1iJ\n" + "KHC0/jAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBzKrsiYywl\n" + "RKeB2LbddgSf7ahiQMXCZpAjZeJikIoEmx+AmjQk1bam+M7WfpRAMnCKooU+Utp5\n" + "TwtijjnJydkZHFR6UH6oCWm8RsUVxruao/B0UFRlD8q+ZxGd4fGTdLg/ztmA+9oC\n" + "EmrcQNdz/KIxJj/fRB3j9GM4lkdaIju47V998Z619E/6pt7GWcAySm1faPB0X4fL\n" + "FJ6iYR2r/kJLoppPqL0EE49uwyYQ1dKhXS2hk+IIfA9mBn8eAFb/0435A2fXutds\n" + "qhvwIOmAObCzcoKkz3sChbk4ToUTqbC0TmFAXI5Upz1wnADzjpbJrpegCA3pmvhT\n" + "7356drqnCGY9\n" + "-----END CERTIFICATE-----\n"; + + std::string const key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz0GwgnxSBhygx\n" + "BdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOTLppr5MKxqQHEpYdyDYGD1noBoz4T\n" + "iIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05P41c2F9pBEnUwUxIUG1Cb6AN0cZW\n" + "F/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATmWm9SJc2lsjWptbyIN6hFXLYPXTwn\n" + "YzCLvv1EK6Ft7tMPc/FcJpd/w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Jb6FNFM3JnNoQctnuuvYPWxwM1yjRMqkOIHCczAlD4oFEeLoqZrNhpuP8Ij4wd\n" + "GjpqBbpzyVLNP043B6FC3C/edz4Lh+resjDczVPaUZ8aosLbLiREoxE0udfWf2dU\n" + "oBNnrMwwcs6jrRga7Kr1iVgUSwBQRAxiP2CYUv7tAoGBAKdPdekPNP/rCnHkKIkj\n" + "o13pr+LJ8t+15vVzZNHwPHUWiYXFhG8Ivx7rqLQSPGcuPhNss3bg1RJiZAUvF6fd\n" + "e6QS4EZM9dhhlO2FmPQCJMrRVDXaV+9TcJZXCbclQnzzBus9pwZZyw4Anxo0vmir\n" + "nOMOU6XI4lO9Xge/QDEN4Y2R\n" + "-----END PRIVATE KEY-----\n"; + + std::string const dh = + "-----BEGIN DH PARAMETERS-----\n" + "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" + "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" + "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" + "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; + + ctx.set_password_callback( + [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + + ctx.set_options(boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + + ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + + ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), + boost::asio::ssl::context::file_format::pem); + + ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/http_examples.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/http_examples.hpp new file mode 100644 index 0000000..f0705f2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/http_examples.hpp @@ -0,0 +1,940 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include + +/* This file contains the functions and classes found in the documentation + + They are compiled and run as part of the unit tests, so you can copy + the code and use it in your own projects as a starting point for + building a network application. +*/ + +// The documentation assumes the webcpp::beast::http namespace +namespace boost { +namespace beast { +namespace http { + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_http_send_expect_100_continue + +/** Send a request with Expect: 100-continue + + This function will send a request with the Expect: 100-continue + field by first sending the header, then waiting for a successful + response from the server before continuing to send the body. If + a non-successful server response is received, the function + returns immediately. + + @param stream The remote HTTP server stream. + + @param buffer The buffer used for reading. + + @param req The request to send. This function modifies the object: + the Expect header field is inserted into the message if it does + not already exist, and set to "100-continue". + + @param ec Set to the error, if any occurred. +*/ +template +void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, + request>& req, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); + + // Create the serializer + request_serializer> sr{req}; + + // Send just the header + write_header(stream, sr, ec); + if (ec) + return; + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); + if (ec) + return; + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; + } + } + + // Server is OK with the request, send the body + write(stream, sr, ec); +} + +//] + +//[example_http_receive_expect_100_continue + +/** Receive a request, handling Expect: 100-continue if present. + + This function will read a request from the specified stream. + If the request contains the Expect: 100-continue field, a + status response will be delivered. + + @param stream The remote HTTP client stream. + + @param buffer The buffer used for reading. + + @param ec Set to the error, if any occurred. +*/ +template +void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); + if (ec) + return; + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); + if (ec) + return; + } + + // Read the rest of the message. + // + read(stream, buffer, parser, ec); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Send Child Process Output +// +//------------------------------------------------------------------------------ + +//[example_http_send_cgi_response + +/** Send the output of a child process as an HTTP response. + + The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. + + @param input A stream to read the child process output from. + + @param output A stream to write the HTTP response to. + + @param ec Set to the error, if any occurred. +*/ +template +void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. + response res; + + res.result(status::ok); + res.version(11); + res.set(field::server, "Beast"); + res.set(field::transfer_encoding, "chunked"); + + // No data yet, but we set more = true to indicate + // that it might be coming later. Otherwise the + // serializer::is_done would return true right after + // sending the header. + res.body().data = nullptr; + res.body().more = true; + + // Create the serializer. + response_serializer sr{res}; + + // Send the header immediately. + write_header(output, sr, ec); + if (ec) + return; + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process + char buffer[2048]; + auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer + res.body().data = nullptr; + + // `false` means no more data is coming + res.body().more = false; + } else { + if (ec) + return; + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming + res.body().data = buffer; + res.body().size = bytes_transferred; + res.body().more = true; + } + + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. + if (ec == error::need_buffer) { + ec = {}; + continue; + } + if (ec) + return; + } while (!sr.is_done()); +} + +//] + +//-------------------------------------------------------------------------- +// +// Example: HEAD Request +// +//-------------------------------------------------------------------------- + +//[example_http_do_head_response + +/** Handle a HEAD request for a resource. + */ +template +void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; + + // Read the request + request req; + read(stream, buffer, req, ec); + if (ec) + return; + + // Set up the response, starting with the common fields + response res; + res.version(11); + res.set(field::server, "test"); + + // Now handle request-specific fields + switch (req.method()) { + case verb::head: + case verb::get: { + // A HEAD request is handled by delivering the same + // set of headers that would be sent for a GET request, + // including the Content-Length, except for the body. + res.result(status::ok); + res.content_length(payload.size()); + + // For GET requests, we include the body + if (req.method() == verb::get) { + // We deliver the same payload for GET requests + // regardless of the target. A real server might + // deliver a file based on the target. + res.body() = payload; + } + break; + } + + default: { + // We return responses indicating an error if + // we do not recognize the request method. + res.result(status::bad_request); + res.set(field::content_type, "text/plain"); + res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; + res.prepare_payload(); + break; + } + } + + // Send the response + write(stream, res, ec); + if (ec) + return; +} + +//] + +//[example_http_do_head_request + +/** Send a HEAD request for a resource. + + This function submits a HEAD request for the specified resource + and returns the response. + + @param res The response. This is an output parameter. + + @param stream The synchronous stream to use. + + @param buffer The buffer to use. + + @param target The request target. + + @param ec Set to the error, if any occurred. + + @throws std::invalid_argument if target is empty. +*/ +template +response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, + error_code& ec) { + // Do some type checking to be a good citizen + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. + if (target.empty()) + webcpp_fixture::fail_stop(); + + // Build the HEAD request for the target + request req; + req.version(11); + req.method(verb::head); + req.target(target); + req.set(field::user_agent, "test"); + + // A client MUST send a Host header field in all HTTP/1.1 request messages. + // https://tools.ietf.org/html/rfc7230#section-5.4 + req.set(field::host, "localhost"); + + // Now send it + write(stream, req, ec); + if (ec) + return {}; + + // Create a parser to read the response. + // We use the `empty_body` type since + // a response to a HEAD request MUST NOT + // include a body. + response_parser p; + + // Inform the parser that there will be no body. + p.skip(true); + + // Read the message. Even though fields like + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); + if (ec) + return {}; + + // Transfer ownership of the response to the caller. + return p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: HTTP Relay +// +//------------------------------------------------------------------------------ + +//[example_http_relay + +/** Relay an HTTP message. + + This function efficiently relays an HTTP message from a downstream + client to an upstream server, or from an upstream server to a + downstream client. After the message header is read from the input, + a user provided transformation function is invoked which may change + the contents of the header before forwarding to the output. This may + be used to adjust fields such as Server, or proxy fields. + + @param output The stream to write to. + + @param input The stream to read from. + + @param buffer The buffer to use for the input. + + @param transform The header transformation to apply. The function will + be called with this signature: + @code + template + void transform(message< + isRequest, Body, Fields>&, // The message to transform + error_code&); // Set to the error, if any + @endcode + + @param ec Set to the error if any occurred. + + @tparam isRequest `true` to relay a request. + + @tparam Fields The type of fields to use for the message. +*/ +template +void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, + Transform&& transform) { + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + char buf[2048]; + + // Create a parser with a buffer body to read from the input. + parser p; + + // Create a serializer from the message contained in the parser. + serializer sr{p.get()}; + + // Read just the header from the input + read_header(input, buffer, p, ec); + if (ec) + return; + + // Apply the caller's header transformation + transform(p.get(), ec); + if (ec) + return; + + // Send the transformed message to the output + write_header(output, sr, ec); + if (ec) + return; + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = sizeof(buf) - p.get().body().size; + p.get().body().data = buf; + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } + + // Write everything in the buffer (which might be empty) + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + } while (!p.is_done() && !sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Serialize to std::ostream +// +//------------------------------------------------------------------------------ + +//[example_http_write_ostream + +// The detail namespace means "not public" +namespace detail { + +// This helper is needed for C++11. +// When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +template +class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + +public: + write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer + template + void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + + // Keep a running total of how much we wrote + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence + for (auto it = boost::asio::buffer_sequence_begin(buffers); + it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream + os_.write(reinterpret_cast(buffer.data()), buffer.size()); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } + + // Adjust our running total + bytes_transferred += buffer_size(buffer); + } + + // Inform the serializer of the amount we consumed + sr_.consume(bytes_transferred); + } +}; + +} // namespace detail + +/** Write a message to a `std::ostream`. + + This function writes the serialized representation of the + HTTP/1 message to the sream. + + @param os The `std::ostream` to write to. + + @param msg The message to serialize. + + @param ec Set to the error, if any occurred. +*/ +template +void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; + do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); + if (ec) + return; + } while (!sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Parse from std::istream +// +//------------------------------------------------------------------------------ + +//[example_http_read_istream + +/** Read a message from a `std::istream`. + + This function attempts to parse a complete HTTP/1 message from the stream. + + @param is The `std::istream` to read from. + + @param buffer The buffer to use. + + @param msg The message to store the result. + + @param ec Set to the error, if any occurred. +*/ +template +void read_istream(std::istream& is, basic_flat_buffer& buffer, + message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are + // forwarded to the message constructor. Here, we use + // a move construction in case the caller has constructed + // their message in a non-default way. + // + parser p{std::move(msg)}; + + do { + // Extract whatever characters are presently available in the istream + if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream + buffer.commit( + static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); + } else if (buffer.size() == 0) { + // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream + if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + + // Try to get more from the istream. This might block. + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. + if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; + } + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); + if (ec) + return; + break; + } + } + + // Write the data to the parser + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. + if (ec == error::need_more) + ec = {}; + if (ec) + return; + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); + } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Deferred Body Type +// +//------------------------------------------------------------------------------ + +//[example_http_defer_body + +/** Handle a form POST request, choosing a body type depending on the Content-Type. + + This reads a request from the input stream. If the method is POST, and + the Content-Type is "application/x-www-form-urlencoded " or + "multipart/form-data", a `string_body` is used to receive and store + the message body. Otherwise, a `dynamic_body` is used to store the message + body. After the request is received, the handler will be invoked with the + request. + + @param stream The stream to read from. + + @param buffer The buffer to use for reading. + + @param handler The handler to invoke when the request is complete. + The handler must be invokable with this signature: + @code + template + void handler(request&& req); + @endcode + + @throws system_error Thrown on failure. +*/ +template +void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + + // Read just the header. Otherwise, the empty_body + // would generate an error if body octets were received. + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb + switch (req0.get().method()) { + case verb::post: { + // If this is not a form upload then use a string_body + if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && + req0.get()[field::content_type] != "multipart/form-data") + goto do_dynamic_body; + + // Commit to string_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + + do_dynamic_body: + default: { + // Commit to dynamic_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Incremental Read +// +//------------------------------------------------------------------------------ + +//[example_incremental_read + +/* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. +*/ +template +void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); + if (ec) + return; + while (!p.is_done()) { + char buf[512]; + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + read(stream, buffer, p, ec); + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + os.write(buf, sizeof(buf) - p.get().body().size); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Read large response body +// +//------------------------------------------------------------------------------ + +//[example_read_large_response_body + +/* This function uses custom size limit of the resposne body. + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. +*/ +template +std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, + message>& msg, + std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); + if (ec) + return bytes_transferred; + msg = p.release(); + return bytes_transferred; +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_chunk_parsing + +/** Read a message with a chunked body and print the chunks and extensions + */ +template +void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); + if (ec) + return; + + // This container will hold the extensions for each chunk + chunk_extensions ce; + + // This string will hold the body of each chunk + std::string chunk; + + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = + [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk + string_view extensions, // The raw chunk-extensions string. Already validated. + error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); + if (ev) + return; + + // See if the chunk is too big + if (size > (std::numeric_limits::max)()) { + ev = error::body_limit; + return; + } + + // Make sure we have enough storage, and + // reset the container for the upcoming chunk + chunk.reserve(static_cast(size)); + chunk.clear(); + }; + + // Set the callback. The function requires a non-const reference so we + // use a local variable, since temporaries can only bind to const refs. + p.on_chunk_header(header_cb); + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. + auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk + string_view body, // A buffer holding chunk body data + error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. + if (remain == body.size()) + ec = error::end_of_chunk; + + // Append this piece to our container + chunk.append(body.data(), body.size()); + + // The return value informs the parser of how much of the body we + // consumed. We will indicate that we consumed everything passed in. + return body.size(); + }; + p.on_chunk_body(body_cb); + + while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); + if (!ec) + continue; + else if (ec != error::end_of_chunk) + return; + else + ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; + if (!extension.second.empty()) + os << " = " << extension.second << std::endl; + else + os << std::endl; + } + + // Now print the chunk body + os << "Chunk Body: " << chunk << std::endl; + } + + // Get a reference to the parsed message, this is for convenience + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it + for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << std::endl; + continue; + } + os << it->name() << ": " << it->value() << std::endl; + } +} + +//] + +} // namespace http +} // namespace beast +} // namespace boost diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/ssl/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/ssl/client.cpp new file mode 100644 index 0000000..d6a773c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/ssl/client.cpp @@ -0,0 +1,145 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + { + webcpp_fixture::fail_stop(); + } + } +} + +net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) + if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { + webcpp_fixture::fail_stop(); + } + + // Set a callback to verify that the hostname in the server + // certificate matches the expected value + stream.set_verify_callback(ssl::host_name_verification("localhost")); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request + http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); + + // Read the response + beast::flat_buffer buf; + http::response res; + co_await http::async_read(stream, buf, res); + + // Print the response body + std::cout << res.body(); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +} // namespace + +int main() { + { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful + ctx.set_verify_mode(ssl::verify_peer); + + // The servers's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Client certificate and private key (if server request for). + ctx.use_certificate_chain_file("client.crt"); + ctx.use_private_key_file("client.key", ssl::context::pem); + + net::co_spawn(ioc, request(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/ssl/server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/ssl/server.cpp new file mode 100644 index 0000000..ce98a2a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/doc/ssl/server.cpp @@ -0,0 +1,140 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + { + webcpp_fixture::fail_stop(); + } + } +} + +net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + + // Read and discard a request + beast::flat_buffer buf; + http::request req; + co_await http::async_read(stream, buf, req); + + // Write the response + http::response res; + res.body() = "Hello!"; + co_await http::async_write(stream, res); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +net::awaitable acceptor(ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), + print_exception); + } +} + +} // namespace + +int main() { + { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. + // Asio exposes the OpenSSL verification bitmask as signed integer constants. + // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Server certificate and private key. + ctx.use_certificate_chain_file("server.crt"); + ctx.use_private_key_file("server.key", ssl::context::pem); + + // DH parameters for DHE-based cipher suites + ctx.use_tmp_dh_file("dh4096.pem"); + + net::co_spawn(ioc, acceptor(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/echo-op/echo_op.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/echo-op/echo_op.cpp new file mode 100644 index 0000000..2882bd7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/echo-op/echo_op.cpp @@ -0,0 +1,405 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; +namespace beast = webcpp::beast; + +//[example_core_echo_op_1 + +namespace { +template +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] + -> net::async_result, void(beast::error_code)>::return_type; + +//------------------------------------------------------------------------------ + +//[example_core_echo_op_2 + +/** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending + in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + + - A line was read in and written back on the stream + + - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` + and `async_write_some` function. The program must ensure that no + other reads or writes are performed until this operation completes. + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the + first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the + requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is + responsible for ensuring that the lifetime of this object is + extended least until the completion handler is invoked. + + @param token The handler to be called when the operation completes. + The implementation takes ownership of the handler by performing a decay-copy. + The handler must be invocable with this signature: + @code + void handler( + beast::error_code error // Result of operation. + ); + @endcode + + Regardless of whether the asynchronous operation completes immediately or + not, the handler will not be invoked from within this function. Invocation + of the handler will be performed in a manner equivalent to using + `net::post`. +*/ +template +// Upstream documentation repeats the initiating signature before its implementation. +// NOLINTNEXTLINE(readability-redundant-declaration) +// Each documentation snippet presents the complete public declaration. +// NOLINTNEXTLINE(readability-redundant-declaration) +auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ + CompletionToken&& token) + -> net::async_result*/ + std::decay_t, + void(beast::error_code) /*< The completion handler signature goes here >*/ + >::return_type; +//] + +//[example_core_echo_op_3 + +template +class echo_op; + +// This example uses the Asio's stackless "fauxroutines", implemented +// using a macro-based solution. It makes the code easier to write and +// easier to read. This include file defines the necessary macros and types. +#include + +// Read a line and echo it back +// +template +// The retained stackless coroutine expands each yield into nested resume branches. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +// Stackless coroutine macros generate the branches in this operation. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + -> net::async_result, + void(beast::error_code)>::return_type /*< The completion handler + signature goes here >*/ +{ + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. + static_assert(beast::is_async_stream::value, + "AsyncStream type requirements not met"); + static_assert(net::is_dynamic_buffer::value, + "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, + // and creates the `async_result` object which becomes the + // return value of this initiating function. + + net::async_completion init(token); + + // The helper macro BOOST_ASIO_HANDLER_TYPE converts the completion + // token type into a concrete handler type of the correct signature. + + using handler_type = BOOST_ASIO_HANDLER_TYPE(CompletionToken, void(beast::error_code)); + + // The class template `async_base` holds the caller's completion + // handler for us, and provides all of the boilerplate for forwarding + // the associated allocator and associated executor from the caller's + // handler to our operation. It also maintains a `net::executor_work_guard` + // for the executor associated with the stream. This work guard is + // inexpensive, and prevents the execution context from running out + // of work. It is usually necessary although rarely it can be skipped + // depending on the operation (this echo example needs it because it + // performs more than one asynchronous operation in a row). + // We declare this type alias to make the code easier to read. + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ + beast::executor_type /*< The type of executor used by the stream to dispatch + asynchronous operations >*/ + >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + + // Upstream combines coroutine state and shared lifetime as independent mixins. + // NOLINTNEXTLINE(misc-multiple-inheritance) + // Asio operation state combines completion ownership with coroutine resume state. + // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream; + DynamicBuffer& buffer; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( + std::move( + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , + stream(stream), + buffer(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our + // asynchronous control flow. + (*this)({}, 0, false); + } + + // If a newline is present in the buffer sequence, this function returns + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + + static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + + auto const begin = + net::buffers_iterator::begin(buffers); + auto const end = + net::buffers_iterator::end(buffers); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + const auto result = std::find(begin, end, '\n'); + + if (result == end) { + return 0; // not found + } + + return result + 1 - begin; + } + + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + // Resume labels generated by the stackless coroutine form one state machine. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + + reenter(*this) { + for (;;) { + // Stackless resume labels require this local to be assigned after resumption. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + // Resume labels cannot cross an initialized local; it is assigned before use. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer.data()); + + // If we don't have the newline, then read more + if (pos == 0) { + // Stackless resume labels require this local to be assigned after + // resumption. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + // Resume labels cannot cross an initialized local; it is assigned before + // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, + buffer.capacity() - buffer.size()), + std::min(65536, // and over 65536 is too much. + buffer.max_size() - buffer.size())); + + // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + + yield stream.async_read_some(buffer.prepare(bytes_to_read), + std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. + + // Move the bytes read from the writable area to the + // readable area. + + buffer.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. + if (ec) { + break; + } + + // Keep looping until we get the newline + continue; + } + + // We have our newline, so send the first `pos` bytes of the + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + + yield net::async_write(stream, beast::buffers_prefix(pos, buffer.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, + // and the `reenter` statement above will cause control to jump + // to the following line. The variable `pos` is no longer valid + // (remember that we returned from the function using `yield` above) + // but we can use `bytes_transferred` to know how much of the buffer + // to consume. With "real" coroutines this will be easier and more + // natural. + + buffer.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. + + break; + } + + // When a composed operation completes immediately, it must not + // directly invoke the completion handler otherwise it could + // lead to unfairness, starvation, or stack overflow. Therefore, + // if cont == false (meaning, that the call stack still includes + // the frame of the initiating function) then we need to use + // `net::post` to cause us to be called again after the initiating + // function. The function `async_base::invoke` takes care of + // calling the final completion handler, using post if the + // first argument is false, otherwise invoking it directly. + + this->complete(cont, ec); + } + } + }; + + // Create the composed operation and launch it. This is a constructor + // call followed by invocation of operator(). We use BOOST_ASIO_HANDLER_TYPE + // to convert the completion token into the correct handler type, + // allowing user-defined specializations of the async_result template + // to be used. + + echo_op(stream, buffer, std::move(init.completion_handler)); + + // This hook lets the caller see a return value when appropriate. + // For example this might return std::future if + // CompletionToken is net::use_future, or this might + // return an error code if CompletionToken specifies a coroutine. + + return init.result.get(); +} + +// Including this file undefines the macros used by the stackless fauxroutines. +#include + +//] + +struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { + if (ec) { + std::cerr << ": " << ec.message() << '\n'; + } + } +}; + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" + << "Example:\n" + << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; + endpoint_type const ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); + acceptor.listen(); + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); + ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-local/http_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-local/http_client_async_local.cpp new file mode 100644 index 0000000..1345cff --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-local/http_client_async_local.cpp @@ -0,0 +1,185 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* target, + int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, std::string{host} + ":" + port); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { + std::cerr << "Usage: http-client-async-local []\n" + << "Example:\n" + << " http-client-async-local /tmp/http.sock localhost 80 /\n" + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + const auto* const host = argv[2]; + const auto* const port = argv[3]; + const auto* const target = argv[4]; + int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..5fa055f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,261 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..a069f2b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,256 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..8096dc5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/async/http_client_async.cpp @@ -0,0 +1,199 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..5e780a8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,196 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include "common/root_certificates.hpp" + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + webcpp_fixture::fail_stop(); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..a14b8a6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,153 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/body/json_body.hpp new file mode 100644 index 0000000..6810a55 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/body/json_body.hpp @@ -0,0 +1,121 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(webcpp::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(webcpp::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/body/json_client.cpp new file mode 100644 index 0000000..f63d312 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/body/json_client.cpp @@ -0,0 +1,81 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +#include "json_body.hpp" + +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/coro-ssl/http_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/coro-ssl/http_client_coro_ssl.cpp new file mode 100644 index 0000000..d46ea3f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -0,0 +1,208 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, ssl::context& ctx, + net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res << std::endl; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream.async_shutdown(yield[ec]); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro-ssl []\n" + << "Example:\n" + << " http-client-coro-ssl www.example.com 443 /\n" + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/coro/http_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/coro/http_client_coro.cpp new file mode 100644 index 0000000..fea9d67 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/coro/http_client_coro.cpp @@ -0,0 +1,160 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro []\n" + << "Example:\n" + << " http-client-coro www.example.com 80 /\n" + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..354875c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/http_crawl.cpp @@ -0,0 +1,314 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + webcpp_fixture::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, webcpp::asio::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. + for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); + } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..d954d1c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,25 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..3e59659 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..096b6c8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/methods/http_client_methods.cpp @@ -0,0 +1,216 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..bf1059c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,154 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { + webcpp_fixture::fail_stop(); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); + } + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..7191389 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/client/sync/http_client_sync.cpp @@ -0,0 +1,122 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); + } + + // If we get here then the connection is closed gracefully + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async-local/http_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async-local/http_server_async_local.cpp new file mode 100644 index 0000000..f4203f9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async-local/http_server_async_local.cpp @@ -0,0 +1,440 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-async-local \n" + << "Example:\n" + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async-ssl/http_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async-ssl/http_server_async_ssl.cpp new file mode 100644 index 0000000..f01a75c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async-ssl/http_server_async_ssl.cpp @@ -0,0 +1,528 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + void on_run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + do_read(); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" + << "Example:\n" + << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async/http_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async/http_server_async.cpp new file mode 100644 index 0000000..d0b4393 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/async/http_server_async.cpp @@ -0,0 +1,462 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" + << "Example:\n" + << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/awaitable/http_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/awaitable/http_server_awaitable.cpp new file mode 100644 index 0000000..4ca2cff --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/awaitable/http_server_awaitable.cpp @@ -0,0 +1,355 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +// Handles an HTTP server connection +net::awaitable do_session(beast::tcp_stream stream, + std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + co_await http::async_read(stream, buffer, req); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have + // dropped the connection already. +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" + << "Example:\n" + << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/coro-ssl/http_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/coro-ssl/http_server_coro_ssl.cpp new file mode 100644 index 0000000..8faff66 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -0,0 +1,398 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) + return "text/html"; + if (iequals(ext, ".html")) + return "text/html"; + if (iequals(ext, ".php")) + return "text/html"; + if (iequals(ext, ".css")) + return "text/css"; + if (iequals(ext, ".txt")) + return "text/plain"; + if (iequals(ext, ".js")) + return "application/javascript"; + if (iequals(ext, ".json")) + return "application/json"; + if (iequals(ext, ".xml")) + return "application/xml"; + if (iequals(ext, ".swf")) + return "application/x-shockwave-flash"; + if (iequals(ext, ".flv")) + return "video/x-flv"; + if (iequals(ext, ".png")) + return "image/png"; + if (iequals(ext, ".jpe")) + return "image/jpeg"; + if (iequals(ext, ".jpeg")) + return "image/jpeg"; + if (iequals(ext, ".jpg")) + return "image/jpeg"; + if (iequals(ext, ".gif")) + return "image/gif"; + if (iequals(ext, ".bmp")) + return "image/bmp"; + if (iequals(ext, ".ico")) + return "image/vnd.microsoft.icon"; + if (iequals(ext, ".tiff")) + return "image/tiff"; + if (iequals(ext, ".tif")) + return "image/tiff"; + if (iequals(ext, ".svg")) + return "image/svg+xml"; + if (iequals(ext, ".svgz")) + return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(ssl::stream& stream, + std::shared_ptr const& doc_root, net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) + break; + if (ec) + return fail(ec, "read"); + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + + if (ec) + return fail(ec, "write"); + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); + if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" + << "Example:\n" + << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/coro/http_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/coro/http_server_coro.cpp new file mode 100644 index 0000000..c8dc14e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/coro/http_server_coro.cpp @@ -0,0 +1,355 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) + return "text/html"; + if (iequals(ext, ".html")) + return "text/html"; + if (iequals(ext, ".php")) + return "text/html"; + if (iequals(ext, ".css")) + return "text/css"; + if (iequals(ext, ".txt")) + return "text/plain"; + if (iequals(ext, ".js")) + return "application/javascript"; + if (iequals(ext, ".json")) + return "application/json"; + if (iequals(ext, ".xml")) + return "application/xml"; + if (iequals(ext, ".swf")) + return "application/x-shockwave-flash"; + if (iequals(ext, ".flv")) + return "video/x-flv"; + if (iequals(ext, ".png")) + return "image/png"; + if (iequals(ext, ".jpe")) + return "image/jpeg"; + if (iequals(ext, ".jpeg")) + return "image/jpeg"; + if (iequals(ext, ".jpg")) + return "image/jpeg"; + if (iequals(ext, ".gif")) + return "image/gif"; + if (iequals(ext, ".bmp")) + return "image/bmp"; + if (iequals(ext, ".ico")) + return "image/vnd.microsoft.icon"; + if (iequals(ext, ".tiff")) + return "image/tiff"; + if (iequals(ext, ".tif")) + return "image/tiff"; + if (iequals(ext, ".svg")) + return "image/svg+xml"; + if (iequals(ext, ".svgz")) + return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, + net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) + break; + if (ec) + return fail(ec, "read"); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + + if (ec) + return fail(ec, "write"); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn(acceptor.get_executor(), + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" + << "Example:\n" + << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/fast/fields_alloc.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/fast/fields_alloc.hpp new file mode 100644 index 0000000..408b44a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/fast/fields_alloc.hpp @@ -0,0 +1,169 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP +#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP + +#include +#include +#include +#include + +namespace detail { + +class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + + char* end() { return reinterpret_cast(this + 1) + size_; } + + explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} + +public: + static static_pool& construct(std::size_t size) { + auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + + static static_pool& share(static_pool& pool) { + ++pool.refs_; + return pool; + } + + void destroy() { + if ((--refs_) != 0u) { + return; + } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { + auto* last = p_ + n; + if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + } + ++count_; + auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { + if ((--count_) != 0u) { + return; + } + p_ = reinterpret_cast(this + 1); + } +}; + +} // namespace detail + +/** A non-thread-safe allocator optimized for @ref basic_fields. + + This allocator obtains memory from a pre-allocated memory block + of a given size. It does nothing in deallocate until all + previously allocated blocks are deallocated, upon which it + resets the internal memory block for re-use. + + To use this allocator declare an instance persistent to the + connection or session, and construct with the block size. + A good rule of thumb is 20% more than the maximum allowed + header size. For example if the application only allows up + to an 8,000 byte header, the block size could be 9,600. + + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. +*/ +template +struct fields_alloc { + detail::static_pool* pool; + +public: + using value_type = T; + using is_always_equal = std::false_type; + using pointer = T*; + using reference = T&; + using const_pointer = T const*; + using const_reference = T const&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template + struct rebind { + using other = fields_alloc; + }; + +#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) + // Workaround for g++ + // basic_string assumes that allocators are default-constructible + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 + fields_alloc() = default; +#endif + + explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + + fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template + explicit fields_alloc(fields_alloc const& other) + : pool(&detail::static_pool::share(*other.pool)) {} + + ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { + return static_cast(pool->alloc(n * sizeof(T))); + } + + void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template + void construct(U* ptr, Args&&... args) { + ::new (static_cast(ptr)) U(std::forward(args)...); + } + + template + void destroy(U* ptr) { + ptr->~U(); + } +#endif + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool == &rhs.pool_; + } + + template + friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { + return !(lhs == rhs); + } +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/fast/http_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/fast/http_server_fast.cpp new file mode 100644 index 0000000..cdf03fa --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/fast/http_server_fast.cpp @@ -0,0 +1,369 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include "fields_alloc.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +class http_worker { +public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + + // Retain the upstream borrowing constructor contract in this reference counterpart. + // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + + void start() { + accept(); + check_deadline(); + } + +private: + using alloc_t = fields_alloc; + // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. + tcp::acceptor& acceptor_; + + // The path to the root of the document directory. + std::string doc_root_; + + // The socket for the currently connected client. + tcp::socket socket_{acceptor_.get_executor()}; + + // The buffer for performing reads + beast::flat_static_buffer<8192> buffer_; + + // The allocator used for the fields in the request and reply. + alloc_t alloc_{8192}; + + // The parser for reading the requests + boost::optional> parser_; + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), + std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> + string_response_; + + // The string-based response serializer. + boost::optional>> + string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. + boost::optional>> + file_serializer_; + + void accept() { + // Clean up any previous connection. + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { + if (ec) { + accept(); + } else { + // Request must be fully processed within 60 seconds. + request_deadline_.expires_after(std::chrono::seconds(60)); + + read_request(); + } + }); + } + + void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. + // + // Arguments passed to the parser constructor are + // forwarded to the message object. A single argument + // is forwarded to the body constructor. + // + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { + if (ec) { + accept(); + } else { + process_request(parser_->get()); + } + }); + } + + void process_request(http::request> const& req) { + if (req.method() == http::verb::get) { + send_file(req.target()); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + + void send_bad_response(http::status status, std::string const& error) { + string_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); + }); + } + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open(full_path.c_str(), beast::file_mode::read, ec); + if (ec) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + file_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); + }); + } + + void check_deadline() { + // The deadline may have moved, so check it has really passed. + if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. + request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 6) { + std::cerr << "Usage: http_server_fast
" + "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " http_server_fast 0::0 80 . 100 block\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + std::string const doc_root = argv[3]; + int const num_workers = webcpp_fixture::integer(argv[4]); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; + for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) { + for (;;) { + ioc.poll(); + } + } else { + ioc.run(); // lint-run: drives the application's network operations + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/flex/http_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/flex/http_server_flex.cpp new file mode 100644 index 0000000..c93219e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/flex/http_server_flex.cpp @@ -0,0 +1,629 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP flex server (plain and SSL), asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; + +protected: + beast::flat_buffer buffer; + +public: + // Take ownership of the buffer +private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), + beast::bind_front_handler(&session::on_write, + derived().shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Read another request + do_read(); + } + + friend Derived; +}; + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_session(tcp::socket&& socket, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the session + ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( + ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake + async_detect_ssl(stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" + << "Example:\n" + << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/small/http_server_small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/small/http_server_small.cpp new file mode 100644 index 0000000..e819fc4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/small/http_server_small.cpp @@ -0,0 +1,232 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +namespace { +namespace my_program_state { +std::size_t request_count() { + static std::size_t count = 0; + return ++count; +} + +std::time_t now() { + return std::time(nullptr); +} +} // namespace my_program_state + +class http_connection : public std::enable_shared_from_this { +public: + explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { + read_request(); + check_deadline(); + } + +private: + // The socket for the currently connected client. + tcp::socket socket_; + + // The buffer for performing reads. + beast::flat_buffer buffer_{8192}; + + // The request message. + http::request request_; + + // The response message. + http::response response_; + + // The timer for putting a deadline on connection processing. + net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. + void read_request() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + if (!ec) { + self->process_request(); + } + }); + } + + // Determine what needs to be done with the request message. + void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + + if (request_.method() == http::verb::get) { + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); + } + + // Construct a response message based on the program state. + void create_response() { + if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + // Asynchronously transmit the response message. + void write_response() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.close(ec)); + } + }); + } +}; + +// "Loop" forever accepting new connections. +void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { + if (!ec) { + std::make_shared(std::move(socket))->start(); + } + http_server(acceptor, socket); + }); +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + + ioc.run(); // lint-run: drives the application's network operations + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/stackless-ssl/http_server_stackless_ssl.cpp new file mode 100644 index 0000000..8996b5d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -0,0 +1,539 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + yield stream_.async_shutdown( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + ctx_(ctx), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" + << "Example:\n" + << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/stackless/http_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/stackless/http_server_stackless.cpp new file mode 100644 index 0000000..c94f167 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/stackless/http_server_stackless.cpp @@ -0,0 +1,476 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" + << "Example:\n" + << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/sync-ssl/http_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/sync-ssl/http_server_sync_ssl.cpp new file mode 100644 index 0000000..5d96f9d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -0,0 +1,374 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.handshake(ssl::stream_base::server, ec)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Perform the SSL shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync-ssl
\n" + << "Example:\n" + << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(socket, ctx, doc_root); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/sync/http_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/sync/http_server_sync.cpp new file mode 100644 index 0000000..6f843ef --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/http/server/sync/http_server_sync.cpp @@ -0,0 +1,342 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync
\n" + << "Example:\n" + << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(socket, doc_root); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/mapping.json new file mode 100644 index 0000000..1b44748 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/mapping.json @@ -0,0 +1,73 @@ +{ + "applications": [ + "advanced-server", + "advanced-server-flex", + "advanced-server-flex-awaitable", + "doc-ssl-client", + "doc-ssl-server", + "echo-op", + "http-client-async", + "http-client-async-local", + "http-client-async-ssl", + "http-client-async-ssl-system-executor", + "http-client-awaitable", + "http-client-awaitable-ssl", + "json_client", + "http-crawl", + "http-client-methods", + "http-client-sync", + "http-client-sync-ssl", + "http-server-async", + "http-server-async-local", + "http-server-async-ssl", + "http-server-awaitable", + "http-server-fast", + "http-server-flex", + "http-server-small", + "http-server-stackless", + "http-server-stackless-ssl", + "http-server-sync", + "http-server-sync-ssl", + "websocket-client-async", + "websocket-client-async-local", + "websocket-client-async-ssl", + "websocket-client-async-ssl-system-executor", + "websocket-client-awaitable", + "websocket-client-sync", + "websocket-client-sync-ssl", + "websocket-server-async", + "websocket-server-async-local", + "websocket-server-async-ssl", + "websocket-server-awaitable", + "websocket-chat-multi", + "websocket-server-stackless", + "websocket-server-stackless-ssl", + "websocket-server-sync", + "websocket-server-sync-ssl" + ], + "browser_applications": [ + "http-client-async", + "http-client-async-ssl", + "http-client-async-ssl-system-executor", + "http-client-awaitable", + "http-client-awaitable-ssl", + "json_client", + "http-crawl", + "http-client-methods", + "http-client-sync", + "http-client-sync-ssl", + "websocket-client-async", + "websocket-client-async-ssl", + "websocket-client-async-ssl-system-executor", + "websocket-client-awaitable", + "websocket-client-sync", + "websocket-client-sync-ssl" + ], + "adaptations": [ + "Explicit throw/rethrow sites terminate with a diagnostic and abort.", + "Catch blocks are removed; error_code paths and successful flows retained.", + "Sync WebSocket servers observe normal close through error_code and return.", + "Boost.Context stackful source remains blocked in exception-off modes.", + "Single-thread variants additionally apply explicit WASIp3 scheduling." + ] +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-local/websocket_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-local/websocket_client_async_local.cpp new file mode 100644 index 0000000..57d5b49 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-local/websocket_client_async_local.cpp @@ -0,0 +1,199 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; + + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr + << "Usage: websocket-client-async-local \n" + << "Example:\n" + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + const auto* const host = argv[2]; + const auto* const port = argv[3]; + const auto* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..e2230d7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,267 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..9316135 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,261 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..54f434a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,219 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); + })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..e81d13e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,147 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); + + // Send the message + co_await stream.async_write(net::buffer(text)); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + webcpp_fixture::fail_stop(); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp new file mode 100644 index 0000000..cce1e10 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -0,0 +1,198 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + return fail(ec, "connect"); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro-ssl \n" + << "Example:\n" + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/coro/websocket_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/coro/websocket_client_coro.cpp new file mode 100644 index 0000000..a6ecac5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/coro/websocket_client_coro.cpp @@ -0,0 +1,165 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) + return fail(ec, "connect"); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro \n" + << "Example:\n" + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..84f9d5c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,139 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + webcpp_fixture::fail_stop(); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..2b81742 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,117 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async-local/websocket_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async-local/websocket_server_async_local.cpp new file mode 100644 index 0000000..d9dc040 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async-local/websocket_server_async_local.cpp @@ -0,0 +1,229 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; + } + // Create the session and run it + std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-async-local \n" + << "Example:\n" + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async-ssl/websocket_server_async_ssl.cpp new file mode 100644 index 0000000..d544ef9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -0,0 +1,286 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async/websocket_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async/websocket_server_async.cpp new file mode 100644 index 0000000..1c6363a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/async/websocket_server_async.cpp @@ -0,0 +1,251 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" + << "Example:\n" + << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/awaitable/websocket_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/awaitable/websocket_server_awaitable.cpp new file mode 100644 index 0000000..69891ef --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/awaitable/websocket_server_awaitable.cpp @@ -0,0 +1,152 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Echoes back all received WebSocket messages +namespace { +net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + co_await stream.async_accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed) { + co_return; + } + + if (ec) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + stream.text(stream.got_text()); + co_await stream.async_write(buffer.data()); + } +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" + << "Example:\n" + << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { + webcpp_fixture::fail_stop(); + } + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/beast.hpp new file mode 100644 index 0000000..5ba29f7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/beast.hpp @@ -0,0 +1,38 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/http_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/http_session.cpp new file mode 100644 index 0000000..1c0e13f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/http_session.cpp @@ -0,0 +1,338 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include +#include "http_session.hpp" +#include "websocket_session.hpp" + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +} // namespace + +http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +void http_session::run() { + do_read(); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, parser_->get(), + beast::bind_front_handler(&http_session::on_read, shared_from_this())); +} + +void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + boost::make_shared(stream_.release_socket(), state_) + ->run(parser_->release()); + return; + } + + // Handle request + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response + beast::async_write(stream_, std::move(msg), + [self, keep_alive](beast::error_code ec, std::size_t bytes) { + self->on_write(ec, bytes, keep_alive); + }); +} + +void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Read another request + do_read(); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/http_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/http_session.hpp new file mode 100644 index 0000000..88485ed --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/http_session.hpp @@ -0,0 +1,63 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +#include +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +/** Represents an established HTTP connection + */ +class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + + struct send_lambda; + + void fail(beast::error_code ec, char const* what); + void do_read(); + void on_read(beast::error_code ec, std::size_t /*unused*/); + void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + +public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/listener.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/listener.cpp new file mode 100644 index 0000000..a7d2bc4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/listener.cpp @@ -0,0 +1,109 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "http_session.hpp" +#include "listener.hpp" + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } +} + +void listener::run() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handle a connection +void listener::on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); + } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/listener.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/listener.hpp new file mode 100644 index 0000000..2329291 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/listener.hpp @@ -0,0 +1,57 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" + +// Forward declaration +class shared_state; + +// Accepts incoming connections and launches the sessions +class listener : public boost::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec, tcp::socket socket); + +public: + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/main.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/main.cpp new file mode 100644 index 0000000..aaa2a22 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/main.cpp @@ -0,0 +1,80 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +//------------------------------------------------------------------------------ +/* + WebSocket chat server, multi-threaded + + This implements a multi-user chat room using WebSocket. The + `io_context` runs on any number of threads, specified at + the command line. + +*/ +//------------------------------------------------------------------------------ + +#include "listener.hpp" +#include "shared_state.hpp" + +#include +#include +#include + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" + << "Example:\n" + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto* doc_root = argv[3]; + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Create and launch a listening port + boost::make_shared(ioc, tcp::endpoint{address, port}, + boost::make_shared(doc_root)) + ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/net.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/net.hpp new file mode 100644 index 0000000..ca25c6c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/net.hpp @@ -0,0 +1,47 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/shared_state.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/shared_state.cpp new file mode 100644 index 0000000..647a06e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/shared_state.cpp @@ -0,0 +1,70 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "shared_state.hpp" +#include "websocket_session.hpp" + +shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + +void shared_state::join(websocket_session* session) { + std::scoped_lock const lock(mutex_); + sessions_.insert(session); +} + +void shared_state::leave(websocket_session* session) { + std::scoped_lock const lock(mutex_); + sessions_.erase(session); +} + +// Broadcast a message to all websocket client sessions +void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + + // Make a local list of all the weak pointers representing + // the sessions, so we can do the actual sending without + // holding the mutex: + std::vector> v; + { + std::scoped_lock const lock(mutex_); + v.reserve(sessions_.size()); + for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); + } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. + for (auto const& wp : v) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + if (const auto sp = wp.lock()) { + sp->send(ss); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/shared_state.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/shared_state.hpp new file mode 100644 index 0000000..9bd9991 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/shared_state.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP + +#include +#include +#include +#include +#include + +// Forward declaration +class websocket_session; + +// Represents the shared server state +class shared_state { + std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; + + // Keep a list of all the connected clients + std::unordered_set sessions_; + +public: + explicit shared_state(std::string doc_root); + + [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); + void send(std::string message); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/websocket_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/websocket_session.cpp new file mode 100644 index 0000000..4e356e5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/websocket_session.cpp @@ -0,0 +1,130 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "websocket_session.hpp" + +websocket_session::websocket_session(tcp::socket&& socket, + boost::shared_ptr const& state) + : ws_(std::move(socket)), state_(state) {} + +websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); +} + +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these + if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Read another message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + + net::post(ws_.get_executor(), + beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); +} + +void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? + if (queue_.size() > 1) { + return; + } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); +} + +void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any + if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/websocket_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/websocket_session.hpp new file mode 100644 index 0000000..ade13f1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/chat-multi/websocket_session.hpp @@ -0,0 +1,90 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// Forward declaration +class shared_state; + +/** Represents an active WebSocket connection to the server + */ +class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; + std::vector> queue_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); + +public: + websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + + template + void run(http::request> req); + + // Send a message + void send(boost::shared_ptr const& ss); + +private: + void on_send(boost::shared_ptr const& ss); +}; + +template +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); + })); + + // Accept the websocket handshake + ws_.async_accept(req, + beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp new file mode 100644 index 0000000..bb678e4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -0,0 +1,206 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void do_session(websocket::stream>& ws, net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) + return fail(ec, "accept"); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) + break; + + if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) + return fail(ec, "write"); + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" + << "Example:\n" + << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/coro/websocket_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/coro/websocket_server_coro.cpp new file mode 100644 index 0000000..fc193e6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/coro/websocket_server_coro.cpp @@ -0,0 +1,181 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) + return fail(ec, "accept"); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) + break; + + if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) + return fail(ec, "write"); + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" + << "Example:\n" + << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + boost::asio::spawn( + ioc, + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) + webcpp_fixture::fail_stop(); + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/fast/websocket_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/fast/websocket_server_fast.cpp new file mode 100644 index 0000000..eb24976 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/fast/websocket_server_fast.cpp @@ -0,0 +1,342 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, fast +// +//------------------------------------------------------------------------------ + +/* This server contains the following ports: + + Synchronous + Asynchronous + Coroutine + + This program is optimized for the Autobahn|Testsuite + benchmarking and WebSocket compliants testing program. + + See: + https://github.com/crossbario/autobahn-testsuite +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); +} + +// Adjust settings on the stream +template +void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + + websocket::permessage_deflate pmd; + pmd.client_enable = true; + pmd.server_enable = true; + pmd.compLevel = 3; + ws.set_option(pmd); + + ws.auto_fragment(false); + + // Autobahn|Testsuite needs this + ws.read_message_max(64 * 1024 * 1024); +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation + void run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&async_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed + if (ec == websocket::error::closed) + return; + + if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&async_session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +// Accepts incoming connections and launches the sessions +class async_listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen(net::socket_base::max_listen_connections, ec); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); + })); + + ws.async_accept(yield[ec]); + if (ec) + return fail(ec, "accept"); + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); + if (ec == websocket::error::closed) + break; + if (ec) + return fail(ec, "read"); + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) + return fail(ec, "write"); + } +} + +void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if (ec) + return fail(ec, "open"); + + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if (ec) + return fail(ec, "set_option"); + + acceptor.bind(endpoint, ec); + if (ec) + return fail(ec, "bind"); + + acceptor.listen(net::socket_base::max_listen_connections, ec); + if (ec) + return fail(ec, "listen"); + + for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); + } +} + +//------------------------------------------------------------------------------ + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" + << "Example:\n" + " websocket-server-fast 0.0.0.0 8080 1\n" + " Connect to:\n" + " starting-port+0 for synchronous,\n" + " starting-port+1 for asynchronous,\n" + " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create sync port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Create async port + std::make_shared(ioc, + tcp::endpoint{address, static_cast(port + 1u)}) + ->run(); + + // Create coro port + boost::asio::spawn(ioc, + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), + boost::asio::detached); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp new file mode 100644 index 0000000..ae1cf04 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -0,0 +1,305 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless-ssl"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/stackless/websocket_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/stackless/websocket_server_stackless.cpp new file mode 100644 index 0000000..39064d9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/stackless/websocket_server_stackless.cpp @@ -0,0 +1,271 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" + << "Example:\n" + << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp new file mode 100644 index 0000000..23f1c41 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -0,0 +1,138 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "close_observation.hpp" +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket, ssl::context& ctx) { + { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + beast::error_code read_error; + ws.read(buffer, read_error); + if (read_error == websocket::error::closed) { + webcpp_fixture::observe_normal_close(); + return; + } + if (read_error) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync-ssl
\n" + << "Example:\n" + << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(std::move(socket), ctx); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/sync/websocket_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/sync/websocket_server_sync.cpp new file mode 100644 index 0000000..a9ff76e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/noexcept-single/websocket/server/sync/websocket_server_sync.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "close_observation.hpp" +#include "failure.hpp" +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket) { + { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + beast::error_code read_error; + ws.read(buffer, read_error); + if (read_error == websocket::error::closed) { + webcpp_fixture::observe_normal_close(); + return; + } + if (read_error) { + webcpp_fixture::fail_stop(); + } + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync
\n" + << "Example:\n" + << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(std::move(socket)); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/normalization.patch b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/normalization.patch new file mode 100644 index 0000000..3d34ae8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/normalization.patch @@ -0,0 +1,63713 @@ +--- a/browser/http/client/async/http_client_async.cpp ++++ b/browser/http/client/async/http_client_async.cpp +@@ -31,23 +31,22 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -79,9 +78,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -92,9 +97,15 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -107,8 +118,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -118,18 +133,26 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -137,6 +160,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -147,10 +172,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -164,6 +189,8 @@ + + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -180,15 +207,20 @@ + { + std::vector storage{"http-client-async", "127.0.0.1", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-async: passed\n"; + return 0; +--- a/browser/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/browser/http/client/async-ssl/http_client_async_ssl.cpp +@@ -32,23 +32,22 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -62,6 +61,8 @@ + http::response res_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + +@@ -84,9 +85,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -97,9 +104,15 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -108,8 +121,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -122,8 +139,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -133,11 +154,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -147,6 +172,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -165,13 +192,19 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (bool(ec)) +- return fail(ec, "shutdown"); ++ if (static_cast(ec)) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -182,10 +215,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -211,6 +244,8 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include + #include +@@ -226,15 +261,20 @@ + { + std::vector storage{"http-client-async-ssl", "localhost", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-async-ssl: passed\n"; + return 0; +--- a/browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -33,23 +33,22 @@ + + #include + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -64,6 +63,8 @@ + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +@@ -92,9 +93,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -105,9 +112,15 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -116,8 +129,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -130,8 +147,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -141,11 +162,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -155,6 +180,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -173,13 +200,19 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (bool(ec)) +- return fail(ec, "shutdown"); ++ if (static_cast(ec)) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -190,10 +223,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +@@ -216,6 +249,8 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include + #include +@@ -229,18 +264,27 @@ + return 1; + } + { +- std::vector storage{"http-client-async-ssl-system-executor", "localhost", port, +- "/http"}; ++ std::vector storage{ ++ "http-client-async-ssl-system-executor", ++ "localhost", ++ port, ++ "/http", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-async-ssl-system-executor: passed\n"; + return 0; +--- a/browser/http/client/awaitable/http_client_awaitable.cpp ++++ b/browser/http/client/awaitable/http_client_awaitable.cpp +@@ -33,24 +33,23 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -83,7 +82,7 @@ + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -92,14 +91,17 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -111,10 +113,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -124,16 +126,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +@@ -143,6 +148,8 @@ + #error "This application requires its declared Asio backend" + + #endif ++ ++} // namespace + + #include + #include +@@ -159,15 +166,20 @@ + { + std::vector storage{"http-client-awaitable", "127.0.0.1", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-awaitable: passed\n"; + return 0; +--- a/browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -35,16 +35,14 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -54,14 +52,15 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::ssl_stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) +- beast::set_server_name(stream, host.c_str()).value(); ++ beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); +@@ -101,7 +100,7 @@ + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -126,12 +125,15 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && bool(ec)) ++ if (ec && static_cast(ec)) { + throw boost::system::system_error(ec, "shutdown"); ++ } + } + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -143,10 +145,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -165,16 +167,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +@@ -184,6 +189,8 @@ + #error "This application requires its declared Asio backend" + + #endif ++ ++} // namespace + + #include + #include +@@ -200,15 +207,20 @@ + { + std::vector storage{"http-client-awaitable-ssl", "localhost", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-awaitable-ssl: passed\n"; + return 0; +--- a/browser/http/client/body/json_body.hpp ++++ b/browser/http/client/body/json_body.hpp +@@ -33,6 +33,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -48,11 +49,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(webcpp::beast::http::header const&, value_type const& body) { ++ writer(webcpp::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -61,20 +65,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ reader(webcpp::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -82,8 +87,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -91,21 +98,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/browser/http/client/body/json_client.cpp ++++ b/browser/http/client/body/json_client.cpp +@@ -18,20 +18,19 @@ + #include "fixture.hpp" + #include "json_body.hpp" + +-#include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from ++using webcpp::asio::ip::tcp; // from + +-int application_main(int, char**) { ++namespace { ++int application_main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -66,7 +65,7 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -74,6 +73,8 @@ + + return 0; + } ++ ++} // namespace + + #include + #include +@@ -90,15 +91,20 @@ + { + std::vector storage{"json_client"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) ++ if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) { + return 1; ++ } + } + std::cout << "application json_client: passed\n"; + return 0; +--- a/browser/http/client/crawl/http_crawl.cpp ++++ b/browser/http/client/crawl/http_crawl.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -47,20 +46,20 @@ + #include + #include + #include +-#include + + #include + #include + +-namespace chrono = std::chrono; // from +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++namespace chrono = std::chrono; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -68,7 +67,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(webcpp::asio::io_context& ioc) ++ explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -88,8 +87,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -126,9 +126,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -139,7 +140,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -167,11 +168,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -182,10 +184,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -197,10 +202,13 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -216,7 +224,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -230,7 +239,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -259,16 +269,18 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int application_main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[1])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; +@@ -276,11 +288,14 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. +- for (int index = 0; index < threads; ++index) ++ for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); ++ } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() +@@ -290,9 +305,10 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include +-#include + + int main() { + const auto port = emscripten::val::global("location")["port"].as(); +@@ -305,15 +321,20 @@ + { + std::vector storage{"http-crawl", "2"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Success : 3") == std::string::npos) ++ if (result != 0 || output.str().find("Success : 3") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-crawl: passed\n"; + return 0; +--- a/browser/http/client/methods/http_client_methods.cpp ++++ b/browser/http/client/methods/http_client_methods.cpp +@@ -35,19 +35,18 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from ++using webcpp::asio::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { +@@ -131,6 +130,8 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -142,8 +143,9 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); ++ } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +@@ -170,28 +172,28 @@ + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -200,18 +202,21 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } + + //] ++ ++} // namespace + + #include + #include +@@ -228,15 +233,20 @@ + for (const auto* method : {"get", "head", "post", "put", "patch", "delete"}) { + std::vector storage{"http-client-methods", method}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("200 OK") == std::string::npos) ++ if (result != 0 || output.str().find("200 OK") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-methods: passed\n"; + return 0; +--- a/browser/http/client/sync/http_client_sync.cpp ++++ b/browser/http/client/sync/http_client_sync.cpp +@@ -34,19 +34,20 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from ++using webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -58,10 +59,10 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -93,7 +94,7 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -102,18 +103,21 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } + + //] ++ ++} // namespace + + #include + #include +@@ -130,15 +134,20 @@ + { + std::vector storage{"http-client-sync", "127.0.0.1", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-sync: passed\n"; + return 0; +--- a/browser/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/browser/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -33,20 +33,21 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -58,10 +59,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -111,7 +112,7 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +@@ -134,14 +135,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (bool(ec)) ++ if (static_cast(ec)) { + throw beast::system_error{ec}; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -158,15 +162,20 @@ + { + std::vector storage{"http-client-sync-ssl", "localhost", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-sync-ssl: passed\n"; + return 0; +--- a/browser/websocket/client/async/websocket_client_async.cpp ++++ b/browser/websocket/client/async/websocket_client_async.cpp +@@ -38,17 +38,17 @@ + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++ ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -77,9 +77,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -90,9 +96,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -115,8 +127,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -126,8 +142,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -136,8 +156,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -145,18 +169,24 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -165,9 +195,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -181,6 +211,8 @@ + + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -195,18 +227,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-async", "127.0.0.1", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-async", ++ "127.0.0.1", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-async: passed\n"; + return 0; +--- a/browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -33,7 +33,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + + #include + #include +@@ -42,16 +41,17 @@ + #include + #include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -86,9 +86,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -99,9 +105,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -118,8 +130,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -137,8 +153,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -148,8 +168,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -158,8 +182,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -167,18 +195,24 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -187,9 +221,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -212,6 +246,8 @@ + + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -226,18 +262,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-async-ssl", "localhost", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-async-ssl", ++ "localhost", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-async-ssl: passed\n"; + return 0; +--- a/browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -33,7 +33,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + + #include + #include +@@ -43,16 +42,17 @@ + #include + #include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -67,6 +67,8 @@ + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +@@ -93,9 +95,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -106,9 +114,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -125,8 +139,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -144,8 +162,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -155,8 +177,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -165,8 +191,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -174,18 +204,24 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -194,9 +230,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +@@ -219,6 +255,8 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include + #include +@@ -232,18 +270,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-async-ssl-system-executor", "localhost", +- port, "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-async-ssl-system-executor", ++ "localhost", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-async-ssl-system-executor: passed\n"; + return 0; +--- a/browser/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/browser/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -35,22 +35,21 @@ + #include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; +-namespace http = beast::http; + namespace websocket = beast::websocket; + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -61,7 +60,8 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); ++ auto const ep = ++ co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -96,11 +96,13 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -110,24 +112,27 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +@@ -137,6 +142,8 @@ + #error "This application requires its declared Asio backend" + + #endif ++ ++} // namespace + + #include + #include +@@ -151,18 +158,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-awaitable", "127.0.0.1", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-awaitable", ++ "127.0.0.1", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-awaitable: passed\n"; + return 0; +--- a/browser/websocket/client/sync/websocket_client_sync.cpp ++++ b/browser/websocket/client/sync/websocket_client_sync.cpp +@@ -39,15 +39,17 @@ + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -58,8 +60,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -72,7 +74,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = ws.next_layer().connect(results); ++ auto const ep = ws.next_layer().connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -100,15 +102,17 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } + + //] ++ ++} // namespace + + #include + #include +@@ -123,18 +127,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-sync", "127.0.0.1", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-sync", ++ "127.0.0.1", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-sync: passed\n"; + return 0; +--- a/browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -33,7 +33,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + + #include + #include +@@ -42,14 +41,17 @@ + #include + #include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -60,8 +62,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -83,10 +85,10 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).connect(results); ++ auto const ep = beast::get_lowest_layer(ws).connect(results); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- beast::set_server_name(ws.next_layer(), host.c_str()).value(); ++ beast::set_server_name(ws.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); +@@ -120,13 +122,15 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -141,18 +145,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-sync-ssl", "localhost", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-sync-ssl", ++ "localhost", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-sync-ssl: passed\n"; + return 0; +--- a/host/advanced-server-flex-awaitable.cpp ++++ b/host/advanced-server-flex-awaitable.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/advanced-server-flex.cpp ++++ b/host/advanced-server-flex.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/advanced-server.cpp ++++ b/host/advanced-server.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-async-local.cpp ++++ b/host/http-server-async-local.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-async-ssl.cpp ++++ b/host/http-server-async-ssl.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-async.cpp ++++ b/host/http-server-async.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-awaitable.cpp ++++ b/host/http-server-awaitable.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-coro-ssl.cpp ++++ b/host/http-server-coro-ssl.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-coro.cpp ++++ b/host/http-server-coro.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-flex.cpp ++++ b/host/http-server-flex.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-stackless-ssl.cpp ++++ b/host/http-server-stackless-ssl.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-stackless.cpp ++++ b/host/http-server-stackless.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-sync-ssl.cpp ++++ b/host/http-server-sync-ssl.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host/http-server-sync.cpp ++++ b/host/http-server-sync.cpp +@@ -18,64 +18,88 @@ + std::variant, http::response, + http::response>; + ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -87,8 +111,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -135,18 +160,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -154,12 +182,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -175,8 +205,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -187,4 +220,6 @@ + application_response handle(http::request request) { + return handle_request(".", std::move(request)); + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/doc-ssl-client.cpp ++++ b/host-clients/doc-ssl-client.cpp +@@ -22,6 +22,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -29,6 +30,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -44,8 +47,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -53,4 +57,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-async-local.cpp ++++ b/host-clients/http-client-async-local.cpp +@@ -29,6 +29,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -36,6 +37,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -51,8 +54,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -60,4 +64,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-async-ssl-system-executor.cpp ++++ b/host-clients/http-client-async-ssl-system-executor.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-async-ssl.cpp ++++ b/host-clients/http-client-async-ssl.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-async.cpp ++++ b/host-clients/http-client-async.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-awaitable-ssl.cpp ++++ b/host-clients/http-client-awaitable-ssl.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-awaitable.cpp ++++ b/host-clients/http-client-awaitable.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-coro-ssl.cpp ++++ b/host-clients/http-client-coro-ssl.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-coro.cpp ++++ b/host-clients/http-client-coro.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-methods.cpp ++++ b/host-clients/http-client-methods.cpp +@@ -24,12 +24,14 @@ + + //[example_http_client_methods + ++#include + #include + #include + + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -37,6 +39,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -47,27 +51,35 @@ + boost::system::error_code error; + unsigned completed = 0; + +- const http::verb methods[] = {http::verb::get, http::verb::head, http::verb::post, +- http::verb::put, http::verb::patch, http::verb::delete_}; ++ const std::array methods = { ++ http::verb::get, http::verb::head, http::verb::post, ++ http::verb::put, http::verb::patch, http::verb::delete_, ++ }; + for (const auto method : methods) { + http::request request{method, "/fixture", 11}; + request.set(http::field::host, authority); +- if (method == http::verb::post) ++ if (method == http::verb::post) { + request.body() = "Some random post data"; +- if (method == http::verb::put) ++ } ++ if (method == http::verb::put) { + request.body() = "Some random put data"; +- if (method == http::verb::delete_) ++ } ++ if (method == http::verb::delete_) { + request.body() = "Some random delete data"; +- if (method == http::verb::patch) ++ } ++ if (method == http::verb::patch) { + request.body() = "Some random patch data"; ++ } + request.prepare_payload(); + http::response response; + peer.perform(request, response, error); +- if (error || response.result() != http::status::ok) ++ if (error || response.result() != http::status::ok) { + return failure(error); ++ } + if (method != http::verb::head && !request.body().empty() && +- response.body() != request.body()) ++ response.body() != request.body()) { + return failure(error); ++ } + ++completed; + } + +@@ -76,4 +88,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-sync-ssl.cpp ++++ b/host-clients/http-client-sync-ssl.cpp +@@ -28,6 +28,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -35,6 +36,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -50,8 +53,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -59,4 +63,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/http-client-sync.cpp ++++ b/host-clients/http-client-sync.cpp +@@ -30,6 +30,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -37,6 +38,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -52,8 +55,9 @@ + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || +- response.body() != "beast-application-fixture\n") ++ response.body() != "beast-application-fixture\n") { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -61,4 +65,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/host-clients/json_body.hpp ++++ b/host-clients/json_body.hpp +@@ -25,6 +25,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -40,11 +41,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(boost::beast::http::header const&, value_type const& body) { ++ writer(boost::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -53,20 +57,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(boost::beast::http::header&, value_type& body) : body(body) {} ++ reader(boost::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -74,8 +79,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -83,21 +90,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/host-clients/json_client.cpp ++++ b/host-clients/json_client.cpp +@@ -15,6 +15,7 @@ + namespace beast = webcpp::beast; + namespace http = beast::http; + ++namespace { + http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); +@@ -22,6 +23,8 @@ + return response; + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); +@@ -40,8 +43,9 @@ + request.chunked(false); // Host owns framing for the original unsized JSON Body. + http::response response; + peer.perform(request, response, error); +- if (error || response.result() != http::status::ok || response.body() != request.body()) ++ if (error || response.result() != http::status::ok || response.body() != request.body()) { + return failure(error); ++ } + ++completed; + + http::response result{http::status::ok, 11}; +@@ -49,4 +53,6 @@ + result.prepare_payload(); + return result; + } ++} // namespace ++ + WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +--- a/noexcept-browser/http/client/async/http_client_async.cpp ++++ b/noexcept-browser/http/client/async/http_client_async.cpp +@@ -32,23 +32,22 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -80,9 +79,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -93,9 +98,15 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -108,8 +119,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -119,18 +134,26 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -138,6 +161,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -148,10 +173,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -165,6 +190,8 @@ + + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -181,15 +208,20 @@ + { + std::vector storage{"http-client-async", "127.0.0.1", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-async: passed\n"; + return 0; +--- a/noexcept-browser/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/noexcept-browser/http/client/async-ssl/http_client_async_ssl.cpp +@@ -33,23 +33,22 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -63,6 +62,8 @@ + http::response res_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + +@@ -85,9 +86,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -98,9 +105,15 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -109,8 +122,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -123,8 +140,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -134,11 +155,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -148,6 +173,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -166,13 +193,19 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (bool(ec)) +- return fail(ec, "shutdown"); ++ if (static_cast(ec)) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -183,10 +216,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -201,8 +234,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // Launch the asynchronous operation +@@ -217,6 +251,8 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include + #include +@@ -232,15 +268,20 @@ + { + std::vector storage{"http-client-async-ssl", "localhost", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-async-ssl: passed\n"; + return 0; +--- a/noexcept-browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/noexcept-browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -34,23 +34,22 @@ + + #include + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -65,6 +64,8 @@ + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +@@ -93,9 +94,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -106,9 +113,15 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -117,8 +130,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -131,8 +148,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -142,11 +163,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -156,6 +181,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -174,13 +201,19 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (bool(ec)) +- return fail(ec, "shutdown"); ++ if (static_cast(ec)) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -191,10 +224,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +@@ -207,8 +240,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // Launch the asynchronous operation +@@ -222,6 +256,8 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include + #include +@@ -235,18 +271,27 @@ + return 1; + } + { +- std::vector storage{"http-client-async-ssl-system-executor", "localhost", port, +- "/http"}; ++ std::vector storage{ ++ "http-client-async-ssl-system-executor", ++ "localhost", ++ port, ++ "/http", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-async-ssl-system-executor: passed\n"; + return 0; +--- a/noexcept-browser/http/client/awaitable/http_client_awaitable.cpp ++++ b/noexcept-browser/http/client/awaitable/http_client_awaitable.cpp +@@ -34,24 +34,23 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -84,7 +83,7 @@ + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -93,14 +92,17 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -112,10 +114,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -125,9 +127,12 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +@@ -141,6 +146,8 @@ + #error "This application requires its declared Asio backend" + + #endif ++ ++} // namespace + + #include + #include +@@ -157,15 +164,20 @@ + { + std::vector storage{"http-client-awaitable", "127.0.0.1", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-awaitable: passed\n"; + return 0; +--- a/noexcept-browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/noexcept-browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -36,16 +36,14 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -55,14 +53,15 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::ssl_stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) +- beast::set_server_name(stream, host.c_str()).value(); ++ beast::set_server_name(stream, host).value(); + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); +@@ -102,7 +101,7 @@ + co_await http::async_read(stream, buffer, res, net::use_awaitable); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -127,12 +126,15 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && bool(ec)) ++ if (ec && static_cast(ec)) { + webcpp_fixture::fail_stop(); ++ } + } + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -144,10 +146,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -162,8 +164,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // Launch the asynchronous operation +@@ -171,9 +174,12 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +@@ -187,6 +193,8 @@ + #error "This application requires its declared Asio backend" + + #endif ++ ++} // namespace + + #include + #include +@@ -203,15 +211,20 @@ + { + std::vector storage{"http-client-awaitable-ssl", "localhost", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-awaitable-ssl: passed\n"; + return 0; +--- a/noexcept-browser/http/client/body/json_body.hpp ++++ b/noexcept-browser/http/client/body/json_body.hpp +@@ -34,6 +34,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -49,11 +50,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(webcpp::beast::http::header const&, value_type const& body) { ++ writer(webcpp::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -62,20 +66,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ reader(webcpp::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -83,8 +88,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -92,21 +99,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/noexcept-browser/http/client/body/json_client.cpp ++++ b/noexcept-browser/http/client/body/json_client.cpp +@@ -19,20 +19,19 @@ + #include "fixture.hpp" + #include "json_body.hpp" + +-#include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from ++using webcpp::asio::ip::tcp; // from + +-int application_main(int, char**) { ++namespace { ++int application_main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -67,7 +66,7 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -75,6 +74,8 @@ + + return 0; + } ++ ++} // namespace + + #include + #include +@@ -91,15 +92,20 @@ + { + std::vector storage{"json_client"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) ++ if (result != 0 || output.str().find("pure awesomeness") == std::string::npos) { + return 1; ++ } + } + std::cout << "application json_client: passed\n"; + return 0; +--- a/noexcept-browser/http/client/crawl/http_crawl.cpp ++++ b/noexcept-browser/http/client/crawl/http_crawl.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -48,20 +47,20 @@ + #include + #include + #include +-#include + + #include + #include + +-namespace chrono = std::chrono; // from +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++namespace chrono = std::chrono; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -69,7 +68,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(webcpp::asio::io_context& ioc) ++ explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -89,8 +88,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -127,9 +127,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -140,7 +141,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -168,11 +169,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -183,10 +185,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -198,10 +203,13 @@ + } + + void on_connect(beast::error_code ec, +- webcpp::asio::ip::tcp::resolver::results_type::endpoint_type) { ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp::asio::ip::tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -217,7 +225,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -231,7 +240,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -260,16 +270,18 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int application_main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[1])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; +@@ -277,11 +289,14 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. +- for (int index = 0; index < threads; ++index) ++ for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); ++ } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() +@@ -291,9 +306,10 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include +-#include + + int main() { + const auto port = emscripten::val::global("location")["port"].as(); +@@ -306,15 +322,20 @@ + { + std::vector storage{"http-crawl", "2"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Success : 3") == std::string::npos) ++ if (result != 0 || output.str().find("Success : 3") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-crawl: passed\n"; + return 0; +--- a/noexcept-browser/http/client/methods/http_client_methods.cpp ++++ b/noexcept-browser/http/client/methods/http_client_methods.cpp +@@ -36,19 +36,18 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from ++using webcpp::asio::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::browser::http_byte_stream& stream, + http::request& req, beast::flat_buffer buffer, + http::response& res) { +@@ -132,6 +131,8 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -143,8 +144,9 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); ++ } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +@@ -172,28 +174,28 @@ + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -202,8 +204,9 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } +@@ -211,6 +214,8 @@ + } + + //] ++ ++} // namespace + + #include + #include +@@ -227,15 +232,20 @@ + for (const auto* method : {"get", "head", "post", "put", "patch", "delete"}) { + std::vector storage{"http-client-methods", method}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("200 OK") == std::string::npos) ++ if (result != 0 || output.str().find("200 OK") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-methods: passed\n"; + return 0; +--- a/noexcept-browser/http/client/sync/http_client_sync.cpp ++++ b/noexcept-browser/http/client/sync/http_client_sync.cpp +@@ -35,19 +35,20 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from ++using webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -59,10 +60,10 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -94,7 +95,7 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +@@ -103,8 +104,9 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } +@@ -112,6 +114,8 @@ + } + + //] ++ ++} // namespace + + #include + #include +@@ -128,15 +132,20 @@ + { + std::vector storage{"http-client-sync", "127.0.0.1", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-sync: passed\n"; + return 0; +--- a/noexcept-browser/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/noexcept-browser/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -34,20 +34,21 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -59,10 +60,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -77,8 +78,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // These objects perform our I/O +@@ -117,7 +119,7 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +@@ -140,11 +142,14 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (bool(ec)) ++ if (static_cast(ec)) { + webcpp_fixture::fail_stop(); ++ } + } + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -161,15 +166,20 @@ + { + std::vector storage{"http-client-sync-ssl", "localhost", port, "/http"}; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("fetch body") == std::string::npos) ++ if (result != 0 || output.str().find("fetch body") == std::string::npos) { + return 1; ++ } + } + std::cout << "application http-client-sync-ssl: passed\n"; + return 0; +--- a/noexcept-browser/websocket/client/async/websocket_client_async.cpp ++++ b/noexcept-browser/websocket/client/async/websocket_client_async.cpp +@@ -39,17 +39,17 @@ + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++ ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -78,9 +78,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -91,9 +97,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -116,8 +128,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -127,8 +143,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -137,8 +157,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -146,18 +170,24 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -166,9 +196,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -182,6 +212,8 @@ + + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -196,18 +228,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-async", "127.0.0.1", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-async", ++ "127.0.0.1", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-async: passed\n"; + return 0; +--- a/noexcept-browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/noexcept-browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -34,7 +34,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + + #include + #include +@@ -43,16 +42,17 @@ + #include + #include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -87,9 +87,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -100,9 +106,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -119,8 +131,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -138,8 +154,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -149,8 +169,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -159,8 +183,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -168,18 +196,24 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -188,9 +222,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -202,8 +236,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // This holds the root certificate used for verification +@@ -218,6 +253,8 @@ + + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -232,18 +269,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-async-ssl", "localhost", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-async-ssl", ++ "localhost", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-async-ssl: passed\n"; + return 0; +--- a/noexcept-browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/noexcept-browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -34,7 +34,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + + #include + #include +@@ -44,16 +43,17 @@ + #include + #include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -68,6 +68,8 @@ + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +@@ -94,9 +96,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp::asio::ip::tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -107,9 +115,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::ip::tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -126,8 +140,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -145,8 +163,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -156,8 +178,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -166,8 +192,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -175,18 +205,24 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -195,9 +231,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +@@ -207,8 +243,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // This holds the root certificate used for verification +@@ -225,6 +262,8 @@ + return EXIT_SUCCESS; + } + ++} // namespace ++ + #include + #include + #include +@@ -238,18 +277,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-async-ssl-system-executor", "localhost", +- port, "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-async-ssl-system-executor", ++ "localhost", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-async-ssl-system-executor: passed\n"; + return 0; +--- a/noexcept-browser/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/noexcept-browser/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -36,22 +36,21 @@ + #include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; +-namespace http = beast::http; + namespace websocket = beast::websocket; + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -62,7 +61,8 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); ++ auto const ep = ++ co_await beast::get_lowest_layer(stream).async_connect(results, net::use_awaitable); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -97,11 +97,13 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -111,17 +113,20 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +@@ -136,6 +141,8 @@ + + #endif + ++} // namespace ++ + #include + #include + #include +@@ -149,18 +156,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-awaitable", "127.0.0.1", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-awaitable", ++ "127.0.0.1", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-awaitable: passed\n"; + return 0; +--- a/noexcept-browser/websocket/client/sync/websocket_client_sync.cpp ++++ b/noexcept-browser/websocket/client/sync/websocket_client_sync.cpp +@@ -40,15 +40,17 @@ + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -59,8 +61,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -73,7 +75,7 @@ + auto const results = webcpp_fixture::resolve(resolver, host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = ws.next_layer().connect(results); ++ auto const ep = ws.next_layer().connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -101,12 +103,14 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; + } + + //] ++ ++} // namespace + + #include + #include +@@ -121,18 +125,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-sync", "127.0.0.1", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-sync", ++ "127.0.0.1", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-sync: passed\n"; + return 0; +--- a/noexcept-browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/noexcept-browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -34,7 +34,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + + #include + #include +@@ -43,14 +42,17 @@ + #include + #include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++// from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = webcpp::asio::ssl; // from +-using tcp = webcpp::asio::ip::tcp; // from ++using webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++namespace { ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int application_main(int argc, char** argv) { + { + // Check command line arguments. +@@ -61,8 +63,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -74,8 +76,9 @@ + { + boost::system::error_code verify_error; + ctx.set_verify_mode(ssl::verify_peer, verify_error); +- if (verify_error) ++ if (verify_error) { + webcpp_fixture::fail_stop(); ++ } + } + + // This holds the root certificate used for verification +@@ -89,10 +92,10 @@ + auto const results = webcpp_fixture::resolve(resolver, host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).connect(results); ++ auto const ep = beast::get_lowest_layer(ws).connect(results); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- beast::set_server_name(ws.next_layer(), host.c_str()).value(); ++ beast::set_server_name(ws.next_layer(), host).value(); + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); +@@ -126,10 +129,12 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; + } ++ ++} // namespace + + #include + #include +@@ -144,18 +149,27 @@ + return 1; + } + { +- std::vector storage{"websocket-client-sync-ssl", "localhost", port, +- "Beast fixture echo"}; ++ std::vector storage{ ++ "websocket-client-sync-ssl", ++ "localhost", ++ port, ++ "Beast fixture echo", ++ }; + std::vector arguments; +- for (auto& value : storage) ++ arguments.reserve(storage.size()); ++ for (auto& value : storage) { + arguments.push_back(value.data()); ++ } ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); +- if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) ++ if (result != 0 || output.str().find("Beast fixture echo") == std::string::npos) { + return 1; ++ } + } + std::cout << "application websocket-client-sync-ssl: passed\n"; + return 0; +--- a/noexcept-native/advanced/server/advanced_server.cpp ++++ b/noexcept-native/advanced/server/advanced_server.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -48,8 +47,6 @@ + #include + #include + #include +-#include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -58,64 +55,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -127,8 +148,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -175,18 +197,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -194,12 +219,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -215,8 +242,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -242,6 +272,8 @@ + + // Start the asynchronous accept operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -259,8 +291,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -276,11 +312,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -291,8 +332,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -355,11 +400,19 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -374,8 +427,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -383,15 +437,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), +@@ -402,18 +457,24 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + +@@ -423,7 +484,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -438,34 +501,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -504,7 +577,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" +@@ -513,9 +590,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -535,17 +612,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/noexcept-native/advanced/server-flex/advanced_server_flex.cpp ++++ b/noexcept-native/advanced/server-flex/advanced_server_flex.cpp +@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -52,8 +51,6 @@ + #include + #include + #include +-#include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -63,64 +60,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -132,8 +153,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -180,18 +202,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -199,12 +224,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -220,8 +247,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -250,8 +280,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -263,6 +294,8 @@ + // the same code works with both SSL streams and regular sockets. + template + class websocket_session { ++ websocket_session() = default; ++ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } +@@ -271,6 +304,8 @@ + + // Start the asynchronous operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +@@ -290,8 +325,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -307,11 +346,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + derived().ws().text(derived().ws().got_text()); +@@ -323,8 +367,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -340,11 +388,15 @@ + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; +@@ -360,6 +412,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; +@@ -408,13 +462,15 @@ + boost::optional> parser_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Construct the session ++private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); +@@ -428,7 +484,7 @@ + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), buffer_, *parser_, ++ derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + +@@ -436,11 +492,16 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -457,8 +518,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -466,15 +528,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, +@@ -485,8 +548,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -495,18 +562,23 @@ + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + + do_write(); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -531,7 +603,9 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -540,6 +614,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; +@@ -559,7 +635,7 @@ + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, buffer_.data(), ++ ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + +@@ -581,18 +657,28 @@ + + private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -632,8 +718,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -657,34 +747,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -716,7 +816,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" +@@ -725,9 +829,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -753,17 +857,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/noexcept-native/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ b/noexcept-native/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -48,7 +47,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -57,69 +56,92 @@ + namespace ssl = boost::asio::ssl; + + using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = +- typename webcpp::asio::ip::tcp::acceptor::rebind_executor::other; ++using stream_type = beast::tcp_stream::rebind_executor::other; ++using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -131,8 +153,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -179,18 +202,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -198,12 +224,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -219,8 +247,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -237,7 +268,11 @@ + std::list css_; + + public: +- task_group(net::any_io_executor exec) ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ explicit task_group(net::any_io_executor exec) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +@@ -261,8 +296,8 @@ + */ + template + auto adapt(CompletionToken&& completion_token) { +- auto lg = std::lock_guard{mtx_}; +- auto cs = css_.emplace(css_.end()); ++ auto const lg = std::scoped_lock{mtx_}; ++ auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; +@@ -276,9 +311,10 @@ + + ~remover() { + if (tg_) { +- auto lg = std::lock_guard{tg_->mtx_}; +- if (tg_->css_.erase(cs_) == tg_->css_.end()) ++ auto const lg = std::scoped_lock{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); ++ } + } + } + }; +@@ -298,9 +334,10 @@ + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { +- auto lg = std::lock_guard{mtx_}; +- for (auto& cs : css_) ++ auto const lg = std::scoped_lock{mtx_}; ++ for (auto& cs : css_) { + cs.emit(type); ++ } + } + + /** Starts an asynchronous wait on the task_group. +@@ -327,24 +364,33 @@ + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( ++ // The apparent recursion crosses an asynchronous completion boundary. ++ // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { +- if (!scheduled) ++ if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); +- +- if (!self.cancelled() && ec == net::error::operation_aborted) ++ } ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; ++ } + + { +- auto lg = std::lock_guard{mtx_}; ++ auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + +- if (!std::exchange(scheduled, true)) ++ if (!std::exchange(scheduled, true)) { ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); ++ } + + self.complete(ec); + }, +@@ -356,7 +402,7 @@ + net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +@@ -375,11 +421,13 @@ + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + + // Echo the message back + ws.text(ws.got_text()); +@@ -392,14 +440,15 @@ + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + + template + net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; +@@ -407,8 +456,9 @@ + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + co_return; ++ } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. +@@ -449,25 +499,28 @@ + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + +- auto bytes_transferred = ++ auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if (!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) { + co_return; ++ } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } else { + co_await run_session(stream, buffer, doc_root); + +- if (!stream.socket().is_open()) ++ if (!stream.socket().is_open()) { + co_return; ++ } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +@@ -476,25 +529,31 @@ + net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; +- auto executor = co_await net::this_coro::executor; ++ auto const cs = co_await net::this_coro::cancellation_state; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { +@@ -506,9 +565,11 @@ + } + + net::awaitable handle_signals(task_group& task_group) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto sig = co_await signal_set.async_wait(); + + if (sig == SIGINT) { +@@ -533,7 +594,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" +@@ -542,10 +607,10 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -560,8 +625,10 @@ + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine +- auto listener_executor = net::make_strand(ioc); ++ auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { +@@ -576,14 +643,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/noexcept-native/common/root_certificates.hpp ++++ b/noexcept-native/common/root_certificates.hpp +@@ -62,7 +62,9 @@ + + inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { +- ctx.load_verify_file(path, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(ctx.load_verify_file(path, ec)); + return; + } + +@@ -3953,9 +3955,13 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); +- if (ec) ++ static_cast( ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); ++ if (ec) { + return; ++ } + } + + } // namespace detail +@@ -3969,8 +3975,9 @@ + inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if (ec) ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + } + + #endif +--- a/noexcept-native/doc/http_examples.hpp ++++ b/noexcept-native/doc/http_examples.hpp +@@ -24,7 +24,9 @@ + // Official repository: https://github.com/boostorg/beast + // + ++#include + #include ++#include + #include + + /* This file contains the functions and classes found in the documentation +@@ -35,9 +37,8 @@ + */ + + // The documentation assumes the webcpp::beast::http namespace +-namespace boost { +-namespace beast { +-namespace http { ++ ++namespace boost::beast::http { + + //------------------------------------------------------------------------------ + // +@@ -81,16 +82,18 @@ + + // Send just the header + write_header(stream, sr, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. +@@ -130,8 +133,9 @@ + + // Read the header + read_header(stream, buffer, parser, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { +@@ -141,8 +145,9 @@ + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + } + + // Read the rest of the message. +@@ -202,16 +207,17 @@ + + // Send the header immediately. + write_header(output, sr, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process +- char buffer[2048]; +- auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); ++ std::array buffer{}; ++ auto bytes_transferred = input.read_some(boost::asio::buffer(buffer), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + +@@ -221,13 +227,14 @@ + // `false` means no more data is coming + res.body().more = false; + } else { +- if (ec) ++ if (ec) { + return; ++ } + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming +- res.body().data = buffer; ++ res.body().data = buffer.data(); + res.body().size = bytes_transferred; + res.body().more = true; + } +@@ -242,8 +249,9 @@ + ec = {}; + continue; + } +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + } while (!sr.is_done()); + } + +@@ -271,8 +279,9 @@ + // Read the request + request req; + read(stream, buffer, req, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Set up the response, starting with the common fields + response res; +@@ -312,8 +321,9 @@ + + // Send the response + write(stream, res, ec); +- if (ec) ++ if (ec) { + return; ++ } + } + + //] +@@ -347,8 +357,9 @@ + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. +- if (target.empty()) ++ if (target.empty()) { + webcpp_fixture::fail_stop(); ++ } + + // Build the HEAD request for the target + request req; +@@ -363,8 +374,9 @@ + + // Now send it + write(stream, req, ec); +- if (ec) ++ if (ec) { + return {}; ++ } + + // Create a parser to read the response. + // We use the `empty_body` type since +@@ -379,8 +391,9 @@ + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return {}; ++ } + + // Transfer ownership of the response to the caller. + return p.release(); +@@ -437,7 +450,7 @@ + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece +- char buf[2048]; ++ std::array buf{}; + + // Create a parser with a buffer body to read from the input. + parser p; +@@ -447,39 +460,44 @@ + + // Read just the header from the input + read_header(input, buffer, p, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Apply the caller's header transformation + transform(p.get(), ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Send the transformed message to the output + write_header(output, sr, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer +- p.get().body().data = buf; +- p.get().body().size = sizeof(buf); ++ p.get().body().data = buf.data(); ++ p.get().body().size = buf.size(); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer +- if (ec == error::need_buffer) ++ if (ec == error::need_buffer) { + ec = {}; +- if (ec) ++ } ++ if (ec) { + return; ++ } + + // Set up the body for reading. + // This is how much was parsed: +- p.get().body().size = sizeof(buf) - p.get().body().size; +- p.get().body().data = buf; ++ p.get().body().size = buf.size() - p.get().body().size; ++ p.get().body().data = buf.data(); + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; +@@ -490,10 +508,12 @@ + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer +- if (ec == error::need_buffer) ++ if (ec == error::need_buffer) { + ec = {}; +- if (ec) +- return; ++ } ++ if (ec) { ++ return; ++ } + } while (!p.is_done() && !sr.is_done()); + } + +@@ -536,7 +556,13 @@ + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream +- os_.write(reinterpret_cast(buffer.data()), buffer.size()); ++ if (buffer.size() > ++ static_cast(std::numeric_limits::max())) { ++ ec = make_error_code(errc::value_too_large); ++ return; ++ } ++ os_.write(reinterpret_cast(buffer.data()), ++ static_cast(buffer.size())); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { +@@ -578,8 +604,9 @@ + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + } while (!sr.is_done()); + } + +@@ -648,8 +675,9 @@ + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); +- if (ec) ++ if (ec) { + return; ++ } + break; + } + } +@@ -658,10 +686,12 @@ + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. +- if (ec == error::need_more) ++ if (ec == error::need_more) { + ec = {}; +- if (ec) +- return; ++ } ++ if (ec) { ++ return; ++ } + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); +@@ -713,42 +743,16 @@ + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb +- switch (req0.get().method()) { +- case verb::post: { +- // If this is not a form upload then use a string_body +- if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && +- req0.get()[field::content_type] != "multipart/form-data") +- goto do_dynamic_body; +- +- // Commit to string_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } +- +- do_dynamic_body: +- default: { +- // Commit to dynamic_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } ++ if (req0.get().method() == verb::post && ++ (req0.get()[field::content_type] == "application/x-www-form-urlencoded" || ++ req0.get()[field::content_type] == "multipart/form-data")) { ++ request_parser req{std::move(req0)}; ++ read(stream, buffer, req); ++ handler(req.release()); ++ } else { ++ request_parser req{std::move(req0)}; ++ read(stream, buffer, req); ++ handler(req.release()); + } + } + +@@ -770,18 +774,21 @@ + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return; ++ } + while (!p.is_done()) { +- char buf[512]; +- p.get().body().data = buf; +- p.get().body().size = sizeof(buf); ++ std::array buf{}; ++ p.get().body().data = buf.data(); ++ p.get().body().size = buf.size(); + read(stream, buffer, p, ec); +- if (ec == error::need_buffer) ++ if (ec == error::need_buffer) { + ec = {}; +- if (ec) +- return; +- os.write(buf, sizeof(buf) - p.get().body().size); ++ } ++ if (ec) { ++ return; ++ } ++ os.write(buf.data(), static_cast(buf.size() - p.get().body().size)); + } + } + +@@ -807,8 +814,9 @@ + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return bytes_transferred; ++ } + msg = p.release(); + return bytes_transferred; + } +@@ -834,8 +842,9 @@ + + // First read the complete header + read_header(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // This container will hold the extensions for each chunk + chunk_extensions ce; +@@ -852,11 +861,12 @@ + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); +- if (ev) +- return; ++ if (ev) { ++ return; ++ } + + // See if the chunk is too big +- if (size > (std::numeric_limits::max)()) { ++ if (size > std::numeric_limits::max()) { + ev = error::body_limit; + return; + } +@@ -880,8 +890,9 @@ + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. +- if (remain == body.size()) ++ if (remain == body.size()) { + ec = error::end_of_chunk; ++ } + + // Append this piece to our container + chunk.append(body.data(), body.size()); +@@ -896,24 +907,26 @@ + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); +- if (!ec) ++ if (!ec) { + continue; +- else if (ec != error::end_of_chunk) +- return; +- else +- ec = {}; ++ } ++ if (ec != error::end_of_chunk) { ++ return; ++ } ++ ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; +- if (!extension.second.empty()) +- os << " = " << extension.second << std::endl; +- else +- os << std::endl; ++ if (!extension.second.empty()) { ++ os << " = " << extension.second << '\n' << std::flush; ++ } else { ++ os << '\n' << std::flush; ++ } + } + + // Now print the chunk body +- os << "Chunk Body: " << chunk << std::endl; ++ os << "Chunk Body: " << chunk << '\n' << std::flush; + } + + // Get a reference to the parsed message, this is for convenience +@@ -925,15 +938,13 @@ + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it +- os << "Missing Trailer: " << name << std::endl; ++ os << "Missing Trailer: " << name << '\n' << std::flush; + continue; + } +- os << it->name() << ": " << it->value() << std::endl; +- } +-} +- +-//] +- +-} // namespace http +-} // namespace beast +-} // namespace boost ++ os << it->name() << ": " << it->value() << '\n' << std::flush; ++ } ++} ++ ++//] ++ ++} // namespace boost::beast::http +--- a/noexcept-native/doc/ssl/client.cpp ++++ b/noexcept-native/doc/ssl/client.cpp +@@ -28,17 +28,19 @@ + #include + #include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + { +@@ -49,8 +51,8 @@ + + net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket +@@ -84,9 +86,12 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } ++ ++} // namespace + + int main() { + { +--- a/noexcept-native/doc/ssl/server.cpp ++++ b/noexcept-native/doc/ssl/server.cpp +@@ -28,17 +28,19 @@ + #include + #include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + { +@@ -63,14 +65,15 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + + net::awaitable acceptor(ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ auto const executor = co_await net::this_coro::executor; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { +@@ -78,6 +81,8 @@ + print_exception); + } + } ++ ++} // namespace + + int main() { + { +@@ -93,6 +98,8 @@ + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. ++ // Asio exposes the OpenSSL verification bitmask as signed integer constants. ++ // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this +--- a/noexcept-native/echo-op/echo_op.cpp ++++ b/noexcept-native/echo-op/echo_op.cpp +@@ -36,12 +36,12 @@ + + //[example_core_echo_op_1 + ++namespace { + template + auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] +- -> typename net::async_result::type, +- void(beast::error_code)>::return_type; ++ -> net::async_result, void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -67,7 +67,7 @@ + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the +- first line. These characters are stored in the dynamic buffer_. ++ first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + +@@ -94,14 +94,18 @@ + `net::post`. + */ + template ++// Upstream documentation repeats the initiating signature before its implementation. ++// NOLINTNEXTLINE(readability-redundant-declaration) ++// Each documentation snippet presents the complete public declaration. ++// NOLINTNEXTLINE(readability-redundant-declaration) + auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> typename net:: +- async_result*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) ++ -> net::async_result*/ ++ std::decay_t, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 +@@ -117,10 +121,14 @@ + // Read a line and echo it back + // + template +-auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> +- typename net::async_result::type, +- void(beast::error_code)>::return_type /*< The completion handler +- signature goes here >*/ ++// The retained stackless coroutine expands each yield into nested resume branches. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++// Stackless coroutine macros generate the branches in this operation. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ -> net::async_result, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +@@ -163,9 +171,13 @@ + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + ++ // Upstream combines coroutine state and shared lifetime as independent mixins. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) ++ // Asio operation state combines completion ownership with coroutine resume state. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { +- AsyncStream& stream_; +- DynamicBuffer& buffer_; ++ AsyncStream& stream; ++ DynamicBuffer& buffer; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +@@ -173,8 +185,8 @@ + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , +- stream_(stream), +- buffer_(buffer) { ++ stream(stream), ++ buffer(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -186,19 +198,22 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { ++ static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = ++ auto const begin = + net::buffers_iterator::begin(buffers); +- auto end = ++ auto const end = + net::buffers_iterator::end(buffers); +- auto result = std::find(begin, end, '\n'); +- +- if (result == end) ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) ++ const auto result = std::find(begin, end, '\n'); ++ ++ if (result == end) { + return 0; // not found ++ } + + return result + 1 - begin; + } +@@ -206,6 +221,10 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) ++ // Resume labels generated by the stackless coroutine form one state machine. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ +@@ -216,13 +235,21 @@ + + reenter(*this) { + for (;;) { ++ // Stackless resume labels require this local to be assigned after resumption. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) ++ // Resume labels cannot cross an initialized local; it is assigned before use. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer +- pos = find_newline(buffer_.data()); ++ pos = find_newline(buffer.data()); + + // If we don't have the newline, then read more + if (pos == 0) { ++ // Stackless resume labels require this local to be assigned after ++ // resumption. NOLINTNEXTLINE(cppcoreguidelines-init-variables) ++ // Resume labels cannot cross an initialized local; it is assigned before ++ // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, +@@ -230,18 +257,18 @@ + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), ++ buffer.capacity() - buffer.size()), + std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); +- +- // Read some data into our dynamic buffer_. We transfer ++ buffer.max_size() - buffer.size())); ++ ++ // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some(buffer_.prepare(bytes_to_read), +- std::move(*this)); ++ yield stream.async_read_some(buffer.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -249,11 +276,12 @@ + // Move the bytes read from the writable area to the + // readable area. + +- buffer_.commit(bytes_transferred); ++ buffer.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if (ec) ++ if (ec) { + break; ++ } + + // Keep looping until we get the newline + continue; +@@ -263,7 +291,7 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ yield net::async_write(stream, beast::buffers_prefix(pos, buffer.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will +@@ -275,7 +303,7 @@ + // to consume. With "real" coroutines this will be easier and more + // natural. + +- buffer_.consume(bytes_transferred); ++ buffer.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. +@@ -325,11 +353,16 @@ + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { +- if (ec) +- std::cerr << ": " << ec.message() << std::endl; ++ if (ec) { ++ std::cerr << ": " << ec.message() << '\n'; ++ } + } + }; + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" +@@ -340,7 +373,7 @@ + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + +@@ -348,7 +381,7 @@ + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; +- endpoint_type ep(address, port); ++ endpoint_type const ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); +--- a/noexcept-native/http/client/async/http_client_async.cpp ++++ b/noexcept-native/http/client/async/http_client_async.cpp +@@ -31,14 +31,12 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +46,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -80,9 +79,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -92,9 +97,15 @@ + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -107,8 +118,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -118,18 +133,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -137,6 +162,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -147,10 +176,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-native/http/client/async-local/http_client_async_local.cpp ++++ b/noexcept-native/http/client/async-local/http_client_async_local.cpp +@@ -32,25 +32,24 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -84,8 +83,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -98,8 +101,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -109,18 +116,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -128,6 +145,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { +@@ -138,11 +159,11 @@ + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const target = argv[4]; +- int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; ++ const auto* const path = argv[1]; ++ const auto* const host = argv[2]; ++ const auto* const port = argv[3]; ++ const auto* const target = argv[4]; ++ int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-native/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/noexcept-native/http/client/async-ssl/http_client_async_ssl.cpp +@@ -35,12 +35,10 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -92,9 +91,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -104,9 +109,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -115,8 +126,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -129,8 +144,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -140,11 +159,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -154,6 +177,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -172,13 +197,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -189,10 +222,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-native/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/noexcept-native/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -36,12 +36,10 @@ + #include + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +50,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -99,9 +98,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -111,9 +116,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -122,8 +133,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -136,8 +151,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -147,11 +166,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -161,6 +184,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -179,13 +204,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -196,10 +229,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- a/noexcept-native/http/client/awaitable/http_client_awaitable.cpp ++++ b/noexcept-native/http/client/awaitable/http_client_awaitable.cpp +@@ -33,24 +33,23 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -84,23 +83,30 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -112,10 +118,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -125,9 +131,12 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +--- a/noexcept-native/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/noexcept-native/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -36,9 +36,7 @@ + #include + #include + #include +-#include + #include +-#include + + #include "common/root_certificates.hpp" + +@@ -46,7 +44,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -56,6 +54,7 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +@@ -106,7 +105,7 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -131,12 +130,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -148,10 +152,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -170,9 +174,12 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +--- a/noexcept-native/http/client/body/json_body.hpp ++++ b/noexcept-native/http/client/body/json_body.hpp +@@ -33,6 +33,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -48,11 +49,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(webcpp::beast::http::header const&, value_type const& body) { ++ writer(webcpp::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -61,20 +65,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ reader(webcpp::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -82,8 +87,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -91,21 +98,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/noexcept-native/http/client/body/json_client.cpp ++++ b/noexcept-native/http/client/body/json_client.cpp +@@ -18,20 +18,18 @@ + #include "fixture.hpp" + #include "json_body.hpp" + +-#include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char**) { ++int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -66,11 +64,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; + } +--- a/noexcept-native/http/client/coro/http_client_coro.cpp ++++ b/noexcept-native/http/client/coro/http_client_coro.cpp +@@ -114,6 +114,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +--- a/noexcept-native/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ b/noexcept-native/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -153,6 +153,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +--- a/noexcept-native/http/client/crawl/http_crawl.cpp ++++ b/noexcept-native/http/client/crawl/http_crawl.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -50,7 +49,6 @@ + #include + #include + #include +-#include + + namespace chrono = std::chrono; // from + namespace beast = webcpp::beast; // from +@@ -61,6 +59,7 @@ + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -68,7 +67,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(webcpp::asio::io_context& ioc) ++ explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -88,8 +87,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -126,9 +126,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -139,7 +140,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -168,11 +169,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -183,10 +185,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -197,10 +202,13 @@ + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -216,7 +224,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -230,7 +239,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -240,7 +250,9 @@ + }); + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully +@@ -259,16 +271,20 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- auto const threads = std::max(1, std::atoi(argv[1])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; +@@ -276,6 +292,8 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Create and launch the worker threads. +@@ -286,7 +304,11 @@ + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto reporting_work = ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); + + workers.emplace_back([&report, reporting_work] { +@@ -307,8 +329,9 @@ + }); + + // Now block until all threads exit +- for (std::size_t i = 0; i < workers.size(); ++i) +- workers[i].join(); ++ for (auto& worker : workers) { ++ worker.join(); ++ } + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; +--- a/noexcept-native/http/client/methods/http_client_methods.cpp ++++ b/noexcept-native/http/client/methods/http_client_methods.cpp +@@ -34,19 +34,18 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); +@@ -124,6 +123,10 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -135,8 +138,9 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); ++ } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +@@ -163,38 +167,41 @@ + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } +--- a/noexcept-native/http/client/sync/http_client_sync.cpp ++++ b/noexcept-native/http/client/sync/http_client_sync.cpp +@@ -34,19 +34,19 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -58,10 +58,10 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -94,17 +94,20 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } +--- a/noexcept-native/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/noexcept-native/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -36,11 +36,9 @@ + #include + #include + #include +-#include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,6 +47,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -60,10 +60,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -116,11 +116,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +- stream.shutdown(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -139,8 +141,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + return EXIT_SUCCESS; + } +--- a/noexcept-native/http/server/async/http_server_async.cpp ++++ b/noexcept-native/http/server/async/http_server_async.cpp +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -43,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,64 +49,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -120,8 +142,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -168,18 +191,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -187,12 +213,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -208,8 +236,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -263,18 +294,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -285,13 +324,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -301,7 +345,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -316,34 +362,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -364,10 +420,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -376,7 +431,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" +@@ -385,9 +444,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -398,10 +457,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/http/server/async-local/http_server_async_local.cpp ++++ b/noexcept-native/http/server/async-local/http_server_async_local.cpp +@@ -34,10 +34,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -47,72 +45,96 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -124,8 +146,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -172,18 +195,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -191,12 +217,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -212,8 +240,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -268,18 +299,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -290,13 +329,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -306,7 +350,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -321,8 +367,12 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +@@ -339,10 +389,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -351,7 +400,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { +@@ -360,15 +413,15 @@ + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; ++ const auto* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); +@@ -376,10 +429,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/http/server/async-ssl/http_server_async_ssl.cpp ++++ b/noexcept-native/http/server/async-ssl/http_server_async_ssl.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -46,7 +45,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -55,64 +53,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -124,8 +146,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -172,18 +195,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -191,12 +217,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -212,8 +240,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -242,8 +273,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -282,8 +314,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + do_read(); + } +@@ -305,18 +341,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -327,13 +371,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -349,9 +398,15 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -367,34 +422,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -415,10 +480,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), ctx_, doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -427,7 +491,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" +@@ -436,9 +504,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -455,10 +523,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/http/server/awaitable/http_server_awaitable.cpp ++++ b/noexcept-native/http/server/awaitable/http_server_awaitable.cpp +@@ -34,10 +34,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -47,71 +45,95 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -238,7 +269,7 @@ + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); +@@ -261,12 +292,14 @@ + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +@@ -277,7 +310,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +@@ -286,15 +323,17 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +@@ -306,10 +345,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- a/noexcept-native/http/server/coro/http_server_coro.cpp ++++ b/noexcept-native/http/server/coro/http_server_coro.cpp +@@ -313,7 +313,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" +@@ -322,9 +324,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-native/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ b/noexcept-native/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -350,7 +350,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" +@@ -359,9 +361,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-native/http/server/fast/fields_alloc.hpp ++++ b/noexcept-native/http/server/fast/fields_alloc.hpp +@@ -34,7 +34,7 @@ + + namespace detail { + +-struct static_pool { ++class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; +@@ -46,7 +46,7 @@ + + public: + static static_pool& construct(std::size_t size) { +- auto p = new char[sizeof(static_pool) + size]; ++ auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + +@@ -56,25 +56,28 @@ + } + + void destroy() { +- if (--refs_) ++ if ((--refs_) != 0u) { + return; ++ } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { +- auto last = p_ + n; +- if (last >= end()) ++ auto* last = p_ + n; ++ if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); ++ } + ++count_; +- auto p = p_; ++ auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { +- if (--count_) ++ if ((--count_) != 0u) { + return; ++ } + p_ = reinterpret_cast(this + 1); + } + }; +@@ -99,7 +102,7 @@ + */ + template + struct fields_alloc { +- detail::static_pool* pool_; ++ detail::static_pool* pool; + + public: + using value_type = T; +@@ -123,20 +126,21 @@ + fields_alloc() = default; + #endif + +- explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ explicit fields_alloc(fields_alloc const& other) ++ : pool(&detail::static_pool::share(*other.pool)) {} + +- ~fields_alloc() { pool_->destroy(); } ++ ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { +- return static_cast(pool_->alloc(n * sizeof(T))); ++ return static_cast(pool->alloc(n * sizeof(T))); + } + +- void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + + #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template +@@ -152,7 +156,7 @@ + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { +- return &lhs.pool_ == &rhs.pool_; ++ return &lhs.pool == &rhs.pool_; + } + + template +--- a/noexcept-native/http/server/fast/http_server_fast.cpp ++++ b/noexcept-native/http/server/fast/http_server_fast.cpp +@@ -33,7 +33,6 @@ + #include "fields_alloc.hpp" + + #include +-#include + #include + #include + #include +@@ -42,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,56 +48,79 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + +@@ -108,6 +129,8 @@ + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + ++ // Retain the upstream borrowing constructor contract in this reference counterpart. ++ // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + +@@ -141,7 +164,7 @@ + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), +- (std::chrono::steady_clock::time_point::max)()}; ++ std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> +@@ -161,7 +184,9 @@ + void accept() { + // Clean up any previous connection. + beast::error_code ec; +- socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { +@@ -191,24 +216,23 @@ + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { +- if (ec) ++ if (ec) { + accept(); +- else ++ } else { + process_request(parser_->get()); ++ } + }); + } + + void process_request(http::request> const& req) { +- switch (req.method()) { +- case http::verb::get: send_file(req.target()); break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; ++ if (req.method() == http::verb::get) { ++ send_file(req.target()); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + +@@ -226,7 +250,9 @@ + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); +@@ -235,7 +261,7 @@ + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } +@@ -264,7 +290,9 @@ + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); +@@ -278,14 +306,18 @@ + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 6) { +@@ -299,9 +331,11 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- std::string doc_root = argv[3]; +- int num_workers = std::atoi(argv[4]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ std::string const doc_root = argv[3]; ++ int const num_workers = webcpp_fixture::integer(argv[4]); ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; +@@ -313,10 +347,12 @@ + workers.back().start(); + } + +- if (spin) +- for (;;) ++ if (spin) { ++ for (;;) { + ioc.poll(); +- else ++ } ++ } else { + ioc.run(); // lint-run: drives the application's network operations ++ } + } + } +--- a/noexcept-native/http/server/flex/http_server_flex.cpp ++++ b/noexcept-native/http/server/flex/http_server_flex.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -45,7 +44,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,64 +52,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -241,8 +272,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -260,20 +292,22 @@ + http::request req_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Take ownership of the buffer ++private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), buffer_, req_, ++ derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + +@@ -281,18 +315,23 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), +@@ -303,8 +342,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -315,9 +358,13 @@ + // Read another request + do_read(); + } ++ ++ friend Derived; + }; + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -344,13 +391,17 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + }; + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +@@ -365,27 +416,33 @@ + + // Start the asynchronous operation + void run() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. +- net::dispatch(stream_.get_executor(), [self]() { ++ net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, self->buffer_.data(), ++ ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } +@@ -399,9 +456,15 @@ + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -432,8 +495,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -457,34 +524,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -516,7 +593,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" +@@ -525,9 +606,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -544,10 +625,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/http/server/small/http_server_small.cpp ++++ b/noexcept-native/http/server/small/http_server_small.cpp +@@ -31,7 +31,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include +@@ -39,13 +38,13 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + using tcp = webcpp::asio::ip::tcp; // from + ++namespace { + namespace my_program_state { + std::size_t request_count() { + static std::size_t count = 0; +@@ -53,13 +52,13 @@ + } + + std::time_t now() { +- return std::time(0); ++ return std::time(nullptr); + } + } // namespace my_program_state + + class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) : socket_(std::move(socket)) {} ++ explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { +@@ -85,13 +84,16 @@ + + // Asynchronously receive a complete request message. + void read_request() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- if (!ec) ++ if (!ec) { + self->process_request(); ++ } + }); + } + +@@ -100,21 +102,17 @@ + response_.version(request_.version()); + response_.keep_alive(false); + +- switch (request_.method()) { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" << std::string(request_.method_string()) << "'"; +- break; ++ if (request_.method() == http::verb::get) { ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); +@@ -152,24 +150,32 @@ + + // Asynchronously transmit the response message. + void write_response() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.close(ec)); + } + }); + } +@@ -178,13 +184,18 @@ + // "Loop" forever accepting new connections. + void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { +- if (!ec) ++ if (!ec) { + std::make_shared(std::move(socket))->start(); ++ } + http_server(acceptor, socket); + }); + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -197,7 +208,7 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + +--- a/noexcept-native/http/server/stackless/http_server_stackless.cpp ++++ b/noexcept-native/http/server/stackless/http_server_stackless.cpp +@@ -34,7 +34,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -44,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,64 +50,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -121,8 +143,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -169,18 +192,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -188,12 +214,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -209,8 +237,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -226,6 +257,8 @@ + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; +@@ -251,6 +284,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -271,8 +306,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -287,8 +326,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -297,7 +340,9 @@ + } + + // Send a TCP shutdown +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -309,6 +354,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; +@@ -316,6 +363,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -325,28 +374,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -357,8 +414,12 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { +@@ -377,12 +438,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" +@@ -391,9 +458,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -404,10 +471,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ b/noexcept-native/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -48,7 +47,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -57,64 +55,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -126,8 +148,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -174,18 +197,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -193,12 +219,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -214,8 +242,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -244,13 +275,16 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; +@@ -277,6 +311,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -286,9 +322,15 @@ + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + for (;;) { + // Set the timeout. +@@ -307,8 +349,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -323,8 +369,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -337,9 +387,15 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -351,6 +407,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -359,6 +417,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -369,28 +429,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -401,12 +469,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -421,12 +495,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" +@@ -435,9 +515,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -454,10 +534,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/http/server/sync/http_server_sync.cpp ++++ b/noexcept-native/http/server/sync/http_server_sync.cpp +@@ -31,7 +31,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include +@@ -39,7 +38,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,64 +47,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -118,8 +140,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -166,18 +189,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -185,12 +211,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -206,8 +234,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -233,22 +264,31 @@ + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -257,14 +297,20 @@ + } + + // Send a TCP shutdown +- socket.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { +@@ -274,7 +320,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -290,6 +336,8 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } + } +--- a/noexcept-native/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ b/noexcept-native/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -44,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,64 +51,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -122,8 +144,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -170,18 +193,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -189,12 +215,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -210,8 +238,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -235,9 +266,15 @@ + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake +- stream.handshake(ssl::stream_base::server, ec); +- if (ec) +- return fail(ec, "handshake"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.handshake(ssl::stream_base::server, ec)); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -246,22 +283,31 @@ + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -271,16 +317,26 @@ + } + + // Perform the SSL shutdown +- stream.shutdown(ec); +- if (ec) +- return fail(ec, "shutdown"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { +@@ -290,7 +346,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -312,6 +368,8 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} + .detach(); + } +--- a/noexcept-native/websocket/client/async/websocket_client_async.cpp ++++ b/noexcept-native/websocket/client/async/websocket_client_async.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,6 +48,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -77,9 +77,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -89,9 +95,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -117,8 +129,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -128,8 +144,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -138,8 +158,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -147,18 +171,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -167,9 +199,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-native/websocket/client/async-local/websocket_client_async_local.cpp ++++ b/noexcept-native/websocket/client/async-local/websocket_client_async_local.cpp +@@ -35,24 +35,24 @@ + #include + #include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -81,8 +81,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); +@@ -99,8 +103,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -110,8 +118,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -120,8 +132,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -129,18 +145,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { +@@ -150,10 +174,10 @@ + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const text = argv[4]; ++ const auto* const path = argv[1]; ++ const auto* const host = argv[2]; ++ const auto* const port = argv[3]; ++ const auto* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-native/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/noexcept-native/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -93,9 +93,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -105,9 +111,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -124,8 +136,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -146,8 +162,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -157,8 +177,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -167,8 +191,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -176,18 +204,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -196,9 +232,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-native/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/noexcept-native/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -43,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -55,6 +54,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -99,9 +99,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -111,9 +117,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -130,8 +142,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -152,8 +168,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -163,8 +183,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -173,8 +197,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -182,18 +210,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -202,9 +238,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- a/noexcept-native/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/noexcept-native/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -35,13 +35,12 @@ + #include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -49,8 +48,9 @@ + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -61,7 +61,7 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); ++ auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -99,11 +99,15 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -113,17 +117,20 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +--- a/noexcept-native/websocket/client/coro/websocket_client_coro.cpp ++++ b/noexcept-native/websocket/client/coro/websocket_client_coro.cpp +@@ -123,6 +123,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +--- a/noexcept-native/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ b/noexcept-native/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -146,6 +146,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +--- a/noexcept-native/websocket/client/sync/websocket_client_sync.cpp ++++ b/noexcept-native/websocket/client/sync/websocket_client_sync.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +47,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -58,8 +59,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -72,7 +73,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(ws.next_layer(), results); ++ auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -103,7 +104,7 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; + } +--- a/noexcept-native/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/noexcept-native/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +51,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -62,8 +63,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -85,7 +86,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(beast::get_lowest_layer(ws), results); ++ auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { +@@ -127,7 +128,7 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; + } +--- a/noexcept-native/websocket/server/async/websocket_server_async.cpp ++++ b/noexcept-native/websocket/server/async/websocket_server_async.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,6 +52,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -91,8 +91,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -107,11 +111,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -122,8 +131,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -141,32 +154,42 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -198,7 +221,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" +@@ -207,8 +234,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -219,10 +246,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/websocket/server/async-local/websocket_server_async_local.cpp ++++ b/noexcept-native/websocket/server/async-local/websocket_server_async_local.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -46,17 +45,18 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -95,8 +95,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -111,11 +115,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -126,8 +135,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -145,7 +158,11 @@ + stream_protocol::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +@@ -162,10 +179,9 @@ + if (ec) { + fail(ec, "accept"); + return; +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket))->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); +@@ -174,7 +190,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -183,14 +203,14 @@ + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const threads = std::max(1, std::atoi(argv[2])); ++ const auto* const path = argv[1]; ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); +@@ -198,10 +218,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ b/noexcept-native/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -46,7 +46,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -58,6 +57,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -93,8 +93,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -114,8 +118,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -130,11 +138,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -145,8 +158,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -165,33 +182,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -223,7 +250,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -232,8 +263,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -250,10 +281,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ b/noexcept-native/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -45,7 +44,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -53,6 +52,7 @@ + namespace net = boost::asio; + + // Echoes back all received WebSocket messages ++namespace { + net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -73,11 +73,13 @@ + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + co_return; ++ } + +- if (ec) ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + + // Echo the message back + stream.text(stream.got_text()); +@@ -87,13 +89,15 @@ + + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +@@ -104,7 +108,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" +@@ -113,14 +121,16 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +@@ -132,10 +142,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- a/noexcept-native/websocket/server/chat-multi/http_session.cpp ++++ b/noexcept-native/websocket/server/chat-multi/http_session.cpp +@@ -33,64 +33,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -102,8 +126,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -150,18 +175,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -169,12 +197,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -190,8 +220,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -201,6 +234,8 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ + http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +@@ -209,10 +244,13 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -233,16 +271,22 @@ + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + +-void http_session::on_read(beast::error_code ec, std::size_t) { ++void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -257,8 +301,10 @@ + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); +- ++ bool const keep_alive = msg.keep_alive(); ++ ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response +@@ -268,15 +314,21 @@ + }); + } + +-void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { ++void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + +--- a/noexcept-native/websocket/server/chat-multi/http_session.hpp ++++ b/noexcept-native/websocket/server/chat-multi/http_session.hpp +@@ -50,8 +50,8 @@ + + void fail(beast::error_code ec, char const* what); + void do_read(); +- void on_read(beast::error_code ec, std::size_t); +- void on_write(beast::error_code ec, std::size_t, bool close); ++ void on_read(beast::error_code ec, std::size_t /*unused*/); ++ void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + + public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); +--- a/noexcept-native/websocket/server/chat-multi/listener.cpp ++++ b/noexcept-native/websocket/server/chat-multi/listener.cpp +@@ -28,34 +28,44 @@ + #include "http_session.hpp" + #include "listener.hpp" + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -69,20 +79,28 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection + void listener::on_accept(beast::error_code ec, tcp::socket socket) { +- if (ec) +- return fail(ec, "accept"); +- else ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } ++ { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); ++ } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), +--- a/noexcept-native/websocket/server/chat-multi/main.cpp ++++ b/noexcept-native/websocket/server/chat-multi/main.cpp +@@ -44,7 +44,9 @@ + #include + #include + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" +@@ -52,10 +54,10 @@ + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } +- auto address = net::ip::make_address(argv[1]); +- auto port = static_cast(std::atoi(argv[2])); +- auto doc_root = argv[3]; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto* doc_root = argv[3]; ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -77,17 +79,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/noexcept-native/websocket/server/chat-multi/shared_state.cpp ++++ b/noexcept-native/websocket/server/chat-multi/shared_state.cpp +@@ -28,15 +28,15 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} ++shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + + void shared_state::join(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + sessions_.insert(session); + } + + void shared_state::leave(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + sessions_.erase(session); + } + +@@ -50,15 +50,20 @@ + // holding the mutex: + std::vector> v; + { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + v.reserve(sessions_.size()); +- for (auto p : sessions_) ++ for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); ++ } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for (auto const& wp : v) +- if (auto sp = wp.lock()) ++ for (auto const& wp : v) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) ++ if (const auto sp = wp.lock()) { + sp->send(ss); ++ } ++ } + } +--- a/noexcept-native/websocket/server/chat-multi/shared_state.hpp ++++ b/noexcept-native/websocket/server/chat-multi/shared_state.hpp +@@ -39,7 +39,7 @@ + + // Represents the shared server state + class shared_state { +- std::string const doc_root_; ++ std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; +@@ -50,7 +50,7 @@ + public: + explicit shared_state(std::string doc_root); + +- std::string const& doc_root() const noexcept { return doc_root_; } ++ [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); +--- a/noexcept-native/websocket/server/chat-multi/websocket_session.cpp ++++ b/noexcept-native/websocket/server/chat-multi/websocket_session.cpp +@@ -37,18 +37,25 @@ + state_->leave(this); + } + ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if (ec == net::error::operation_aborted || ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Add this session to the list of active sessions + state_->join(this); +@@ -58,10 +65,14 @@ + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void websocket_session::on_read(beast::error_code ec, std::size_t) { ++void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); +@@ -88,25 +99,31 @@ + queue_.push_back(ss); + + // Are we already writing? +- if (queue_.size() > 1) ++ if (queue_.size() > 1) { + return; ++ } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void websocket_session::on_write(beast::error_code ec, std::size_t) { ++void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if (!queue_.empty()) ++ if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); ++ } + } +--- a/noexcept-native/websocket/server/chat-multi/websocket_session.hpp ++++ b/noexcept-native/websocket/server/chat-multi/websocket_session.hpp +@@ -69,6 +69,8 @@ + }; + + template ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +--- a/noexcept-native/websocket/server/coro/websocket_server_coro.cpp ++++ b/noexcept-native/websocket/server/coro/websocket_server_coro.cpp +@@ -140,7 +140,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" +@@ -149,8 +151,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); +--- a/noexcept-native/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ b/noexcept-native/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -159,7 +159,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" +@@ -168,8 +170,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-native/websocket/server/fast/websocket_server_fast.cpp ++++ b/noexcept-native/websocket/server/fast/websocket_server_fast.cpp +@@ -345,7 +345,9 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" +@@ -358,8 +360,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-native/websocket/server/stackless/websocket_server_stackless.cpp ++++ b/noexcept-native/websocket/server/stackless/websocket_server_stackless.cpp +@@ -43,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,11 +53,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; +@@ -80,6 +82,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -94,29 +98,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -130,39 +153,51 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -173,12 +208,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -193,12 +234,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" +@@ -207,8 +254,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -219,10 +266,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ b/noexcept-native/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -48,7 +48,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -60,11 +59,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -86,6 +88,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +@@ -96,9 +100,15 @@ + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -115,29 +125,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -151,6 +180,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -158,33 +189,43 @@ + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -195,12 +236,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -215,12 +262,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -229,8 +282,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -247,10 +300,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/noexcept-native/websocket/server/sync/websocket_server_sync.cpp ++++ b/noexcept-native/websocket/server/sync/websocket_server_sync.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket) { + { + // Construct the stream by moving in the socket +@@ -88,7 +88,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -98,7 +102,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +--- a/noexcept-native/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ b/noexcept-native/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -44,7 +44,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -56,6 +55,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket, ssl::context& ctx) { + { + // Construct the websocket stream around the socket +@@ -97,7 +97,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -107,7 +111,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +--- a/noexcept-single/advanced/server/advanced_server.cpp ++++ b/noexcept-single/advanced/server/advanced_server.cpp +@@ -34,10 +34,7 @@ + + #include + #include +-#include + #include +-#include +-#include + + #include + #include +@@ -59,64 +56,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -128,8 +149,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -176,18 +198,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -195,12 +220,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -216,8 +243,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -243,6 +273,8 @@ + + // Start the asynchronous accept operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -260,8 +292,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -277,11 +313,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -292,8 +333,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -356,11 +401,19 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -375,8 +428,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -384,15 +438,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), +@@ -403,18 +458,24 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + +@@ -424,7 +485,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -439,34 +502,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -505,7 +578,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" +@@ -514,9 +591,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/advanced/server-flex/advanced_server_flex.cpp ++++ b/noexcept-single/advanced/server-flex/advanced_server_flex.cpp +@@ -37,11 +37,8 @@ + + #include + #include +-#include + #include + #include +-#include +-#include + + #include + #include +@@ -64,64 +61,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -133,8 +154,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -181,18 +203,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -200,12 +225,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -221,8 +248,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -251,8 +281,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -264,6 +295,8 @@ + // the same code works with both SSL streams and regular sockets. + template + class websocket_session { ++ websocket_session() = default; ++ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } +@@ -272,6 +305,8 @@ + + // Start the asynchronous operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +@@ -291,8 +326,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -308,11 +347,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + derived().ws().text(derived().ws().got_text()); +@@ -324,8 +368,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -341,11 +389,15 @@ + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; +@@ -361,6 +413,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; +@@ -409,13 +463,15 @@ + boost::optional> parser_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Construct the session ++private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); +@@ -429,7 +485,7 @@ + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), buffer_, *parser_, ++ derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + +@@ -437,11 +493,16 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -458,8 +519,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -467,15 +529,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, +@@ -486,8 +549,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -496,18 +563,23 @@ + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + + do_write(); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -532,7 +604,9 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -541,6 +615,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; +@@ -560,7 +636,7 @@ + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, buffer_.data(), ++ ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + +@@ -582,18 +658,28 @@ + + private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -633,8 +719,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -658,34 +748,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -717,7 +817,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" +@@ -726,9 +830,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ b/noexcept-single/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -48,9 +48,7 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include +@@ -60,7 +58,7 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -69,69 +67,92 @@ + namespace ssl = boost::asio::ssl; + + using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = +- typename webcpp::asio::ip::tcp::acceptor::rebind_executor::other; ++using stream_type = beast::tcp_stream::rebind_executor::other; ++using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -143,8 +164,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -191,18 +213,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -210,12 +235,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -231,8 +258,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -249,7 +279,11 @@ + std::list css_; + + public: +- task_group(net::any_io_executor exec) ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ explicit task_group(net::any_io_executor exec) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +@@ -273,8 +307,8 @@ + */ + template + auto adapt(CompletionToken&& completion_token) { +- auto lg = std::lock_guard{mtx_}; +- auto cs = css_.emplace(css_.end()); ++ auto const lg = std::scoped_lock{mtx_}; ++ auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; +@@ -288,9 +322,10 @@ + + ~remover() { + if (tg_) { +- auto lg = std::lock_guard{tg_->mtx_}; +- if (tg_->css_.erase(cs_) == tg_->css_.end()) ++ auto const lg = std::scoped_lock{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); ++ } + } + } + }; +@@ -310,9 +345,10 @@ + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { +- auto lg = std::lock_guard{mtx_}; +- for (auto& cs : css_) ++ auto const lg = std::scoped_lock{mtx_}; ++ for (auto& cs : css_) { + cs.emit(type); ++ } + } + + /** Starts an asynchronous wait on the task_group. +@@ -339,24 +375,33 @@ + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( ++ // The apparent recursion crosses an asynchronous completion boundary. ++ // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { +- if (!scheduled) ++ if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); +- +- if (!self.cancelled() && ec == net::error::operation_aborted) ++ } ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; ++ } + + { +- auto lg = std::lock_guard{mtx_}; ++ auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + +- if (!std::exchange(scheduled, true)) ++ if (!std::exchange(scheduled, true)) { ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); ++ } + + self.complete(ec); + }, +@@ -368,7 +413,7 @@ + net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +@@ -387,11 +432,13 @@ + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + + // Echo the message back + ws.text(ws.got_text()); +@@ -404,14 +451,15 @@ + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + + template + net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; +@@ -419,8 +467,9 @@ + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + co_return; ++ } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. +@@ -461,25 +510,28 @@ + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + +- auto bytes_transferred = ++ auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if (!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) { + co_return; ++ } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } else { + co_await run_session(stream, buffer, doc_root); + +- if (!stream.socket().is_open()) ++ if (!stream.socket().is_open()) { + co_return; ++ } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +@@ -488,25 +540,31 @@ + net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; +- auto executor = co_await net::this_coro::executor; ++ auto const cs = co_await net::this_coro::cancellation_state; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { +@@ -518,13 +576,13 @@ + } + + net::awaitable handle_signals(task_group& task_group) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto deadline = net::steady_timer{executor}; + deadline.expires_after(std::chrono::seconds(4)); + + co_await deadline.async_wait(); + +- if (true) { ++ { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + +@@ -540,13 +598,14 @@ + } + + std::cout << "Child tasks completed.\n"; +- } else // SIGTERM +- { +- net::query(executor.get_inner_executor(), net::execution::context).stop(); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" +@@ -555,10 +614,10 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -573,8 +632,10 @@ + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine +- auto listener_executor = net::make_strand(ioc); ++ auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + { +--- a/noexcept-single/common/root_certificates.hpp ++++ b/noexcept-single/common/root_certificates.hpp +@@ -63,7 +63,9 @@ + + inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { +- ctx.load_verify_file(path, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(ctx.load_verify_file(path, ec)); + return; + } + +@@ -3954,9 +3956,13 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); +- if (ec) ++ static_cast( ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); ++ if (ec) { + return; ++ } + } + + } // namespace detail +@@ -3970,8 +3976,9 @@ + inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if (ec) ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + } + + #endif +--- a/noexcept-single/doc/ssl/client.cpp ++++ b/noexcept-single/doc/ssl/client.cpp +@@ -38,19 +38,20 @@ + #include + #include + #include +-#include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + { +@@ -61,8 +62,8 @@ + + net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket +@@ -96,9 +97,12 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } ++ ++} // namespace + + int main() { + { +--- a/noexcept-single/doc/ssl/server.cpp ++++ b/noexcept-single/doc/ssl/server.cpp +@@ -38,19 +38,20 @@ + #include + #include + #include +-#include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + { +@@ -75,14 +76,15 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + + net::awaitable acceptor(ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ auto const executor = co_await net::this_coro::executor; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { +@@ -90,6 +92,8 @@ + print_exception); + } + } ++ ++} // namespace + + int main() { + { +@@ -105,6 +109,8 @@ + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. ++ // Asio exposes the OpenSSL verification bitmask as signed integer constants. ++ // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this +--- a/noexcept-single/echo-op/echo_op.cpp ++++ b/noexcept-single/echo-op/echo_op.cpp +@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + #include + + namespace net = boost::asio; +@@ -48,12 +47,12 @@ + + //[example_core_echo_op_1 + ++namespace { + template + auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] +- -> typename net::async_result::type, +- void(beast::error_code)>::return_type; ++ -> net::async_result, void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -79,7 +78,7 @@ + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the +- first line. These characters are stored in the dynamic buffer_. ++ first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + +@@ -106,14 +105,18 @@ + `net::post`. + */ + template ++// Upstream documentation repeats the initiating signature before its implementation. ++// NOLINTNEXTLINE(readability-redundant-declaration) ++// Each documentation snippet presents the complete public declaration. ++// NOLINTNEXTLINE(readability-redundant-declaration) + auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> typename net:: +- async_result*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) ++ -> net::async_result*/ ++ std::decay_t, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 +@@ -129,10 +132,14 @@ + // Read a line and echo it back + // + template +-auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> +- typename net::async_result::type, +- void(beast::error_code)>::return_type /*< The completion handler +- signature goes here >*/ ++// The retained stackless coroutine expands each yield into nested resume branches. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++// Stackless coroutine macros generate the branches in this operation. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ -> net::async_result, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +@@ -175,9 +182,13 @@ + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + ++ // Upstream combines coroutine state and shared lifetime as independent mixins. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) ++ // Asio operation state combines completion ownership with coroutine resume state. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { +- AsyncStream& stream_; +- DynamicBuffer& buffer_; ++ AsyncStream& stream; ++ DynamicBuffer& buffer; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +@@ -185,8 +196,8 @@ + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , +- stream_(stream), +- buffer_(buffer) { ++ stream(stream), ++ buffer(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -198,19 +209,22 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { ++ static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = ++ auto const begin = + net::buffers_iterator::begin(buffers); +- auto end = ++ auto const end = + net::buffers_iterator::end(buffers); +- auto result = std::find(begin, end, '\n'); +- +- if (result == end) ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) ++ const auto result = std::find(begin, end, '\n'); ++ ++ if (result == end) { + return 0; // not found ++ } + + return result + 1 - begin; + } +@@ -218,6 +232,10 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) ++ // Resume labels generated by the stackless coroutine form one state machine. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ +@@ -228,13 +246,21 @@ + + reenter(*this) { + for (;;) { ++ // Stackless resume labels require this local to be assigned after resumption. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) ++ // Resume labels cannot cross an initialized local; it is assigned before use. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer +- pos = find_newline(buffer_.data()); ++ pos = find_newline(buffer.data()); + + // If we don't have the newline, then read more + if (pos == 0) { ++ // Stackless resume labels require this local to be assigned after ++ // resumption. NOLINTNEXTLINE(cppcoreguidelines-init-variables) ++ // Resume labels cannot cross an initialized local; it is assigned before ++ // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, +@@ -242,18 +268,18 @@ + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), ++ buffer.capacity() - buffer.size()), + std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); +- +- // Read some data into our dynamic buffer_. We transfer ++ buffer.max_size() - buffer.size())); ++ ++ // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some(buffer_.prepare(bytes_to_read), +- std::move(*this)); ++ yield stream.async_read_some(buffer.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -261,11 +287,12 @@ + // Move the bytes read from the writable area to the + // readable area. + +- buffer_.commit(bytes_transferred); ++ buffer.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if (ec) ++ if (ec) { + break; ++ } + + // Keep looping until we get the newline + continue; +@@ -275,7 +302,7 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ yield net::async_write(stream, beast::buffers_prefix(pos, buffer.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will +@@ -287,7 +314,7 @@ + // to consume. With "real" coroutines this will be easier and more + // natural. + +- buffer_.consume(bytes_transferred); ++ buffer.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. +@@ -337,11 +364,16 @@ + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { +- if (ec) +- std::cerr << ": " << ec.message() << std::endl; ++ if (ec) { ++ std::cerr << ": " << ec.message() << '\n'; ++ } + } + }; + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" +@@ -352,7 +384,7 @@ + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + +@@ -360,7 +392,7 @@ + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; +- endpoint_type ep(address, port); ++ endpoint_type const ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); +--- a/noexcept-single/http/client/async/http_client_async.cpp ++++ b/noexcept-single/http/client/async/http_client_async.cpp +@@ -32,14 +32,12 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,6 +47,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -81,9 +80,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -93,9 +98,18 @@ + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -108,8 +122,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -119,18 +137,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -138,6 +166,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -148,10 +180,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/http/client/async-local/http_client_async_local.cpp ++++ b/noexcept-single/http/client/async-local/http_client_async_local.cpp +@@ -33,25 +33,24 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -85,8 +84,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -99,8 +102,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -110,18 +117,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -129,6 +146,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { +@@ -139,11 +160,11 @@ + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const target = argv[4]; +- int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; ++ const auto* const path = argv[1]; ++ const auto* const host = argv[2]; ++ const auto* const port = argv[3]; ++ const auto* const target = argv[4]; ++ int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/noexcept-single/http/client/async-ssl/http_client_async_ssl.cpp +@@ -36,12 +36,10 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +50,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -93,9 +92,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -105,9 +110,18 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -116,8 +130,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -130,8 +148,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -141,11 +163,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -155,6 +181,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -173,13 +201,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -190,10 +226,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/noexcept-single/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -37,12 +37,10 @@ + #include + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,6 +51,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -101,9 +100,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -113,9 +118,18 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -124,8 +138,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -138,8 +156,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -149,11 +171,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -163,6 +189,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -181,13 +209,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -198,10 +234,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +--- a/noexcept-single/http/client/awaitable/http_client_awaitable.cpp ++++ b/noexcept-single/http/client/awaitable/http_client_awaitable.cpp +@@ -34,24 +34,23 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -85,23 +84,30 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -113,10 +119,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -126,9 +132,12 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +--- a/noexcept-single/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/noexcept-single/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -37,9 +37,7 @@ + #include + #include + #include +-#include + #include +-#include + + #include "common/root_certificates.hpp" + +@@ -47,7 +45,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -57,6 +55,7 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +@@ -107,7 +106,7 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -132,12 +131,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -149,10 +153,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -171,9 +175,12 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +--- a/noexcept-single/http/client/body/json_body.hpp ++++ b/noexcept-single/http/client/body/json_body.hpp +@@ -34,6 +34,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -49,11 +50,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(webcpp::beast::http::header const&, value_type const& body) { ++ writer(webcpp::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -62,20 +66,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ reader(webcpp::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -83,8 +88,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -92,21 +99,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/noexcept-single/http/client/body/json_client.cpp ++++ b/noexcept-single/http/client/body/json_client.cpp +@@ -19,29 +19,31 @@ + #include "fixture_resolver.hpp" + #include "json_body.hpp" + +-#include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char**) { ++int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup +@@ -67,11 +69,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; + } +--- a/noexcept-single/http/client/coro/http_client_coro.cpp ++++ b/noexcept-single/http/client/coro/http_client_coro.cpp +@@ -115,6 +115,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +--- a/noexcept-single/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ b/noexcept-single/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -154,6 +154,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +--- a/noexcept-single/http/client/crawl/http_crawl.cpp ++++ b/noexcept-single/http/client/crawl/http_crawl.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -48,7 +47,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -62,6 +60,7 @@ + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -69,7 +68,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(webcpp::asio::io_context& ioc) ++ explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -89,8 +88,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -127,9 +127,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -140,7 +141,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -169,11 +170,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -184,10 +186,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -198,10 +203,16 @@ + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -217,7 +228,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -231,7 +243,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -241,7 +254,9 @@ + }); + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully +@@ -260,16 +275,20 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[1])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; +@@ -277,11 +296,14 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. +- for (int index = 0; index < threads; ++index) ++ for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); ++ } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() +--- a/noexcept-single/http/client/methods/http_client_methods.cpp ++++ b/noexcept-single/http/client/methods/http_client_methods.cpp +@@ -35,19 +35,18 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); +@@ -125,6 +124,10 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -136,18 +139,23 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); ++ } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup +@@ -164,38 +172,41 @@ + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } +--- a/noexcept-single/http/client/sync/http_client_sync.cpp ++++ b/noexcept-single/http/client/sync/http_client_sync.cpp +@@ -35,19 +35,19 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -59,19 +59,23 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +@@ -95,17 +99,20 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + webcpp_fixture::fail_stop(); ++ } + + // If we get here then the connection is closed gracefully + } +--- a/noexcept-single/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/noexcept-single/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -37,11 +37,9 @@ + #include + #include + #include +-#include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,6 +48,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -61,10 +61,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -79,6 +79,8 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + +@@ -91,6 +93,8 @@ + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +@@ -117,11 +121,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +- stream.shutdown(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -140,8 +146,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) { + webcpp_fixture::fail_stop(); ++ } + } + return EXIT_SUCCESS; + } +--- a/noexcept-single/http/server/async/http_server_async.cpp ++++ b/noexcept-single/http/server/async/http_server_async.cpp +@@ -34,7 +34,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -42,7 +41,6 @@ + #include + #include + #include +-#include + + #include + +@@ -52,64 +50,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -121,8 +143,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -169,18 +192,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -188,12 +214,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -209,8 +237,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -264,18 +295,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -286,13 +325,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -302,7 +346,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -317,34 +363,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -365,10 +421,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -377,7 +432,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" +@@ -386,9 +445,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/async-local/http_server_async_local.cpp ++++ b/noexcept-single/http/server/async-local/http_server_async_local.cpp +@@ -35,10 +35,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -48,72 +46,96 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -125,8 +147,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -173,18 +196,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -192,12 +218,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -213,8 +241,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -269,18 +300,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -291,13 +330,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -307,7 +351,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -322,8 +368,12 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +@@ -340,10 +390,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -352,7 +401,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { +@@ -361,15 +414,15 @@ + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; ++ const auto* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); +--- a/noexcept-single/http/server/async-ssl/http_server_async_ssl.cpp ++++ b/noexcept-single/http/server/async-ssl/http_server_async_ssl.cpp +@@ -38,14 +38,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + #include + +@@ -56,64 +54,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -125,8 +147,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -173,18 +196,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -192,12 +218,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -213,8 +241,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -243,8 +274,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -283,8 +315,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + do_read(); + } +@@ -306,18 +342,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -328,13 +372,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -350,9 +399,15 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -368,34 +423,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -416,10 +481,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), ctx_, doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -428,7 +492,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" +@@ -437,9 +505,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/awaitable/http_server_awaitable.cpp ++++ b/noexcept-single/http/server/awaitable/http_server_awaitable.cpp +@@ -35,10 +35,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -48,71 +46,95 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -124,8 +146,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -172,18 +195,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -191,12 +217,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -212,8 +240,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -239,7 +270,7 @@ + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); +@@ -262,12 +293,14 @@ + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +@@ -278,7 +311,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +@@ -287,15 +324,17 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +--- a/noexcept-single/http/server/coro/http_server_coro.cpp ++++ b/noexcept-single/http/server/coro/http_server_coro.cpp +@@ -314,7 +314,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" +@@ -323,9 +325,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ b/noexcept-single/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -351,7 +351,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" +@@ -360,9 +362,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/fast/fields_alloc.hpp ++++ b/noexcept-single/http/server/fast/fields_alloc.hpp +@@ -35,7 +35,7 @@ + + namespace detail { + +-struct static_pool { ++class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; +@@ -47,7 +47,7 @@ + + public: + static static_pool& construct(std::size_t size) { +- auto p = new char[sizeof(static_pool) + size]; ++ auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + +@@ -57,25 +57,28 @@ + } + + void destroy() { +- if (--refs_) ++ if ((--refs_) != 0u) { + return; ++ } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { +- auto last = p_ + n; +- if (last >= end()) ++ auto* last = p_ + n; ++ if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); ++ } + ++count_; +- auto p = p_; ++ auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { +- if (--count_) ++ if ((--count_) != 0u) { + return; ++ } + p_ = reinterpret_cast(this + 1); + } + }; +@@ -100,7 +103,7 @@ + */ + template + struct fields_alloc { +- detail::static_pool* pool_; ++ detail::static_pool* pool; + + public: + using value_type = T; +@@ -124,20 +127,21 @@ + fields_alloc() = default; + #endif + +- explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ explicit fields_alloc(fields_alloc const& other) ++ : pool(&detail::static_pool::share(*other.pool)) {} + +- ~fields_alloc() { pool_->destroy(); } ++ ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { +- return static_cast(pool_->alloc(n * sizeof(T))); ++ return static_cast(pool->alloc(n * sizeof(T))); + } + +- void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + + #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template +@@ -153,7 +157,7 @@ + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { +- return &lhs.pool_ == &rhs.pool_; ++ return &lhs.pool == &rhs.pool_; + } + + template +--- a/noexcept-single/http/server/fast/http_server_fast.cpp ++++ b/noexcept-single/http/server/fast/http_server_fast.cpp +@@ -44,7 +44,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -52,9 +51,7 @@ + #include + #include + #include +-#include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -62,56 +59,79 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + +@@ -120,6 +140,8 @@ + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + ++ // Retain the upstream borrowing constructor contract in this reference counterpart. ++ // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + +@@ -153,7 +175,7 @@ + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), +- (std::chrono::steady_clock::time_point::max)()}; ++ std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> +@@ -173,7 +195,9 @@ + void accept() { + // Clean up any previous connection. + beast::error_code ec; +- socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { +@@ -203,24 +227,23 @@ + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { +- if (ec) ++ if (ec) { + accept(); +- else ++ } else { + process_request(parser_->get()); ++ } + }); + } + + void process_request(http::request> const& req) { +- switch (req.method()) { +- case http::verb::get: send_file(req.target()); break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; ++ if (req.method() == http::verb::get) { ++ send_file(req.target()); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + +@@ -238,7 +261,9 @@ + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); +@@ -247,7 +272,7 @@ + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } +@@ -276,7 +301,9 @@ + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); +@@ -290,14 +317,18 @@ + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 6) { +@@ -311,9 +342,11 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- std::string doc_root = argv[3]; +- int num_workers = std::atoi(argv[4]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ std::string const doc_root = argv[3]; ++ int const num_workers = webcpp_fixture::integer(argv[4]); ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; +@@ -325,10 +358,12 @@ + workers.back().start(); + } + +- if (spin) +- for (;;) ++ if (spin) { ++ for (;;) { + ioc.poll(); +- else ++ } ++ } else { + ioc.run(); // lint-run: drives the application's network operations ++ } + } + } +--- a/noexcept-single/http/server/flex/http_server_flex.cpp ++++ b/noexcept-single/http/server/flex/http_server_flex.cpp +@@ -38,14 +38,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,64 +52,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -241,8 +272,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -260,20 +292,22 @@ + http::request req_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Take ownership of the buffer ++private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), buffer_, req_, ++ derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + +@@ -281,18 +315,23 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), +@@ -303,8 +342,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -315,9 +358,13 @@ + // Read another request + do_read(); + } ++ ++ friend Derived; + }; + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -344,13 +391,17 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + }; + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +@@ -365,27 +416,33 @@ + + // Start the asynchronous operation + void run() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. +- net::dispatch(stream_.get_executor(), [self]() { ++ net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, self->buffer_.data(), ++ ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } +@@ -399,9 +456,15 @@ + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -432,8 +495,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -457,34 +524,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -516,7 +593,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" +@@ -525,9 +606,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/small/http_server_small.cpp ++++ b/noexcept-single/http/server/small/http_server_small.cpp +@@ -42,22 +42,20 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + using tcp = webcpp::asio::ip::tcp; // from + ++namespace { + namespace my_program_state { + std::size_t request_count() { + static std::size_t count = 0; +@@ -65,13 +63,13 @@ + } + + std::time_t now() { +- return std::time(0); ++ return std::time(nullptr); + } + } // namespace my_program_state + + class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) : socket_(std::move(socket)) {} ++ explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { +@@ -97,13 +95,16 @@ + + // Asynchronously receive a complete request message. + void read_request() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- if (!ec) ++ if (!ec) { + self->process_request(); ++ } + }); + } + +@@ -112,21 +113,17 @@ + response_.version(request_.version()); + response_.keep_alive(false); + +- switch (request_.method()) { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" << std::string(request_.method_string()) << "'"; +- break; ++ if (request_.method() == http::verb::get) { ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); +@@ -164,24 +161,32 @@ + + // Asynchronously transmit the response message. + void write_response() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.close(ec)); + } + }); + } +@@ -190,13 +195,18 @@ + // "Loop" forever accepting new connections. + void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { +- if (!ec) ++ if (!ec) { + std::make_shared(std::move(socket))->start(); ++ } + http_server(acceptor, socket); + }); + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -209,7 +219,7 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + +--- a/noexcept-single/http/server/stackless/http_server_stackless.cpp ++++ b/noexcept-single/http/server/stackless/http_server_stackless.cpp +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -43,7 +42,6 @@ + #include + #include + #include +-#include + + #include + +@@ -53,64 +51,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -122,8 +144,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -170,18 +193,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -189,12 +215,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -210,8 +238,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -227,6 +258,8 @@ + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; +@@ -252,6 +285,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -272,8 +307,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -288,8 +327,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -298,7 +341,9 @@ + } + + // Send a TCP shutdown +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -310,6 +355,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; +@@ -317,6 +364,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -326,28 +375,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -358,8 +415,12 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { +@@ -378,12 +439,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" +@@ -392,9 +459,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ b/noexcept-single/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -47,7 +46,6 @@ + #include + #include + #include +-#include + + #include + +@@ -58,64 +56,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -127,8 +149,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -175,18 +198,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -194,12 +220,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -215,8 +243,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -245,13 +276,16 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; +@@ -278,6 +312,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -287,9 +323,15 @@ + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + for (;;) { + // Set the timeout. +@@ -308,8 +350,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -324,8 +370,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -338,9 +388,15 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -352,6 +408,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -360,6 +418,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -370,28 +430,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -402,12 +470,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -422,12 +496,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" +@@ -436,9 +516,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/http/server/sync/http_server_sync.cpp ++++ b/noexcept-single/http/server/sync/http_server_sync.cpp +@@ -32,14 +32,12 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,64 +47,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -118,8 +140,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -166,18 +189,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -185,12 +211,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -206,8 +234,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -233,22 +264,31 @@ + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -257,14 +297,20 @@ + } + + // Send a TCP shutdown +- socket.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { +@@ -274,7 +320,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +--- a/noexcept-single/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ b/noexcept-single/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -37,14 +37,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,64 +51,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -122,8 +144,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -170,18 +193,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -189,12 +215,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -210,8 +238,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -235,9 +266,15 @@ + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake +- stream.handshake(ssl::stream_base::server, ec); +- if (ec) +- return fail(ec, "handshake"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.handshake(ssl::stream_base::server, ec)); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -246,22 +283,31 @@ + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -271,16 +317,26 @@ + } + + // Perform the SSL shutdown +- stream.shutdown(ec); +- if (ec) +- return fail(ec, "shutdown"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 4) { +@@ -290,7 +346,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +--- a/noexcept-single/websocket/client/async/websocket_client_async.cpp ++++ b/noexcept-single/websocket/client/async/websocket_client_async.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -78,9 +78,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -91,9 +97,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -119,8 +131,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -130,8 +146,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -140,8 +160,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -149,18 +173,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -169,9 +201,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/websocket/client/async-local/websocket_client_async_local.cpp ++++ b/noexcept-single/websocket/client/async-local/websocket_client_async_local.cpp +@@ -36,24 +36,24 @@ + #include + #include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -82,8 +82,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); +@@ -100,8 +104,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -111,8 +119,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -121,8 +133,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -130,18 +146,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { +@@ -151,10 +175,10 @@ + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const text = argv[4]; ++ const auto* const path = argv[1]; ++ const auto* const host = argv[2]; ++ const auto* const port = argv[3]; ++ const auto* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/noexcept-single/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -43,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -55,6 +54,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -94,9 +94,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -107,9 +113,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -126,8 +138,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -148,8 +164,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -159,8 +179,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -169,8 +193,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -178,18 +206,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -198,9 +234,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/noexcept-single/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -44,7 +44,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -56,6 +55,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -101,9 +101,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -114,9 +120,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -133,8 +145,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -155,8 +171,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -166,8 +186,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -176,8 +200,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -185,18 +213,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -205,9 +241,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +--- a/noexcept-single/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/noexcept-single/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -36,13 +36,12 @@ + #include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -50,8 +49,9 @@ + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -62,7 +62,7 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); ++ auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -100,11 +100,15 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -114,17 +118,20 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + webcpp_fixture::fail_stop(); ++ } + }); + + // Run the I/O service. The call will return when +--- a/noexcept-single/websocket/client/coro/websocket_client_coro.cpp ++++ b/noexcept-single/websocket/client/coro/websocket_client_coro.cpp +@@ -124,6 +124,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +--- a/noexcept-single/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ b/noexcept-single/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -147,6 +147,8 @@ + + //------------------------------------------------------------------------------ + ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +--- a/noexcept-single/websocket/client/sync/websocket_client_sync.cpp ++++ b/noexcept-single/websocket/client/sync/websocket_client_sync.cpp +@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,6 +48,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -59,21 +60,25 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(ws.next_layer(), results); ++ auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -104,7 +109,7 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; + } +--- a/noexcept-single/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/noexcept-single/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -43,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,6 +52,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + { + // Check command line arguments. +@@ -63,8 +64,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -79,14 +80,18 @@ + load_root_certificates(ctx); + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(beast::get_lowest_layer(ws), results); ++ auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { +@@ -128,7 +133,7 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + return EXIT_SUCCESS; + } +--- a/noexcept-single/websocket/server/async/websocket_server_async.cpp ++++ b/noexcept-single/websocket/server/async/websocket_server_async.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + #include + +@@ -54,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -92,8 +92,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -108,11 +112,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -123,8 +132,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -142,32 +155,42 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -199,7 +222,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" +@@ -208,8 +235,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/websocket/server/async-local/websocket_server_async_local.cpp ++++ b/noexcept-single/websocket/server/async-local/websocket_server_async_local.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -47,17 +46,18 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -96,8 +96,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -112,11 +116,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -127,8 +136,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -146,7 +159,11 @@ + stream_protocol::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +@@ -163,10 +180,9 @@ + if (ec) { + fail(ec, "accept"); + return; +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket))->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); +@@ -175,7 +191,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -184,14 +204,14 @@ + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[2])); ++ const auto* const path = argv[1]; ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); +--- a/noexcept-single/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ b/noexcept-single/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -45,7 +45,6 @@ + #include + #include + #include +-#include + + #include + +@@ -59,6 +58,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -94,8 +94,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -115,8 +119,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -131,11 +139,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -146,8 +159,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -166,33 +183,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -224,7 +251,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -233,8 +264,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ b/noexcept-single/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -46,7 +45,7 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -54,6 +53,7 @@ + namespace net = boost::asio; + + // Echoes back all received WebSocket messages ++namespace { + net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -74,11 +74,13 @@ + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + co_return; ++ } + +- if (ec) ++ if (ec) { + webcpp_fixture::fail_stop(); ++ } + + // Echo the message back + stream.text(stream.got_text()); +@@ -88,13 +90,15 @@ + + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +@@ -105,7 +109,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" +@@ -114,14 +122,16 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + { +--- a/noexcept-single/websocket/server/chat-multi/http_session.cpp ++++ b/noexcept-single/websocket/server/chat-multi/http_session.cpp +@@ -34,64 +34,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -103,8 +127,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -151,18 +176,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -170,12 +198,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -191,8 +221,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -202,6 +235,8 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ + http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +@@ -210,10 +245,13 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -234,16 +272,22 @@ + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + +-void http_session::on_read(beast::error_code ec, std::size_t) { ++void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -258,8 +302,10 @@ + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); +- ++ bool const keep_alive = msg.keep_alive(); ++ ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response +@@ -269,15 +315,21 @@ + }); + } + +-void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { ++void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + +--- a/noexcept-single/websocket/server/chat-multi/http_session.hpp ++++ b/noexcept-single/websocket/server/chat-multi/http_session.hpp +@@ -51,8 +51,8 @@ + + void fail(beast::error_code ec, char const* what); + void do_read(); +- void on_read(beast::error_code ec, std::size_t); +- void on_write(beast::error_code ec, std::size_t, bool close); ++ void on_read(beast::error_code ec, std::size_t /*unused*/); ++ void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + + public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); +--- a/noexcept-single/websocket/server/chat-multi/listener.cpp ++++ b/noexcept-single/websocket/server/chat-multi/listener.cpp +@@ -29,34 +29,44 @@ + #include "http_session.hpp" + #include "listener.hpp" + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -70,20 +80,28 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection + void listener::on_accept(beast::error_code ec, tcp::socket socket) { +- if (ec) +- return fail(ec, "accept"); +- else ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } ++ { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); ++ } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), +--- a/noexcept-single/websocket/server/chat-multi/main.cpp ++++ b/noexcept-single/websocket/server/chat-multi/main.cpp +@@ -44,7 +44,9 @@ + #include + #include + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" +@@ -52,10 +54,10 @@ + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } +- auto address = net::ip::make_address(argv[1]); +- auto port = static_cast(std::atoi(argv[2])); +- auto doc_root = argv[3]; +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto* doc_root = argv[3]; ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/noexcept-single/websocket/server/chat-multi/shared_state.cpp ++++ b/noexcept-single/websocket/server/chat-multi/shared_state.cpp +@@ -29,15 +29,15 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} ++shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + + void shared_state::join(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + sessions_.insert(session); + } + + void shared_state::leave(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + sessions_.erase(session); + } + +@@ -51,15 +51,20 @@ + // holding the mutex: + std::vector> v; + { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + v.reserve(sessions_.size()); +- for (auto p : sessions_) ++ for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); ++ } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for (auto const& wp : v) +- if (auto sp = wp.lock()) ++ for (auto const& wp : v) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) ++ if (const auto sp = wp.lock()) { + sp->send(ss); ++ } ++ } + } +--- a/noexcept-single/websocket/server/chat-multi/shared_state.hpp ++++ b/noexcept-single/websocket/server/chat-multi/shared_state.hpp +@@ -40,7 +40,7 @@ + + // Represents the shared server state + class shared_state { +- std::string const doc_root_; ++ std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; +@@ -51,7 +51,7 @@ + public: + explicit shared_state(std::string doc_root); + +- std::string const& doc_root() const noexcept { return doc_root_; } ++ [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); +--- a/noexcept-single/websocket/server/chat-multi/websocket_session.cpp ++++ b/noexcept-single/websocket/server/chat-multi/websocket_session.cpp +@@ -38,18 +38,25 @@ + state_->leave(this); + } + ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if (ec == net::error::operation_aborted || ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Add this session to the list of active sessions + state_->join(this); +@@ -59,10 +66,14 @@ + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void websocket_session::on_read(beast::error_code ec, std::size_t) { ++void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); +@@ -89,25 +100,31 @@ + queue_.push_back(ss); + + // Are we already writing? +- if (queue_.size() > 1) ++ if (queue_.size() > 1) { + return; ++ } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void websocket_session::on_write(beast::error_code ec, std::size_t) { ++void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if (!queue_.empty()) ++ if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); ++ } + } +--- a/noexcept-single/websocket/server/chat-multi/websocket_session.hpp ++++ b/noexcept-single/websocket/server/chat-multi/websocket_session.hpp +@@ -70,6 +70,8 @@ + }; + + template ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +--- a/noexcept-single/websocket/server/coro/websocket_server_coro.cpp ++++ b/noexcept-single/websocket/server/coro/websocket_server_coro.cpp +@@ -141,7 +141,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" +@@ -150,8 +152,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); +--- a/noexcept-single/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ b/noexcept-single/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -160,7 +160,9 @@ + } + } + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" +@@ -169,8 +171,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/websocket/server/fast/websocket_server_fast.cpp ++++ b/noexcept-single/websocket/server/fast/websocket_server_fast.cpp +@@ -299,7 +299,9 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" +@@ -312,8 +314,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/websocket/server/stackless/websocket_server_stackless.cpp ++++ b/noexcept-single/websocket/server/stackless/websocket_server_stackless.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + #include + +@@ -55,11 +54,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; +@@ -81,6 +83,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -95,29 +99,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -131,39 +154,51 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -174,12 +209,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -194,12 +235,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" +@@ -208,8 +255,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ b/noexcept-single/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -47,7 +47,6 @@ + #include + #include + #include +-#include + + #include + +@@ -61,11 +60,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -87,6 +89,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +@@ -97,9 +101,15 @@ + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -116,29 +126,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -152,6 +181,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -159,33 +190,43 @@ + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -196,12 +237,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -216,12 +263,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -230,8 +283,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/noexcept-single/websocket/server/sync/websocket_server_sync.cpp ++++ b/noexcept-single/websocket/server/sync/websocket_server_sync.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket) { + { + // Construct the stream by moving in the socket +@@ -88,7 +88,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -98,7 +102,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +--- a/noexcept-single/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ b/noexcept-single/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -44,7 +44,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -56,6 +55,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket, ssl::context& ctx) { + { + // Construct the websocket stream around the socket +@@ -97,7 +97,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + { + // Check command line arguments. + if (argc != 3) { +@@ -107,7 +111,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +--- a/oracle/advanced/server/advanced_server.cpp ++++ b/oracle/advanced/server/advanced_server.cpp +@@ -47,67 +47,91 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -119,8 +143,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -167,18 +192,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -186,12 +214,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -207,8 +237,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -234,6 +267,8 @@ + + // Start the asynchronous accept operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -251,8 +286,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -268,11 +307,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -283,8 +327,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -347,11 +395,19 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -366,8 +422,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -375,15 +432,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), +@@ -394,18 +452,24 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + +@@ -415,7 +479,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -430,34 +496,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -496,7 +572,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" +@@ -505,9 +585,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -527,17 +607,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/oracle/advanced/server-flex/advanced_server_flex.cpp ++++ b/oracle/advanced/server-flex/advanced_server_flex.cpp +@@ -51,67 +51,91 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +147,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +196,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +218,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +241,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -241,8 +274,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -254,6 +288,8 @@ + // the same code works with both SSL streams and regular sockets. + template + class websocket_session { ++ websocket_session() = default; ++ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } +@@ -262,6 +298,8 @@ + + // Start the asynchronous operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +@@ -281,8 +319,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -298,11 +340,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + derived().ws().text(derived().ws().got_text()); +@@ -314,8 +361,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -331,11 +382,15 @@ + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; +@@ -351,6 +406,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; +@@ -399,13 +456,15 @@ + boost::optional> parser_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Construct the session ++private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); +@@ -419,7 +478,7 @@ + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), buffer_, *parser_, ++ derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + +@@ -427,11 +486,16 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -448,8 +512,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -457,15 +522,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, +@@ -476,8 +542,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -486,18 +556,23 @@ + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + + do_write(); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -522,7 +597,9 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -531,6 +608,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; +@@ -550,7 +629,7 @@ + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, buffer_.data(), ++ ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + +@@ -572,18 +651,28 @@ + + private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -623,8 +712,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -648,34 +741,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -707,7 +810,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" +@@ -716,9 +823,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -744,17 +851,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/oracle/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ b/oracle/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -39,7 +39,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; +@@ -48,68 +48,92 @@ + namespace ssl = boost::asio::ssl; + + using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = typename net::ip::tcp::acceptor::rebind_executor::other; ++using stream_type = beast::tcp_stream::rebind_executor::other; ++using acceptor_type = net::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -121,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -169,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -188,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -209,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -227,7 +260,11 @@ + std::list css_; + + public: +- task_group(net::any_io_executor exec) ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ explicit task_group(net::any_io_executor exec) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +@@ -251,8 +288,8 @@ + */ + template + auto adapt(CompletionToken&& completion_token) { +- auto lg = std::lock_guard{mtx_}; +- auto cs = css_.emplace(css_.end()); ++ auto const lg = std::scoped_lock{mtx_}; ++ auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; +@@ -264,11 +301,14 @@ + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + ++ // A mutex or timer failure during this upstream task teardown is fatal by design. ++ // NOLINTNEXTLINE(bugprone-exception-escape) + ~remover() { + if (tg_) { +- auto lg = std::lock_guard{tg_->mtx_}; +- if (tg_->css_.erase(cs_) == tg_->css_.end()) ++ auto const lg = std::scoped_lock{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); ++ } + } + } + }; +@@ -288,9 +328,10 @@ + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { +- auto lg = std::lock_guard{mtx_}; +- for (auto& cs : css_) ++ auto const lg = std::scoped_lock{mtx_}; ++ for (auto& cs : css_) { + cs.emit(type); ++ } + } + + /** Starts an asynchronous wait on the task_group. +@@ -317,24 +358,33 @@ + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( ++ // The apparent recursion crosses an asynchronous completion boundary. ++ // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { +- if (!scheduled) ++ if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); +- +- if (!self.cancelled() && ec == net::error::operation_aborted) ++ } ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; ++ } + + { +- auto lg = std::lock_guard{mtx_}; ++ auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + +- if (!std::exchange(scheduled, true)) ++ if (!std::exchange(scheduled, true)) { ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); ++ } + + self.complete(ec); + }, +@@ -346,7 +396,7 @@ + net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +@@ -365,11 +415,13 @@ + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + // Echo the message back + ws.text(ws.got_text()); +@@ -382,14 +434,15 @@ + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; ++ } + } + + template + net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; +@@ -397,8 +450,9 @@ + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + co_return; ++ } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. +@@ -439,25 +493,28 @@ + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + +- auto bytes_transferred = ++ auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if (!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) { + co_return; ++ } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; ++ } + } else { + co_await run_session(stream, buffer, doc_root); + +- if (!stream.socket().is_open()) ++ if (!stream.socket().is_open()) { + co_return; ++ } + + stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); + } +@@ -466,25 +523,31 @@ + net::awaitable listen(task_group& task_group, ssl::context& ctx, + net::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; +- auto executor = co_await net::this_coro::executor; ++ auto const cs = co_await net::this_coro::cancellation_state; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { +@@ -498,9 +561,11 @@ + } + + net::awaitable handle_signals(task_group& task_group) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto sig = co_await signal_set.async_wait(); + + if (sig == SIGINT) { +@@ -525,7 +590,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" +@@ -534,10 +603,10 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = net::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -552,8 +621,10 @@ + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine +- auto listener_executor = net::make_strand(ioc); ++ auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { +@@ -570,14 +641,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/oracle/common/root_certificates.hpp ++++ b/oracle/common/root_certificates.hpp +@@ -54,7 +54,9 @@ + + inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { +- ctx.load_verify_file(path, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(ctx.load_verify_file(path, ec)); + return; + } + +@@ -3945,9 +3947,13 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); +- if (ec) ++ static_cast( ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); ++ if (ec) { + return; ++ } + } + + } // namespace detail +@@ -3961,8 +3967,9 @@ + inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if (ec) ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + } + + #endif +--- a/oracle/doc/ssl/client.cpp ++++ b/oracle/doc/ssl/client.cpp +@@ -24,27 +24,30 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + } + + net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ net::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket +@@ -79,9 +82,12 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); ++ } + } ++ ++} // namespace + + int main() { + try { +@@ -116,7 +122,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + +--- a/oracle/doc/ssl/server.cpp ++++ b/oracle/doc/ssl/server.cpp +@@ -24,19 +24,22 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + } +@@ -57,14 +60,15 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); ++ } + } + + net::awaitable acceptor(ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ auto const executor = co_await net::this_coro::executor; ++ net::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + net::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { +@@ -72,6 +76,8 @@ + print_exception); + } + } ++ ++} // namespace + + int main() { + try { +@@ -87,6 +93,8 @@ + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. ++ // Asio exposes the OpenSSL verification bitmask as signed integer constants. ++ // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this +@@ -108,7 +116,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + +--- a/oracle/echo-op/echo_op.cpp ++++ b/oracle/echo-op/echo_op.cpp +@@ -27,14 +27,15 @@ + namespace net = boost::asio; + namespace beast = boost::beast; + ++namespace { ++ + //[example_core_echo_op_1 + + template + auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] +- -> typename net::async_result::type, +- void(beast::error_code)>::return_type; ++ -> net::async_result, void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -60,7 +61,7 @@ + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the +- first line. These characters are stored in the dynamic buffer_. ++ first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + +@@ -87,14 +88,16 @@ + `net::post`. + */ + template ++// Each documentation snippet presents the complete public declaration. ++// NOLINTNEXTLINE(readability-redundant-declaration) + auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> typename net:: +- async_result*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) ++ -> net::async_result*/ ++ std::decay_t, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 +@@ -110,10 +113,12 @@ + // Read a line and echo it back + // + template +-auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> +- typename net::async_result::type, +- void(beast::error_code)>::return_type /*< The completion handler +- signature goes here >*/ ++// Stackless coroutine macros generate the branches in this operation. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ -> net::async_result, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +@@ -156,9 +161,11 @@ + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + ++ // Asio operation state combines completion ownership with coroutine resume state. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { +- AsyncStream& stream_; +- DynamicBuffer& buffer_; ++ AsyncStream& stream_state; ++ DynamicBuffer& buffer_state; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +@@ -166,8 +173,8 @@ + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , +- stream_(stream), +- buffer_(buffer) { ++ stream_state(stream), ++ buffer_state(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -179,19 +186,20 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { ++ static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = ++ const auto begin = + net::buffers_iterator::begin(buffers); +- auto end = ++ const auto end = + net::buffers_iterator::end(buffers); +- auto result = std::find(begin, end, '\n'); +- +- if (result == end) ++ const auto result = std::find(begin, end, '\n'); ++ ++ if (result == end) { + return 0; // not found ++ } + + return result + 1 - begin; + } +@@ -199,6 +207,8 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + ++ // Resume labels generated by the stackless coroutine form one state machine. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ +@@ -209,13 +219,17 @@ + + reenter(*this) { + for (;;) { ++ // Resume labels cannot cross an initialized local; it is assigned before use. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer +- pos = find_newline(buffer_.data()); ++ pos = find_newline(buffer_state.data()); + + // If we don't have the newline, then read more + if (pos == 0) { ++ // Resume labels cannot cross an initialized local; it is assigned before ++ // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, +@@ -223,18 +237,18 @@ + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), ++ buffer_state.capacity() - buffer_state.size()), + std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); +- +- // Read some data into our dynamic buffer_. We transfer ++ buffer_state.max_size() - buffer_state.size())); ++ ++ // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some(buffer_.prepare(bytes_to_read), +- std::move(*this)); ++ yield stream_state.async_read_some(buffer_state.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -242,11 +256,12 @@ + // Move the bytes read from the writable area to the + // readable area. + +- buffer_.commit(bytes_transferred); ++ buffer_state.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if (ec) ++ if (ec) { + break; ++ } + + // Keep looping until we get the newline + continue; +@@ -256,7 +271,8 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ yield net::async_write(stream_state, ++ beast::buffers_prefix(pos, buffer_state.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will +@@ -268,7 +284,7 @@ + // to consume. With "real" coroutines this will be easier and more + // natural. + +- buffer_.consume(bytes_transferred); ++ buffer_state.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. +@@ -318,11 +334,16 @@ + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { +- if (ec) +- std::cerr << ": " << ec.message() << std::endl; ++ if (ec) { ++ std::cerr << ": " << ec.message() << '\n'; ++ } + } + }; + ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" +@@ -333,7 +354,7 @@ + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = net::ip::tcp::endpoint; + +@@ -341,7 +362,7 @@ + // the echo, and then shut everything down and exit. + net::io_context ioc; + net::ip::tcp::acceptor acceptor{ioc}; +- endpoint_type ep(address, port); ++ const endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); +--- a/oracle/http/client/async/http_client_async.cpp ++++ b/oracle/http/client/async/http_client_async.cpp +@@ -33,14 +33,15 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -73,9 +74,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -85,9 +92,15 @@ + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -100,8 +113,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -111,18 +128,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -130,6 +157,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -140,10 +171,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +--- a/oracle/http/client/async-local/http_client_async_local.cpp ++++ b/oracle/http/client/async-local/http_client_async_local.cpp +@@ -34,16 +34,17 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -77,8 +78,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -91,8 +96,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -102,18 +111,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -121,6 +140,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { +@@ -131,11 +154,11 @@ + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const target = argv[4]; +- int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; ++ auto const* const path = argv[1]; ++ auto const* const host = argv[2]; ++ auto const* const port = argv[3]; ++ auto const* const target = argv[4]; ++ int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +--- a/oracle/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/oracle/http/client/async-ssl/http_client_async_ssl.cpp +@@ -38,11 +38,12 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -63,6 +64,8 @@ + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; +@@ -84,9 +87,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -96,9 +105,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -107,8 +122,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -121,8 +140,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -132,11 +155,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -146,6 +173,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -164,13 +193,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -181,10 +218,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +--- a/oracle/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/oracle/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -39,11 +39,12 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -70,6 +71,8 @@ + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; +@@ -91,9 +94,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -103,9 +112,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -114,8 +129,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -128,8 +147,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -139,11 +162,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -153,6 +180,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -171,13 +200,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -188,10 +225,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- a/oracle/http/client/awaitable/http_client_awaitable.cpp ++++ b/oracle/http/client/awaitable/http_client_awaitable.cpp +@@ -34,16 +34,17 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -77,23 +78,30 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -105,10 +113,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -118,16 +126,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/oracle/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -38,7 +38,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; +@@ -48,6 +48,7 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +@@ -99,7 +100,7 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -124,12 +125,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) { + throw boost::system::system_error(ec, "shutdown"); ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -141,10 +147,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -163,16 +169,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/http/client/body/json_body.hpp ++++ b/oracle/http/client/body/json_body.hpp +@@ -26,6 +26,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -41,11 +42,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(boost::beast::http::header const&, value_type const& body) { ++ writer(boost::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -54,20 +58,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(boost::beast::http::header&, value_type& body) : body(body) {} ++ reader(boost::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -75,8 +80,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -84,21 +91,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/oracle/http/client/body/json_client.cpp ++++ b/oracle/http/client/body/json_client.cpp +@@ -19,12 +19,12 @@ + namespace beast = boost::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using net::ip::tcp; // from + +-int main(int, char**) { ++int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -59,11 +59,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; + } +--- a/oracle/http/client/coro/http_client_coro.cpp ++++ b/oracle/http/client/coro/http_client_coro.cpp +@@ -32,20 +32,23 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response + void do_session(std::string const& host, std::string const& port, std::string const& target, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + int version, net::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + +@@ -55,16 +58,24 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; +@@ -76,8 +87,12 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; +@@ -87,26 +102,40 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -117,10 +146,10 @@ + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -128,9 +157,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -138,8 +171,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/oracle/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ b/oracle/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -39,18 +39,22 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response + void do_session(std::string const& host, std::string const& port, std::string const& target, +- int version, net::io_context& ioc, ssl::context& ctx, net::yield_context yield) { ++ int version, net::io_context& ioc, ssl::context& ctx, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +@@ -69,24 +73,36 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; +@@ -98,8 +114,12 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; +@@ -109,11 +129,15 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -138,12 +162,20 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -154,10 +186,10 @@ + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -174,9 +206,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -184,8 +220,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/oracle/http/client/crawl/http_crawl.cpp ++++ b/oracle/http/client/crawl/http_crawl.cpp +@@ -49,11 +49,12 @@ + namespace beast = boost::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using net::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -61,7 +62,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(net::io_context& ioc) ++ explicit crawl_report(net::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -81,8 +82,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -119,9 +121,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -132,7 +135,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -161,11 +164,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -176,10 +180,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -190,10 +197,13 @@ + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -209,7 +219,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -223,7 +234,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -233,7 +245,9 @@ + }); + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully +@@ -252,16 +266,20 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- auto const threads = std::max(1, std::atoi(argv[1])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + net::io_context ioc; +@@ -269,6 +287,8 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Create and launch the worker threads. +@@ -279,7 +299,11 @@ + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto reporting_work = ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); + + workers.emplace_back([&report, reporting_work] { +@@ -300,8 +324,9 @@ + }); + + // Now block until all threads exit +- for (std::size_t i = 0; i < workers.size(); ++i) +- workers[i].join(); ++ for (auto& worker : workers) { ++ worker.join(); ++ } + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; +--- a/oracle/http/client/methods/http_client_methods.cpp ++++ b/oracle/http/client/methods/http_client_methods.cpp +@@ -37,9 +37,10 @@ + namespace beast = boost::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using net::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); +@@ -117,6 +118,10 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -128,9 +133,10 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); +- beast::string_view method{argv[1]}; ++ } ++ beast::string_view const method{argv[1]}; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -151,47 +157,52 @@ + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // This buffer is used for reading and must be persisted ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/http/client/sync/http_client_sync.cpp ++++ b/oracle/http/client/sync/http_client_sync.cpp +@@ -37,9 +37,11 @@ + namespace beast = boost::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using net::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -51,10 +53,10 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -87,21 +89,24 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/oracle/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -38,9 +38,11 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = net::ssl; // from +-using tcp = net::ip::tcp; // from ++using net::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -52,10 +54,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -109,11 +111,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +- stream.shutdown(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -132,10 +136,11 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) { + throw beast::system_error{ec}; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/http/server/async/http_server_async.cpp ++++ b/oracle/http/server/async/http_server_async.cpp +@@ -38,70 +38,94 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -113,8 +137,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -161,18 +186,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -180,12 +208,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -201,8 +231,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -256,18 +289,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -278,13 +319,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -294,7 +340,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -309,34 +357,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -357,10 +415,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -369,7 +426,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" +@@ -378,9 +439,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -391,10 +452,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/async-local/http_server_async_local.cpp ++++ b/oracle/http/server/async-local/http_server_async_local.cpp +@@ -40,72 +40,96 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -117,8 +141,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -165,18 +190,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -184,12 +212,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -205,8 +235,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -261,18 +294,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -283,13 +324,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -299,7 +345,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -314,8 +362,12 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +@@ -332,10 +384,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -344,7 +395,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -353,15 +408,15 @@ + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; ++ auto const* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); +@@ -369,15 +424,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/http/server/async-ssl/http_server_async_ssl.cpp ++++ b/oracle/http/server/async-ssl/http_server_async_ssl.cpp +@@ -44,67 +44,91 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -116,8 +140,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -164,18 +189,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -183,12 +211,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -204,8 +234,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -234,8 +267,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -274,8 +308,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + do_read(); + } +@@ -297,18 +335,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -319,13 +365,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -341,9 +392,15 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -359,34 +416,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -407,10 +474,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), ctx_, doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -419,7 +485,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" +@@ -428,9 +498,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -447,10 +517,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/awaitable/http_server_awaitable.cpp ++++ b/oracle/http/server/awaitable/http_server_awaitable.cpp +@@ -40,71 +40,95 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -116,8 +140,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -164,18 +189,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -183,12 +211,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -204,8 +234,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -231,7 +264,7 @@ + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); +@@ -254,12 +287,14 @@ + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(net::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = net::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { +@@ -272,7 +307,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +@@ -281,21 +320,23 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(net::ip::tcp::endpoint{address, port}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + }); +@@ -303,10 +344,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- a/oracle/http/server/coro/http_server_coro.cpp ++++ b/oracle/http/server/coro/http_server_coro.cpp +@@ -38,70 +38,94 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -113,8 +137,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -161,18 +186,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -180,12 +208,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -201,8 +231,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -219,6 +252,8 @@ + + // Handles an HTTP server connection + void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + +@@ -233,22 +268,31 @@ + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -258,7 +302,9 @@ + } + + // Send a TCP shutdown +- stream.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -266,47 +312,83 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(net::io_context& ioc, tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, net::yield_context yield) { ++ std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn(acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio ++ // spawn/completion overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" +@@ -315,18 +397,22 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -334,17 +420,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ b/oracle/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -44,67 +44,91 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -116,8 +140,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -164,18 +189,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -183,12 +211,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -204,8 +234,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -234,15 +267,19 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection + void do_session(ssl::stream& stream, +- std::shared_ptr const& doc_root, net::yield_context yield) { ++ std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + +@@ -251,8 +288,12 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -264,10 +305,15 @@ + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); +@@ -278,8 +324,12 @@ + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -292,8 +342,12 @@ + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -301,48 +355,84 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, net::yield_context yield) { ++ std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" +@@ -351,9 +441,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -366,9 +456,13 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -376,17 +470,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/fast/fields_alloc.hpp ++++ b/oracle/http/server/fast/fields_alloc.hpp +@@ -27,7 +27,7 @@ + + namespace detail { + +-struct static_pool { ++class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; +@@ -39,7 +39,7 @@ + + public: + static static_pool& construct(std::size_t size) { +- auto p = new char[sizeof(static_pool) + size]; ++ auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + +@@ -49,25 +49,28 @@ + } + + void destroy() { +- if (--refs_) ++ if ((--refs_) != 0u) { + return; ++ } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { +- auto last = p_ + n; +- if (last >= end()) ++ auto* last = p_ + n; ++ if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); ++ } + ++count_; +- auto p = p_; ++ auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { +- if (--count_) ++ if ((--count_) != 0u) { + return; ++ } + p_ = reinterpret_cast(this + 1); + } + }; +@@ -92,7 +95,7 @@ + */ + template + struct fields_alloc { +- detail::static_pool* pool_; ++ detail::static_pool* pool; + + public: + using value_type = T; +@@ -116,20 +119,21 @@ + fields_alloc() = default; + #endif + +- explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ explicit fields_alloc(fields_alloc const& other) ++ : pool(&detail::static_pool::share(*other.pool)) {} + +- ~fields_alloc() { pool_->destroy(); } ++ ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { +- return static_cast(pool_->alloc(n * sizeof(T))); ++ return static_cast(pool->alloc(n * sizeof(T))); + } + +- void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + + #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template +@@ -145,7 +149,7 @@ + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { +- return &lhs.pool_ == &rhs.pool_; ++ return &lhs.pool == &rhs.pool_; + } + + template +--- a/oracle/http/server/fast/http_server_fast.cpp ++++ b/oracle/http/server/fast/http_server_fast.cpp +@@ -37,62 +37,85 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + +@@ -101,6 +124,8 @@ + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + ++ // Retain the upstream borrowing constructor contract in this reference counterpart. ++ // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + +@@ -134,7 +159,7 @@ + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), +- (std::chrono::steady_clock::time_point::max)()}; ++ std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> +@@ -154,7 +179,9 @@ + void accept() { + // Clean up any previous connection. + beast::error_code ec; +- socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { +@@ -184,24 +211,23 @@ + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { +- if (ec) ++ if (ec) { + accept(); +- else ++ } else { + process_request(parser_->get()); ++ } + }); + } + + void process_request(http::request> const& req) { +- switch (req.method()) { +- case http::verb::get: send_file(req.target()); break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; ++ if (req.method() == http::verb::get) { ++ send_file(req.target()); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + +@@ -219,7 +245,9 @@ + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); +@@ -228,7 +256,7 @@ + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } +@@ -257,7 +285,9 @@ + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); +@@ -271,14 +301,18 @@ + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 6) { +@@ -292,9 +326,11 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- std::string doc_root = argv[3]; +- int num_workers = std::atoi(argv[4]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ std::string const doc_root = argv[3]; ++ int const num_workers = webcpp_fixture::integer(argv[4]); ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + net::io_context ioc{1}; +@@ -306,13 +342,15 @@ + workers.back().start(); + } + +- if (spin) +- for (;;) ++ if (spin) { ++ for (;;) { + ioc.poll(); +- else ++ } ++ } else { + ioc.run(); // lint-run: drives the application's network operations ++ } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/http/server/flex/http_server_flex.cpp ++++ b/oracle/http/server/flex/http_server_flex.cpp +@@ -43,67 +43,91 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -115,8 +139,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -163,18 +188,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -182,12 +210,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -203,8 +233,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -233,8 +266,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -252,20 +286,22 @@ + http::request req_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Take ownership of the buffer ++private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), buffer_, req_, ++ derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + +@@ -273,18 +309,23 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), +@@ -295,8 +336,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -307,9 +352,13 @@ + // Read another request + do_read(); + } ++ ++ friend Derived; + }; + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -336,13 +385,17 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + }; + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +@@ -357,27 +410,33 @@ + + // Start the asynchronous operation + void run() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. +- net::dispatch(stream_.get_executor(), [self]() { ++ net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, self->buffer_.data(), ++ ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } +@@ -391,9 +450,15 @@ + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -424,8 +489,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -449,34 +518,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -508,7 +587,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" +@@ -517,9 +600,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -536,10 +619,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/small/http_server_small.cpp ++++ b/oracle/http/server/small/http_server_small.cpp +@@ -34,11 +34,12 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from +- ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from ++ ++namespace { + namespace my_program_state { + std::size_t request_count() { + static std::size_t count = 0; +@@ -46,13 +47,13 @@ + } + + std::time_t now() { +- return std::time(0); ++ return std::time(nullptr); + } + } // namespace my_program_state + + class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) : socket_(std::move(socket)) {} ++ explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { +@@ -78,13 +79,16 @@ + + // Asynchronously receive a complete request message. + void read_request() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- if (!ec) ++ if (!ec) { + self->process_request(); ++ } + }); + } + +@@ -93,21 +97,17 @@ + response_.version(request_.version()); + response_.keep_alive(false); + +- switch (request_.method()) { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" << std::string(request_.method_string()) << "'"; +- break; ++ if (request_.method() == http::verb::get) { ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); +@@ -145,24 +145,32 @@ + + // Asynchronously transmit the response message. + void write_response() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.close(ec)); + } + }); + } +@@ -171,13 +179,18 @@ + // "Loop" forever accepting new connections. + void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { +- if (!ec) ++ if (!ec) { + std::make_shared(std::move(socket))->start(); ++ } + http_server(acceptor, socket); + }); + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -190,7 +203,7 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + net::io_context ioc{1}; + +@@ -200,7 +213,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/http/server/stackless/http_server_stackless.cpp ++++ b/oracle/http/server/stackless/http_server_stackless.cpp +@@ -39,70 +39,94 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -114,8 +138,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -162,18 +187,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -181,12 +209,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -202,8 +232,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -219,6 +252,8 @@ + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; +@@ -244,6 +279,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -264,8 +301,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -280,8 +321,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -290,7 +335,9 @@ + } + + // Send a TCP shutdown +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -302,6 +349,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; +@@ -309,6 +358,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -318,28 +369,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -350,8 +409,12 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { +@@ -370,12 +433,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" +@@ -384,9 +453,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -397,10 +466,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ b/oracle/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -46,67 +46,91 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -118,8 +142,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -166,18 +191,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -185,12 +213,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -206,8 +236,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -236,13 +269,16 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; +@@ -269,6 +305,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -278,9 +316,15 @@ + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + for (;;) { + // Set the timeout. +@@ -299,8 +343,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -315,8 +363,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -329,9 +381,15 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -343,6 +401,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; +@@ -351,6 +411,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -361,28 +423,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -393,12 +463,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -413,12 +489,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" +@@ -427,9 +509,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -446,10 +528,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/http/server/sync/http_server_sync.cpp ++++ b/oracle/http/server/sync/http_server_sync.cpp +@@ -34,72 +34,96 @@ + #include + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -111,8 +135,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -159,18 +184,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -178,12 +206,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -199,8 +229,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -226,22 +259,31 @@ + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -250,14 +292,20 @@ + } + + // Send a TCP shutdown +- socket.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -267,7 +315,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -283,10 +331,12 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ b/oracle/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -42,67 +42,91 @@ + namespace http = beast::http; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -114,8 +138,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -162,18 +187,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -181,12 +209,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -202,8 +232,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -227,9 +260,15 @@ + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake +- stream.handshake(ssl::stream_base::server, ec); +- if (ec) +- return fail(ec, "handshake"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.handshake(ssl::stream_base::server, ec)); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -238,22 +277,31 @@ + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -263,16 +311,26 @@ + } + + // Perform the SSL shutdown +- stream.shutdown(ec); +- if (ec) +- return fail(ec, "shutdown"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -282,7 +340,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -304,11 +362,13 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} + .detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/websocket/client/async/websocket_client_async.cpp ++++ b/oracle/websocket/client/async/websocket_client_async.cpp +@@ -36,11 +36,12 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -69,9 +70,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -81,9 +88,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -109,8 +122,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -120,8 +137,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -130,8 +151,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -139,18 +164,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -159,9 +192,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; +--- a/oracle/websocket/client/async-local/websocket_client_async_local.cpp ++++ b/oracle/websocket/client/async-local/websocket_client_async_local.cpp +@@ -34,17 +34,18 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -73,8 +74,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); +@@ -91,8 +96,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -102,8 +111,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -112,8 +125,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -121,18 +138,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { +@@ -142,10 +167,10 @@ + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const text = argv[4]; ++ auto const* const path = argv[1]; ++ auto const* const host = argv[2]; ++ auto const* const port = argv[3]; ++ auto const* const text = argv[4]; + + // The io_context is required for all I/O + net::io_context ioc; +--- a/oracle/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/oracle/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -40,11 +40,12 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -66,6 +67,8 @@ + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; +@@ -84,9 +87,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -96,9 +105,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -115,8 +130,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -137,8 +156,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -148,8 +171,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -158,8 +185,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -167,18 +198,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -187,9 +226,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; +--- a/oracle/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/oracle/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -41,11 +41,12 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -72,6 +73,8 @@ + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; +@@ -90,9 +93,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -102,9 +111,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -121,8 +136,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -143,8 +162,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -154,8 +177,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -164,8 +191,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -173,18 +204,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -193,9 +232,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- a/oracle/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/oracle/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -33,7 +33,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; +@@ -41,8 +41,9 @@ + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -53,7 +54,7 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); ++ auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -91,11 +92,15 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -105,24 +110,27 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/websocket/client/coro/websocket_client_coro.cpp ++++ b/oracle/websocket/client/coro/websocket_client_coro.cpp +@@ -35,17 +35,20 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response + void do_session(std::string host, std::string const& port, std::string const& text, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + +@@ -55,16 +58,24 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -86,35 +97,55 @@ + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -123,18 +154,22 @@ + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -142,8 +177,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/oracle/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ b/oracle/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -40,17 +40,20 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response + void do_session(std::string host, std::string const& port, std::string const& text, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + +@@ -60,21 +63,30 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); +- return fail(ec, "connect"); ++ fail(ec, "connect"); ++ return; + } + + // Set the expected hostname in the peer certificate for verification +@@ -96,8 +108,12 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -108,35 +124,55 @@ + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -145,9 +181,9 @@ + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -164,9 +200,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -174,8 +214,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/oracle/websocket/client/sync/websocket_client_sync.cpp ++++ b/oracle/websocket/client/sync/websocket_client_sync.cpp +@@ -37,9 +37,11 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -50,8 +52,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -64,7 +66,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(ws.next_layer(), results); ++ auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -95,9 +97,9 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/oracle/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -40,9 +40,11 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -53,8 +55,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; +@@ -76,7 +78,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(beast::get_lowest_layer(ws), results); ++ auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { +@@ -119,9 +121,9 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/oracle/websocket/server/async/websocket_server_async.cpp ++++ b/oracle/websocket/server/async/websocket_server_async.cpp +@@ -40,11 +40,12 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -83,8 +84,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -99,11 +104,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -114,8 +124,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -133,32 +147,42 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -190,7 +214,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" +@@ -199,8 +227,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -211,10 +239,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/async-local/websocket_server_async_local.cpp ++++ b/oracle/websocket/server/async-local/websocket_server_async_local.cpp +@@ -38,17 +38,18 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = boost::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -87,8 +88,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -103,11 +108,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -118,8 +128,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -137,7 +151,11 @@ + stream_protocol::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, stream_protocol::endpoint endpoint) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +@@ -154,10 +172,9 @@ + if (ec) { + fail(ec, "accept"); + return; +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket))->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); +@@ -166,7 +183,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -175,14 +196,14 @@ + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const threads = std::max(1, std::atoi(argv[2])); ++ auto const* const path = argv[1]; ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); +@@ -190,15 +211,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ b/oracle/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -44,11 +44,12 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -84,8 +85,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -105,8 +110,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -121,11 +130,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -136,8 +150,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -156,33 +174,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -214,7 +242,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -223,8 +255,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -241,10 +273,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ b/oracle/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -37,7 +37,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = boost::beast; + namespace http = beast::http; +@@ -45,6 +45,7 @@ + namespace net = boost::asio; + + // Echoes back all received WebSocket messages ++namespace { + net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -65,11 +66,13 @@ + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + co_return; ++ } + +- if (ec) ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + // Echo the message back + stream.text(stream.got_text()); +@@ -79,13 +82,15 @@ + + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(net::ip::tcp::endpoint endpoint) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = net::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { +@@ -98,7 +103,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" +@@ -107,19 +116,21 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc(threads); + + // Spawn a listening port ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_listen(net::ip::tcp::endpoint{address, port}), [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + }); +@@ -127,10 +138,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- a/oracle/websocket/server/chat-multi/http_session.cpp ++++ b/oracle/websocket/server/chat-multi/http_session.cpp +@@ -25,64 +25,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -94,8 +118,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -142,18 +167,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -161,12 +189,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -182,8 +212,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -193,6 +226,8 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ + http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +@@ -201,10 +236,13 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -225,16 +263,22 @@ + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + +-void http_session::on_read(beast::error_code ec, std::size_t) { ++void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -249,8 +293,10 @@ + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); +- ++ bool const keep_alive = msg.keep_alive(); ++ ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response +@@ -260,15 +306,21 @@ + }); + } + +-void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { ++void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + +--- a/oracle/websocket/server/chat-multi/http_session.hpp ++++ b/oracle/websocket/server/chat-multi/http_session.hpp +@@ -43,8 +43,8 @@ + + void fail(beast::error_code ec, char const* what); + void do_read(); +- void on_read(beast::error_code ec, std::size_t); +- void on_write(beast::error_code ec, std::size_t, bool close); ++ void on_read(beast::error_code ec, std::size_t /*unused*/); ++ void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + + public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); +--- a/oracle/websocket/server/chat-multi/listener.cpp ++++ b/oracle/websocket/server/chat-multi/listener.cpp +@@ -21,34 +21,44 @@ + #include "http_session.hpp" + #include "listener.hpp" + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + listener::listener(net::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -62,20 +72,28 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection + void listener::on_accept(beast::error_code ec, tcp::socket socket) { +- if (ec) +- return fail(ec, "accept"); +- else ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } ++ { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); ++ } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), +--- a/oracle/websocket/server/chat-multi/main.cpp ++++ b/oracle/websocket/server/chat-multi/main.cpp +@@ -36,7 +36,9 @@ + #include + #include + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" +@@ -44,10 +46,10 @@ + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } +- auto address = net::ip::make_address(argv[1]); +- auto port = static_cast(std::atoi(argv[2])); +- auto doc_root = argv[3]; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto* doc_root = argv[3]; ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc; +@@ -69,17 +71,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/oracle/websocket/server/chat-multi/net.hpp ++++ b/oracle/websocket/server/chat-multi/net.hpp +@@ -22,7 +22,7 @@ + + #include + +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace net = boost::asio; // from ++using boost::asio::ip::tcp; // from + + #endif +--- a/oracle/websocket/server/chat-multi/shared_state.cpp ++++ b/oracle/websocket/server/chat-multi/shared_state.cpp +@@ -20,15 +20,15 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} ++shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + + void shared_state::join(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ const std::scoped_lock lock(mutex_); + sessions_.insert(session); + } + + void shared_state::leave(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ const std::scoped_lock lock(mutex_); + sessions_.erase(session); + } + +@@ -42,15 +42,18 @@ + // holding the mutex: + std::vector> v; + { +- std::lock_guard lock(mutex_); ++ const std::scoped_lock lock(mutex_); + v.reserve(sessions_.size()); +- for (auto p : sessions_) ++ for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); ++ } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for (auto const& wp : v) +- if (auto sp = wp.lock()) ++ for (auto const& wp : v) { ++ if (const auto sp = wp.lock()) { + sp->send(ss); ++ } ++ } + } +--- a/oracle/websocket/server/chat-multi/shared_state.hpp ++++ b/oracle/websocket/server/chat-multi/shared_state.hpp +@@ -31,7 +31,7 @@ + + // Represents the shared server state + class shared_state { +- std::string const doc_root_; ++ std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; +@@ -42,7 +42,7 @@ + public: + explicit shared_state(std::string doc_root); + +- std::string const& doc_root() const noexcept { return doc_root_; } ++ [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); +--- a/oracle/websocket/server/chat-multi/websocket_session.cpp ++++ b/oracle/websocket/server/chat-multi/websocket_session.cpp +@@ -29,18 +29,25 @@ + state_->leave(this); + } + ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if (ec == net::error::operation_aborted || ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Add this session to the list of active sessions + state_->join(this); +@@ -50,10 +57,14 @@ + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void websocket_session::on_read(beast::error_code ec, std::size_t) { ++void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); +@@ -80,25 +91,31 @@ + queue_.push_back(ss); + + // Are we already writing? +- if (queue_.size() > 1) ++ if (queue_.size() > 1) { + return; ++ } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void websocket_session::on_write(beast::error_code ec, std::size_t) { ++void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if (!queue_.empty()) ++ if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); ++ } + } +--- a/oracle/websocket/server/chat-multi/websocket_session.hpp ++++ b/oracle/websocket/server/chat-multi/websocket_session.hpp +@@ -61,6 +61,8 @@ + }; + + template ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +--- a/oracle/websocket/server/coro/websocket_server_coro.cpp ++++ b/oracle/websocket/server/coro/websocket_server_coro.cpp +@@ -40,16 +40,19 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -64,8 +67,12 @@ + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // This buffer will hold the incoming message +@@ -75,64 +82,106 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(net::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" +@@ -141,8 +190,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc(threads); +@@ -150,8 +199,12 @@ + // Spawn a listening port + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -159,17 +212,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ b/oracle/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -44,17 +44,21 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-void do_session(websocket::stream>& ws, net::yield_context yield) { ++void do_session(websocket::stream>& ws, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. +@@ -62,8 +66,12 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -80,8 +88,12 @@ + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // This buffer will hold the incoming message +@@ -91,66 +103,110 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" +@@ -159,8 +215,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -173,9 +229,13 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -183,17 +243,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/fast/websocket_server_fast.cpp ++++ b/oracle/websocket/server/fast/websocket_server_fast.cpp +@@ -56,11 +56,12 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); + } +@@ -96,35 +97,58 @@ + })); + + ws.accept(ec); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + beast::flat_buffer buffer; + + ws.read(buffer, ec); +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); +- if (ec) +- return fail(ec, "write"); +- } +-} +- ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } ++ } ++} ++ ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_sync_listen(net::io_context& ioc, tcp::endpoint endpoint) { + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; + for (;;) { + tcp::socket socket{ioc}; + +- acceptor.accept(socket, ec); +- if (ec) +- return fail(ec, "accept"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.accept(socket, ec)); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + std::thread( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_sync_session, websocket::stream(std::move(socket)))) + .detach(); + } +@@ -156,8 +180,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -173,11 +201,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -188,8 +221,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -205,33 +242,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + async_listener(net::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -264,6 +311,8 @@ + + //------------------------------------------------------------------------------ + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -278,44 +327,83 @@ + })); + + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); +- } +-} +- ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } ++ } ++} ++ ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_coro_listen(net::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); +- +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); +- +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); +- +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); +@@ -328,6 +416,8 @@ + + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); +@@ -336,7 +426,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" +@@ -349,8 +443,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -368,6 +462,8 @@ + + // Create coro port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), +@@ -376,10 +472,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/stackless/websocket_server_stackless.cpp ++++ b/oracle/websocket/server/stackless/websocket_server_stackless.cpp +@@ -41,16 +41,19 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; +@@ -72,6 +75,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -86,29 +91,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -122,39 +146,51 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -165,12 +201,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -185,12 +227,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" +@@ -199,8 +247,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -211,10 +259,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ b/oracle/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -46,16 +46,19 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -77,6 +80,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +@@ -87,9 +92,15 @@ + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -106,29 +117,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -142,6 +172,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; +@@ -149,33 +181,43 @@ + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -186,12 +228,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -206,12 +254,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -220,8 +274,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; +@@ -238,10 +292,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/oracle/websocket/server/sync/websocket_server_sync.cpp ++++ b/oracle/websocket/server/sync/websocket_server_sync.cpp +@@ -36,11 +36,12 @@ + namespace http = beast::http; // from + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket) { + try { + // Construct the stream by moving in the socket +@@ -68,16 +69,21 @@ + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if (se.code() != websocket::error::closed) +- std::cerr << "Error: " << se.code().message() << std::endl; ++ if (se.code() != websocket::error::closed) { ++ std::cerr << "Error: " << se.code().message() << '\n'; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -87,7 +93,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{1}; +@@ -105,7 +111,7 @@ + std::thread(&do_session, std::move(socket)).detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/oracle/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ b/oracle/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -41,11 +41,12 @@ + namespace websocket = beast::websocket; // from + namespace net = boost::asio; // from + namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++using boost::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket, ssl::context& ctx) { + try { + // Construct the websocket stream around the socket +@@ -76,16 +77,21 @@ + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if (se.code() != websocket::error::closed) +- std::cerr << "Error: " << se.code().message() << std::endl; ++ if (se.code() != websocket::error::closed) { ++ std::cerr << "Error: " << se.code().message() << '\n'; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -95,7 +101,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{1}; +@@ -119,7 +125,7 @@ + std::thread(&do_session, std::move(socket), std::ref(ctx)).detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/advanced/server/advanced_server.cpp ++++ b/port/advanced/server/advanced_server.cpp +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -47,8 +46,6 @@ + #include + #include + #include +-#include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -57,64 +54,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -126,8 +147,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -174,18 +196,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -193,12 +218,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -214,8 +241,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -241,6 +271,8 @@ + + // Start the asynchronous accept operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -258,8 +290,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -275,11 +311,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -290,8 +331,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -354,11 +399,19 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -373,8 +426,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -382,15 +436,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), +@@ -401,18 +456,24 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + +@@ -422,7 +483,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -437,34 +500,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -503,7 +576,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" +@@ -512,9 +589,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -534,17 +611,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/port/advanced/server-flex/advanced_server_flex.cpp ++++ b/port/advanced/server-flex/advanced_server_flex.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -51,8 +50,6 @@ + #include + #include + #include +-#include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -62,64 +59,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -131,8 +152,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -179,18 +201,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -198,12 +223,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -219,8 +246,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -249,8 +279,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -262,6 +293,8 @@ + // the same code works with both SSL streams and regular sockets. + template + class websocket_session { ++ websocket_session() = default; ++ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } +@@ -270,6 +303,8 @@ + + // Start the asynchronous operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +@@ -289,8 +324,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -306,11 +345,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + derived().ws().text(derived().ws().got_text()); +@@ -322,8 +366,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -339,11 +387,15 @@ + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; +@@ -359,6 +411,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; +@@ -407,13 +461,15 @@ + boost::optional> parser_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Construct the session ++private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); +@@ -427,7 +483,7 @@ + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), buffer_, *parser_, ++ derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + +@@ -435,11 +491,16 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -456,8 +517,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -465,15 +527,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, +@@ -484,8 +547,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -494,18 +561,23 @@ + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + + do_write(); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -530,7 +602,9 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -539,6 +613,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; +@@ -558,7 +634,7 @@ + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, buffer_.data(), ++ ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + +@@ -580,18 +656,28 @@ + + private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -631,8 +717,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -656,34 +746,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -715,7 +815,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" +@@ -724,9 +828,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -752,17 +856,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ b/port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -47,7 +46,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -56,69 +55,92 @@ + namespace ssl = boost::asio::ssl; + + using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = +- typename webcpp::asio::ip::tcp::acceptor::rebind_executor::other; ++using stream_type = beast::tcp_stream::rebind_executor::other; ++using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -130,8 +152,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -178,18 +201,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -197,12 +223,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -218,8 +246,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -236,7 +267,11 @@ + std::list css_; + + public: +- task_group(net::any_io_executor exec) ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ explicit task_group(net::any_io_executor exec) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +@@ -260,8 +295,8 @@ + */ + template + auto adapt(CompletionToken&& completion_token) { +- auto lg = std::lock_guard{mtx_}; +- auto cs = css_.emplace(css_.end()); ++ auto const lg = std::scoped_lock{mtx_}; ++ auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; +@@ -273,11 +308,14 @@ + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + ++ // A mutex or timer failure during this upstream task teardown is fatal by design. ++ // NOLINTNEXTLINE(bugprone-exception-escape) + ~remover() { + if (tg_) { +- auto lg = std::lock_guard{tg_->mtx_}; +- if (tg_->css_.erase(cs_) == tg_->css_.end()) ++ auto const lg = std::scoped_lock{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); ++ } + } + } + }; +@@ -297,9 +335,10 @@ + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { +- auto lg = std::lock_guard{mtx_}; +- for (auto& cs : css_) ++ auto const lg = std::scoped_lock{mtx_}; ++ for (auto& cs : css_) { + cs.emit(type); ++ } + } + + /** Starts an asynchronous wait on the task_group. +@@ -326,24 +365,33 @@ + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( ++ // The apparent recursion crosses an asynchronous completion boundary. ++ // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { +- if (!scheduled) ++ if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); +- +- if (!self.cancelled() && ec == net::error::operation_aborted) ++ } ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; ++ } + + { +- auto lg = std::lock_guard{mtx_}; ++ auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + +- if (!std::exchange(scheduled, true)) ++ if (!std::exchange(scheduled, true)) { ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); ++ } + + self.complete(ec); + }, +@@ -355,7 +403,7 @@ + net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +@@ -374,11 +422,13 @@ + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + // Echo the message back + ws.text(ws.got_text()); +@@ -391,14 +441,15 @@ + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; ++ } + } + + template + net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; +@@ -406,8 +457,9 @@ + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + co_return; ++ } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. +@@ -448,25 +500,28 @@ + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + +- auto bytes_transferred = ++ auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if (!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) { + co_return; ++ } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; ++ } + } else { + co_await run_session(stream, buffer, doc_root); + +- if (!stream.socket().is_open()) ++ if (!stream.socket().is_open()) { + co_return; ++ } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +@@ -475,25 +530,31 @@ + net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; +- auto executor = co_await net::this_coro::executor; ++ auto const cs = co_await net::this_coro::cancellation_state; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { +@@ -507,9 +568,11 @@ + } + + net::awaitable handle_signals(task_group& task_group) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto sig = co_await signal_set.async_wait(); + + if (sig == SIGINT) { +@@ -534,7 +597,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" +@@ -543,10 +610,10 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -561,8 +628,10 @@ + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine +- auto listener_executor = net::make_strand(ioc); ++ auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { +@@ -579,14 +648,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/port/common/root_certificates.hpp ++++ b/port/common/root_certificates.hpp +@@ -61,7 +61,9 @@ + + inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { +- ctx.load_verify_file(path, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(ctx.load_verify_file(path, ec)); + return; + } + +@@ -3952,9 +3954,13 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); +- if (ec) ++ static_cast( ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); ++ if (ec) { + return; ++ } + } + + } // namespace detail +@@ -3968,8 +3974,9 @@ + inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if (ec) ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + } + + #endif +--- a/port/doc/http_examples.hpp ++++ b/port/doc/http_examples.hpp +@@ -23,7 +23,9 @@ + // Official repository: https://github.com/boostorg/beast + // + ++#include + #include ++#include + #include + + /* This file contains the functions and classes found in the documentation +@@ -34,9 +36,8 @@ + */ + + // The documentation assumes the webcpp::beast::http namespace +-namespace boost { +-namespace beast { +-namespace http { ++ ++namespace boost::beast::http { + + //------------------------------------------------------------------------------ + // +@@ -80,16 +81,18 @@ + + // Send just the header + write_header(stream, sr, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. +@@ -129,8 +132,9 @@ + + // Read the header + read_header(stream, buffer, parser, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { +@@ -140,8 +144,9 @@ + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + } + + // Read the rest of the message. +@@ -201,16 +206,17 @@ + + // Send the header immediately. + write_header(output, sr, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process +- char buffer[2048]; +- auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); ++ std::array buffer{}; ++ auto bytes_transferred = input.read_some(boost::asio::buffer(buffer), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + +@@ -220,13 +226,14 @@ + // `false` means no more data is coming + res.body().more = false; + } else { +- if (ec) ++ if (ec) { + return; ++ } + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming +- res.body().data = buffer; ++ res.body().data = buffer.data(); + res.body().size = bytes_transferred; + res.body().more = true; + } +@@ -241,8 +248,9 @@ + ec = {}; + continue; + } +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + } while (!sr.is_done()); + } + +@@ -270,8 +278,9 @@ + // Read the request + request req; + read(stream, buffer, req, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Set up the response, starting with the common fields + response res; +@@ -311,8 +320,9 @@ + + // Send the response + write(stream, res, ec); +- if (ec) ++ if (ec) { + return; ++ } + } + + //] +@@ -346,8 +356,9 @@ + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. +- if (target.empty()) ++ if (target.empty()) { + throw std::invalid_argument("target may not be empty"); ++ } + + // Build the HEAD request for the target + request req; +@@ -362,8 +373,9 @@ + + // Now send it + write(stream, req, ec); +- if (ec) ++ if (ec) { + return {}; ++ } + + // Create a parser to read the response. + // We use the `empty_body` type since +@@ -378,8 +390,9 @@ + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return {}; ++ } + + // Transfer ownership of the response to the caller. + return p.release(); +@@ -436,7 +449,7 @@ + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece +- char buf[2048]; ++ std::array buf{}; + + // Create a parser with a buffer body to read from the input. + parser p; +@@ -446,39 +459,44 @@ + + // Read just the header from the input + read_header(input, buffer, p, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Apply the caller's header transformation + transform(p.get(), ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Send the transformed message to the output + write_header(output, sr, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer +- p.get().body().data = buf; +- p.get().body().size = sizeof(buf); ++ p.get().body().data = buf.data(); ++ p.get().body().size = buf.size(); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer +- if (ec == error::need_buffer) ++ if (ec == error::need_buffer) { + ec = {}; +- if (ec) ++ } ++ if (ec) { + return; ++ } + + // Set up the body for reading. + // This is how much was parsed: +- p.get().body().size = sizeof(buf) - p.get().body().size; +- p.get().body().data = buf; ++ p.get().body().size = buf.size() - p.get().body().size; ++ p.get().body().data = buf.data(); + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; +@@ -489,10 +507,12 @@ + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer +- if (ec == error::need_buffer) ++ if (ec == error::need_buffer) { + ec = {}; +- if (ec) +- return; ++ } ++ if (ec) { ++ return; ++ } + } while (!p.is_done() && !sr.is_done()); + } + +@@ -535,7 +555,13 @@ + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream +- os_.write(reinterpret_cast(buffer.data()), buffer.size()); ++ if (buffer.size() > ++ static_cast(std::numeric_limits::max())) { ++ ec = make_error_code(errc::value_too_large); ++ return; ++ } ++ os_.write(reinterpret_cast(buffer.data()), ++ static_cast(buffer.size())); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { +@@ -577,8 +603,9 @@ + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); +- if (ec) +- return; ++ if (ec) { ++ return; ++ } + } while (!sr.is_done()); + } + +@@ -647,8 +674,9 @@ + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); +- if (ec) ++ if (ec) { + return; ++ } + break; + } + } +@@ -657,10 +685,12 @@ + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. +- if (ec == error::need_more) ++ if (ec == error::need_more) { + ec = {}; +- if (ec) +- return; ++ } ++ if (ec) { ++ return; ++ } + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); +@@ -712,42 +742,16 @@ + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb +- switch (req0.get().method()) { +- case verb::post: { +- // If this is not a form upload then use a string_body +- if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && +- req0.get()[field::content_type] != "multipart/form-data") +- goto do_dynamic_body; +- +- // Commit to string_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } +- +- do_dynamic_body: +- default: { +- // Commit to dynamic_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } ++ if (req0.get().method() == verb::post && ++ (req0.get()[field::content_type] == "application/x-www-form-urlencoded" || ++ req0.get()[field::content_type] == "multipart/form-data")) { ++ request_parser req{std::move(req0)}; ++ read(stream, buffer, req); ++ handler(req.release()); ++ } else { ++ request_parser req{std::move(req0)}; ++ read(stream, buffer, req); ++ handler(req.release()); + } + } + +@@ -769,18 +773,21 @@ + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return; ++ } + while (!p.is_done()) { +- char buf[512]; +- p.get().body().data = buf; +- p.get().body().size = sizeof(buf); ++ std::array buf{}; ++ p.get().body().data = buf.data(); ++ p.get().body().size = buf.size(); + read(stream, buffer, p, ec); +- if (ec == error::need_buffer) ++ if (ec == error::need_buffer) { + ec = {}; +- if (ec) +- return; +- os.write(buf, sizeof(buf) - p.get().body().size); ++ } ++ if (ec) { ++ return; ++ } ++ os.write(buf.data(), static_cast(buf.size() - p.get().body().size)); + } + } + +@@ -806,8 +813,9 @@ + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return bytes_transferred; ++ } + msg = p.release(); + return bytes_transferred; + } +@@ -833,8 +841,9 @@ + + // First read the complete header + read_header(stream, buffer, p, ec); +- if (ec) ++ if (ec) { + return; ++ } + + // This container will hold the extensions for each chunk + chunk_extensions ce; +@@ -851,11 +860,12 @@ + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); +- if (ev) +- return; ++ if (ev) { ++ return; ++ } + + // See if the chunk is too big +- if (size > (std::numeric_limits::max)()) { ++ if (size > std::numeric_limits::max()) { + ev = error::body_limit; + return; + } +@@ -879,8 +889,9 @@ + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. +- if (remain == body.size()) ++ if (remain == body.size()) { + ec = error::end_of_chunk; ++ } + + // Append this piece to our container + chunk.append(body.data(), body.size()); +@@ -895,24 +906,26 @@ + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); +- if (!ec) ++ if (!ec) { + continue; +- else if (ec != error::end_of_chunk) +- return; +- else +- ec = {}; ++ } ++ if (ec != error::end_of_chunk) { ++ return; ++ } ++ ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; +- if (!extension.second.empty()) +- os << " = " << extension.second << std::endl; +- else +- os << std::endl; ++ if (!extension.second.empty()) { ++ os << " = " << extension.second << '\n' << std::flush; ++ } else { ++ os << '\n' << std::flush; ++ } + } + + // Now print the chunk body +- os << "Chunk Body: " << chunk << std::endl; ++ os << "Chunk Body: " << chunk << '\n' << std::flush; + } + + // Get a reference to the parsed message, this is for convenience +@@ -924,15 +937,13 @@ + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it +- os << "Missing Trailer: " << name << std::endl; ++ os << "Missing Trailer: " << name << '\n' << std::flush; + continue; + } +- os << it->name() << ": " << it->value() << std::endl; +- } +-} +- +-//] +- +-} // namespace http +-} // namespace beast +-} // namespace boost ++ os << it->name() << ": " << it->value() << '\n' << std::flush; ++ } ++} ++ ++//] ++ ++} // namespace boost::beast::http +--- a/port/doc/ssl/client.cpp ++++ b/port/doc/ssl/client.cpp +@@ -27,31 +27,33 @@ + #include + #include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + } + + net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket +@@ -86,9 +88,12 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); ++ } + } ++ ++} // namespace + + int main() { + try { +@@ -123,7 +128,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + +--- a/port/doc/ssl/server.cpp ++++ b/port/doc/ssl/server.cpp +@@ -27,23 +27,25 @@ + #include + #include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + } +@@ -64,14 +66,15 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); ++ } + } + + net::awaitable acceptor(ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ auto const executor = co_await net::this_coro::executor; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { +@@ -79,6 +82,8 @@ + print_exception); + } + } ++ ++} // namespace + + int main() { + try { +@@ -94,6 +99,8 @@ + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. ++ // Asio exposes the OpenSSL verification bitmask as signed integer constants. ++ // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this +@@ -115,7 +122,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + +--- a/port/echo-op/echo_op.cpp ++++ b/port/echo-op/echo_op.cpp +@@ -33,14 +33,15 @@ + namespace net = boost::asio; + namespace beast = webcpp::beast; + ++namespace { ++ + //[example_core_echo_op_1 + + template + auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] +- -> typename net::async_result::type, +- void(beast::error_code)>::return_type; ++ -> net::async_result, void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -66,7 +67,7 @@ + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the +- first line. These characters are stored in the dynamic buffer_. ++ first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + +@@ -93,14 +94,16 @@ + `net::post`. + */ + template ++// Each documentation snippet presents the complete public declaration. ++// NOLINTNEXTLINE(readability-redundant-declaration) + auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> typename net:: +- async_result*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) ++ -> net::async_result*/ ++ std::decay_t, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 +@@ -116,10 +119,12 @@ + // Read a line and echo it back + // + template +-auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> +- typename net::async_result::type, +- void(beast::error_code)>::return_type /*< The completion handler +- signature goes here >*/ ++// Stackless coroutine macros generate the branches in this operation. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ -> net::async_result, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +@@ -162,9 +167,11 @@ + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + ++ // Asio operation state combines completion ownership with coroutine resume state. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { +- AsyncStream& stream_; +- DynamicBuffer& buffer_; ++ AsyncStream& stream_state; ++ DynamicBuffer& buffer_state; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +@@ -172,8 +179,8 @@ + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , +- stream_(stream), +- buffer_(buffer) { ++ stream_state(stream), ++ buffer_state(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -185,19 +192,20 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { ++ static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = ++ const auto begin = + net::buffers_iterator::begin(buffers); +- auto end = ++ const auto end = + net::buffers_iterator::end(buffers); +- auto result = std::find(begin, end, '\n'); +- +- if (result == end) ++ const auto result = std::find(begin, end, '\n'); ++ ++ if (result == end) { + return 0; // not found ++ } + + return result + 1 - begin; + } +@@ -205,6 +213,8 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + ++ // Resume labels generated by the stackless coroutine form one state machine. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ +@@ -215,13 +225,17 @@ + + reenter(*this) { + for (;;) { ++ // Resume labels cannot cross an initialized local; it is assigned before use. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer +- pos = find_newline(buffer_.data()); ++ pos = find_newline(buffer_state.data()); + + // If we don't have the newline, then read more + if (pos == 0) { ++ // Resume labels cannot cross an initialized local; it is assigned before ++ // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, +@@ -229,18 +243,18 @@ + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), ++ buffer_state.capacity() - buffer_state.size()), + std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); +- +- // Read some data into our dynamic buffer_. We transfer ++ buffer_state.max_size() - buffer_state.size())); ++ ++ // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some(buffer_.prepare(bytes_to_read), +- std::move(*this)); ++ yield stream_state.async_read_some(buffer_state.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -248,11 +262,12 @@ + // Move the bytes read from the writable area to the + // readable area. + +- buffer_.commit(bytes_transferred); ++ buffer_state.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if (ec) ++ if (ec) { + break; ++ } + + // Keep looping until we get the newline + continue; +@@ -262,7 +277,8 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ yield net::async_write(stream_state, ++ beast::buffers_prefix(pos, buffer_state.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will +@@ -274,7 +290,7 @@ + // to consume. With "real" coroutines this will be easier and more + // natural. + +- buffer_.consume(bytes_transferred); ++ buffer_state.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. +@@ -324,11 +340,16 @@ + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { +- if (ec) +- std::cerr << ": " << ec.message() << std::endl; ++ if (ec) { ++ std::cerr << ": " << ec.message() << '\n'; ++ } + } + }; + ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" +@@ -339,7 +360,7 @@ + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + +@@ -347,7 +368,7 @@ + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; +- endpoint_type ep(address, port); ++ const endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); +--- a/port/http/client/async/http_client_async.cpp ++++ b/port/http/client/async/http_client_async.cpp +@@ -30,14 +30,12 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -47,6 +45,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -79,9 +78,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -91,9 +96,15 @@ + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -106,8 +117,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -117,18 +132,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -136,6 +161,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -146,10 +175,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/port/http/client/async-local/http_client_async_local.cpp ++++ b/port/http/client/async-local/http_client_async_local.cpp +@@ -31,25 +31,24 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -83,8 +82,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -97,8 +100,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -108,18 +115,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -127,6 +144,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { +@@ -137,11 +158,11 @@ + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const target = argv[4]; +- int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; ++ auto const* const path = argv[1]; ++ auto const* const host = argv[2]; ++ auto const* const port = argv[3]; ++ auto const* const target = argv[4]; ++ int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/port/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/port/http/client/async-ssl/http_client_async_ssl.cpp +@@ -34,12 +34,10 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,6 +48,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -91,9 +90,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -103,9 +108,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -114,8 +125,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -128,8 +143,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -139,11 +158,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -153,6 +176,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -171,13 +196,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -188,10 +221,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -35,12 +35,10 @@ + #include + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -98,9 +97,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -110,9 +115,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -121,8 +132,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -135,8 +150,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -146,11 +165,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -160,6 +183,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -178,13 +203,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -195,10 +228,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- a/port/http/client/awaitable/http_client_awaitable.cpp ++++ b/port/http/client/awaitable/http_client_awaitable.cpp +@@ -32,24 +32,23 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -83,23 +82,30 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -111,10 +117,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -124,16 +130,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -35,9 +35,7 @@ + #include + #include + #include +-#include + #include +-#include + + #include "common/root_certificates.hpp" + +@@ -45,7 +43,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -55,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +@@ -106,7 +105,7 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -131,12 +130,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) { + throw boost::system::system_error(ec, "shutdown"); ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -148,10 +152,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -170,16 +174,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/http/client/body/json_body.hpp ++++ b/port/http/client/body/json_body.hpp +@@ -32,6 +32,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -47,11 +48,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(webcpp::beast::http::header const&, value_type const& body) { ++ writer(webcpp::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -60,20 +64,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ reader(webcpp::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -81,8 +86,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -90,21 +97,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/port/http/client/body/json_client.cpp ++++ b/port/http/client/body/json_client.cpp +@@ -17,20 +17,18 @@ + #include "fixture.hpp" + #include "json_body.hpp" + +-#include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char**) { ++int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -65,11 +63,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; + } +--- a/port/http/client/coro/http_client_coro.cpp ++++ b/port/http/client/coro/http_client_coro.cpp +@@ -30,13 +30,11 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -46,12 +44,15 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response + void do_session(std::string const& host, std::string const& port, std::string const& target, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + +@@ -61,16 +62,24 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; +@@ -82,8 +91,12 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; +@@ -93,26 +106,40 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -123,10 +150,10 @@ + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -134,9 +161,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -144,8 +175,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/port/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ b/port/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -34,13 +34,11 @@ + + #include + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -58,6 +57,8 @@ + // Performs an HTTP GET and prints the response + void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, ssl::context& ctx, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + +@@ -77,24 +78,36 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; +@@ -106,8 +119,12 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; +@@ -117,11 +134,15 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -146,12 +167,20 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -162,10 +191,10 @@ + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -182,9 +211,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -192,8 +225,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/port/http/client/crawl/http_crawl.cpp ++++ b/port/http/client/crawl/http_crawl.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -49,7 +48,6 @@ + #include + #include + #include +-#include + + namespace chrono = std::chrono; // from + namespace beast = webcpp::beast; // from +@@ -60,6 +58,7 @@ + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -67,7 +66,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(webcpp::asio::io_context& ioc) ++ explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -87,8 +86,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -125,9 +125,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -138,7 +139,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -167,11 +168,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -182,10 +184,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -196,10 +201,13 @@ + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) { ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -215,7 +223,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -229,7 +238,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -239,7 +249,9 @@ + }); + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully +@@ -258,16 +270,20 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- auto const threads = std::max(1, std::atoi(argv[1])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; +@@ -275,6 +291,8 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Create and launch the worker threads. +@@ -285,7 +303,11 @@ + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto reporting_work = ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); + + workers.emplace_back([&report, reporting_work] { +@@ -306,8 +328,9 @@ + }); + + // Now block until all threads exit +- for (std::size_t i = 0; i < workers.size(); ++i) +- workers[i].join(); ++ for (auto& worker : workers) { ++ worker.join(); ++ } + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; +--- a/port/http/client/methods/http_client_methods.cpp ++++ b/port/http/client/methods/http_client_methods.cpp +@@ -33,19 +33,18 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); +@@ -123,6 +122,10 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -134,8 +137,9 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); ++ } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +@@ -162,42 +166,45 @@ + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/http/client/sync/http_client_sync.cpp ++++ b/port/http/client/sync/http_client_sync.cpp +@@ -33,19 +33,19 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -57,10 +57,10 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -93,21 +93,24 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/port/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -35,11 +35,9 @@ + #include + #include + #include +-#include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +46,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -59,10 +59,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -116,11 +116,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +- stream.shutdown(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -139,10 +141,11 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) { + throw beast::system_error{ec}; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/http/server/async/http_server_async.cpp ++++ b/port/http/server/async/http_server_async.cpp +@@ -32,7 +32,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -42,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,64 +48,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -119,8 +141,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -167,18 +190,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -186,12 +212,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -207,8 +235,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -262,18 +293,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -284,13 +323,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -300,7 +344,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -315,34 +361,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -363,10 +419,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -375,7 +430,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" +@@ -384,9 +443,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -397,10 +456,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/async-local/http_server_async_local.cpp ++++ b/port/http/server/async-local/http_server_async_local.cpp +@@ -33,10 +33,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -46,72 +44,96 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -267,18 +298,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -289,13 +328,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -305,7 +349,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -320,8 +366,12 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +@@ -338,10 +388,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -350,7 +399,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -359,15 +412,15 @@ + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; ++ auto const* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); +@@ -375,15 +428,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/http/server/async-ssl/http_server_async_ssl.cpp ++++ b/port/http/server/async-ssl/http_server_async_ssl.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -45,7 +44,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,64 +52,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -241,8 +272,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -281,8 +313,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + do_read(); + } +@@ -304,18 +340,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -326,13 +370,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -348,9 +397,15 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -366,34 +421,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -414,10 +479,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), ctx_, doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -426,7 +490,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" +@@ -435,9 +503,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -454,10 +522,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/awaitable/http_server_awaitable.cpp ++++ b/port/http/server/awaitable/http_server_awaitable.cpp +@@ -33,10 +33,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -46,71 +44,95 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -122,8 +144,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -170,18 +193,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -189,12 +215,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -210,8 +238,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -237,7 +268,7 @@ + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); +@@ -260,12 +291,14 @@ + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { +@@ -278,7 +311,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +@@ -287,21 +324,23 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + }); +@@ -309,10 +348,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- a/port/http/server/coro/http_server_coro.cpp ++++ b/port/http/server/coro/http_server_coro.cpp +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -42,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -50,64 +48,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -119,8 +141,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -167,18 +190,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -186,12 +212,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -207,8 +235,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -225,6 +256,8 @@ + + // Handles an HTTP server connection + void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + +@@ -239,22 +272,31 @@ + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -264,7 +306,9 @@ + } + + // Send a TCP shutdown +- stream.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -272,47 +316,83 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, net::yield_context yield) { ++ std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn(acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio ++ // spawn/completion overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" +@@ -321,18 +401,22 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -340,17 +424,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ b/port/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -45,7 +44,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,64 +52,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -241,15 +272,19 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection + void do_session(ssl::stream& stream, +- std::shared_ptr const& doc_root, net::yield_context yield) { ++ std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + +@@ -258,8 +293,12 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -271,10 +310,15 @@ + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); +@@ -285,8 +329,12 @@ + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -299,8 +347,12 @@ + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -308,48 +360,84 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, net::yield_context yield) { ++ std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" +@@ -358,9 +446,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -373,9 +461,13 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -383,17 +475,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/fast/fields_alloc.hpp ++++ b/port/http/server/fast/fields_alloc.hpp +@@ -33,7 +33,7 @@ + + namespace detail { + +-struct static_pool { ++class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; +@@ -45,7 +45,7 @@ + + public: + static static_pool& construct(std::size_t size) { +- auto p = new char[sizeof(static_pool) + size]; ++ auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + +@@ -55,25 +55,28 @@ + } + + void destroy() { +- if (--refs_) ++ if ((--refs_) != 0u) { + return; ++ } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { +- auto last = p_ + n; +- if (last >= end()) ++ auto* last = p_ + n; ++ if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); ++ } + ++count_; +- auto p = p_; ++ auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { +- if (--count_) ++ if ((--count_) != 0u) { + return; ++ } + p_ = reinterpret_cast(this + 1); + } + }; +@@ -98,7 +101,7 @@ + */ + template + struct fields_alloc { +- detail::static_pool* pool_; ++ detail::static_pool* pool; + + public: + using value_type = T; +@@ -122,20 +125,21 @@ + fields_alloc() = default; + #endif + +- explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ explicit fields_alloc(fields_alloc const& other) ++ : pool(&detail::static_pool::share(*other.pool)) {} + +- ~fields_alloc() { pool_->destroy(); } ++ ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { +- return static_cast(pool_->alloc(n * sizeof(T))); ++ return static_cast(pool->alloc(n * sizeof(T))); + } + +- void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + + #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template +@@ -151,7 +155,7 @@ + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { +- return &lhs.pool_ == &rhs.pool_; ++ return &lhs.pool == &rhs.pool_; + } + + template +--- a/port/http/server/fast/http_server_fast.cpp ++++ b/port/http/server/fast/http_server_fast.cpp +@@ -32,7 +32,6 @@ + #include "fields_alloc.hpp" + + #include +-#include + #include + #include + #include +@@ -41,7 +40,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,56 +47,79 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + +@@ -107,6 +128,8 @@ + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + ++ // Retain the upstream borrowing constructor contract in this reference counterpart. ++ // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + +@@ -140,7 +163,7 @@ + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), +- (std::chrono::steady_clock::time_point::max)()}; ++ std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> +@@ -160,7 +183,9 @@ + void accept() { + // Clean up any previous connection. + beast::error_code ec; +- socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { +@@ -190,24 +215,23 @@ + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { +- if (ec) ++ if (ec) { + accept(); +- else ++ } else { + process_request(parser_->get()); ++ } + }); + } + + void process_request(http::request> const& req) { +- switch (req.method()) { +- case http::verb::get: send_file(req.target()); break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; ++ if (req.method() == http::verb::get) { ++ send_file(req.target()); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + +@@ -225,7 +249,9 @@ + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); +@@ -234,7 +260,7 @@ + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } +@@ -263,7 +289,9 @@ + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); +@@ -277,14 +305,18 @@ + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 6) { +@@ -298,9 +330,11 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- std::string doc_root = argv[3]; +- int num_workers = std::atoi(argv[4]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ std::string const doc_root = argv[3]; ++ int const num_workers = webcpp_fixture::integer(argv[4]); ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; +@@ -312,13 +346,15 @@ + workers.back().start(); + } + +- if (spin) +- for (;;) ++ if (spin) { ++ for (;;) { + ioc.poll(); +- else ++ } ++ } else { + ioc.run(); // lint-run: drives the application's network operations ++ } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/http/server/flex/http_server_flex.cpp ++++ b/port/http/server/flex/http_server_flex.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -44,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,64 +51,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -122,8 +144,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -170,18 +193,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -189,12 +215,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -210,8 +238,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -240,8 +271,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -259,20 +291,22 @@ + http::request req_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Take ownership of the buffer ++private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), buffer_, req_, ++ derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + +@@ -280,18 +314,23 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), +@@ -302,8 +341,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -314,9 +357,13 @@ + // Read another request + do_read(); + } ++ ++ friend Derived; + }; + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -343,13 +390,17 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + }; + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +@@ -364,27 +415,33 @@ + + // Start the asynchronous operation + void run() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. +- net::dispatch(stream_.get_executor(), [self]() { ++ net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, self->buffer_.data(), ++ ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } +@@ -398,9 +455,15 @@ + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -431,8 +494,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -456,34 +523,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -515,7 +592,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" +@@ -524,9 +605,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -543,10 +624,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/small/http_server_small.cpp ++++ b/port/http/server/small/http_server_small.cpp +@@ -30,7 +30,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include +@@ -38,13 +37,13 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + using tcp = webcpp::asio::ip::tcp; // from + ++namespace { + namespace my_program_state { + std::size_t request_count() { + static std::size_t count = 0; +@@ -52,13 +51,13 @@ + } + + std::time_t now() { +- return std::time(0); ++ return std::time(nullptr); + } + } // namespace my_program_state + + class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) : socket_(std::move(socket)) {} ++ explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { +@@ -84,13 +83,16 @@ + + // Asynchronously receive a complete request message. + void read_request() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- if (!ec) ++ if (!ec) { + self->process_request(); ++ } + }); + } + +@@ -99,21 +101,17 @@ + response_.version(request_.version()); + response_.keep_alive(false); + +- switch (request_.method()) { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" << std::string(request_.method_string()) << "'"; +- break; ++ if (request_.method() == http::verb::get) { ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); +@@ -151,24 +149,32 @@ + + // Asynchronously transmit the response message. + void write_response() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.close(ec)); + } + }); + } +@@ -177,13 +183,18 @@ + // "Loop" forever accepting new connections. + void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { +- if (!ec) ++ if (!ec) { + std::make_shared(std::move(socket))->start(); ++ } + http_server(acceptor, socket); + }); + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -196,7 +207,7 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + +@@ -206,7 +217,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/http/server/stackless/http_server_stackless.cpp ++++ b/port/http/server/stackless/http_server_stackless.cpp +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -43,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,64 +49,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -120,8 +142,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -168,18 +191,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -187,12 +213,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -208,8 +236,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -225,6 +256,8 @@ + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; +@@ -250,6 +283,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -270,8 +305,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -286,8 +325,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -296,7 +339,9 @@ + } + + // Send a TCP shutdown +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -308,6 +353,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; +@@ -315,6 +362,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -324,28 +373,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -356,8 +413,12 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { +@@ -376,12 +437,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" +@@ -390,9 +457,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -403,10 +470,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ b/port/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -47,7 +46,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -56,64 +54,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -125,8 +147,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -173,18 +196,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -192,12 +218,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -213,8 +241,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -243,13 +274,16 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; +@@ -276,6 +310,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -285,9 +321,15 @@ + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + for (;;) { + // Set the timeout. +@@ -306,8 +348,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -322,8 +368,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -336,9 +386,15 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -350,6 +406,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -358,6 +416,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -368,28 +428,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -400,12 +468,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -420,12 +494,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" +@@ -434,9 +514,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -453,10 +533,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/http/server/sync/http_server_sync.cpp ++++ b/port/http/server/sync/http_server_sync.cpp +@@ -30,7 +30,6 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include +@@ -38,7 +37,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,64 +46,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -117,8 +139,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -165,18 +188,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -184,12 +210,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -205,8 +233,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -232,22 +263,31 @@ + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -256,14 +296,20 @@ + } + + // Send a TCP shutdown +- socket.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -273,7 +319,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -289,10 +335,12 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ b/port/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -43,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,64 +50,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -121,8 +143,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -169,18 +192,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -188,12 +214,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -209,8 +237,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -234,9 +265,15 @@ + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake +- stream.handshake(ssl::stream_base::server, ec); +- if (ec) +- return fail(ec, "handshake"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.handshake(ssl::stream_base::server, ec)); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -245,22 +282,31 @@ + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -270,16 +316,26 @@ + } + + // Perform the SSL shutdown +- stream.shutdown(ec); +- if (ec) +- return fail(ec, "shutdown"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -289,7 +345,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -311,11 +367,13 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} + .detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/websocket/client/async/websocket_client_async.cpp ++++ b/port/websocket/client/async/websocket_client_async.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +47,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -76,9 +76,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -88,9 +94,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -116,8 +128,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -127,8 +143,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -137,8 +157,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -146,18 +170,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -166,9 +198,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/port/websocket/client/async-local/websocket_client_async_local.cpp ++++ b/port/websocket/client/async-local/websocket_client_async_local.cpp +@@ -34,24 +34,24 @@ + #include + #include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -80,8 +80,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); +@@ -98,8 +102,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -109,8 +117,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -119,8 +131,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -128,18 +144,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { +@@ -149,10 +173,10 @@ + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const text = argv[4]; ++ auto const* const path = argv[1]; ++ auto const* const host = argv[2]; ++ auto const* const port = argv[3]; ++ auto const* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/port/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/port/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,6 +52,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -92,9 +92,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -104,9 +110,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -123,8 +135,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -145,8 +161,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -156,8 +176,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -166,8 +190,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -175,18 +203,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -195,9 +231,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -98,9 +98,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -110,9 +116,15 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -129,8 +141,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -151,8 +167,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -162,8 +182,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -172,8 +196,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -181,18 +209,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -201,9 +237,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +--- a/port/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/port/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -34,13 +34,12 @@ + #include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -48,8 +47,9 @@ + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -60,7 +60,7 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); ++ auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -98,11 +98,15 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -112,24 +116,27 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/websocket/client/coro/websocket_client_coro.cpp ++++ b/port/websocket/client/coro/websocket_client_coro.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -47,12 +46,15 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response + void do_session(std::string host, std::string const& port, std::string const& text, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + +@@ -62,16 +64,24 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -93,35 +103,55 @@ + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -130,18 +160,22 @@ + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -149,8 +183,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ b/port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,12 +52,15 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response + void do_session(std::string host, std::string const& port, std::string const& text, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + +@@ -68,21 +70,30 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); +- return fail(ec, "connect"); ++ fail(ec, "connect"); ++ return; + } + + // Set the expected hostname in the peer certificate for verification +@@ -104,8 +115,12 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -116,35 +131,55 @@ + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -153,9 +188,9 @@ + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -172,9 +207,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -182,8 +221,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/port/websocket/client/sync/websocket_client_sync.cpp ++++ b/port/websocket/client/sync/websocket_client_sync.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -47,6 +46,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -57,8 +58,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -71,7 +72,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(ws.next_layer(), results); ++ auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -102,9 +103,9 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,6 +50,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -61,8 +62,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const* const port = argv[2]; ++ auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -84,7 +85,7 @@ + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(beast::get_lowest_layer(ws), results); ++ auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { +@@ -127,9 +128,9 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/port/websocket/server/async/websocket_server_async.cpp ++++ b/port/websocket/server/async/websocket_server_async.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +51,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -90,8 +90,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -106,11 +110,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -121,8 +130,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -140,32 +153,42 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -197,7 +220,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" +@@ -206,8 +233,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -218,10 +245,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/async-local/websocket_server_async_local.cpp ++++ b/port/websocket/server/async-local/websocket_server_async_local.cpp +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -45,17 +44,18 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -94,8 +94,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -110,11 +114,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -125,8 +134,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -144,7 +157,11 @@ + stream_protocol::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +@@ -161,10 +178,9 @@ + if (ec) { + fail(ec, "accept"); + return; +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket))->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); +@@ -173,7 +189,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -182,14 +202,14 @@ + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const threads = std::max(1, std::atoi(argv[2])); ++ auto const* const path = argv[1]; ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); +@@ -197,15 +217,16 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ b/port/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -45,7 +45,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -57,6 +56,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -92,8 +92,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -113,8 +117,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -129,11 +137,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -144,8 +157,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -164,33 +181,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -222,7 +249,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -231,8 +262,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -249,10 +280,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ b/port/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -44,7 +43,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -52,6 +51,7 @@ + namespace net = boost::asio; + + // Echoes back all received WebSocket messages ++namespace { + net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -72,11 +72,13 @@ + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + co_return; ++ } + +- if (ec) ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + // Echo the message back + stream.text(stream.got_text()); +@@ -86,13 +88,15 @@ + + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { +@@ -105,7 +109,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" +@@ -114,20 +122,22 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + }); +@@ -135,10 +145,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations +- ioc.run(); // lint-run: drives the application's network operations ++ } ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- a/port/websocket/server/chat-multi/http_session.cpp ++++ b/port/websocket/server/chat-multi/http_session.cpp +@@ -32,64 +32,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -101,8 +125,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -149,18 +174,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -168,12 +196,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -189,8 +219,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -200,6 +233,8 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ + http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +@@ -208,10 +243,13 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -232,16 +270,22 @@ + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + +-void http_session::on_read(beast::error_code ec, std::size_t) { ++void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -256,8 +300,10 @@ + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); +- ++ bool const keep_alive = msg.keep_alive(); ++ ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response +@@ -267,15 +313,21 @@ + }); + } + +-void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { ++void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + +--- a/port/websocket/server/chat-multi/http_session.hpp ++++ b/port/websocket/server/chat-multi/http_session.hpp +@@ -49,8 +49,8 @@ + + void fail(beast::error_code ec, char const* what); + void do_read(); +- void on_read(beast::error_code ec, std::size_t); +- void on_write(beast::error_code ec, std::size_t, bool close); ++ void on_read(beast::error_code ec, std::size_t /*unused*/); ++ void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + + public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); +--- a/port/websocket/server/chat-multi/listener.cpp ++++ b/port/websocket/server/chat-multi/listener.cpp +@@ -27,34 +27,44 @@ + #include "http_session.hpp" + #include "listener.hpp" + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -68,20 +78,28 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection + void listener::on_accept(beast::error_code ec, tcp::socket socket) { +- if (ec) +- return fail(ec, "accept"); +- else ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } ++ { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); ++ } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), +--- a/port/websocket/server/chat-multi/main.cpp ++++ b/port/websocket/server/chat-multi/main.cpp +@@ -43,7 +43,9 @@ + #include + #include + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" +@@ -51,10 +53,10 @@ + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } +- auto address = net::ip::make_address(argv[1]); +- auto port = static_cast(std::atoi(argv[2])); +- auto doc_root = argv[3]; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto* doc_root = argv[3]; ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -76,17 +78,19 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for (auto& t : v) ++ for (auto& t : v) { + t.join(); ++ } + + return EXIT_SUCCESS; + } +--- a/port/websocket/server/chat-multi/shared_state.cpp ++++ b/port/websocket/server/chat-multi/shared_state.cpp +@@ -27,15 +27,15 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} ++shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + + void shared_state::join(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ const std::scoped_lock lock(mutex_); + sessions_.insert(session); + } + + void shared_state::leave(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ const std::scoped_lock lock(mutex_); + sessions_.erase(session); + } + +@@ -49,15 +49,18 @@ + // holding the mutex: + std::vector> v; + { +- std::lock_guard lock(mutex_); ++ const std::scoped_lock lock(mutex_); + v.reserve(sessions_.size()); +- for (auto p : sessions_) ++ for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); ++ } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for (auto const& wp : v) +- if (auto sp = wp.lock()) ++ for (auto const& wp : v) { ++ if (const auto sp = wp.lock()) { + sp->send(ss); ++ } ++ } + } +--- a/port/websocket/server/chat-multi/shared_state.hpp ++++ b/port/websocket/server/chat-multi/shared_state.hpp +@@ -38,7 +38,7 @@ + + // Represents the shared server state + class shared_state { +- std::string const doc_root_; ++ std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; +@@ -49,7 +49,7 @@ + public: + explicit shared_state(std::string doc_root); + +- std::string const& doc_root() const noexcept { return doc_root_; } ++ [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); +--- a/port/websocket/server/chat-multi/websocket_session.cpp ++++ b/port/websocket/server/chat-multi/websocket_session.cpp +@@ -36,18 +36,25 @@ + state_->leave(this); + } + ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if (ec == net::error::operation_aborted || ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Add this session to the list of active sessions + state_->join(this); +@@ -57,10 +64,14 @@ + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void websocket_session::on_read(beast::error_code ec, std::size_t) { ++void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); +@@ -87,25 +98,31 @@ + queue_.push_back(ss); + + // Are we already writing? +- if (queue_.size() > 1) ++ if (queue_.size() > 1) { + return; ++ } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void websocket_session::on_write(beast::error_code ec, std::size_t) { ++void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if (!queue_.empty()) ++ if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); ++ } + } +--- a/port/websocket/server/chat-multi/websocket_session.hpp ++++ b/port/websocket/server/chat-multi/websocket_session.hpp +@@ -68,6 +68,8 @@ + }; + + template ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +--- a/port/websocket/server/coro/websocket_server_coro.cpp ++++ b/port/websocket/server/coro/websocket_server_coro.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,11 +51,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -71,8 +73,12 @@ + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // This buffer will hold the incoming message +@@ -82,64 +88,109 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) ++void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" +@@ -148,8 +199,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); +@@ -157,8 +208,12 @@ + // Spawn a listening port + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -166,17 +221,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ b/port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -45,7 +45,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -57,12 +56,16 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-void do_session(websocket::stream>& ws, net::yield_context yield) { ++void do_session(websocket::stream>& ws, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. +@@ -70,8 +73,12 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -88,8 +95,12 @@ + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // This buffer will hold the incoming message +@@ -99,66 +110,110 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" +@@ -167,8 +222,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -181,9 +236,13 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -191,17 +250,19 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/fast/websocket_server_fast.cpp ++++ b/port/websocket/server/fast/websocket_server_fast.cpp +@@ -47,7 +47,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -56,8 +55,6 @@ + #include + #include + #include +-#include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -68,6 +65,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); + } +@@ -103,35 +101,58 @@ + })); + + ws.accept(ec); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + beast::flat_buffer buffer; + + ws.read(buffer, ec); +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); +- if (ec) +- return fail(ec, "write"); +- } +-} +- ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } ++ } ++} ++ ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_sync_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) { + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; + for (;;) { + tcp::socket socket{ioc}; + +- acceptor.accept(socket, ec); +- if (ec) +- return fail(ec, "accept"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.accept(socket, ec)); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + std::thread( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_sync_session, websocket::stream(std::move(socket)))) + .detach(); + } +@@ -163,8 +184,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -180,11 +205,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -195,8 +225,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -212,33 +246,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -271,6 +315,8 @@ + + //------------------------------------------------------------------------------ + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -285,45 +331,86 @@ + })); + + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); +- } +-} +- ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } ++ } ++} ++ ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); +- +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); +- +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); +- +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); +@@ -336,6 +423,8 @@ + + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); +@@ -344,7 +433,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" +@@ -357,8 +450,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -376,6 +469,8 @@ + + // Create coro port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), +@@ -384,10 +479,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/stackless/websocket_server_stackless.cpp ++++ b/port/websocket/server/stackless/websocket_server_stackless.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,11 +52,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; +@@ -79,6 +81,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -93,29 +97,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -129,39 +152,51 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -172,12 +207,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -192,12 +233,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" +@@ -206,8 +253,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -218,10 +265,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ b/port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -47,7 +47,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -59,11 +58,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -85,6 +87,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +@@ -95,9 +99,15 @@ + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -114,29 +124,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -150,6 +179,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -157,33 +188,43 @@ + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -194,12 +235,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -214,12 +261,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -228,8 +281,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -246,10 +299,11 @@ + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); +- for (auto i = threads - 1; i > 0; --i) ++ for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); ++ } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +--- a/port/websocket/server/sync/websocket_server_sync.cpp ++++ b/port/websocket/server/sync/websocket_server_sync.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +47,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket) { + try { + // Construct the stream by moving in the socket +@@ -75,16 +75,21 @@ + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if (se.code() != websocket::error::closed) +- std::cerr << "Error: " << se.code().message() << std::endl; ++ if (se.code() != websocket::error::closed) { ++ std::cerr << "Error: " << se.code().message() << '\n'; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -94,7 +99,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +@@ -112,7 +117,7 @@ + std::thread(&do_session, std::move(socket)).detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ b/port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket, ssl::context& ctx) { + try { + // Construct the websocket stream around the socket +@@ -84,16 +84,21 @@ + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if (se.code() != websocket::error::closed) +- std::cerr << "Error: " << se.code().message() << std::endl; ++ if (se.code() != websocket::error::closed) { ++ std::cerr << "Error: " << se.code().message() << '\n'; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -103,7 +108,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +@@ -127,7 +132,7 @@ + std::thread(&do_session, std::move(socket), std::ref(ctx)).detach(); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/advanced/server/advanced_server.cpp ++++ b/wasip3/advanced/server/advanced_server.cpp +@@ -33,10 +33,7 @@ + + #include + #include +-#include + #include +-#include +-#include + + #include + #include +@@ -58,64 +55,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -127,8 +148,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -175,18 +197,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -194,12 +219,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -215,8 +242,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -242,6 +272,8 @@ + + // Start the asynchronous accept operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -259,8 +291,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -276,11 +312,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -291,8 +332,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -355,11 +400,19 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -374,8 +427,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -383,15 +437,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), +@@ -402,18 +457,24 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + +@@ -423,7 +484,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -438,34 +501,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -504,7 +577,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" +@@ -513,9 +590,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/advanced/server-flex/advanced_server_flex.cpp ++++ b/wasip3/advanced/server-flex/advanced_server_flex.cpp +@@ -36,11 +36,8 @@ + + #include + #include +-#include + #include + #include +-#include +-#include + + #include + #include +@@ -63,64 +60,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -132,8 +153,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -180,18 +202,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -199,12 +224,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -220,8 +247,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -250,8 +280,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -263,6 +294,8 @@ + // the same code works with both SSL streams and regular sockets. + template + class websocket_session { ++ websocket_session() = default; ++ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } +@@ -271,6 +304,8 @@ + + // Start the asynchronous operation + template ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +@@ -290,8 +325,12 @@ + + private: + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -307,11 +346,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + derived().ws().text(derived().ws().got_text()); +@@ -323,8 +367,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -340,11 +388,15 @@ + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; +@@ -360,6 +412,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; +@@ -408,13 +462,15 @@ + boost::optional> parser_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Construct the session ++private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); +@@ -428,7 +484,7 @@ + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), buffer_, *parser_, ++ derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + +@@ -436,11 +492,16 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -457,8 +518,9 @@ + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request +- if (response_queue_.size() < queue_limit) ++ if (response_queue_.size() < queue_limit) { + do_read(); ++ } + } + + void queue_write(http::message_generator response) { +@@ -466,15 +528,16 @@ + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop +- if (response_queue_.size() == 1) ++ if (response_queue_.size() == 1) { + do_write(); ++ } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { +- bool keep_alive = response_queue_.front().keep_alive(); ++ bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, +@@ -485,8 +548,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -495,18 +562,23 @@ + } + + // Resume the read if it has been paused +- if (response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) { + do_read(); ++ } + + response_queue_.pop(); + + do_write(); + } ++ ++ friend Derived; + }; + + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -531,7 +603,9 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -540,6 +614,8 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; +@@ -559,7 +635,7 @@ + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, buffer_.data(), ++ ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + +@@ -581,18 +657,28 @@ + + private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -632,8 +718,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -657,34 +747,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -716,7 +816,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" +@@ -725,9 +829,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ b/wasip3/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -47,9 +47,7 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include +@@ -59,7 +57,7 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -68,69 +66,92 @@ + namespace ssl = boost::asio::ssl; + + using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = +- typename webcpp::asio::ip::tcp::acceptor::rebind_executor::other; ++using stream_type = beast::tcp_stream::rebind_executor::other; ++using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -142,8 +163,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -190,18 +212,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -209,12 +234,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -230,8 +257,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -248,7 +278,11 @@ + std::list css_; + + public: +- task_group(net::any_io_executor exec) ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ explicit task_group(net::any_io_executor exec) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +@@ -272,8 +306,8 @@ + */ + template + auto adapt(CompletionToken&& completion_token) { +- auto lg = std::lock_guard{mtx_}; +- auto cs = css_.emplace(css_.end()); ++ auto const lg = std::scoped_lock{mtx_}; ++ auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; +@@ -285,11 +319,14 @@ + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + ++ // A mutex or timer failure during this upstream task teardown is fatal by design. ++ // NOLINTNEXTLINE(bugprone-exception-escape) + ~remover() { + if (tg_) { +- auto lg = std::lock_guard{tg_->mtx_}; +- if (tg_->css_.erase(cs_) == tg_->css_.end()) ++ auto const lg = std::scoped_lock{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); ++ } + } + } + }; +@@ -309,9 +346,10 @@ + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { +- auto lg = std::lock_guard{mtx_}; +- for (auto& cs : css_) ++ auto const lg = std::scoped_lock{mtx_}; ++ for (auto& cs : css_) { + cs.emit(type); ++ } + } + + /** Starts an asynchronous wait on the task_group. +@@ -338,24 +376,33 @@ + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( ++ // The apparent recursion crosses an asynchronous completion boundary. ++ // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { +- if (!scheduled) ++ if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); +- +- if (!self.cancelled() && ec == net::error::operation_aborted) ++ } ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; ++ } + + { +- auto lg = std::lock_guard{mtx_}; ++ auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + +- if (!std::exchange(scheduled, true)) ++ if (!std::exchange(scheduled, true)) { ++ // Asio composed operations transfer their own state to the next completion. ++ // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); ++ } + + self.complete(ec); + }, +@@ -367,7 +414,7 @@ + net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +@@ -386,11 +433,13 @@ + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + // Echo the message back + ws.text(ws.got_text()); +@@ -403,14 +452,15 @@ + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; ++ } + } + + template + net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; ++ auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; +@@ -418,8 +468,9 @@ + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + co_return; ++ } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. +@@ -460,25 +511,28 @@ + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + +- auto bytes_transferred = ++ auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if (!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) { + co_return; ++ } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; ++ } + } else { + co_await run_session(stream, buffer, doc_root); + +- if (!stream.socket().is_open()) ++ if (!stream.socket().is_open()) { + co_return; ++ } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +@@ -487,25 +541,31 @@ + net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { +- auto cs = co_await net::this_coro::cancellation_state; +- auto executor = co_await net::this_coro::executor; ++ auto const cs = co_await net::this_coro::cancellation_state; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + co_return; +- +- if (ec) ++ } ++ ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { +@@ -519,13 +579,13 @@ + } + + net::awaitable handle_signals(task_group& task_group) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto deadline = net::steady_timer{executor}; + deadline.expires_after(std::chrono::seconds(4)); + + co_await deadline.async_wait(); + +- if (true) { ++ { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + +@@ -541,13 +601,14 @@ + } + + std::cout << "Child tasks completed.\n"; +- } else // SIGTERM +- { +- net::query(executor.get_inner_executor(), net::execution::context).stop(); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" +@@ -556,10 +617,10 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -574,8 +635,10 @@ + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine +- auto listener_executor = net::make_strand(ioc); ++ auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { +--- a/wasip3/common/root_certificates.hpp ++++ b/wasip3/common/root_certificates.hpp +@@ -62,7 +62,9 @@ + + inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { +- ctx.load_verify_file(path, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(ctx.load_verify_file(path, ec)); + return; + } + +@@ -3953,9 +3955,13 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); +- if (ec) ++ static_cast( ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); ++ if (ec) { + return; ++ } + } + + } // namespace detail +@@ -3969,8 +3975,9 @@ + inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if (ec) ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + } + + #endif +--- a/wasip3/doc/ssl/client.cpp ++++ b/wasip3/doc/ssl/client.cpp +@@ -37,33 +37,34 @@ + #include + #include + #include +-#include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + } + + net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket +@@ -98,9 +99,12 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); ++ } + } ++ ++} // namespace + + int main() { + try { +@@ -135,7 +139,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + +--- a/wasip3/doc/ssl/server.cpp ++++ b/wasip3/doc/ssl/server.cpp +@@ -37,25 +37,26 @@ + #include + #include + #include +-#include + #include +-#include + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + namespace ssl = net::ssl; + ++namespace { ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + } +@@ -76,14 +77,15 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if (ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); ++ } + } + + net::awaitable acceptor(ssl::context& ctx) { +- auto executor = co_await net::this_coro::executor; +- webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), +- webcpp_fixture::port_number()}; ++ auto const executor = co_await net::this_coro::executor; ++ webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { +@@ -91,6 +93,8 @@ + print_exception); + } + } ++ ++} // namespace + + int main() { + try { +@@ -106,6 +110,8 @@ + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. ++ // Asio exposes the OpenSSL verification bitmask as signed integer constants. ++ // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this +@@ -127,7 +133,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + } + } + +--- a/wasip3/echo-op/echo_op.cpp ++++ b/wasip3/echo-op/echo_op.cpp +@@ -39,20 +39,20 @@ + #include + #include + #include +-#include + #include + + namespace net = boost::asio; + namespace beast = webcpp::beast; + ++namespace { ++ + //[example_core_echo_op_1 + + template + auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] +- -> typename net::async_result::type, +- void(beast::error_code)>::return_type; ++ -> net::async_result, void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -78,7 +78,7 @@ + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the +- first line. These characters are stored in the dynamic buffer_. ++ first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + +@@ -105,14 +105,16 @@ + `net::post`. + */ + template ++// Each documentation snippet presents the complete public declaration. ++// NOLINTNEXTLINE(readability-redundant-declaration) + auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> typename net:: +- async_result*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) ++ -> net::async_result*/ ++ std::decay_t, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 +@@ -128,10 +130,12 @@ + // Read a line and echo it back + // + template +-auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> +- typename net::async_result::type, +- void(beast::error_code)>::return_type /*< The completion handler +- signature goes here >*/ ++// Stackless coroutine macros generate the branches in this operation. ++// NOLINTNEXTLINE(readability-function-cognitive-complexity) ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ -> net::async_result, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +@@ -174,9 +178,11 @@ + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + ++ // Asio operation state combines completion ownership with coroutine resume state. ++ // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { +- AsyncStream& stream_; +- DynamicBuffer& buffer_; ++ AsyncStream& stream_state; ++ DynamicBuffer& buffer_state; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +@@ -184,8 +190,8 @@ + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , +- stream_(stream), +- buffer_(buffer) { ++ stream_state(stream), ++ buffer_state(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -197,19 +203,20 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { ++ static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = ++ const auto begin = + net::buffers_iterator::begin(buffers); +- auto end = ++ const auto end = + net::buffers_iterator::end(buffers); +- auto result = std::find(begin, end, '\n'); +- +- if (result == end) ++ const auto result = std::find(begin, end, '\n'); ++ ++ if (result == end) { + return 0; // not found ++ } + + return result + 1 - begin; + } +@@ -217,6 +224,8 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + ++ // Resume labels generated by the stackless coroutine form one state machine. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ +@@ -227,13 +236,17 @@ + + reenter(*this) { + for (;;) { ++ // Resume labels cannot cross an initialized local; it is assigned before use. ++ // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer +- pos = find_newline(buffer_.data()); ++ pos = find_newline(buffer_state.data()); + + // If we don't have the newline, then read more + if (pos == 0) { ++ // Resume labels cannot cross an initialized local; it is assigned before ++ // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, +@@ -241,18 +254,18 @@ + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), ++ buffer_state.capacity() - buffer_state.size()), + std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); +- +- // Read some data into our dynamic buffer_. We transfer ++ buffer_state.max_size() - buffer_state.size())); ++ ++ // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some(buffer_.prepare(bytes_to_read), +- std::move(*this)); ++ yield stream_state.async_read_some(buffer_state.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -260,11 +273,12 @@ + // Move the bytes read from the writable area to the + // readable area. + +- buffer_.commit(bytes_transferred); ++ buffer_state.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if (ec) ++ if (ec) { + break; ++ } + + // Keep looping until we get the newline + continue; +@@ -274,7 +288,8 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ yield net::async_write(stream_state, ++ beast::buffers_prefix(pos, buffer_state.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will +@@ -286,7 +301,7 @@ + // to consume. With "real" coroutines this will be easier and more + // natural. + +- buffer_.consume(bytes_transferred); ++ buffer_state.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. +@@ -336,11 +351,16 @@ + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { +- if (ec) +- std::cerr << ": " << ec.message() << std::endl; ++ if (ec) { ++ std::cerr << ": " << ec.message() << '\n'; ++ } + } + }; + ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" +@@ -351,7 +371,7 @@ + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + +@@ -359,7 +379,7 @@ + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; +- endpoint_type ep(address, port); ++ const endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); +--- a/wasip3/http/client/async/http_client_async.cpp ++++ b/wasip3/http/client/async/http_client_async.cpp +@@ -31,14 +31,12 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +46,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -80,9 +79,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -92,9 +97,18 @@ + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -107,8 +121,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -118,18 +136,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -137,6 +165,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -147,10 +179,10 @@ + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/http/client/async-local/http_client_async_local.cpp ++++ b/wasip3/http/client/async-local/http_client_async_local.cpp +@@ -32,25 +32,24 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -84,8 +83,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); +@@ -98,8 +101,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -109,18 +116,28 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Gracefully close the socket +- stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } +@@ -128,6 +145,10 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { +@@ -138,11 +159,11 @@ + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const target = argv[4]; +- int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; ++ const auto* const path = argv[1]; ++ const auto* const host = argv[2]; ++ const auto* const port = argv[3]; ++ const auto* const target = argv[4]; ++ int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/http/client/async-ssl/http_client_async_ssl.cpp ++++ b/wasip3/http/client/async-ssl/http_client_async_ssl.cpp +@@ -35,12 +35,10 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -51,6 +49,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -92,9 +91,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -104,9 +109,18 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -115,8 +129,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -129,8 +147,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -140,11 +162,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -154,6 +180,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -172,13 +200,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -189,10 +225,10 @@ + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ b/wasip3/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -36,12 +36,10 @@ + #include + #include + #include +-#include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +50,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -100,9 +99,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -112,9 +117,18 @@ + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { +- if (ec) +- return fail(ec, "connect"); ++ void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Perform the SSL handshake + stream_.async_handshake( +@@ -123,8 +137,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -137,8 +155,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +@@ -148,11 +170,15 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res_ << std::endl; ++ std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); +@@ -162,6 +188,8 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -180,13 +208,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -197,10 +233,10 @@ + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +--- a/wasip3/http/client/awaitable/http_client_awaitable.cpp ++++ b/wasip3/http/client/awaitable/http_client_awaitable.cpp +@@ -33,24 +33,23 @@ + #include + #include + #include +-#include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + +@@ -84,23 +83,30 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -112,10 +118,10 @@ + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -125,16 +131,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ b/wasip3/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -36,9 +36,7 @@ + #include + #include + #include +-#include + #include +-#include + + #include "common/root_certificates.hpp" + +@@ -46,7 +44,7 @@ + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -56,6 +54,7 @@ + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +@@ -107,7 +106,7 @@ + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -132,12 +131,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) { + throw boost::system::system_error(ec, "shutdown"); ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -149,10 +153,10 @@ + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -171,16 +175,19 @@ + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/http/client/body/json_body.hpp ++++ b/wasip3/http/client/body/json_body.hpp +@@ -33,6 +33,7 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include + #include + #include +@@ -48,11 +49,14 @@ + using const_buffers_type = boost::asio::const_buffer; + + template +- writer(webcpp::beast::http::header const&, value_type const& body) { ++ writer(webcpp::beast::http::header const& /*unused*/, ++ value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. +- serializer.reset(&body); ++ serializer_.reset(&body); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; +@@ -61,20 +65,21 @@ + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice +- const auto len = serializer.read(buffer, sizeof(buffer)); ++ const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ !serializer_.done()); + } + + private: +- json::serializer serializer; ++ json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ std::array buffer_{}; + }; + + struct reader { + template +- reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ reader(webcpp::beast::http::header& /*unused*/, value_type& body) ++ : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { +@@ -82,8 +87,10 @@ + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. +- if (content_length) +- parser.reset(json::make_shared_resource(*content_length)); ++ if (content_length) { ++ parser_.reset( ++ json::make_shared_resource(*content_length)); ++ } + ec = {}; + } + +@@ -91,21 +98,22 @@ + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); ++ return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. +- if (parser.done()) +- body = parser.release(); +- else ++ if (parser_.done()) { ++ body_ = parser_.release(); ++ } else { + ec = boost::json::error::incomplete; ++ } + } + + private: +- json::stream_parser parser; +- value_type& body; ++ json::stream_parser parser_; ++ value_type& body_; + }; + }; + +--- a/wasip3/http/client/body/json_client.cpp ++++ b/wasip3/http/client/body/json_client.cpp +@@ -18,29 +18,31 @@ + #include "fixture_resolver.hpp" + #include "json_body.hpp" + +-#include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char**) { ++int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json +- const auto host = webcpp_fixture::host(); +- const auto target = "/post"; ++ const auto* const host = webcpp_fixture::host(); ++ const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup +@@ -66,11 +68,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; + } +--- a/wasip3/http/client/coro/http_client_coro.cpp ++++ b/wasip3/http/client/coro/http_client_coro.cpp +@@ -31,13 +31,11 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -47,12 +45,15 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response + void do_session(std::string const& host, std::string const& port, std::string const& target, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + +@@ -62,16 +63,24 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; +@@ -83,8 +92,12 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; +@@ -94,26 +107,40 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) +- return fail(ec, "shutdown"); ++ if (ec && ec != beast::errc::not_connected) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -124,10 +151,10 @@ + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -135,9 +162,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -145,8 +176,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/wasip3/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ b/wasip3/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -35,13 +35,11 @@ + + #include + #include +-#include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +50,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -59,6 +58,8 @@ + // Performs an HTTP GET and prints the response + void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, ssl::context& ctx, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + +@@ -78,24 +79,36 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; +@@ -107,8 +120,12 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; +@@ -118,11 +135,15 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); +@@ -147,12 +168,20 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) +- return fail(ec, "shutdown"); ++ if (ec != net::ssl::error::stream_truncated) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { +@@ -163,10 +192,10 @@ + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -183,9 +212,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -193,8 +226,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/wasip3/http/client/crawl/http_crawl.cpp ++++ b/wasip3/http/client/crawl/http_crawl.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -47,7 +46,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -61,6 +59,7 @@ + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites ++namespace { + class crawl_report { + net::strand strand_; + std::atomic index_; +@@ -68,7 +67,7 @@ + std::size_t count_ = 0; + + public: +- crawl_report(webcpp::asio::io_context& ioc) ++ explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. +@@ -88,8 +87,9 @@ + // Returns the next host to check + char const* get_host() { + auto const n = index_++; +- if (n >= hosts_.size()) ++ if (n >= hosts_.size()) { + return nullptr; ++ } + return hosts_[n]; + } + +@@ -126,9 +126,10 @@ + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; +- for (auto const& result : report.status_codes) ++ for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ } + os.flush(); + return os; + } +@@ -139,7 +140,7 @@ + class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively +- timeout = 5 ++ timeout = 5, + }; + + crawl_report& report_; +@@ -168,11 +169,12 @@ + + void do_get_host() { + // Grab another host +- auto const host = report_.get_host(); ++ const auto* const host = report_.get_host(); + + // nullptr means no more work +- if (!host) +- return; ++ if (host == nullptr) { ++ return; ++ } + + // The Host HTTP field is required + req_.set(http::field::host, host); +@@ -183,10 +185,13 @@ + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -197,10 +202,16 @@ + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + +- void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { ++ void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) ++ // Value type is required by the original asynchronous callback contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) ++ webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Set a timeout on the operation +@@ -216,7 +227,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + // Receive the HTTP response +@@ -230,7 +242,8 @@ + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); +- return do_get_host(); ++ do_get_host(); ++ return; + } + + auto const code = res_.result_int(); +@@ -240,7 +253,9 @@ + }); + + // Gracefully close the socket +- stream_.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully +@@ -259,16 +274,20 @@ + + timer() : when_(clock_type::now()) {} + +- duration elapsed() const { return clock_type::now() - when_; } ++ [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[1])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; +@@ -276,11 +295,14 @@ + // The report holds the aggregated statistics + crawl_report report{ioc}; + ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. +- for (int index = 0; index < threads; ++index) ++ for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); ++ } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() +--- a/wasip3/http/client/methods/http_client_methods.cpp ++++ b/wasip3/http/client/methods/http_client_methods.cpp +@@ -34,19 +34,18 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request ++namespace { + void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); +@@ -124,6 +123,10 @@ + } + + // Performs an HTTP request against httpbin.cpp.al and prints request & response ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -135,18 +138,23 @@ + return EXIT_FAILURE; + } + +- for (char* c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); ++ } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup +@@ -163,42 +171,45 @@ + // Declare a container to hold the response + http::response res; + +- if (method == "get") ++ if (method == "get") { + do_get(stream, req, buffer, res); +- else if (method == "head") ++ } else if (method == "head") { + do_head(stream, req, buffer, res); +- else if (method == "patch") ++ } else if (method == "patch") { + do_patch(stream, req, buffer, res); +- else if (method == "put") ++ } else if (method == "put") { + do_put(stream, req, buffer, res); +- else if (method == "post") ++ } else if (method == "post") { + do_post(stream, req, buffer, res); +- else if (method == "delete") ++ } else if (method == "delete") { + do_delete(stream, req, buffer, res); +- else { +- std::cerr << "Unknown method: " << method << std::endl; ++ } else { ++ std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" << req << std::endl; ++ std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/http/client/sync/http_client_sync.cpp ++++ b/wasip3/http/client/sync/http_client_sync.cpp +@@ -34,19 +34,19 @@ + + #include + #include +-#include + #include + #include + #include + #include +-#include + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++// from + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -58,19 +58,23 @@ + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +@@ -94,21 +98,24 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(tcp::socket::shutdown_both, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if (ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; ++ } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ b/wasip3/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -36,11 +36,9 @@ + #include + #include + #include +-#include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,6 +47,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -60,10 +60,10 @@ + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const target = argv[3]; +- int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ const auto* const host = argv[1]; ++ auto const* const port = argv[2]; ++ auto const* const target = argv[3]; ++ int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -78,6 +78,8 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + +@@ -91,6 +93,8 @@ + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +@@ -117,11 +121,13 @@ + http::read(stream, buffer, res); + + // Write the message to standard out +- std::cout << res << std::endl; ++ std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; +- stream.shutdown(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the +@@ -140,10 +146,11 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) { + throw beast::system_error{ec}; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/http/server/async/http_server_async.cpp ++++ b/wasip3/http/server/async/http_server_async.cpp +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -41,7 +40,6 @@ + #include + #include + #include +-#include + + #include + +@@ -51,64 +49,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -120,8 +142,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -168,18 +191,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -187,12 +213,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -208,8 +236,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -263,18 +294,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -285,13 +324,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -301,7 +345,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -316,34 +362,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -364,10 +420,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -376,7 +431,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" +@@ -385,9 +444,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/http/server/async-local/http_server_async_local.cpp ++++ b/wasip3/http/server/async-local/http_server_async_local.cpp +@@ -34,10 +34,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -47,72 +45,96 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -124,8 +146,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -172,18 +195,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -191,12 +217,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -212,8 +240,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -268,18 +299,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -290,13 +329,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -306,7 +350,9 @@ + void do_close() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -321,8 +367,12 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +@@ -339,10 +389,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -351,7 +400,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -360,15 +413,15 @@ + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; ++ const auto* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); +@@ -378,7 +431,7 @@ + + return EXIT_SUCCESS; + } catch (std::exception const& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/http/server/async-ssl/http_server_async_ssl.cpp ++++ b/wasip3/http/server/async-ssl/http_server_async_ssl.cpp +@@ -37,14 +37,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + #include + +@@ -55,64 +53,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -124,8 +146,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -172,18 +195,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -191,12 +217,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -212,8 +240,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -242,8 +273,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -282,8 +314,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + do_read(); + } +@@ -305,18 +341,26 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) +- return do_close(); +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == http::error::end_of_stream) { ++ { ++ do_close(); ++ return; ++ } ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +@@ -327,13 +371,18 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- return do_close(); ++ do_close(); ++ return; + } + + // Read another request +@@ -349,9 +398,15 @@ + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -367,34 +422,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -415,10 +480,9 @@ + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket), ctx_, doc_root_)->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); +@@ -427,7 +491,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" +@@ -436,9 +504,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/http/server/awaitable/http_server_awaitable.cpp ++++ b/wasip3/http/server/awaitable/http_server_awaitable.cpp +@@ -34,10 +34,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include + #include +@@ -47,71 +45,95 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; + namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -123,8 +145,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -171,18 +194,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -190,12 +216,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -211,8 +239,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -238,7 +269,7 @@ + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); +@@ -261,12 +292,14 @@ + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { +@@ -279,7 +312,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +@@ -288,21 +325,23 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + }); +--- a/wasip3/http/server/coro/http_server_coro.cpp ++++ b/wasip3/http/server/coro/http_server_coro.cpp +@@ -34,14 +34,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + #include + +@@ -51,64 +49,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -120,8 +142,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -168,18 +191,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -187,12 +213,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -208,8 +236,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -226,6 +257,8 @@ + + // Handles an HTTP server connection + void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + +@@ -240,22 +273,31 @@ + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -265,7 +307,9 @@ + } + + // Send a TCP shutdown +- stream.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -273,47 +317,82 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn(acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio ++ // spawn/completion overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" +@@ -322,18 +401,22 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -341,8 +424,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads +--- a/wasip3/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ b/wasip3/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -37,14 +37,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + #include + +@@ -55,64 +53,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -124,8 +146,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -172,18 +195,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -191,12 +217,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -212,8 +240,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -242,14 +273,17 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection + void do_session(ssl::stream& stream, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::shared_ptr const& doc_root, net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; +@@ -259,8 +293,12 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -272,10 +310,15 @@ + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); +@@ -286,8 +329,12 @@ + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -300,8 +347,12 @@ + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -309,48 +360,83 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" +@@ -359,9 +445,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -374,9 +460,13 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -384,8 +474,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads +--- a/wasip3/http/server/fast/fields_alloc.hpp ++++ b/wasip3/http/server/fast/fields_alloc.hpp +@@ -34,7 +34,7 @@ + + namespace detail { + +-struct static_pool { ++class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; +@@ -46,7 +46,7 @@ + + public: + static static_pool& construct(std::size_t size) { +- auto p = new char[sizeof(static_pool) + size]; ++ auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + +@@ -56,25 +56,28 @@ + } + + void destroy() { +- if (--refs_) ++ if ((--refs_) != 0u) { + return; ++ } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { +- auto last = p_ + n; +- if (last >= end()) ++ auto* last = p_ + n; ++ if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); ++ } + ++count_; +- auto p = p_; ++ auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { +- if (--count_) ++ if ((--count_) != 0u) { + return; ++ } + p_ = reinterpret_cast(this + 1); + } + }; +@@ -99,7 +102,7 @@ + */ + template + struct fields_alloc { +- detail::static_pool* pool_; ++ detail::static_pool* pool; + + public: + using value_type = T; +@@ -123,20 +126,21 @@ + fields_alloc() = default; + #endif + +- explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template +- fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ explicit fields_alloc(fields_alloc const& other) ++ : pool(&detail::static_pool::share(*other.pool)) {} + +- ~fields_alloc() { pool_->destroy(); } ++ ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { +- return static_cast(pool_->alloc(n * sizeof(T))); ++ return static_cast(pool->alloc(n * sizeof(T))); + } + +- void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + + #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template +@@ -152,7 +156,7 @@ + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { +- return &lhs.pool_ == &rhs.pool_; ++ return &lhs.pool == &rhs.pool_; + } + + template +--- a/wasip3/http/server/fast/http_server_fast.cpp ++++ b/wasip3/http/server/fast/http_server_fast.cpp +@@ -43,7 +43,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -51,9 +50,7 @@ + #include + #include + #include +-#include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -61,56 +58,79 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + +@@ -119,6 +139,8 @@ + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + ++ // Retain the upstream borrowing constructor contract in this reference counterpart. ++ // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + +@@ -152,7 +174,7 @@ + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), +- (std::chrono::steady_clock::time_point::max)()}; ++ std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> +@@ -172,7 +194,9 @@ + void accept() { + // Clean up any previous connection. + beast::error_code ec; +- socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { +@@ -202,24 +226,23 @@ + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { +- if (ec) ++ if (ec) { + accept(); +- else ++ } else { + process_request(parser_->get()); ++ } + }); + } + + void process_request(http::request> const& req) { +- switch (req.method()) { +- case http::verb::get: send_file(req.target()); break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; ++ if (req.method() == http::verb::get) { ++ send_file(req.target()); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + +@@ -237,7 +260,9 @@ + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); +@@ -246,7 +271,7 @@ + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } +@@ -275,7 +300,9 @@ + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { +- socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); +@@ -289,14 +316,18 @@ + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 6) { +@@ -310,9 +341,11 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); +- std::string doc_root = argv[3]; +- int num_workers = std::atoi(argv[4]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ std::string const doc_root = argv[3]; ++ int const num_workers = webcpp_fixture::integer(argv[4]); ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; +@@ -324,13 +357,15 @@ + workers.back().start(); + } + +- if (spin) +- for (;;) ++ if (spin) { ++ for (;;) { + ioc.poll(); +- else ++ } ++ } else { + ioc.run(); // lint-run: drives the application's network operations ++ } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/http/server/flex/http_server_flex.cpp ++++ b/wasip3/http/server/flex/http_server_flex.cpp +@@ -37,14 +37,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -53,64 +51,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -122,8 +144,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -170,18 +193,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -189,12 +215,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -210,8 +238,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -240,8 +271,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -259,20 +291,22 @@ + http::request req_; + + protected: +- beast::flat_buffer buffer_; ++ beast::flat_buffer buffer; + + public: + // Take ownership of the buffer ++private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) +- : doc_root_(doc_root), buffer_(std::move(buffer)) {} +- ++ : doc_root_(doc_root), buffer(std::move(buffer)) {} ++ ++public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), buffer_, req_, ++ derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + +@@ -280,18 +314,23 @@ + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + return derived().do_eof(); +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), +@@ -302,8 +341,12 @@ + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -314,9 +357,13 @@ + // Read another request + do_read(); + } ++ ++ friend Derived; + }; + + // Handles a plain HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; +@@ -343,13 +390,17 @@ + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + }; + + // Handles an SSL HTTP connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +@@ -364,27 +415,33 @@ + + // Start the asynchronous operation + void run() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. +- net::dispatch(stream_.get_executor(), [self]() { ++ net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, self->buffer_.data(), ++ ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Consume the portion of the buffer used by the handshake +- buffer_.consume(bytes_used); ++ buffer.consume(bytes_used); + + do_read(); + } +@@ -398,9 +455,15 @@ + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + ++ // Member shape is part of the upstream Body or bound-callback interface. ++ // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -431,8 +494,12 @@ + } + + void on_detect(beast::error_code ec, bool result) { +- if (ec) +- return fail(ec, "detect"); ++ if (ec) { ++ { ++ fail(ec, "detect"); ++ return; ++ } ++ } + + if (result) { + // Launch SSL session +@@ -456,34 +523,44 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -515,7 +592,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" +@@ -524,9 +605,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/http/server/small/http_server_small.cpp ++++ b/wasip3/http/server/small/http_server_small.cpp +@@ -41,22 +41,20 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from + namespace net = boost::asio; // from + using tcp = webcpp::asio::ip::tcp; // from + ++namespace { + namespace my_program_state { + std::size_t request_count() { + static std::size_t count = 0; +@@ -64,13 +62,13 @@ + } + + std::time_t now() { +- return std::time(0); ++ return std::time(nullptr); + } + } // namespace my_program_state + + class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) : socket_(std::move(socket)) {} ++ explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { +@@ -96,13 +94,16 @@ + + // Asynchronously receive a complete request message. + void read_request() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- if (!ec) ++ if (!ec) { + self->process_request(); ++ } + }); + } + +@@ -111,21 +112,17 @@ + response_.version(request_.version()); + response_.keep_alive(false); + +- switch (request_.method()) { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" << std::string(request_.method_string()) << "'"; +- break; ++ if (request_.method() == http::verb::get) { ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ } else { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); +@@ -163,24 +160,32 @@ + + // Asynchronously transmit the response message. + void write_response() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(self->socket_.close(ec)); + } + }); + } +@@ -189,13 +194,18 @@ + // "Loop" forever accepting new connections. + void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { +- if (!ec) ++ if (!ec) { + std::make_shared(std::move(socket))->start(); ++ } + http_server(acceptor, socket); + }); + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -208,7 +218,7 @@ + } + + auto const address = net::ip::make_address(argv[1]); +- unsigned short port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + +@@ -218,7 +228,7 @@ + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/http/server/stackless/http_server_stackless.cpp ++++ b/wasip3/http/server/stackless/http_server_stackless.cpp +@@ -34,7 +34,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -42,7 +41,6 @@ + #include + #include + #include +-#include + + #include + +@@ -52,64 +50,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -121,8 +143,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -169,18 +192,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -188,12 +214,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -209,8 +237,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -226,6 +257,8 @@ + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; +@@ -251,6 +284,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -271,8 +306,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -287,8 +326,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -297,7 +340,9 @@ + } + + // Send a TCP shutdown +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +@@ -309,6 +354,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; +@@ -316,6 +363,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -325,28 +374,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -357,8 +414,12 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { +@@ -377,12 +438,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" +@@ -391,9 +458,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ b/wasip3/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -46,7 +45,6 @@ + #include + #include + #include +-#include + + #include + +@@ -57,64 +55,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -126,8 +148,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -174,18 +197,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -193,12 +219,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -214,8 +242,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -244,13 +275,16 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if (ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; +@@ -277,6 +311,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -286,9 +322,15 @@ + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + for (;;) { + // Set the timeout. +@@ -307,8 +349,12 @@ + // The remote host closed the connection + break; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + yield { + // Handle request +@@ -323,8 +369,12 @@ + beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -337,9 +387,15 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "shutdown"); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } +@@ -351,6 +407,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -359,6 +417,8 @@ + std::shared_ptr doc_root_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), +@@ -369,28 +429,36 @@ + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -401,12 +469,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -421,12 +495,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" +@@ -435,9 +515,9 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/http/server/sync/http_server_sync.cpp ++++ b/wasip3/http/server/sync/http_server_sync.cpp +@@ -31,14 +31,12 @@ + //------------------------------------------------------------------------------ + + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,64 +46,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -117,8 +139,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -165,18 +188,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -184,12 +210,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -205,8 +233,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -232,22 +263,31 @@ + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +@@ -256,14 +296,20 @@ + } + + // Send a TCP shutdown +- socket.shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -273,7 +319,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -292,7 +338,7 @@ + do_session(socket, doc_root); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ b/wasip3/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -36,14 +36,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,64 +50,88 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -121,8 +143,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -169,18 +192,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -188,12 +214,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -209,8 +237,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -234,9 +265,15 @@ + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake +- stream.handshake(ssl::stream_base::server, ec); +- if (ec) +- return fail(ec, "handshake"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.handshake(ssl::stream_base::server, ec)); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; +@@ -245,22 +282,31 @@ + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if (ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); ++ bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because +@@ -270,16 +316,26 @@ + } + + // Perform the SSL shutdown +- stream.shutdown(ec); +- if (ec) +- return fail(ec, "shutdown"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream.shutdown(ec)); ++ if (ec) { ++ { ++ fail(ec, "shutdown"); ++ return; ++ } ++ } + + // At this point the connection is closed gracefully + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { +@@ -289,7 +345,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +@@ -314,7 +370,7 @@ + do_session(socket, ctx, doc_root); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/websocket/client/async/websocket_client_async.cpp ++++ b/wasip3/websocket/client/async/websocket_client_async.cpp +@@ -38,7 +38,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -49,6 +48,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -77,9 +77,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -90,9 +96,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -118,8 +130,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -129,8 +145,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -139,8 +159,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -148,18 +172,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -168,9 +200,9 @@ + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/websocket/client/async-local/websocket_client_async_local.cpp ++++ b/wasip3/websocket/client/async-local/websocket_client_async_local.cpp +@@ -35,24 +35,24 @@ + #include + #include + #include +-#include + + #include + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -81,8 +81,12 @@ + } + + void on_connect(beast::error_code ec) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); +@@ -99,8 +103,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -110,8 +118,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -120,8 +132,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -129,18 +145,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { +@@ -150,10 +174,10 @@ + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- auto const host = argv[2]; +- auto const port = argv[3]; +- auto const text = argv[4]; ++ const auto* const path = argv[1]; ++ const auto* const host = argv[2]; ++ const auto* const port = argv[3]; ++ const auto* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ b/wasip3/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -93,9 +93,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -106,9 +112,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -125,8 +137,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -147,8 +163,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -158,8 +178,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -168,8 +192,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -177,18 +205,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -197,9 +233,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ b/wasip3/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -43,7 +43,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -55,6 +54,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -100,9 +100,15 @@ + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -113,9 +119,15 @@ + } + + void on_connect(beast::error_code ec, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { +- if (ec) +- return fail(ec, "connect"); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +@@ -132,8 +144,12 @@ + } + + void on_ssl_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -154,8 +170,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws_.async_write(net::buffer(text_), +@@ -165,8 +185,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); +@@ -175,8 +199,12 @@ + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +@@ -184,18 +212,26 @@ + } + + void on_close(beast::error_code ec) { +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer_.data()) << std::endl; ++ std::cout << beast::make_printable(buffer_.data()) << '\n'; + } + }; + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -204,9 +240,9 @@ + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates +--- a/wasip3/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ b/wasip3/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -35,13 +35,12 @@ + #include + #include + #include +-#include + + #include + #include + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -49,8 +48,9 @@ + namespace net = boost::asio; + + // Sends a WebSocket message and prints the response ++namespace { + net::awaitable do_session(std::string host, std::string port, std::string text) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = websocket::stream{executor}; + +@@ -61,7 +61,7 @@ + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); ++ auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -99,11 +99,15 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -113,24 +117,27 @@ + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { +- if (e) ++ if (e) { + std::rethrow_exception(e); ++ } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/websocket/client/coro/websocket_client_coro.cpp ++++ b/wasip3/websocket/client/coro/websocket_client_coro.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,12 +47,15 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response + void do_session(std::string host, std::string const& port, std::string const& text, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + +@@ -63,16 +65,24 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -94,35 +104,55 @@ + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -131,18 +161,22 @@ + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -150,8 +184,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/wasip3/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ b/wasip3/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,12 +53,15 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response + void do_session(std::string host, std::string const& port, std::string const& text, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + +@@ -69,21 +71,30 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if (ec) +- return fail(ec, "resolve"); ++ if (ec) { ++ { ++ fail(ec, "resolve"); ++ return; ++ } ++ } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if (ec) +- return fail(ec, "connect"); ++ auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); ++ if (ec) { ++ { ++ fail(ec, "connect"); ++ return; ++ } ++ } + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); +- return fail(ec, "connect"); ++ fail(ec, "connect"); ++ return; + } + + // Set the expected hostname in the peer certificate for verification +@@ -105,8 +116,12 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); +- if (ec) +- return fail(ec, "ssl_handshake"); ++ if (ec) { ++ { ++ fail(ec, "ssl_handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -117,35 +132,55 @@ + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if (ec) +- return fail(ec, "close"); ++ if (ec) { ++ { ++ fail(ec, "close"); ++ return; ++ } ++ } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } + + //------------------------------------------------------------------------------ + ++} // namespace ++ ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { +@@ -154,9 +189,9 @@ + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const host = argv[1]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -173,9 +208,13 @@ + // Launch the asynchronous operation + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -183,8 +222,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service. The call will return when +--- a/wasip3/websocket/client/sync/websocket_client_sync.cpp ++++ b/wasip3/websocket/client/sync/websocket_client_sync.cpp +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +47,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -58,21 +59,25 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(ws.next_layer(), results); ++ auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -103,9 +108,9 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ b/wasip3/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -52,6 +51,8 @@ + using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response ++// The process entry point retains the standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) + int main(int argc, char** argv) { + try { + // Check command line arguments. +@@ -62,8 +63,8 @@ + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ const auto* const port = argv[2]; ++ const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +@@ -78,14 +79,18 @@ + load_root_certificates(ctx); + + // These objects perform our I/O ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name ++ // Keep native-shaped resolver and execution-property call syntax across backends. ++ // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup +- auto ep = net::connect(beast::get_lowest_layer(ws), results); ++ auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { +@@ -128,9 +133,9 @@ + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence +- std::cout << beast::make_printable(buffer.data()) << std::endl; ++ std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +--- a/wasip3/websocket/server/async/websocket_server_async.cpp ++++ b/wasip3/websocket/server/async/websocket_server_async.cpp +@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + + #include + +@@ -53,6 +52,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -91,8 +91,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -107,11 +111,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -122,8 +131,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -141,32 +154,42 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -198,7 +221,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" +@@ -207,8 +234,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/websocket/server/async-local/websocket_server_async_local.cpp ++++ b/wasip3/websocket/server/async-local/websocket_server_async_local.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -46,17 +45,18 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +- +-namespace beast = webcpp::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -95,8 +95,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -111,11 +115,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + return; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -126,8 +135,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -145,7 +158,11 @@ + stream_protocol::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) ++ // The same completion handoff supports native owning and host borrowing overloads. ++ // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +@@ -162,10 +179,9 @@ + if (ec) { + fail(ec, "accept"); + return; +- } else { +- // Create the session and run it +- std::make_shared(std::move(socket))->run(); +- } ++ } ++ // Create the session and run it ++ std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); +@@ -174,7 +190,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -183,14 +203,14 @@ + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } +- auto const path = argv[1]; +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[2])); ++ const auto* const path = argv[1]; ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding +- std::remove(path); ++ static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); +@@ -200,7 +220,7 @@ + + return EXIT_SUCCESS; + } catch (std::exception const& e) { +- std::cerr << e.what() << std::endl; ++ std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ b/wasip3/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -44,7 +44,6 @@ + #include + #include + #include +-#include + + #include + +@@ -58,6 +57,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -93,8 +93,12 @@ + } + + void on_handshake(beast::error_code ec) { +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -114,8 +118,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -130,11 +138,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -145,8 +158,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -165,33 +182,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -223,7 +250,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -232,8 +263,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ b/wasip3/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -45,7 +44,7 @@ + + #include + +-#if defined(BOOST_ASIO_HAS_CO_AWAIT) ++#ifdef BOOST_ASIO_HAS_CO_AWAIT + + namespace beast = webcpp::beast; + namespace http = beast::http; +@@ -53,6 +52,7 @@ + namespace net = boost::asio; + + // Echoes back all received WebSocket messages ++namespace { + net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +@@ -73,11 +73,13 @@ + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + co_return; ++ } + +- if (ec) ++ if (ec) { + throw boost::system::system_error{ec}; ++ } + + // Echo the message back + stream.text(stream.got_text()); +@@ -87,13 +89,15 @@ + + // Accepts incoming connections and launches the sessions + net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { +- auto executor = co_await net::this_coro::executor; ++ auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { +@@ -106,7 +110,11 @@ + } + } + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" +@@ -115,20 +123,22 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + }); +--- a/wasip3/websocket/server/chat-multi/http_session.cpp ++++ b/wasip3/websocket/server/chat-multi/http_session.cpp +@@ -33,64 +33,88 @@ + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. ++namespace { + beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); +- if (pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) { + return beast::string_view{}; ++ } + return path.substr(pos); + }(); +- if (iequals(ext, ".htm")) ++ if (iequals(ext, ".htm")) { + return "text/html"; +- if (iequals(ext, ".html")) ++ } ++ if (iequals(ext, ".html")) { + return "text/html"; +- if (iequals(ext, ".php")) ++ } ++ if (iequals(ext, ".php")) { + return "text/html"; +- if (iequals(ext, ".css")) ++ } ++ if (iequals(ext, ".css")) { + return "text/css"; +- if (iequals(ext, ".txt")) ++ } ++ if (iequals(ext, ".txt")) { + return "text/plain"; +- if (iequals(ext, ".js")) ++ } ++ if (iequals(ext, ".js")) { + return "application/javascript"; +- if (iequals(ext, ".json")) ++ } ++ if (iequals(ext, ".json")) { + return "application/json"; +- if (iequals(ext, ".xml")) ++ } ++ if (iequals(ext, ".xml")) { + return "application/xml"; +- if (iequals(ext, ".swf")) ++ } ++ if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; +- if (iequals(ext, ".flv")) ++ } ++ if (iequals(ext, ".flv")) { + return "video/x-flv"; +- if (iequals(ext, ".png")) ++ } ++ if (iequals(ext, ".png")) { + return "image/png"; +- if (iequals(ext, ".jpe")) ++ } ++ if (iequals(ext, ".jpe")) { + return "image/jpeg"; +- if (iequals(ext, ".jpeg")) ++ } ++ if (iequals(ext, ".jpeg")) { + return "image/jpeg"; +- if (iequals(ext, ".jpg")) ++ } ++ if (iequals(ext, ".jpg")) { + return "image/jpeg"; +- if (iequals(ext, ".gif")) ++ } ++ if (iequals(ext, ".gif")) { + return "image/gif"; +- if (iequals(ext, ".bmp")) ++ } ++ if (iequals(ext, ".bmp")) { + return "image/bmp"; +- if (iequals(ext, ".ico")) ++ } ++ if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; +- if (iequals(ext, ".tiff")) ++ } ++ if (iequals(ext, ".tiff")) { + return "image/tiff"; +- if (iequals(ext, ".tif")) ++ } ++ if (iequals(ext, ".tif")) { + return "image/tiff"; +- if (iequals(ext, ".svg")) ++ } ++ if (iequals(ext, ".svg")) { + return "image/svg+xml"; +- if (iequals(ext, ".svgz")) ++ } ++ if (iequals(ext, ".svgz")) { + return "image/svg+xml"; ++ } + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. + std::string path_cat(beast::string_view base, beast::string_view path) { +- if (base.empty()) ++ if (base.empty()) { + return std::string(path); ++ } + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +@@ -102,8 +126,9 @@ + c = path_separator; + #else + char constexpr path_separator = '/'; +- if (result.back() == path_separator) ++ if (result.back() == path_separator) { + result.resize(result.size() - 1); ++ } + result.append(path.data(), path.size()); + #endif + return result; +@@ -150,18 +175,21 @@ + }; + + // Make sure we can handle the method +- if (req.method() != http::verb::get && req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); ++ } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || +- req.target().find("..") != beast::string_view::npos) ++ req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); ++ } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if (req.target().back() == '/') ++ if (req.target().back() == '/') { + path.append("index.html"); ++ } + + // Attempt to open the file + beast::error_code ec; +@@ -169,12 +197,14 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if (ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); ++ } + + // Handle an unknown error +- if (ec) ++ if (ec) { + return server_error(ec.message()); ++ } + + // Cache the size since we need it after the move + auto const size = body.size(); +@@ -190,8 +220,11 @@ + } + + // Respond to GET request +- http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{ ++ std::piecewise_construct, ++ std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version()), ++ }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -201,6 +234,8 @@ + + //------------------------------------------------------------------------------ + ++} // namespace ++ + http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +@@ -209,10 +244,13 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } +@@ -233,16 +271,22 @@ + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + +-void http_session::on_read(beast::error_code ec, std::size_t) { ++void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { +@@ -257,8 +301,10 @@ + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection +- bool keep_alive = msg.keep_alive(); +- ++ bool const keep_alive = msg.keep_alive(); ++ ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response +@@ -268,15 +314,21 @@ + }); + } + +-void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { ++void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. +- stream_.socket().shutdown(tcp::socket::shutdown_send, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + +--- a/wasip3/websocket/server/chat-multi/http_session.hpp ++++ b/wasip3/websocket/server/chat-multi/http_session.hpp +@@ -50,8 +50,8 @@ + + void fail(beast::error_code ec, char const* what); + void do_read(); +- void on_read(beast::error_code ec, std::size_t); +- void on_write(beast::error_code ec, std::size_t, bool close); ++ void on_read(beast::error_code ec, std::size_t /*unused*/); ++ void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + + public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); +--- a/wasip3/websocket/server/chat-multi/listener.cpp ++++ b/wasip3/websocket/server/chat-multi/listener.cpp +@@ -28,34 +28,44 @@ + #include "http_session.hpp" + #include "listener.hpp" + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -69,20 +79,28 @@ + } + + // Report a failure ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if (ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) { + return; ++ } + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection + void listener::on_accept(beast::error_code ec, tcp::socket socket) { +- if (ec) +- return fail(ec, "accept"); +- else ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } ++ { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); ++ } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), +--- a/wasip3/websocket/server/chat-multi/main.cpp ++++ b/wasip3/websocket/server/chat-multi/main.cpp +@@ -43,7 +43,9 @@ + #include + #include + +-int main(int argc, char* argv[]) { ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" +@@ -51,10 +53,10 @@ + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } +- auto address = net::ip::make_address(argv[1]); +- auto port = static_cast(std::atoi(argv[2])); +- auto doc_root = argv[3]; +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ auto* doc_root = argv[3]; ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; +--- a/wasip3/websocket/server/chat-multi/shared_state.cpp ++++ b/wasip3/websocket/server/chat-multi/shared_state.cpp +@@ -28,15 +28,15 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} ++shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + + void shared_state::join(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + sessions_.insert(session); + } + + void shared_state::leave(websocket_session* session) { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + sessions_.erase(session); + } + +@@ -50,15 +50,20 @@ + // holding the mutex: + std::vector> v; + { +- std::lock_guard lock(mutex_); ++ std::scoped_lock const lock(mutex_); + v.reserve(sessions_.size()); +- for (auto p : sessions_) ++ for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); ++ } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for (auto const& wp : v) +- if (auto sp = wp.lock()) ++ for (auto const& wp : v) { ++ // This mutable object is passed through the upstream asynchronous or stream interface. ++ // NOLINTNEXTLINE(misc-const-correctness) ++ if (const auto sp = wp.lock()) { + sp->send(ss); ++ } ++ } + } +--- a/wasip3/websocket/server/chat-multi/shared_state.hpp ++++ b/wasip3/websocket/server/chat-multi/shared_state.hpp +@@ -39,7 +39,7 @@ + + // Represents the shared server state + class shared_state { +- std::string const doc_root_; ++ std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; +@@ -50,7 +50,7 @@ + public: + explicit shared_state(std::string doc_root); + +- std::string const& doc_root() const noexcept { return doc_root_; } ++ [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); +--- a/wasip3/websocket/server/chat-multi/websocket_session.cpp ++++ b/wasip3/websocket/server/chat-multi/websocket_session.cpp +@@ -37,18 +37,25 @@ + state_->leave(this); + } + ++// Member shape is part of the upstream Body or bound-callback interface. ++// NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if (ec == net::error::operation_aborted || ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; ++ } + + std::cerr << what << ": " << ec.message() << "\n"; + } + + void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Add this session to the list of active sessions + state_->join(this); +@@ -58,10 +65,14 @@ + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void websocket_session::on_read(beast::error_code ec, std::size_t) { ++void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); +@@ -88,25 +99,31 @@ + queue_.push_back(ss); + + // Are we already writing? +- if (queue_.size() > 1) ++ if (queue_.size() > 1) { + return; ++ } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void websocket_session::on_write(beast::error_code ec, std::size_t) { ++void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if (!queue_.empty()) ++ if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); ++ } + } +--- a/wasip3/websocket/server/chat-multi/websocket_session.hpp ++++ b/wasip3/websocket/server/chat-multi/websocket_session.hpp +@@ -69,6 +69,8 @@ + }; + + template ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); +--- a/wasip3/websocket/server/coro/websocket_server_coro.cpp ++++ b/wasip3/websocket/server/coro/websocket_server_coro.cpp +@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + + #include + +@@ -53,11 +52,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -72,8 +74,12 @@ + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // This buffer will hold the incoming message +@@ -83,64 +89,106 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" +@@ -149,8 +197,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); +@@ -158,8 +206,12 @@ + // Spawn a listening port + boost::asio::spawn( + ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -167,8 +219,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads +--- a/wasip3/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ b/wasip3/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -44,7 +44,6 @@ + #include + #include + #include +-#include + + #include + +@@ -58,11 +57,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_session(websocket::stream>& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -71,8 +73,12 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -89,8 +95,12 @@ + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // This buffer will hold the incoming message +@@ -100,66 +110,110 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- +- if (ec) +- return fail(ec, "read"); ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } + + // Allow address reuse +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } + + // Bind to the server address +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } + + // Start listening for connections +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if (ec) ++ if (ec) { + fail(ec, "accept"); +- else ++ } else { + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); +- } +-} +- +-int main(int argc, char* argv[]) { ++ } ++ } ++} ++ ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" +@@ -168,8 +222,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -182,9 +236,13 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory +@@ -192,8 +250,9 @@ + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations +- if (ex) ++ if (ex) { + std::rethrow_exception(ex); ++ } + }); + + // Run the I/O service on the requested number of threads +--- a/wasip3/websocket/server/fast/websocket_server_fast.cpp ++++ b/wasip3/websocket/server/fast/websocket_server_fast.cpp +@@ -48,15 +48,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include +-#include + + #include + +@@ -69,6 +66,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); + } +@@ -117,8 +115,12 @@ + } + + void on_accept(beast::error_code ec) { +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + // Read a message + do_read(); +@@ -134,11 +136,16 @@ + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed +- if (ec == websocket::error::closed) +- return; +- +- if (ec) +- return fail(ec, "read"); ++ if (ec == websocket::error::closed) { ++ return; ++ } ++ ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +@@ -149,8 +156,12 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -166,33 +177,43 @@ + tcp::acceptor acceptor_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -225,6 +246,8 @@ + + //------------------------------------------------------------------------------ + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + +@@ -239,45 +262,86 @@ + })); + + ws.async_accept(yield[ec]); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); +- if (ec == websocket::error::closed) ++ if (ec == websocket::error::closed) { + break; +- if (ec) +- return fail(ec, "read"); ++ } ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if (ec) +- return fail(ec, "write"); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + } + } + ++// Value parameters retain the upstream callback and coroutine ownership contract. ++// NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ // Value parameters retain the upstream callback and coroutine ownership ++ // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); +- acceptor.open(endpoint.protocol(), ec); +- if (ec) +- return fail(ec, "open"); +- +- acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if (ec) +- return fail(ec, "set_option"); +- +- acceptor.bind(endpoint, ec); +- if (ec) +- return fail(ec, "bind"); +- +- acceptor.listen(net::socket_base::max_listen_connections, ec); +- if (ec) +- return fail(ec, "listen"); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.open(endpoint.protocol(), ec)); ++ if (ec) { ++ { ++ fail(ec, "open"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); ++ if (ec) { ++ { ++ fail(ec, "set_option"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.bind(endpoint, ec)); ++ if (ec) { ++ { ++ fail(ec, "bind"); ++ return; ++ } ++ } ++ ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); ++ if (ec) { ++ { ++ fail(ec, "listen"); ++ return; ++ } ++ } + + for (;;) { + tcp::socket socket(ioc); +@@ -290,6 +354,8 @@ + + boost::asio::spawn( + acceptor.get_executor(), ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); +@@ -298,7 +364,11 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" +@@ -311,8 +381,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +@@ -327,6 +397,8 @@ + + // Create coro port + boost::asio::spawn(ioc, ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), +--- a/wasip3/websocket/server/stackless/websocket_server_stackless.cpp ++++ b/wasip3/websocket/server/stackless/websocket_server_stackless.cpp +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + #include + +@@ -54,11 +53,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; +@@ -80,6 +82,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { +@@ -94,29 +98,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -130,39 +153,51 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -173,12 +208,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -193,12 +234,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" +@@ -207,8 +254,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ b/wasip3/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -46,7 +46,6 @@ + #include + #include + #include +-#include + + #include + +@@ -60,11 +59,14 @@ + //------------------------------------------------------------------------------ + + // Report a failure ++namespace { + void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; +@@ -86,6 +88,8 @@ + + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +@@ -96,9 +100,15 @@ + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "handshake"); ++ if (ec) { ++ { ++ fail(ec, "handshake"); ++ return; ++ } ++ } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. +@@ -115,29 +125,48 @@ + + // Accept the websocket handshake + yield ws_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion overload. ++ // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); +- if (ec) +- return fail(ec, "accept"); ++ if (ec) { ++ { ++ fail(ec, "accept"); ++ return; ++ } ++ } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if (ec) +- return fail(ec, "read"); ++ if (ec) { ++ { ++ fail(ec, "read"); ++ return; ++ } ++ } + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write(buffer_.data(), +- std::bind(&session::loop, shared_from_this(), +- std::placeholders::_1, std::placeholders::_2)); +- if (ec) +- return fail(ec, "write"); ++ yield ws_.async_write( ++ buffer_.data(), ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec) { ++ { ++ fail(ec, "write"); ++ return; ++ } ++ } + + // Clear the buffer + buffer_.consume(buffer_.size()); +@@ -151,6 +180,8 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions ++// Upstream combines coroutine state and shared lifetime as independent mixins. ++// NOLINTNEXTLINE(misc-multiple-inheritance) + class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; +@@ -158,33 +189,43 @@ + tcp::socket socket_; + + public: ++ // Value parameters retain the upstream callback and coroutine ownership contract. ++ // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor +- acceptor_.open(endpoint.protocol(), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse +- acceptor_.set_option(net::socket_base::reuse_address(true), ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address +- acceptor_.bind(endpoint, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ // The ec output and the returned reference carry the same operation status. ++ // NOLINTNEXTLINE(bugprone-unused-return-value) ++ static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; +@@ -195,12 +236,18 @@ + void run() { loop(); } + + private: ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + ++ // The retained stackless coroutine expands each yield into nested resume branches. ++ // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( ++ // The concrete bound signature selects the upstream Asio spawn/completion ++ // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); +@@ -215,12 +262,18 @@ + } + } + ++// Asio yield/unyield headers intentionally toggle macros and have no include guards. ++// NOLINTNEXTLINE(readability-duplicate-include) + #include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" +@@ -229,8 +282,8 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; +--- a/wasip3/websocket/server/sync/websocket_server_sync.cpp ++++ b/wasip3/websocket/server/sync/websocket_server_sync.cpp +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -48,6 +47,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket) { + try { + // Construct the stream by moving in the socket +@@ -75,16 +75,21 @@ + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if (se.code() != websocket::error::closed) +- std::cerr << "Error: " << se.code().message() << std::endl; ++ if (se.code() != websocket::error::closed) { ++ std::cerr << "Error: " << se.code().message() << '\n'; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -94,7 +99,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +@@ -112,7 +117,7 @@ + do_session(std::move(socket)); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } +--- a/wasip3/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ b/wasip3/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -42,7 +42,6 @@ + #include + #include + #include +-#include + + namespace beast = webcpp::beast; // from + namespace http = beast::http; // from +@@ -54,6 +53,7 @@ + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages ++namespace { + void do_session(tcp::socket socket, ssl::context& ctx) { + try { + // Construct the websocket stream around the socket +@@ -84,16 +84,21 @@ + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if (se.code() != websocket::error::closed) +- std::cerr << "Error: " << se.code().message() << std::endl; ++ if (se.code() != websocket::error::closed) { ++ std::cerr << "Error: " << se.code().message() << '\n'; ++ } + } catch (std::exception const& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) { ++} // namespace ++ ++// The process entry point retains its standard char** argv signature. ++// NOLINTNEXTLINE(misc-const-correctness) ++int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { +@@ -103,7 +108,7 @@ + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; +@@ -127,7 +132,7 @@ + do_session(std::move(socket), ctx); + } + } catch (const std::exception& e) { +- std::cerr << "Error: " << e.what() << std::endl; ++ std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + } diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp new file mode 100644 index 0000000..cbcf292 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp @@ -0,0 +1,661 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +using executor_type = net::strand; +using stream_type = beast::tcp_stream::rebind_executor::other; +using acceptor_type = net::ip::tcp::acceptor::rebind_executor::other; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +/** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. +*/ +class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit task_group(net::any_io_executor exec) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; + task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + + @note `completion_token` must have an associated executor that matches + the one the child task runs on (e.g. via `net::bind_executor`). This is + because `emit`() can run on a different thread than the task, and + `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template + auto adapt(CompletionToken&& completion_token) { + auto const lg = std::scoped_lock{mtx_}; + auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: + remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + + // A mutex or timer failure during this upstream task teardown is fatal by design. + // NOLINTNEXTLINE(bugprone-exception-escape) + ~remover() { + if (tg_) { + auto const lg = std::scoped_lock{tg_->mtx_}; + if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); + } + } + } + }; + + return net::bind_cancellation_slot( + cs->slot(), + net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's + handler, if any. + + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { + auto const lg = std::scoped_lock{mtx_}; + for (auto& cs : css_) { + cs.emit(type); + } + } + + /** Starts an asynchronous wait on the task_group. + + The completion handler will be called when: + + - All the child tasks completed. + - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion + handler must be: + @code + void handler( + boost::system::error_code const& error // result of operation + ); + @endcode + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template > + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( + // The apparent recursion crosses an asynchronous completion boundary. + // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { + if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); + } + + if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; + } + + { + auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + + if (!std::exchange(scheduled, true)) { + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); + } + + self.complete(ec); + }, + completion_token, cv_); + } +}; + +template +net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { + auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + + while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + // Echo the message back + ws.text(ws.got_text()); + co_await ws.async_write(buffer.data()); + + // Clear the buffer + buffer.consume(buffer.size()); + } + + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; + } +} + +template +net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + + if (ec == http::error::end_of_stream) { + co_return; + } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + + co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); + if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } + + co_await beast::async_write(stream, std::move(res)); + } +} + +net::awaitable detect_session(stream_type stream, ssl::context& ctx, + beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), + net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be + // inherited by all child coroutines. + co_await net::this_coro::throw_if_cancelled(false); + + stream.expires_after(std::chrono::seconds(30)); + + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + + auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + + if (!ssl_stream.lowest_layer().is_open()) { + co_return; + } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; + } + } else { + co_await run_session(stream, buffer, doc_root); + + if (!stream.socket().is_open()) { + co_return; + } + + stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); + } +} + +net::awaitable listen(task_group& task_group, ssl::context& ctx, + net::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + + if (ec == net::error::operation_aborted) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }))); + } +} + +net::awaitable handle_signals(task_group& task_group) { + auto const executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto sig = co_await signal_set.async_wait(); + + if (sig == SIGINT) { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( + net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); + + if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); + co_await task_group.async_wait(); + } + + std::cout << "Child tasks completed.\n"; + } else // SIGTERM + { + net::query(executor.get_inner_executor(), net::execution::context).stop(); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = net::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in listener: " << e.what() << "\n"; + } + } + }))); + + // Create and launch a signal handler coroutine + net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server-flex/advanced_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server-flex/advanced_server_flex.cpp new file mode 100644 index 0000000..acc795c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server-flex/advanced_server_flex.cpp @@ -0,0 +1,869 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class websocket_session { + websocket_session() = default; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( + websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, + derived().shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, + derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), + beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } + +public: + // Start the asynchronous operation + template + void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; + +public: + // Create the session + explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; + +public: + // Create the ssl_websocket_session + explicit ssl_websocket_session(ssl::stream&& stream) + : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream>& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +template +void make_websocket_session(beast::tcp_stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +template +void make_websocket_session(ssl::stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +protected: + beast::flat_buffer buffer; + +public: + // Construct the session +private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, + derived().shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream)) {} + + // Start the session + void run() { this->do_read(); } + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Called by the base class + beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the http_session + ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream), ctx) {} + + // Start the session + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( + ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Called by the base class + ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + +private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + explicit detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); + } + + void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( + stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(std::move(stream_), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector http_session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" + << "Example:\n" + << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&](beast::error_code const&, int) { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server/advanced_server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server/advanced_server.cpp new file mode 100644 index 0000000..af36c1f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/advanced/server/advanced_server.cpp @@ -0,0 +1,625 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, + shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection +class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +public: + // Take ownership of the socket + http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) { + static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + +private: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read(stream_, buffer_, *parser_, + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + std::make_shared(stream_.release_socket()) + ->do_accept(parser_->release()); + return; + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(acceptor_.get_executor(), + beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the http session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" + << "Example:\n" + << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&](beast::error_code const&, int) { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/common/root_certificates.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/common/root_certificates.hpp new file mode 100644 index 0000000..a60c9b9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/common/root_certificates.hpp @@ -0,0 +1,3975 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP + +#include +#include + +/* + PLEASE READ + + These root certificates here are included just to make the + SSL client examples work. They are NOT intended to be + illustrative of best-practices for performing TLS certificate + verification. + + A REAL program which needs to verify the authenticity of a + server IP address resolved from a given DNS name needs to + consult the operating system specific certificate store + to validate the chain of signatures, compare the domain name + properly against the domain name in the certificate, check + the certificate revocation list, and probably do some other + things. + + ALL of these operations are entirely outside the scope of + both Boost.Beast and Boost.Asio. + + See (work in progress): + https://github.com/djarek/certify + + tl;dr: root_certificates.hpp should not be used in production code +*/ + +namespace ssl = boost::asio::ssl; // from + +namespace detail { + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(ctx.load_verify_file(path, ec)); + return; + } + + std::string cert = + "# ACCVRAIZ1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" + "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" + "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaF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jJ2cJj+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf\n" + "77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrTQfv6MooqtyuGC2mDOL7Nii4LcK2N\n" + "JpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW+YJF1DngoABd15jm\n" + "fZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7Ixjp\n" + "6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp\n" + "1txyM/1d8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B\n" + "9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok\n" + "RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" + "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Actalis Authentication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" + "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" + "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB\n" + "MIICIjANBgkqhkiG9w0BA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KWW+9D+a2fDz\n" + "WochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKxK3JCaKygvU5a2hi/a5iB0P2avl4V\n" + "SM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+Xlff1ANATIGk0k9j\n" + "pwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX\n" + "X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok\n" + "fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R\n" + "K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU\n" + "ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU\n" + "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" + "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Commercial\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" + "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" + "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL\n" + "MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1\n" + "yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr\n" + "VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/\n" + "nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG\n" + "XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj\n" + "vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt\n" + "Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g\n" + "N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" + "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Networking\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBOZXR3b3JraW5nMB4X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eyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TX\n" + "OwF0lkLgAOIua+rF7nKsu7/+6qqo+Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYE\n" + "FJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByvMiPIs0laUZx2\n" + "KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg\n" + "Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B\n" + "8OWycvpEgjNC6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQ\n" + "MKSOyARiqcTtNd56l+0OOF6SL5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc\n" + "0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK+4w1IX2COPKpVJEZNZOUbWo6xbLQ\n" + "u4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF\n" + "u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH\n" + "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" + "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" + "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" + "KeC2uAloGRwYQw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" + "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" + "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" + "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" + "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" + "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" + "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" + "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" + "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" + "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEw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PQFWAJI/TPlUq9LhONm\n" + "UjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oAA7CXDpO8Wqj2\n" + "LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY\n" + "+gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS\n" + "k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl\n" + "7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm\n" + "btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl\n" + "urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+\n" + "fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n" + "n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Atos TrustedRoot 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE\n" + "AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG\n" + "EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM\n" + "FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC\n" + "REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp\n" + "Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM\n" + "VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+\n" + "SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ\n" + "4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L\n" + "cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi\n" + "eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV\n" + "HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG\n" + "A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j\n" + "vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP\n" + "DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc\n" + "maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D\n" + "lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv\n" + "KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Autoridad de Certificacion Firmaprofesional CIF A62634068\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UE\n" + "BhMCRVMxQjBABgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1h\n" + "cHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEy\n" + "MzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIwQAYDVQQDDDlBdXRvcmlkYWQgZGUg\n" + "Q2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBBNjI2MzQwNjgwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDDUtd9\n" + "thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQM\n" + "cas9UX4PB99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvF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XzR4Tgegiv/J2Wv+xYVxC5xhOW1//qkR71kMrv2JYSiJ0L1\n" + "ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaPT481\n" + "PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS\n" + "3a/DTg4fJl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5k\n" + "SeTy36LssUzAKh3ntLFlosS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF\n" + "3dvd6qJ2gHN99ZwExEWN57kci57q13XRcrHedUTnQn3iV2t93Jm8PYMo6oCTjcVM\n" + "ZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoRsaS8I8nkvof/uZS2+F0g\n" + "StRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTDKCOM/icz\n" + "Q0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQB\n" + "jLMi6Et8Vcad+qMUu2WFbm5PEn4KPJ2V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Baltimore CyberTrust Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" + "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" + "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" + "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" + "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" + "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" + "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" + "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" + "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" + "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" + "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" + "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" + "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" + "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" + "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" + "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" + "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" + "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" + "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5c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YDVR0OBBYEFMmAd+BikoL1Rpzz\n" + "uvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAU18h\n" + "9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s\n" + "A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3t\n" + "OluwlN5E40EIosHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo\n" + "+fsicdl9sz1Gv7SEr5AcD48Saq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7\n" + "KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYdDnkM/crqJIByw5c/8nerQyIKx+u2\n" + "DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us\n" + "H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ\n" + "I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7\n" + "5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" + "3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" + "Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 3 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNj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n" + "QTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV\n" + "cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXS\n" + "IGrs/CIBKM+GuIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2\n" + "HJLw5QY33KbmkJs4j1xrG0aGQ0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsa\n" + "O5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8ZORK15FTAaggiG6cX0S5y2CBNOxv\n" + "033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2KSb12tjE8nVhz36u\n" + "dmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz6MkE\n" + "kbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41\n" + "3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD\n" + "u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq\n" + "4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CA Disig Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV\n" + "BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu\n" + "MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy\n" + "MDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sxEzARBgNVBAcTCkJyYXRp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ipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqf\n" + "GopTpti72TVVsRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkb\n" + "lvdhuDvEK7Z4bLQjb/D907JedR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka\n" + "+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W81k/BfDxujRNt+3vrMNDcTa/F1bal\n" + "TFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjxmHHEt38OFdAlab0i\n" + "nSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01utI3\n" + "gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18Dr\n" + "G5gPcFw0sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3Os\n" + "zMOl6W8KjptlwlCFtaOgUxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8x\n" + "L4ysEr3vQCj8KWefshNPZiTEUxnpHikV7+ZtsH8tZ/3zbBt1RqPlShfppNcL\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CFCA EV ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD\n" + "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx\n" + "MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j\n" + "aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJP\n" + "T1QwggIiMA0GCS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+TqhdL\n" + "jOztUmCypAbqTuv0axn96/Ua4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBS\n" + "ESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sGE5uPhnEFtC+NiWYzKXZUmhH4J/qy\n" + "P5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfXBDrDMlI1Dlb4pd19\n" + "xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjnaH9d\n" + "Ci77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN\n" + "5mydLIhyPDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe\n" + "/v5WOaHIz16eGWRGENoXkbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+Z\n" + "AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ\n" + "5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB\n" + "gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV\n" + "BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw\n" + "MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl\n" + "YXRlciBNYW5jaGVzdGVy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a+5Acr5Pr5RzUZ5dd\n" + "BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB\n" + "ZQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" + "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" + "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" + "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" + "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" + "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" + "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" + "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB\n" + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" + "EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" + "Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh\n" + "dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR\n" + "6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X\n" + "pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC\n" + "9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV\n" + "/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf\n" + "Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z\n" + "+pUX2nwzV0E8jVHtC7Zcry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qD5daWb\n" + "QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl\n" + "0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB\n" + "NVOFBkpdn627G190\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNV\n" + "BAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4X\n" + "DTA3MDYyOTE1MTMwNVoXDTI3MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQ\n" + "BgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwIQ2VydGlnbmEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7qXOEm7RFHYeGifBZ4\n" + "QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyHGxny\n" + "gQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbw\n" + "zBfsV1/pogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q\n" + "130yGLMLLGq/jj8UEYkgDncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2\n" + "JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKfIrjxwo1p3Po6WAbfAgMBAAGjgbwwgbkw\n" + "DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQtCRZvgHyUtVF9lo53BEw\n" + "ZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJBgNVBAYT\n" + "AkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzj\n" + "AQ/JSP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG\n" + "9w0BAQUFAAOCAQEAhQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8h\n" + "bV6lUmPOEvjvKtpv6zf+EwLHyzs+ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFnc\n" + "fca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1kluPBS1xp81HlDQwY9qcEQCYsuu\n" + "HWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY1gkIl2PlwS6w\n" + "t0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw\n" + "WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw\n" + "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + "MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x\n" + "MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD\n" + "VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX\n" + "BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" + "ggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2Kyj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aXMuY29tL2NlcnRpZ25hcm9vdGNhLmNybDANBgkq\n" + "hkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOItOoldaDgvUSILSo3L\n" + "6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxPTGRG\n" + "HVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH6\n" + "0BGM+RFq7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncB\n" + "lA2c5uk5jR+mUYyZDDl34bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdi\n" + "o2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1\n" + "gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS6Cvu5zHbugRqh5jnxV/v\n" + "faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63\n" + "Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh\n" + "jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw\n" + "3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM\n" + "MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D\n" + "ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSB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nZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI\n" + "03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCB\n" + "gDELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMu\n" + "QS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIG\n" + "A1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29yayBDQSAyMCIYDzIwMTExMDA2MDgz\n" + "OTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQTDEiMCAGA1UEChMZ\n" + "VW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3\n" + "b3JrIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWA\n" + "DGSdhhuWZGc/IjoedQF97/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn\n" + "0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+oCgCXhVqqndwpyeI1B+twTUrWwbNWuKFB\n" + "OJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40bRr5HMNUuctHFY9rnY3lE\n" + "fktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2puTRZCr+E\n" + "Sv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYm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hehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnj\n" + "XALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P\n" + "5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbi\n" + "DrW5viSP\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Chambers of Commerce Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xKTAnBgNVBAMTIENoYW1iZXJz\n" + "IG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEyMjk1MFoXDTM4MDcz\n" + "MTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBj\n" + "dXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIw\n" + "EAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEp\n" + "MCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0G\n" + "CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW9\n" + "28sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKAXuFixrYp4YFs8r/lfTJq\n" + "VKAyGVn+H4vXPWCGhSRv4xGzdz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PQYDVR0gBDYwNDAyBgRV\n" + "HSAAMCowKAYIKwYBBQUHAgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20w\n" + "DQYJKoZIhvcNAQEFBQADggIBAJASryI1wqM58C7e6bXpeHxIvj99RZJe6dqxGfwW\n" + "PJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH3qLPaYRgM+gQDROpI9CF\n" + "5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbURWpGqOt1\n" + "glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaH\n" + "FoI6M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2\n" + "pSB7+R5KBWIBpih1YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MD\n" + "xvbxrN8y8NmBGuScvfaAFPDRLLmF9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QG\n" + "tjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcKzBIKinmwPQN/aUv0NCB9szTq\n" + "jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De\n" + "fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg\n" + "OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ\n" + "d0jQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Comodo AAA Services root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb\n" + "MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow\n" + "GAYDVQQKDB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Azk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q\n" + "GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz\n" + "Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2\n" + "G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi\n" + "l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3\n" + "smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Cybertrust Global Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYG\n" + "A1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2Jh\n" + "bCBSb290MB4XDTA2MTIxNTA4MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UE\n" + "ChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBS\n" + "b290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Mi8vRRQZhP/8NN5\n" + "7CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW0ozS\n" + "J8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2y\n" + "HLtgwEZLAfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iP\n" + "t3sMpTjr3kfb1V05/Iin89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNz\n" + "FtApD0mpSPCzqrdsxacwOUBdrsTiXSZT8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAY\n" + "XSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/\n" + "MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2MDSgMqAw\n" + "hi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3Js\n" + "MB8GA1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQBW7wojoFROlZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMj\n" + "Wqd8BfP9IjsO0QbE2zZMcwSO5bAi5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUx\n" + "XOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2hO0j9n0Hq0V+09+zv+mKts2o\n" + "omcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+TX3EJIrduPuoc\n" + "A06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW\n" + "WL1WMRJOEcgh4LMRkWXbtKaIOM5V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\n" + "ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM\n" + "HkQ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SfrzkGkj2wTZ51xY/GXUl77M/C4K\n" + "zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8\n" + "PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y\n" + "Johw1+qRzT65ysCQblrGXnRl11z+o+I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 EV 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw\n" + "NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV\n" + "BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAwOTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfSegpn\n" + "ljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM0\n" + "3TP1YtHhzRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6Z\n" + "qQTMFexgaDbtCHu39b+T7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lR\n" + "p75mpoo6Kr3HGrHhFPC+Oh25z1uxav60sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8\n" + "HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure3511H3a6UCAwEAAaOCASQw\n" + "ggEgMA8GA1UdEwEB/wQFMAM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NVow\n" + "PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" + "Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + "AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" + "rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" + "OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" + "xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" + "7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" + "aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" + "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" + "SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" + "ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" + "AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" + "R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" + "JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" + "Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root CA\n" + "-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1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf\n" + "fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm\n" + "NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx\n" + "H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe\n" + "+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSA\n" + "n61UQbVH35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4Htecc\n" + "biJVMWWXvdMX0h5i89vqbFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9Hp\n" + "EgjAALAcKxHad3A2m67OeYfcgnDmCXRwVWmvo2ifv922ebPynXApVfSr/5Vh88lA\n" + "bx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OPYLfykqGxvYmJHzDNw6Yu\n" + "YjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+RnlTGNAgMB\n" + "AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQW\n" + "BBTOw0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPI\n" + "QW5pJ6d1Ee88hjZv0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I\n" + "0jJmwYrA8y8678Dj1JGG0VDjA9tzd29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4Gni\n" + "lmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAWhsI6yLETcDbYz+70CjTVW0z9\n" + "B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv\n" + "ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo\n" + "IhNzbM8m9Yop5w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg\n" + "RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq\n" + "hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf\n" + "Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q\n" + "RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD\n" + "AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY\n" + "JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv\n" + "6pZjamVFkpUBtA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" + "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" + "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" + "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" + "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" + "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" + "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" + "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" + "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" + "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUN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JZ91\n" + "8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe\n" + "pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl\n" + "MrY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe\n" + "Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw\n" + "EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x\n" + "IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF\n" + "K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG\n" + "fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO\n" + "Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd\n" + "BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx\n" + "AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/\n" + "oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8\n" + "sycX\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert High Assurance EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n" + "ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n" + "LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug\n" + "RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm\n" + "+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW\n" + "PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM\n" + "xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB\n" + "Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3\n" + "hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg\n" + "EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA\n" + "FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec\n" + "nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z\n" + "eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF\n" + "hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2\n" + "Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe\n" + "vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep\n" + "+OkuE6N36B9K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Trusted Root G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3Qg\n" + "RzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBiMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3y\n" + "ithZwuEppz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1If\n" + "xp4VpX6+n6lXFllVcq9ok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iahixTXTBmyUEFxPT9N\n" + "cCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN5r5N\n" + "0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie\n" + "4u1Ki7wb/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI\n" + "r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1\n" + "/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm\n" + "gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# E-Tugra Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNV\n" + "BAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBC\n" + "aWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNV\n" + "BAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQDDB9FLVR1\n" + "Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMwNTEyMDk0OFoXDTIz\n" + "MDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+\n" + "BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhp\n" + "em1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN\n" + "ZXJrZXppMSg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D4eKexd0dCrfOAKkEh47U6YA5n+KGCR\n" + "HTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jOXKqY\n" + "GwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c\n" + "77NCR807VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3\n" + "+GbHeJAAFS6LrVE1Uweoa2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WK\n" + "vJUawSg5TB9D0pH0clmKuVb8P7Sd2nCcdlqMQ1DujjByTd//SffGqWfZbawCEeI6\n" + "FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEVKV0jq9BgoRJP3vQXzTLl\n" + "yb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gTDx4JnW2P\n" + "AJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpD\n" + "y4Q08ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8d\n" + "NL/+I5c30jn6PQ0GC7TbO6Orb1wdtn7os4I07QZcJA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EC-ACC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB\n" + "8zELMAkGA1UEBhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2Vy\n" + "dGlmaWNhY2lvIChOSUYgUS0wODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1\n" + "YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYDVQQLEyxWZWdldSBodHRwczovL3d3\n" + "dy5jYXRjZXJ0Lm5ldC92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NVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4\n" + "opvpXY0wfwYDVR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBo\n" + "dHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidW\n" + "ZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAwDQYJKoZIhvcN\n" + "AQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJlF7W2u++AVtd0x7Y\n" + "/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNaAl6k\n" + "SBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhy\n" + "Rp/7SNVel+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOS\n" + "Agu+TGbrIP65y7WZf+a2E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xl\n" + "nJ2lYJU6Un/10asIbvPuW/mIPX64b24D5EI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EE Certification Centre Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1\n" + "MQswCQYDVQQGEwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1\n" + "czEoMCYGA1UEAwwfRUUgQ2VydGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYG\n" + "CSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIwMTAxMDMwMTAxMDMwWhgPMjAzMDEy\n" + "MTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlBUyBTZXJ0aWZpdHNl\n" + "ZXJpbWlza2V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qpYe73dgzzcvRyrc9yAjYHR8/v\n" + "GVCJYMzpJJUPwssd8m92kMfMdcGWxZ0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust.net Premium 2048 Secure Server CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML\n" + "RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp\n" + "bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5\n" + "IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0yOTA3\n" + "MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3\n" + "LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp\n" + "YWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG\n" + "A1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU1LqRKGsuqjIAcVFmQq\n" + "K0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOLGp18EzoOH1u3Hs/lJBQe\n" + "sYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSrhRSGlVuX\n" + "MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT\n" + "XTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/\n" + "HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH\n" + "4QIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV\n" + "HQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJKoZIhvcNAQEFBQADggEBADub\n" + "j1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPyT/4xmf3IDExo\n" + "U8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf\n" + "zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5b\n" + "u/8j72gZyxKTJ1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+\n" + "bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er\n" + "fF6adulZkMV8gzURZVE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\n" + "Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\n" + "KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\n" + "cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw\n" + "NTM0MlowgbAxCzAJBgNVBAYTAl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pQ47RgxRzwIkSNcUesyBrJ6Zua\n" + "AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP\n" + "9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/\n" + "eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\n" + "0vdXcDazv/wor3ElhVsT/h5/WrQ8\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - EC1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG\n" + "A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3\n" + "d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu\n" + "dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq\n" + "RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy\n" + "MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD\n" + "VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0\n" + "L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g\n" + "Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD\n" + "ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi\n" + "A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt\n" + "ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH\n" + "Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O\n" + "BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC\n" + "R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX\n" + "hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50\n" + "cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3Qs\n" + "IEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVz\n" + "dCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwHhcNMDkwNzA3MTcy\n" + "NTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVu\n" + "dHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwt\n" + "dGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0\n" + "aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5IC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + "AoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP/vaCeb9zYQYKpSfYs1/T\n" + "RU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXzHHfV1IWN\n" + "cCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hW\n" + "wcKUs/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1\n" + "U1+cPvQXLOZprE4yTGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0\n" + "jaWvYkxN4FisZDQSA/i2jZRjJKRxAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAP\n" + "BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN\n" + "BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/\n" + "jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ\n" + "Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v\n" + "1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R\n" + "nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH\n" + "VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFV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js4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk\n" + "5F6G+TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuY\n" + "n/PIjhs4ViFqUZPTkcpG2om3PVODLAgfi49T3f+sHw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GDCA TrustAUTH R5 ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UE\n" + "BhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ\n" + "IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0\n" + "MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVowYjELMAkGA1UEBhMCQ04xMjAwBgNV\n" + "BAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8w\n" + "HQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0BAQEF\n" + "AAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJj\n" + "Dp6L3TQsAlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBj\n" + "TnnEt1u9ol2x8kECK62pOqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+u\n" + "KU49tm7srsHwJ5uu4/Ts765/94Y9cnrrpftZTqfrlYwiOXnhLQiPzLyRuEH3FMEj\n" + "qcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ9Cy5WmYqsBebnh52nUpm\n" + "MUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQx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mIGrv/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrq\n" + "T8p+ck0LcIymSLumoRT2+1hEmRSuqguTaaApJUqlyyvdimYHFngVV3Eb7PVHhPOe\n" + "MTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaM\n" + "f/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vX\n" + "mX7wCl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7\n" + "zUjwTcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0P\n" + "fyblqAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtc\n" + "vfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4\n" + "Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zqkUsp\n" + "zBmkMiVOKvF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gzNdws\n" + "E3PYJ/HQcu51OyLemGhmW/HGY0dVHLqlCFF1pkgl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTukk3Lv\n" + "CvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3Kg\n" + "GjSY6Dlo7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9Bu\n" + "XvAuMC6C/Pq8tBcKSOWIm8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOd\n" + "re7kRXuJVfeKH2JShBKzwkCX44ofR5GmdFrS+LFjKBC4swm4VndAoiaYecb+3yXu\n" + "PuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbuak7MkogwTZq9TwtImoS1\n" + "mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscszcTJGr61K\n" + "8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqj\n" + "x5RWIr9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z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TS Root R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout\n" + "736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2A\n" + "DDL24CejQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBTB8Sa6oC2uhYHP0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFuk\n" + "fCPAlaUs3L6JbyO5o91lAFJekazInXJ0glMLfalAvWhgxeG4VDvBNhcl2MG9AjEA\n" + "njWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOaKaqW04MjyaR7YbPMAuhd\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu\n" + "hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/l\n" + "xKvRHYqjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBSATNbrdP9JNqPV2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0\n" + "CMRw3J5QdCHojXohw0+WbhXRIjVhLfoIN+4Zba3bssx9BzT1YBkstTTZbyACMANx\n" + "sbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11xzPKwTdb+mciUqXWi4w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Global CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\n" + "YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG\n" + "EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg\n" + "R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9\n" + "9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq\n" + "fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\n" + "iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\n" + "1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\n" + "bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\n" + "MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\n" + "ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\n" + "uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\n" + "Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\n" + "tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\n" + "PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n" + "hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n" + "5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY\n" + "MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo\n" + "R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx\n" + "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uWgfOgPIh1a6Vk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL\n" + "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj\n" + "KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2\n" + "MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV\n" + "BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw\n" + "NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV\n" + "BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH\n" + "MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL\n" + "So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal\n" + "tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG\n" + "CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT\n" + "qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz\n" + "rD6ogRLQy7rQkgu2npaqBA+K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB\n" + "mDELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsT\n" + "MChjKSAyMDA4IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s\n" + "eTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhv\n" + "cml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIzNTk1OVowgZgxCzAJ\n" + "BgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg\n" + "MjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0\n" + "BgNVBAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg\n" + "LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz\n" + "+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5jK/BGvESyiaHAKAxJcCGVn2TAppMSAmUm\n" + "hsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdEc5IiaacDiGydY8hS2pgn\n" + "5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3CIShwiP/W\n" + "JmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exAL\n" + "DmKudlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZC\n" + "huOl1UcCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw\n" + "HQYDVR0OBBYEFMR5yo6hTgMdHNxr2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IB\n" + "AQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9cr5HqQ6XErhK8WTTOd8lNNTB\n" + "zU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbEAp7aDHdlDkQN\n" + "kv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD\n" + "AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUH\n" + "SJsMC8tJP33st/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2G\n" + "spki4cErx5z481+oghLrGREt\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE\n" + "BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0\n" + "IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV\n" + "VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8\n" + "cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT\n" + "QjOgNB0eRXbdT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Z3b4XUhRxQ4K5RirqN\n" + "Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja\n" + "QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW\n" + "koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9\n" + "ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt\n" + "DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm\n" + "bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYD\n" + "VQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1\n" + "c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" + "AQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0DE81\n" + "WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUG\n" + "FF+3Qs17j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdq\n" + "XbboW0W63M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L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz\n" + "GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m\n" + "1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV\n" + "OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH\n" + "6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX\n" + "QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ\n" + "FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F\n" + "uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX\n" + "kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs\n" + "ewv4n4Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc\n" + "8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke\n" + "hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI\n" + "KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg\n" + "515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO\n" + "xwy8p2Fp8fc74SrL+SvzZpA3\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdTCCAl2gAwIBAgIL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hJIZJrglfCm7ymP\n" + "AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\n" + "DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\n" + "HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1\n" + "MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL\n" + "v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8\n" + "eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq\n" + "tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd\n" + "C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa\n" + "zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB\n" + "mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH\n" + "V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n\n" + "bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG\n" + "3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs\n" + "J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO\n" + "291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS\n" + "ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd\n" + "AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7\n" + "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\n" + "MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\n" + "RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\n" + "gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\n" + "KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\n" + "QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\n" + "XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\n" + "LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\n" + "RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\n" + "jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n" + "6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\n" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\n" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\n" + "WD9f\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R6\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg\n" + "MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh\n" + "bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQ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ANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN\n" + "nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGt\n" + "Ixg93eFyRJa0lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr61\n" + "55wsTLxDKZmOMNOsIeDjHfrYBzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLj\n" + "vUYAGm0CuiVdjaExUd1URhxN25mW7xocBFymFe944Hn+Xds+qkxV/ZoVqW/hpvvf\n" + "cDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr3TsTjxKM4kEaSHpz\n" + "oHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB10jZp\n" + "nOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs\n" + "pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v\n" + "JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R\n" + "8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4\n" + "5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Global Chambersign Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBD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D7+3056huirRXhOukP9DuqqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9O\n" + "AP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETrP3iZ8ntxPjzxmKfFGBI/5rso\n" + "M0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVqc5iJWzouE4ge\n" + "v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z\n" + "09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh\n" + "MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE\n" + "YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3\n" + "MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo\n" + "ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg\n" + "MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN\n" + "ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA\n" + "PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w\n" + "wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi\n" + "EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY\n" + "avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+\n" + "YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE\n" + "sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h\n" + "/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5\n" + "IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD\n" + "ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy\n" + "OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P\n" + "TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ\n" + "HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER\n" + "dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf\n" + "ReYNnyicsbkqWletNw+vHX/bvZ8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" + "EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRke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gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n" + "LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n" + "4uJEvlz36hz1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions ECC RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN\n" + "BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl\n" + "bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv\n" + "b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ\n" + "BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj\n" + "YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5\n" + "MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0\n" + "dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg\n" + "QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa\n" + "jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC\n" + "MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi\n" + "C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep\n" + "lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof\n" + "TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1Ix\n" + "RDBCBgNVBAoTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1p\n" + "YyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIFJvb3RDQSAyMDExMB4XDTExMTIw\n" + "NjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYTAkdSMUQwQgYDVQQK\n" + "EztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIENl\n" + "cnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBAKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPz\n" + "dYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJ\n" + "fel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa71HFK9+WXesyHgLacEns\n" + "bgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u8yBRQlqD\n" + "75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSP\n" + "FEDH3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNV\n" + "HRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp\n" + "5dgTBCPuQSUwRwYDVR0eBEAwPqA8MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQu\n" + "b3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQub3JnMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVtXdMiKahsog2p\n" + "6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8\n" + "TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7\n" + "dIsXRSZMFpGD/md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8Acys\n" + "Nnq/onN694/BtZqhFLKPM58N7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXI\n" + "l7WdmplNsDz4SgCbZN2fOUvRJ9e4\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix\n" + "DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k\n" + "IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT\n" + "N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZX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VFqmjZayc\n" + "Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNV\n" + "HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVd\n" + "ctA4GGqd83EkVAswDQYJKoZIhvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0I\n" + "XtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+D1hYc2Ryx+hFjtyp8iY/xnmMsVMI\n" + "M4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrMd/K4kPFox/la/vot\n" + "9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+yd+2V\n" + "Z5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/ea\n" + "j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh\n" + "X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ\n" + "l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf\n" + "bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4\n" + "pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK\n" + "e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0\n" + "vm9qp/UsQu0yrbYhnr68\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA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H0Ti/L6RoZz71ilTc4afU9hDDl3WY4JxHYB0yvbi\n" + "AmvZWg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL\n" + "BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ\n" + "SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n\n" + "a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5\n" + "NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtvbmcxEjAQBgNVBAcT\n" + "CUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMXSG9u\n" + "Z2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "AoICAQCziNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFO\n" + "dem1p+/l6TWZ5Mwc50tfjTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mI\n" + "VoBc+L0sPOFMV4i707mV78vH9toxdCim5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV\n" + "9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOesL4jpNrcyCse2m5FHomY\n" + "2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj0mRiikKY\n" + "vLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+Tt\n" + "bNe/JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPiv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HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa\n" + "LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG\n" + "mpv0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ISRG Root X1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" + "WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n" + "ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n" + "MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n" + "h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+\n" + "0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U\n" + "A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW\n" + "T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH\n" + "B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC\n" + "B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv\n" + "KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZP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"emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Commercial Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu\n" + "VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw\n" + "MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw\n" + "JQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ldhNlT\n" + "3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU\n" + "+ehcCuz/mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gp\n" + "S0l4PJNgiCL8mdo2yMKi1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1\n" + "bVoE/c40yiTcdCMbXTMTEl3EASX2MN0CXZ/g1Ue9tOsbobtJSdifWwLziuQkkORi\n" + "T0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl3ZBWzvurpWCdxJ35UrCL\n" + "vYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzyNeVJSQjK\n" + "Vsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZK\n" + "dHzVWYfCP04MXFL0PfdSgvHqo6z9STQaKPNB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TIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Public Sector Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu\n" + "VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN\n" + "MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0\n" + "MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTyP4o7\n" + "ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGy\n" + "RBb06tD6Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlS\n" + "bdsHyo+1W/CD80/HLaXIrcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF\n" + "/YTLNiCBWS2ab21ISGHKTN9T0a9SvESfqy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R\n" + "3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoSmJxZZoY+rfGwyj4GD3vw\n" + "EUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFnol57plzy\n" + "9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9V\n" + "GxyhLrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ\n" + "2fjXctscvG29ZV/viDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsV\n" + "WaFHVCkugyhfHMKiq3IXAAaOReyL4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gD\n" + "W/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMwDQYJKoZIhvcN\n" + "AQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj\n" + "t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHV\n" + "DRDtfULAj+7AmgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9\n" + "TaDKQGXSc3z1i9kKlT/YPyNtGtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8G\n" + "lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW\n" + "mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df\n" + "WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5\n" + "+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ\n" + "tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA\n" + "GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv\n" + "8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Izenpe.com\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF8TCCA9mgAwIBAgIQALC3W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YLdE41V4tC5h9Pmzb/CaIxw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# LuxTrust Global Root 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL\n" + "BQAwRjELMAkGA1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNV\n" + "BAMMFkx1eFRydXN0IEdsb2JhbCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUw\n" + "MzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEWMBQGA1UECgwNTHV4VHJ1c3QgUy5B\n" + "LjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBANeFl78RmOnwYoNMPIf5U2o3C/IPPIfOb9wmKb3F\n" + "ibrJgz337spbxm1Jc7TJRqMbNBM/wYlFV/TZsfs2ZUv7COJIcRHIbjuend+JZTem\n" + "hfY7RBi2xjcwYkSSl2l9QjAk5A0MiWtj3sXh306pFGxT4GHO9hcvHTy95iJMHZP1\n" + "EMShduxq3sVs35a0VkBCwGKSMKEtFZSg0iAGCW5qbeXrt77U8PEVfIvmTroTzEsn\n" + "Xpk8F12PgX8zPU/TPxvsXD/wPEx1bvKm1Z3aLQdjAsZy6ZS8TEmVT4hSyNvoaYL4\n" + "zDRbIvCGp4m9SAptZoFtyMhk+wHh9OHe2Z7d21vUKpkmFRseTJIpgp7VkoGSQXAZ\n" + "96Tlk0u8d2cx3Rz9MXANF5kM+Qw5GSoXtTBxVdUPrljhPS80m8+f9niFwpN6cj5m\n" + "j5wWEWCPnolvZ77gR1o7DJpni89Gxq44o/KnvObWhWszJHAiS8sIm7vI+AIpHb4g\n" + "DEa/a4ebsypmQjVGbKq6rfmYe+lQVRQxv7HaLe2ArWgk+2mr2HETMOZns4dA/Yl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P7ghu5sJf0dgYzQ0mg/wu1\n" + "+rUCAwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G\n" + "A1UdDgQWBBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPM\n" + "Pcu1SCOhGnqmKrs0aDAbBgNVHREEFDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqG\n" + "SIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0olZMEyL/azXm4Q5DwpL7v8u8h\n" + "mLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfXI/OMn74dseGk\n" + "ddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775\n" + "tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c\n" + "2Pm2G2JwCz02yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5t\n" + "HMN1Rq41Bab2XD0h7lbwyYIiLXpUq3DDfSJlgnCW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# NetLock Arany (Class Gold) Főtanúsítvány\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG\n" + "EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3\n" + "MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl\n" + "cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR\n" + "dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgxMjA2MTUwODIxWjCB\n" + "pzELMAkGA1UEBh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v0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2\n" + "XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Network Solutions Certificate Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi\n" + "MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu\n" + "MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp\n" + "dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJV\n" + "UzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydO\n" + "ZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqG\n" + "SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwz\n" + "c7MEL7xxjOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPP\n" + "OCwGJgl6cvf6UDL4wpPTaaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rl\n" + "mGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXTcrA/vGp97Eh/jcOrqnErU2lBUzS1sLnF\n" + "BgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc/Qzpf14Dl847ABSHJ3A4\n" + "qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMBAAGjgZcw\n" + "gZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIB\n" + "BjAPBgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwu\n" + "bmV0c29sc3NsLmNvbS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3Jp\n" + "dHkuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc8\n" + "6fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q4LqILPxFzBiwmZVRDuwduIj/\n" + "h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/GGUsyfJj4akH\n" + "/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv\n" + "wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN\n" + "pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GA CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCB\n" + "ijELMAkGA1UEBhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHly\n" + "aWdodCAoYykgMjAwNTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl\n" + "ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQSBDQTAeFw0w\n" + "NTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYDVQQGEwJDSDEQMA4G\n" + "A1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIwIAYD\n" + "VQQLExlPSVN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Nbrgh\n" + "cViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5\n" + "gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3ZwLWoo4rO\n" + "ZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" + "aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic\n" + "Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GC CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw\n" + "CQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91\n" + "bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwg\n" + "Um9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRaFw00MjA1MDkwOTU4MzNaMG0xCzAJ\n" + "BgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBGb3Vu\n" + "ZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2JhbCBS\n" + "b290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4ni\n" + "eUqjFqdrVCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4W\n" + "p2OQ0jnUsYd4XxiWD1AbNTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8E\n" + "BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7T\n" + "rYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0EAwMDaAAwZQIwJsdpW9zV\n" + "57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtkAjEA2zQg\n" + "Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC\n" + "TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0\n" + "aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0\n" + "aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz\n" + "MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw\n" + "IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR\n" + "dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp\n" + "li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D\n" + "rOpm2RgbaIr1VxqYuvXtdj182d6UajtLF8HVj71lODqV0D1VNk7feVcxKh7YWWVJ\n" + "WCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeLYzcS19D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rEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8\n" + "7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R\n" + "cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y\n" + "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n" + "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n" + "SnQ2+Q==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 1 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00\n" + "MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakEPBtV\n" + "wedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWe\n" + "rNrwU8lmPNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF341\n" + "68Xfuw6cwI2H44g4hWf6Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh\n" + "4Pw5qlPafX7PGglTvF0FBM+hSo+Ld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/k\n" + "NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj\n" + "ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp\n" + "q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt\n" + "nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCa\n" + "GMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6XJxg\n" + "Fyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55J\n" + "WpzmM+Yklvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bB\n" + "rrcCaoF6qUWD4gXmuVbBlDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp\n" + "+ARz8un+XJiM9XOva7R+zdRcAitMOeGylZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1\n" + "ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r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ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD\n" + "mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z\n" + "ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y\n" + "4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza\n" + "8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00\n" + "MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFhZiFf\n" + "qq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMW\n" + "n4rjyduYNM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ym\n" + "c5GQYaYDFCDy54ejiK2toIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+\n" + "O7q414AB+6XrW7PFXmAqMaCvN+ggOp+oMiwMzAkd056OXbxMmO7FGmh77FOm6RQ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6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg\n" + "KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM\n" + "HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4\n" + "WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM\n" + "V0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNggDhoB\n" + "4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUr\n" + "H556VOijKTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd\n" + "8lyyBTNvijbO0BNO/79KDDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9Cabwv\n" + "vWhDFlaJKjdhkf2mrk7AyxRllDdLkgbvBNDInIjbC3uBr7E9KsRlOni27tyAsdLT\n" + "mZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwpp5ijJUMv7/FfJuGITfhe\n" + "btfZFG4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+ "oxXqA/4Ti2Tk08HS6IT7SdEQTXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFg\n" + "u/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9DuDcpmvJRPpq3t/O5jrFc/ZSXPsoaP\n" + "0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGibIh6BJpsQBJFxwAYf\n" + "3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmDhPbl\n" + "8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+\n" + "DhcI00iX0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HN\n" + "PlopNLk9hM6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/\n" + "ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx\n" + "NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv\n" + "bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49\n" + "AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA\n" + "VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku\n" + "WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP\n" + "MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX\n" + "5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ\n" + "ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg\n" + "h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority RSA R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNV\n" + "BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UE\n" + "CgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMB4XDTE3MDUzMTE4MTQzN1oXDTQy\n" + "MDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4G\n" + "A1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQD\n" + "DC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNh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m3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nxY/hoLVUE0fKNsKTPvDxeH3jnpaAg\n" + "cLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2GguDKBAdRUNf/ktUM\n" + "79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDzOFSz\n" + "/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXt\n" + "ll9ldDz7CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEm\n" + "Kf7GUmG6sXP/wwyc5WxqlD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKK\n" + "QbNmC1r7fSOl8hqw/96bg5Qu0T/fkreRrwU7ZcegbLHNYhLDkBvjJc40vG93drEQ\n" + "w/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi\n" + "S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07\n" + "mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0\n" + "aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz\n" + "WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0\n" + "b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS\n" + "b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB\n" + "BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI\n" + "7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg\n" + "CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD\n" + "VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T\n" + "kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+\n" + "gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority RSA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz\n" + "OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoM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OCAgEAIBgRlCn7Jp0cHh5wYfGV\n" + "cpNxJK1ok1iOMq8bs3AD/CUrdIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBc\n" + "Hadm47GUBwwyOabqG7B52B2ccETjit3E+ZUfijhDPwGFpUenPUayvOUiaPd7nNgs\n" + "PgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAslu1OJD7OAUN5F7kR/\n" + "q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjqerQ0\n" + "cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jr\n" + "a6x+3uxjMxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90I\n" + "H37hVZkLId6Tngr75qNJvTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/Y\n" + "K9f1JmzJBjSWFupwWRoyeXkLtoh/D1JIPb9s2KJELtFOt3JY04kTlf5Eq/jXixtu\n" + "nLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406ywKBjYZC6VWg3dGq2ktuf\n" + "oYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NIWuuA8ShY\n" + "Ic2wBlX7Jz9TkHCpBB5XJ7k=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SZAFIR ROOT CA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQEL\n" + "BQAwUTELMAkGA1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6\n" + "ZW5pb3dhIFMuQS4xGDAWBgNVBAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkw\n" + "NzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJBgN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hQ\n" + "X5Ucv+2rIrVls4W6ng+4reV6G4pQOh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWr\n" + "QbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01y8hSyn+B/tlr0/cR7SXf+Of5\n" + "pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061lgeLKBObjBmN\n" + "QSdJQO7e5iNEOdyhIta6A/I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureTrust CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI\n" + "MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x\n" + "FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz\n" + "MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv\n" + "cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN\n" + "AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz\n" + "Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO\n" + "0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao\n" + "wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj\n" + "7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS\n" + "8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT\n" + "Bg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ggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jxYDiJ\n" + "iQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa\n" + "/FHtaMbQbqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJ\n" + "jnIFHovdRIWCQtBJwB1g8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnI\n" + "HmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYVHDGA76oYa8J719rO+TMg1fW9ajMtgQT7\n" + "sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi0XPnj3pDAgMBAAGjgZ0w\n" + "gZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCsw\n" + "KaAnoCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsG\n" + "AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L\n" + "URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO\n" + "H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm\n" + "I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY\n" + "iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc\n" + "f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication RootCA2\n" +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7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8\n" + "t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy\n" + "1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/\n" + "SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY\n" + "MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t\n" + "dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5\n" + "WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD\n" + "VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8\n" + "9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ\n" + "DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9\n" + "Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N\n" + "QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ\n" + "xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G\n" + "A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T\n" + "AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG\n" + "kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr\n" + "Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5\n" + "Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU\n" + "JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot\n" + "RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Sonera Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP\n" + "MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx\n" + "MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV\n" + "BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o\n" + "Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt\n" + "5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s\n" + "3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej\n" + "vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu\n" + "8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw\n" + "DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG\n" + "MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil\n" + "zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/\n" + "3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD\n" + "FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6\n" + "Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2\n" + "ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gRVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0y\n" + "MjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIg\n" + "TmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRlcmxhbmRlbiBFViBS\n" + "b290IENBMIICIjANBgkqh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lT5OZEAFTdfETzsemQUHS\n" + "v4ilf0X8rLiltTMMgsT7B/Zq5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTC\n" + "wPTxGfARKbalGAKb12NMcIxHowNDXLldRqANb/9Zjr7dn3LDWyvfjFvO5QxGbJKy\n" + "CqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tNf1zuacpzEPuKqf2e\n" + "vTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi5Dp6\n" + "Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIa\n" + "Gl6I6lD4WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeL\n" + "eG9QgkRQP2YGiqtDhFZKDyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8\n" + "FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGyeUN51q1veieQA6TqJIc/2b3Z6fJfUEkc\n" + "7uzXLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloX\n" + "DTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMCTkwxHjAcBgNVBAoMFVN0YWF0IGRl\n" + "ciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5lZGVybGFuZGVuIFJv\n" + "b3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4yol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oTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixp\n" + "gZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA8KCWAg8zxXHzniN9lLf9OtMJgwYh\n" + "/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b8KKaa8MFSu1BYBQw\n" + "0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0rmj1A\n" + "fsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq\n" + "4BZ+Extq1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR\n" + "1VmiiXTTn74eS9fGbbeIJG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/\n" + "QFH1T/U67cjF68IeHRaVesd+QnGTbksVtzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM\n" + "94B7IWcnMFk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Root Certificate Authority - G2\n"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DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Services Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs\n" + "ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5\n" + "MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD\n" + "VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy\n" + "ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy\n" + "dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p\n" + "OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2\n" + "8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K\n" + "Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe\n" + "hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk\n" + "6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw\n" + "DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q\n" + "AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI\n" + "bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB\n" + "ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z\n" + "qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n" + "iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n" + "0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n" + "sSi6\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Gold CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n" + "BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln\n" + "biBHb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FoAUWyV7lqRlUX64OfPAeGZe6Drn\n" + "8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov\n" + "L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe6\n" + "45R88a7A3hfm5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczO\n" + "UYrHUDFu4Up+GC9pWbY9ZIEr44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5\n" + "O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOfMke6UiI0HTJ6CVanfCU2qT1L2sCC\n" + "bwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6mGu6uLftIdxf+u+yv\n" + "GPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxpmo/a\n" + "77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC\n" + "hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3\n" + "92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp\n" + "Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w\n" + "ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt\n" + "Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Silver CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE\n" + "BhMCQ0gxFTATBgNVBAoTDFN3aXN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4EFgQU\n" + "F6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRBtjpbO8tFnb0c\n" + "wpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0\n" + "cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIB\n" + "AHPGgeAn0i0P4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShp\n" + "WJHckRE1qTodvBqlYJ7YH39FkWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9\n" + "xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L3XWgwF15kIwb4FDm3jH+mHtwX6WQ\n" + "2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx/uNncqCxv1yL5PqZ\n" + "IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8\n" + "aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X\n" + "em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR\n" + "dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/\n" + "OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+\n" + "hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy\n" + "tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9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WiPAC\n" + "uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw\n" + "IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6\n" + "g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN\n" + "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" + "BSeOE6Fuwg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgxMDAxMTAyOTU2WhcNMzMxMDAxMjM1\n" + "OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy\n" + "aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50\n" + "ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0G\n" + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN\n" + "8ELg63iIVl6bmlQdTQyK9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/\n" + "RLyTPWGrTs0NvvAgJ1gORH8EGoel15YUNpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4\n" + "hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZFiP0Zf3WHHx+xGwpzJFu5\n" + "ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W0eDrXltM\n" + "EnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGj\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1\n" + "A/d2O2GCahKqGFPrAyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOy\n" + "WL6ukK2YJ5f+AbGwUgC4TeQbIXQbfsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ\n" + "1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzTucpH9sry9uetuUg/vBa3wW30\n" + "6gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT\n" + "91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml\n" + "e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p\n" + "TpPDpFQUWw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx\n" + "GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp\n" + "bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w\n" + "KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0\n"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WZzJBPqpK5j\n" + "wa19hAM8EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWz\n" + "aGHQRiapIVJpLesux+t3zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmy\n" + "KwbQBM0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES\n" + "MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU\n" + "V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz\n" + "WhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJVEFJV0FO\n" + "LUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + "AQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFE\n" + "AcK0HMMxQhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HH\n" + "K3XLfJ+utdGdIzdjp9xCoi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeX\n" + "RfwZVzsrb+RH9JlF/h3x+JejiB03HFyP4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/z\n" + "rX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1ry+UPizgN7gr8/g+YnzAx\n" + "3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkq\n" + "hkiG9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeC\n" + "MErJk/9q56YAf4lCmtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdls\n" + "XebQ79NqZp4VKIV66IIArB6nCWlWQtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62D\n" + "lhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVYT0bf+215WfKEIlKuD8z7fDvn\n" + "aspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocnyYh0igzyXxfkZ\n" + "YiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Taiwan GRCA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/\n" + "MQswCQYDVQQGEwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5MB4XDTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1ow\n" + "PzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dvdmVybm1lbnQgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\n" + "AJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qNw8XR\n" + "IePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1q\n" + "gQdW8or5BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKy\n" + "yh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OLeq0dDzpD6QzDxARvBMB1uUO07+1\n" + "EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+HbkZ6Mm\n" + "nD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WX\n" + "udpVBrkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz\n" + "ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe\n" + "LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl\n" + "pYYsfPQS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TeliaSonera Root CA v1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAw\n" + "NzEUMBIGA1UECgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJv\n" + "b3QgQ0EgdjEwHhcNMDcxMDE4MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYD\n" + "VQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwWVGVsaWFTb25lcmEgUm9vdCBDQSB2\n" + "MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+6yfwIaPzaSZVfp3F\n" + "VRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA3GV1\n" + "7CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+X\n" + "Z75Ljo1kB1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+\n" + "/jXh7VB7qTCNGdMJjmhnXb88lxhTuylixcpecsHHltTbL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rB6xnhkB1Zem6g23xFUfJ3zSCNV2HykVh0A5\n" + "3ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmcp0yJF4Ou\n" + "owReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/\n" + "wZ0+fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZF\n" + "ZtS6mFjBAgMBAAGjYzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAf\n" + "BgNVHSMEGDAWgBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/\n" + "MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAQEABT41XBVwm8nHc2Fv\n" + "civUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u/ukZMjgDfxT2\n" + "AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F\n" + "hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50\n" + "soIipX1TH0XsJ5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BI\n" + "WJZpTdwHjFGTot+fDz2LYLSCjaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1Wi\n" + "tJ/X5g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBk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wnL\n" + "/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RX\n" + "CI/hOWB3S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYa\n" + "ZH9bDTMJBzN7Bj8RpFxwPIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW\n" + "2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dvDDqPys/cA8GiCcjl/YBeyGBCARsaU1q7\n" + "N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYURpFHmygk71dSTlxCnKr3\n" + "Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANExdqtvArB\n" + "As8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp\n" + "5KeXRKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu\n" + "1uwJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Trustis FPS Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBF\n" + "MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQL\n" + "ExNUcnVzdGlzIEZQUyBSb290IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTEx\n" + "MzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNVBAoTD1RydXN0aXMgTGltaXRlZDEc\n" + "MBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQAD\n" + "ggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQRUN+\n" + "AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihH\n" + "iTHcDnlkH5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjj\n" + "vSkCqPoc4Vu5g6hBSLwacY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA\n" + "0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zto3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlB\n" + "OrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEAAaNTMFEwDwYDVR0TAQH/\n" + "BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAdBgNVHQ4E\n" + "FgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01\n" + "GX2cGE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmW\n" + "zaD+vkAMXBJV+JOCyinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP4\n" + "1BIy+Q7DsdwyhEQsb8tGD+pmQQ9P8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZE\n" + "f1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHVl/9D7S3B2l0pKoU/rGXuhg8F\n" + "jZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYliB6XzCGcKQEN\n" + "ZetX2fNXlrtIzYE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Extended Validation Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBF\n" + "eHRlbmRlZCBW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QYJKoZIhvcNAQELBQADggIBADaN\n" + "l8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR\n" + "ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQ\n" + "VBcZEhrxH9cMaVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5\n" + "c6sq1WnIeJEmMX3ixzDx/BR4dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp\n" + "4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb+7lsq+KePRXBOy5nAliRn+/4Qh8s\n" + "t2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOWF3sGPjLtx7dCvHaj\n" + "2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwiGpWO\n" + "vpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2C\n" + "xR9GUeOcGMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx\n" + "cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM\n" + "fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Global G2 Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH\n" + "bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0x\n" + "CzAJBgNVBAYTAkNOMREwDwYDV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5\n" + "1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl\n" + "1qnN3e92mI0ADs0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oU\n" + "b3n09tDh05S60FdRvScFDcH9yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LV\n" + "PtateJLbXDzz2K36uGt/xDYotgIVilQsnLAXc47QN6MUPJiVAAwpBVueSUmxX8fj\n" + "y88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHojhJi6IjMtX9Gl8Cb\n" + "EGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZkbxqg\n" + "DMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI\n" + "+Vg7RE+xygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGy\n" + "YiGqhkCyLmTTX8jjfhFnRR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bX\n" + "UB+K+wb1whnw0A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + "VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo\n" + "I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng\n" + "o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G\n" + "A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB\n" + "zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW\n" + "RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB\n" + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw\n" + "MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV\n" + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC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PF\n" + "Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO\n" + "VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3\n" + "ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs\n" + "8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR\n" + "iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze\n" + "Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ\n" + "XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/\n" + "qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB\n" + "VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB\n" + "L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n" + "jjxDah2nGN59PRbxYvnKkKj9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5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----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\n" + "ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1\n" + "nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex\n" + "t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz\n" + "SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG\n" + "BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+\n" + "rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/\n" + "NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E\n" + "BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH\n" + "BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy\n" + "aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv\n" + "MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE\n" + "p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y\n" + "5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Universal Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB\n" + "vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQ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\n" + "exkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud\n" + "DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4\n" + "sAPmLGd75JR3Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+\n" + "seQxIcaBlVZaDrHC1LGmWazxY8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz\n" + "4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTxP/jgdFcrGJ2BtMQo2pSXpXDrrB2+\n" + "BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+PwGZsY6rp2aQW9IHR\n" + "lRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3\n" + "7M2CYfE45k+XmCpajQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Verisign Class 3 Public Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw\n" + "CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl\n" + "cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu\n" + "LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT\n" + "aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp\n" + "dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD\n" + "VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIE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qIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5d\n" + "RdY4zTW2ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQ\n" + "OA7+j0xbm0bqQfWwCHTD0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwv\n" + "JoIQ4uNllAoEwF73XVv4EOLQunpL+943AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08C\n" + "AwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAcYwHQYDVR0O\n" + "BBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IBAQA+0hyJ\n" + "LjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecY\n" + "MnQ8SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ\n" + "44gx+FkagQnIl6Z0x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6I\n" + "Jd1hJyMctTEHBDa0GpC9oHRxUIltvBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNw\n" + "i/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7NzTogVZ96edhBiIL5VaZVDADlN\n" + "9u6wWk5JRFRYX0KD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ePKI Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe\n" + "MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0\n" + "ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wNDE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UrDgMCGgUAMAcGBWcqAwAABBRFsMLH\n" + "ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGB\n" + "uvl2ICO1J2B01GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6Yl\n" + "PwZpVnPDimZI+ymBV3QGypzqKOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkP\n" + "JXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdVxrsStZf0X4OFunHB2WyBEXYKCrC/\n" + "gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEPNXubrjlpC2JgQCA2\n" + "j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+rGNm6\n" + "5ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUB\n" + "o2M3IUxExJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS\n" + "/jQ6fbjpKdx2qcgw+BRxgMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z\n" + "Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE\n" + "W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D\n" + "hNQ+IIX3Sj0rnP0qCglN6oH4EZw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - C3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG\n" + "EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx\n" + "IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND\n" + "IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci\n" + "MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti\n" + "sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O\n" + "BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\n" + "Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c\n" + "3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J\n" + "0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n" + "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n" + "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n" + "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n" + "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n" + "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n" + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n" + "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n" + "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n" + "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n" + "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n" + "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n" + "+JbNR6iC8hZVdyR+EhCVBCyj\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - C1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkG\n" + "A1UEBhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEg\n" + "SW5jMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNpZ24gUm9v\n" + "dCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+upufGZ\n" + "BczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZ\n" + "HdPIWoU/Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH\n" + "3DspVpNqs8FqOp099cGXOFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvH\n" + "GPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4VI5b2P/AgNBbeCsbEBEV5f6f9vtKppa+c\n" + "xSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleoomslMuoaJuvimUnzYnu3Yy1\n" + "aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+XJGFehiq\n" + "TbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87\n" + "/kOXSTKZEhVb3xEp/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4\n" + "kqNPEjE2NuLe/gDEo2APJ62gsIq1NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrG\n" + "YQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT\n" + "+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo\n" + "WXzhriKi4gp6D/piq1JM4fHfyr6DDUI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - G1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD\n" + "VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU\n" + "ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH\n" + "MTAeFw0xODAyMTgxODMwMDBaFw00Mz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YHYhX3zUVxx\n" + "iN66zB+Afko=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB\n" + "qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV\n" + "BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw\n" + "NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j\n" + "LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG\n" + "A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl\n" + "IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG\n" + "SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs\n" + "W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta\n" + "3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGcq/gcfomk\n" + "6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6\n" + "Sk/KaAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J\n" + "NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA\n" + "MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP\n" + "r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU\n" + "DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz\n" + "YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX\n" + "xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2\n" + "/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/\n" + "LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7\n" + "jVaMaA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp\n" + "IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi\n" + "BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw\n" + "MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh\n" + "d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig\n" + "YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v\n" + "dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/\n" + "BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6\n" + "papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K\n" + "DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3\n" + "KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox\n" + "XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCB\n" + "rjELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNV\n" + "BAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0wODA0MDIwMDAwMDBa\n" + "Fw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhhd3Rl\n" + "LCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2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Zu\n" + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + + static_cast( + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); + if (ec) { + return; + } +} + +} // namespace detail + +// Load the root certificates into an ssl::context + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); +} + +inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); + if (ec) { + throw boost::system::system_error{ec}; + } +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/common/server_certificate.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/common/server_certificate.hpp new file mode 100644 index 0000000..a455f3b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/common/server_certificate.hpp @@ -0,0 +1,131 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP + +#include +#include +#include +#include + +/* Load a signed certificate into the ssl context, and configure + the context for use with a server. + + For this to work with the browser or operating system, it is + necessary to import the "Beast Test CA" certificate into + the local certificate store, browser, or operating system + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. +*/ +inline void load_server_certificate(boost::asio::ssl::context& ctx) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { + ctx.use_certificate_chain_file(path); + ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), + boost::asio::ssl::context::pem); + return; + } + + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 + openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj + "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = + "-----BEGIN CERTIFICATE-----\n" + "MIIDlTCCAn2gAwIBAgIUOLxr3q7Wd/pto1+2MsW4fdRheCIwDQYJKoZIhvcNAQEL\n" + "BQAwWjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRQwEgYDVQQHDAtMb3MgQW5n\n" + "ZWxlczEOMAwGA1UECgwFQmVhc3QxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTAe\n" + "Fw0yMTA3MDYwMTQ5MjVaFw00ODExMjEwMTQ5MjVaMFoxCzAJBgNVBAYTAlVTMQsw\n" + "CQYDVQQIDAJDQTEUMBIGA1UEBwwLTG9zIEFuZ2VsZXMxDjAMBgNVBAoMBUJlYXN0\n" + "MRgwFgYDVQQDDA93d3cuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" + "DwAwggEKAoIBAQCz0GwgnxSBhygxBdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOT\n" + "Lppr5MKxqQHEpYdyDYGD1noBoz4TiIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05\n" + "P41c2F9pBEnUwUxIUG1Cb6AN0cZWF/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATm\n" + "Wm9SJc2lsjWptbyIN6hFXLYPXTwnYzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7\n" + "rV+AiGTxUU35V0AzpJlmvct5aJV/5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4\n" + "lIzJ8yxzOzSStBPxvdrOobSSNlRZIlE7gnyNAgMBAAGjUzBRMB0GA1UdDgQWBBR+\n" + "dYtY9zmFSw9GYpEXC1iJKHC0/jAfBgNVHSMEGDAWgBR+dYtY9zmFSw9GYpEXC1iJ\n" + "KHC0/jAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBzKrsiYywl\n" + "RKeB2LbddgSf7ahiQMXCZpAjZeJikIoEmx+AmjQk1bam+M7WfpRAMnCKooU+Utp5\n" + "TwtijjnJydkZHFR6UH6oCWm8RsUVxruao/B0UFRlD8q+ZxGd4fGTdLg/ztmA+9oC\n" + "EmrcQNdz/KIxJj/fRB3j9GM4lkdaIju47V998Z619E/6pt7GWcAySm1faPB0X4fL\n" + "FJ6iYR2r/kJLoppPqL0EE49uwyYQ1dKhXS2hk+IIfA9mBn8eAFb/0435A2fXutds\n" + "qhvwIOmAObCzcoKkz3sChbk4ToUTqbC0TmFAXI5Upz1wnADzjpbJrpegCA3pmvhT\n" + "7356drqnCGY9\n" + "-----END CERTIFICATE-----\n"; + + std::string const key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz0GwgnxSBhygx\n" + "BdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOTLppr5MKxqQHEpYdyDYGD1noBoz4T\n" + "iIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05P41c2F9pBEnUwUxIUG1Cb6AN0cZW\n" + "F/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATmWm9SJc2lsjWptbyIN6hFXLYPXTwn\n" + "YzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7rV+AiGTxUU35V0AzpJlmvct5aJV/\n" + "5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4lIzJ8yxzOzSStBPxvdrOobSSN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VPaUZ8aosLbLiREoxE0udfWf2dU\n" + "oBNnrMwwcs6jrRga7Kr1iVgUSwBQRAxiP2CYUv7tAoGBAKdPdekPNP/rCnHkKIkj\n" + "o13pr+LJ8t+15vVzZNHwPHUWiYXFhG8Ivx7rqLQSPGcuPhNss3bg1RJiZAUvF6fd\n" + "e6QS4EZM9dhhlO2FmPQCJMrRVDXaV+9TcJZXCbclQnzzBus9pwZZyw4Anxo0vmir\n" + "nOMOU6XI4lO9Xge/QDEN4Y2R\n" + "-----END PRIVATE KEY-----\n"; + + std::string const dh = + "-----BEGIN DH PARAMETERS-----\n" + "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" + "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" + "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" + "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; + + ctx.set_password_callback( + [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + + ctx.set_options(boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + + ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + + ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), + boost::asio::ssl::context::file_format::pem); + + ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/http_examples.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/http_examples.hpp new file mode 100644 index 0000000..19ba281 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/http_examples.hpp @@ -0,0 +1,932 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include + +/* This file contains the functions and classes found in the documentation + + They are compiled and run as part of the unit tests, so you can copy + the code and use it in your own projects as a starting point for + building a network application. +*/ + +// The documentation assumes the boost::beast::http namespace +namespace boost { +namespace beast { +namespace http { + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_http_send_expect_100_continue + +/** Send a request with Expect: 100-continue + + This function will send a request with the Expect: 100-continue + field by first sending the header, then waiting for a successful + response from the server before continuing to send the body. If + a non-successful server response is received, the function + returns immediately. + + @param stream The remote HTTP server stream. + + @param buffer The buffer used for reading. + + @param req The request to send. This function modifies the object: + the Expect header field is inserted into the message if it does + not already exist, and set to "100-continue". + + @param ec Set to the error, if any occurred. +*/ +template +void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, + request>& req, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); + + // Create the serializer + request_serializer> sr{req}; + + // Send just the header + write_header(stream, sr, ec); + if (ec) + return; + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); + if (ec) + return; + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; + } + } + + // Server is OK with the request, send the body + write(stream, sr, ec); +} + +//] + +//[example_http_receive_expect_100_continue + +/** Receive a request, handling Expect: 100-continue if present. + + This function will read a request from the specified stream. + If the request contains the Expect: 100-continue field, a + status response will be delivered. + + @param stream The remote HTTP client stream. + + @param buffer The buffer used for reading. + + @param ec Set to the error, if any occurred. +*/ +template +void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); + if (ec) + return; + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); + if (ec) + return; + } + + // Read the rest of the message. + // + read(stream, buffer, parser, ec); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Send Child Process Output +// +//------------------------------------------------------------------------------ + +//[example_http_send_cgi_response + +/** Send the output of a child process as an HTTP response. + + The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. + + @param input A stream to read the child process output from. + + @param output A stream to write the HTTP response to. + + @param ec Set to the error, if any occurred. +*/ +template +void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. + response res; + + res.result(status::ok); + res.version(11); + res.set(field::server, "Beast"); + res.set(field::transfer_encoding, "chunked"); + + // No data yet, but we set more = true to indicate + // that it might be coming later. Otherwise the + // serializer::is_done would return true right after + // sending the header. + res.body().data = nullptr; + res.body().more = true; + + // Create the serializer. + response_serializer sr{res}; + + // Send the header immediately. + write_header(output, sr, ec); + if (ec) + return; + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process + char buffer[2048]; + auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer + res.body().data = nullptr; + + // `false` means no more data is coming + res.body().more = false; + } else { + if (ec) + return; + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming + res.body().data = buffer; + res.body().size = bytes_transferred; + res.body().more = true; + } + + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. + if (ec == error::need_buffer) { + ec = {}; + continue; + } + if (ec) + return; + } while (!sr.is_done()); +} + +//] + +//-------------------------------------------------------------------------- +// +// Example: HEAD Request +// +//-------------------------------------------------------------------------- + +//[example_http_do_head_response + +/** Handle a HEAD request for a resource. + */ +template +void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; + + // Read the request + request req; + read(stream, buffer, req, ec); + if (ec) + return; + + // Set up the response, starting with the common fields + response res; + res.version(11); + res.set(field::server, "test"); + + // Now handle request-specific fields + switch (req.method()) { + case verb::head: + case verb::get: { + // A HEAD request is handled by delivering the same + // set of headers that would be sent for a GET request, + // including the Content-Length, except for the body. + res.result(status::ok); + res.content_length(payload.size()); + + // For GET requests, we include the body + if (req.method() == verb::get) { + // We deliver the same payload for GET requests + // regardless of the target. A real server might + // deliver a file based on the target. + res.body() = payload; + } + break; + } + + default: { + // We return responses indicating an error if + // we do not recognize the request method. + res.result(status::bad_request); + res.set(field::content_type, "text/plain"); + res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; + res.prepare_payload(); + break; + } + } + + // Send the response + write(stream, res, ec); + if (ec) + return; +} + +//] + +//[example_http_do_head_request + +/** Send a HEAD request for a resource. + + This function submits a HEAD request for the specified resource + and returns the response. + + @param res The response. This is an output parameter. + + @param stream The synchronous stream to use. + + @param buffer The buffer to use. + + @param target The request target. + + @param ec Set to the error, if any occurred. + + @throws std::invalid_argument if target is empty. +*/ +template +response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, + error_code& ec) { + // Do some type checking to be a good citizen + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. + if (target.empty()) + throw std::invalid_argument("target may not be empty"); + + // Build the HEAD request for the target + request req; + req.version(11); + req.method(verb::head); + req.target(target); + req.set(field::user_agent, "test"); + + // A client MUST send a Host header field in all HTTP/1.1 request messages. + // https://tools.ietf.org/html/rfc7230#section-5.4 + req.set(field::host, "localhost"); + + // Now send it + write(stream, req, ec); + if (ec) + return {}; + + // Create a parser to read the response. + // We use the `empty_body` type since + // a response to a HEAD request MUST NOT + // include a body. + response_parser p; + + // Inform the parser that there will be no body. + p.skip(true); + + // Read the message. Even though fields like + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); + if (ec) + return {}; + + // Transfer ownership of the response to the caller. + return p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: HTTP Relay +// +//------------------------------------------------------------------------------ + +//[example_http_relay + +/** Relay an HTTP message. + + This function efficiently relays an HTTP message from a downstream + client to an upstream server, or from an upstream server to a + downstream client. After the message header is read from the input, + a user provided transformation function is invoked which may change + the contents of the header before forwarding to the output. This may + be used to adjust fields such as Server, or proxy fields. + + @param output The stream to write to. + + @param input The stream to read from. + + @param buffer The buffer to use for the input. + + @param transform The header transformation to apply. The function will + be called with this signature: + @code + template + void transform(message< + isRequest, Body, Fields>&, // The message to transform + error_code&); // Set to the error, if any + @endcode + + @param ec Set to the error if any occurred. + + @tparam isRequest `true` to relay a request. + + @tparam Fields The type of fields to use for the message. +*/ +template +void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, + Transform&& transform) { + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + char buf[2048]; + + // Create a parser with a buffer body to read from the input. + parser p; + + // Create a serializer from the message contained in the parser. + serializer sr{p.get()}; + + // Read just the header from the input + read_header(input, buffer, p, ec); + if (ec) + return; + + // Apply the caller's header transformation + transform(p.get(), ec); + if (ec) + return; + + // Send the transformed message to the output + write_header(output, sr, ec); + if (ec) + return; + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = sizeof(buf) - p.get().body().size; + p.get().body().data = buf; + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } + + // Write everything in the buffer (which might be empty) + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + } while (!p.is_done() && !sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Serialize to std::ostream +// +//------------------------------------------------------------------------------ + +//[example_http_write_ostream + +// The detail namespace means "not public" +namespace detail { + +// This helper is needed for C++11. +// When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +template +class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + +public: + write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer + template + void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + + // Keep a running total of how much we wrote + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence + for (auto it = boost::asio::buffer_sequence_begin(buffers); + it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream + os_.write(reinterpret_cast(buffer.data()), buffer.size()); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } + + // Adjust our running total + bytes_transferred += buffer_size(buffer); + } + + // Inform the serializer of the amount we consumed + sr_.consume(bytes_transferred); + } +}; + +} // namespace detail + +/** Write a message to a `std::ostream`. + + This function writes the serialized representation of the + HTTP/1 message to the sream. + + @param os The `std::ostream` to write to. + + @param msg The message to serialize. + + @param ec Set to the error, if any occurred. +*/ +template +void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; + do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); + if (ec) + return; + } while (!sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Parse from std::istream +// +//------------------------------------------------------------------------------ + +//[example_http_read_istream + +/** Read a message from a `std::istream`. + + This function attempts to parse a complete HTTP/1 message from the stream. + + @param is The `std::istream` to read from. + + @param buffer The buffer to use. + + @param msg The message to store the result. + + @param ec Set to the error, if any occurred. +*/ +template +void read_istream(std::istream& is, basic_flat_buffer& buffer, + message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are + // forwarded to the message constructor. Here, we use + // a move construction in case the caller has constructed + // their message in a non-default way. + // + parser p{std::move(msg)}; + + do { + // Extract whatever characters are presently available in the istream + if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream + buffer.commit( + static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); + } else if (buffer.size() == 0) { + // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream + if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + + // Try to get more from the istream. This might block. + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. + if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; + } + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); + if (ec) + return; + break; + } + } + + // Write the data to the parser + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. + if (ec == error::need_more) + ec = {}; + if (ec) + return; + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); + } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Deferred Body Type +// +//------------------------------------------------------------------------------ + +//[example_http_defer_body + +/** Handle a form POST request, choosing a body type depending on the Content-Type. + + This reads a request from the input stream. If the method is POST, and + the Content-Type is "application/x-www-form-urlencoded " or + "multipart/form-data", a `string_body` is used to receive and store + the message body. Otherwise, a `dynamic_body` is used to store the message + body. After the request is received, the handler will be invoked with the + request. + + @param stream The stream to read from. + + @param buffer The buffer to use for reading. + + @param handler The handler to invoke when the request is complete. + The handler must be invokable with this signature: + @code + template + void handler(request&& req); + @endcode + + @throws system_error Thrown on failure. +*/ +template +void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + + // Read just the header. Otherwise, the empty_body + // would generate an error if body octets were received. + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb + switch (req0.get().method()) { + case verb::post: { + // If this is not a form upload then use a string_body + if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && + req0.get()[field::content_type] != "multipart/form-data") + goto do_dynamic_body; + + // Commit to string_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + + do_dynamic_body: + default: { + // Commit to dynamic_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Incremental Read +// +//------------------------------------------------------------------------------ + +//[example_incremental_read + +/* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. +*/ +template +void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); + if (ec) + return; + while (!p.is_done()) { + char buf[512]; + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + read(stream, buffer, p, ec); + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + os.write(buf, sizeof(buf) - p.get().body().size); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Read large response body +// +//------------------------------------------------------------------------------ + +//[example_read_large_response_body + +/* This function uses custom size limit of the resposne body. + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. +*/ +template +std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, + message>& msg, + std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); + if (ec) + return bytes_transferred; + msg = p.release(); + return bytes_transferred; +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_chunk_parsing + +/** Read a message with a chunked body and print the chunks and extensions + */ +template +void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); + if (ec) + return; + + // This container will hold the extensions for each chunk + chunk_extensions ce; + + // This string will hold the body of each chunk + std::string chunk; + + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = + [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk + string_view extensions, // The raw chunk-extensions string. Already validated. + error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); + if (ev) + return; + + // See if the chunk is too big + if (size > (std::numeric_limits::max)()) { + ev = error::body_limit; + return; + } + + // Make sure we have enough storage, and + // reset the container for the upcoming chunk + chunk.reserve(static_cast(size)); + chunk.clear(); + }; + + // Set the callback. The function requires a non-const reference so we + // use a local variable, since temporaries can only bind to const refs. + p.on_chunk_header(header_cb); + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. + auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk + string_view body, // A buffer holding chunk body data + error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. + if (remain == body.size()) + ec = error::end_of_chunk; + + // Append this piece to our container + chunk.append(body.data(), body.size()); + + // The return value informs the parser of how much of the body we + // consumed. We will indicate that we consumed everything passed in. + return body.size(); + }; + p.on_chunk_body(body_cb); + + while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); + if (!ec) + continue; + else if (ec != error::end_of_chunk) + return; + else + ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; + if (!extension.second.empty()) + os << " = " << extension.second << std::endl; + else + os << std::endl; + } + + // Now print the chunk body + os << "Chunk Body: " << chunk << std::endl; + } + + // Get a reference to the parsed message, this is for convenience + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it + for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << std::endl; + continue; + } + os << it->name() << ": " << it->value() << std::endl; + } +} + +//] + +} // namespace http +} // namespace beast +} // namespace boost diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/ssl/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/ssl/client.cpp new file mode 100644 index 0000000..6937282 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/ssl/client.cpp @@ -0,0 +1,132 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } + } +} + +net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + net::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) + if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set a callback to verify that the hostname in the server + // certificate matches the expected value + stream.set_verify_callback(ssl::host_name_verification("localhost")); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request + http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); + + // Read the response + beast::flat_buffer buf; + http::response res; + co_await http::async_read(stream, buf, res); + + // Print the response body + std::cout << res.body(); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); + } +} + +} // namespace + +int main() { + try { + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful + ctx.set_verify_mode(ssl::verify_peer); + + // The servers's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Client certificate and private key (if server request for). + ctx.use_certificate_chain_file("client.crt"); + ctx.use_private_key_file("client.key", ssl::context::pem); + + net::co_spawn(ioc, request(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/ssl/server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/ssl/server.cpp new file mode 100644 index 0000000..efa4edc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/doc/ssl/server.cpp @@ -0,0 +1,126 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } + } +} + +net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + + // Read and discard a request + beast::flat_buffer buf; + http::request req; + co_await http::async_read(stream, buf, req); + + // Write the response + http::response res; + res.body() = "Hello!"; + co_await http::async_write(stream, res); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); + } +} + +net::awaitable acceptor(ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + net::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + net::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), + print_exception); + } +} + +} // namespace + +int main() { + try { + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. + // Asio exposes the OpenSSL verification bitmask as signed integer constants. + // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Server certificate and private key. + ctx.use_certificate_chain_file("server.crt"); + ctx.use_private_key_file("server.key", ssl::context::pem); + + // DH parameters for DHE-based cipher suites + ctx.use_tmp_dh_file("dh4096.pem"); + + net::co_spawn(ioc, acceptor(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/echo-op/echo_op.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/echo-op/echo_op.cpp new file mode 100644 index 0000000..4e38395 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/echo-op/echo_op.cpp @@ -0,0 +1,375 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; +namespace beast = boost::beast; + +namespace { + +//[example_core_echo_op_1 + +template +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] + -> net::async_result, void(beast::error_code)>::return_type; + +//------------------------------------------------------------------------------ + +//[example_core_echo_op_2 + +/** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending + in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + + - A line was read in and written back on the stream + + - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` + and `async_write_some` function. The program must ensure that no + other reads or writes are performed until this operation completes. + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the + first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the + requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is + responsible for ensuring that the lifetime of this object is + extended least until the completion handler is invoked. + + @param token The handler to be called when the operation completes. + The implementation takes ownership of the handler by performing a decay-copy. + The handler must be invocable with this signature: + @code + void handler( + beast::error_code error // Result of operation. + ); + @endcode + + Regardless of whether the asynchronous operation completes immediately or + not, the handler will not be invoked from within this function. Invocation + of the handler will be performed in a manner equivalent to using + `net::post`. +*/ +template +// Each documentation snippet presents the complete public declaration. +// NOLINTNEXTLINE(readability-redundant-declaration) +auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ + CompletionToken&& token) + -> net::async_result*/ + std::decay_t, + void(beast::error_code) /*< The completion handler signature goes here >*/ + >::return_type; +//] + +//[example_core_echo_op_3 + +template +class echo_op; + +// This example uses the Asio's stackless "fauxroutines", implemented +// using a macro-based solution. It makes the code easier to write and +// easier to read. This include file defines the necessary macros and types. +#include + +// Read a line and echo it back +// +template +// Stackless coroutine macros generate the branches in this operation. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + -> net::async_result, + void(beast::error_code)>::return_type /*< The completion handler + signature goes here >*/ +{ + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. + static_assert(beast::is_async_stream::value, + "AsyncStream type requirements not met"); + static_assert(net::is_dynamic_buffer::value, + "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, + // and creates the `async_result` object which becomes the + // return value of this initiating function. + + net::async_completion init(token); + + // The helper macro BOOST_ASIO_HANDLER_TYPE converts the completion + // token type into a concrete handler type of the correct signature. + + using handler_type = BOOST_ASIO_HANDLER_TYPE(CompletionToken, void(beast::error_code)); + + // The class template `async_base` holds the caller's completion + // handler for us, and provides all of the boilerplate for forwarding + // the associated allocator and associated executor from the caller's + // handler to our operation. It also maintains a `net::executor_work_guard` + // for the executor associated with the stream. This work guard is + // inexpensive, and prevents the execution context from running out + // of work. It is usually necessary although rarely it can be skipped + // depending on the operation (this echo example needs it because it + // performs more than one asynchronous operation in a row). + // We declare this type alias to make the code easier to read. + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ + beast::executor_type /*< The type of executor used by the stream to dispatch + asynchronous operations >*/ + >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + + // Asio operation state combines completion ownership with coroutine resume state. + // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream_state; + DynamicBuffer& buffer_state; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( + std::move( + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , + stream_state(stream), + buffer_state(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our + // asynchronous control flow. + (*this)({}, 0, false); + } + + // If a newline is present in the buffer sequence, this function returns + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + + static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + + const auto begin = + net::buffers_iterator::begin(buffers); + const auto end = + net::buffers_iterator::end(buffers); + const auto result = std::find(begin, end, '\n'); + + if (result == end) { + return 0; // not found + } + + return result + 1 - begin; + } + + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + + // Resume labels generated by the stackless coroutine form one state machine. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + + reenter(*this) { + for (;;) { + // Resume labels cannot cross an initialized local; it is assigned before use. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer_state.data()); + + // If we don't have the newline, then read more + if (pos == 0) { + // Resume labels cannot cross an initialized local; it is assigned before + // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, + buffer_state.capacity() - buffer_state.size()), + std::min(65536, // and over 65536 is too much. + buffer_state.max_size() - buffer_state.size())); + + // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + + yield stream_state.async_read_some(buffer_state.prepare(bytes_to_read), + std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. + + // Move the bytes read from the writable area to the + // readable area. + + buffer_state.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. + if (ec) { + break; + } + + // Keep looping until we get the newline + continue; + } + + // We have our newline, so send the first `pos` bytes of the + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + + yield net::async_write(stream_state, + beast::buffers_prefix(pos, buffer_state.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, + // and the `reenter` statement above will cause control to jump + // to the following line. The variable `pos` is no longer valid + // (remember that we returned from the function using `yield` above) + // but we can use `bytes_transferred` to know how much of the buffer + // to consume. With "real" coroutines this will be easier and more + // natural. + + buffer_state.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. + + break; + } + + // When a composed operation completes immediately, it must not + // directly invoke the completion handler otherwise it could + // lead to unfairness, starvation, or stack overflow. Therefore, + // if cont == false (meaning, that the call stack still includes + // the frame of the initiating function) then we need to use + // `net::post` to cause us to be called again after the initiating + // function. The function `async_base::invoke` takes care of + // calling the final completion handler, using post if the + // first argument is false, otherwise invoking it directly. + + this->complete(cont, ec); + } + } + }; + + // Create the composed operation and launch it. This is a constructor + // call followed by invocation of operator(). We use BOOST_ASIO_HANDLER_TYPE + // to convert the completion token into the correct handler type, + // allowing user-defined specializations of the async_result template + // to be used. + + echo_op(stream, buffer, std::move(init.completion_handler)); + + // This hook lets the caller see a return value when appropriate. + // For example this might return std::future if + // CompletionToken is net::use_future, or this might + // return an error code if CompletionToken specifies a coroutine. + + return init.result.get(); +} + +// Including this file undefines the macros used by the stackless fauxroutines. +#include + +//] + +struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { + if (ec) { + std::cerr << ": " << ec.message() << '\n'; + } + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" + << "Example:\n" + << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = net::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. + net::io_context ioc; + net::ip::tcp::acceptor acceptor{ioc}; + const endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); + acceptor.listen(); + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); + ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-local/http_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-local/http_client_async_local.cpp new file mode 100644 index 0000000..d62161c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-local/http_client_async_local.cpp @@ -0,0 +1,179 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(net::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* target, + int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, std::string{host} + ":" + port); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { + std::cerr << "Usage: http-client-async-local []\n" + << "Example:\n" + << " http-client-async-local /tmp/http.sock localhost 80 /\n" + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const* const host = argv[2]; + auto const* const port = argv[3]; + auto const* const target = argv[4]; + int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..beab15d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,251 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor()), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..b5af09c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,248 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..fc0ac9a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/async/http_client_async.cpp @@ -0,0 +1,190 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(net::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..9f00864 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,193 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common/root_certificates.hpp" + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{executor}; + auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && ec != net::ssl::error::stream_truncated) { + throw boost::system::system_error(ec, "shutdown"); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..1713889 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,150 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/body/json_body.hpp new file mode 100644 index 0000000..60376cb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/body/json_body.hpp @@ -0,0 +1,113 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(boost::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(boost::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/body/json_client.cpp new file mode 100644 index 0000000..fe8446d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/body/json_client.cpp @@ -0,0 +1,71 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include "fixture.hpp" +#include "json_body.hpp" + +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::ip::tcp; // from + +int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/coro-ssl/http_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/coro-ssl/http_client_coro_ssl.cpp new file mode 100644 index 0000000..770da3d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -0,0 +1,233 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, net::io_context& ioc, ssl::context& ctx, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream.async_shutdown(yield[ec]); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro-ssl []\n" + << "Example:\n" + << " http-client-coro-ssl www.example.com 443 /\n" + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/coro/http_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/coro/http_client_coro.cpp new file mode 100644 index 0000000..282c6c8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/coro/http_client_coro.cpp @@ -0,0 +1,184 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + int version, net::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro []\n" + << "Example:\n" + << " http-client-coro www.example.com 80 /\n" + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..ccc3f91 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/http_crawl.cpp @@ -0,0 +1,336 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(net::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, net::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + net::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Create and launch the worker threads. + std::vector workers; + workers.reserve(threads + 1); + for (int i = 0; i < threads; ++i) { + // Each worker will eventually add some data to the aggregated + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto reporting_work = + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); + + workers.emplace_back([&report, reporting_work] { + // We use a separate io_context for each worker because + // the asio resolver simulates asynchronous operation using + // a dedicated worker thread per io_context, and we want to + // do a lot of name resolutions in parallel. + net::io_context ioc; + std::make_shared(report, ioc)->run(); + ioc.run(); // lint-run: drives the application's network operations + }); + } + + // Add another thread to run the main io_context which + // is used to aggregate the statistics + workers.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + + // Now block until all threads exit + for (auto& worker : workers) { + worker.join(); + } + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..b451346 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,17 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include "fixture.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..ffa150c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..c6c75a7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/methods/http_client_methods.cpp @@ -0,0 +1,211 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view const method{argv[1]}; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // This buffer is used for reading and must be persisted + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..95efb8b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,147 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using net::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + throw beast::system_error{ec}; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..45094f9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/client/sync/http_client_sync.cpp @@ -0,0 +1,115 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async-local/http_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async-local/http_server_async_local.cpp new file mode 100644 index 0000000..54e3a78 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async-local/http_server_async_local.cpp @@ -0,0 +1,444 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-async-local \n" + << "Example:\n" + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { + std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async-ssl/http_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async-ssl/http_server_async_ssl.cpp new file mode 100644 index 0000000..049c362 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async-ssl/http_server_async_ssl.cpp @@ -0,0 +1,528 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + void on_run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + do_read(); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" + << "Example:\n" + << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async/http_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async/http_server_async.cpp new file mode 100644 index 0000000..b04c0a7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/async/http_server_async.cpp @@ -0,0 +1,463 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" + << "Example:\n" + << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/awaitable/http_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/awaitable/http_server_awaitable.cpp new file mode 100644 index 0000000..0cf0aa3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/awaitable/http_server_awaitable.cpp @@ -0,0 +1,359 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +// Handles an HTTP server connection +net::awaitable do_session(beast::tcp_stream stream, + std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + co_await http::async_read(stream, buffer, req); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have + // dropped the connection already. +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(net::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = net::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" + << "Example:\n" + << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(net::ip::tcp::endpoint{address, port}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/coro-ssl/http_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/coro-ssl/http_server_coro_ssl.cpp new file mode 100644 index 0000000..7fe770c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -0,0 +1,489 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(ssl::stream& stream, + std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" + << "Example:\n" + << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/coro/http_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/coro/http_server_coro.cpp new file mode 100644 index 0000000..5797b5f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/coro/http_server_coro.cpp @@ -0,0 +1,439 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn(acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio + // spawn/completion overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" + << "Example:\n" + << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/fast/fields_alloc.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/fast/fields_alloc.hpp new file mode 100644 index 0000000..3658009 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/fast/fields_alloc.hpp @@ -0,0 +1,161 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP +#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP + +#include +#include +#include +#include + +namespace detail { + +class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + + char* end() { return reinterpret_cast(this + 1) + size_; } + + explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} + +public: + static static_pool& construct(std::size_t size) { + auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + + static static_pool& share(static_pool& pool) { + ++pool.refs_; + return pool; + } + + void destroy() { + if ((--refs_) != 0u) { + return; + } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { + auto* last = p_ + n; + if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + } + ++count_; + auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { + if ((--count_) != 0u) { + return; + } + p_ = reinterpret_cast(this + 1); + } +}; + +} // namespace detail + +/** A non-thread-safe allocator optimized for @ref basic_fields. + + This allocator obtains memory from a pre-allocated memory block + of a given size. It does nothing in deallocate until all + previously allocated blocks are deallocated, upon which it + resets the internal memory block for re-use. + + To use this allocator declare an instance persistent to the + connection or session, and construct with the block size. + A good rule of thumb is 20% more than the maximum allowed + header size. For example if the application only allows up + to an 8,000 byte header, the block size could be 9,600. + + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. +*/ +template +struct fields_alloc { + detail::static_pool* pool; + +public: + using value_type = T; + using is_always_equal = std::false_type; + using pointer = T*; + using reference = T&; + using const_pointer = T const*; + using const_reference = T const&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template + struct rebind { + using other = fields_alloc; + }; + +#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) + // Workaround for g++ + // basic_string assumes that allocators are default-constructible + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 + fields_alloc() = default; +#endif + + explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + + fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template + explicit fields_alloc(fields_alloc const& other) + : pool(&detail::static_pool::share(*other.pool)) {} + + ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { + return static_cast(pool->alloc(n * sizeof(T))); + } + + void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template + void construct(U* ptr, Args&&... args) { + ::new (static_cast(ptr)) U(std::forward(args)...); + } + + template + void destroy(U* ptr) { + ptr->~U(); + } +#endif + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool == &rhs.pool_; + } + + template + friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { + return !(lhs == rhs); + } +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/fast/http_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/fast/http_server_fast.cpp new file mode 100644 index 0000000..6817145 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/fast/http_server_fast.cpp @@ -0,0 +1,356 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include "fields_alloc.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +class http_worker { +public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + + // Retain the upstream borrowing constructor contract in this reference counterpart. + // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + + void start() { + accept(); + check_deadline(); + } + +private: + using alloc_t = fields_alloc; + // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. + tcp::acceptor& acceptor_; + + // The path to the root of the document directory. + std::string doc_root_; + + // The socket for the currently connected client. + tcp::socket socket_{acceptor_.get_executor()}; + + // The buffer for performing reads + beast::flat_static_buffer<8192> buffer_; + + // The allocator used for the fields in the request and reply. + alloc_t alloc_{8192}; + + // The parser for reading the requests + boost::optional> parser_; + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), + std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> + string_response_; + + // The string-based response serializer. + boost::optional>> + string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. + boost::optional>> + file_serializer_; + + void accept() { + // Clean up any previous connection. + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { + if (ec) { + accept(); + } else { + // Request must be fully processed within 60 seconds. + request_deadline_.expires_after(std::chrono::seconds(60)); + + read_request(); + } + }); + } + + void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. + // + // Arguments passed to the parser constructor are + // forwarded to the message object. A single argument + // is forwarded to the body constructor. + // + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { + if (ec) { + accept(); + } else { + process_request(parser_->get()); + } + }); + } + + void process_request(http::request> const& req) { + if (req.method() == http::verb::get) { + send_file(req.target()); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + + void send_bad_response(http::status status, std::string const& error) { + string_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); + }); + } + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open(full_path.c_str(), beast::file_mode::read, ec); + if (ec) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + file_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); + }); + } + + void check_deadline() { + // The deadline may have moved, so check it has really passed. + if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. + request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 6) { + std::cerr << "Usage: http_server_fast
" + "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " http_server_fast 0::0 80 . 100 block\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + std::string const doc_root = argv[3]; + int const num_workers = webcpp_fixture::integer(argv[4]); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + net::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; + for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) { + for (;;) { + ioc.poll(); + } + } else { + ioc.run(); // lint-run: drives the application's network operations + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/flex/http_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/flex/http_server_flex.cpp new file mode 100644 index 0000000..1bd510e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/flex/http_server_flex.cpp @@ -0,0 +1,630 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP flex server (plain and SSL), asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; + +protected: + beast::flat_buffer buffer; + +public: + // Take ownership of the buffer +private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), + beast::bind_front_handler(&session::on_write, + derived().shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Read another request + do_read(); + } + + friend Derived; +}; + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_session(tcp::socket&& socket, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the session + ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( + ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake + async_detect_ssl(stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" + << "Example:\n" + << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/small/http_server_small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/small/http_server_small.cpp new file mode 100644 index 0000000..84232ea --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/small/http_server_small.cpp @@ -0,0 +1,219 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +namespace { +namespace my_program_state { +std::size_t request_count() { + static std::size_t count = 0; + return ++count; +} + +std::time_t now() { + return std::time(nullptr); +} +} // namespace my_program_state + +class http_connection : public std::enable_shared_from_this { +public: + explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { + read_request(); + check_deadline(); + } + +private: + // The socket for the currently connected client. + tcp::socket socket_; + + // The buffer for performing reads. + beast::flat_buffer buffer_{8192}; + + // The request message. + http::request request_; + + // The response message. + http::response response_; + + // The timer for putting a deadline on connection processing. + net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. + void read_request() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + if (!ec) { + self->process_request(); + } + }); + } + + // Determine what needs to be done with the request message. + void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + + if (request_.method() == http::verb::get) { + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); + } + + // Construct a response message based on the program state. + void create_response() { + if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + // Asynchronously transmit the response message. + void write_response() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.close(ec)); + } + }); + } +}; + +// "Loop" forever accepting new connections. +void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { + if (!ec) { + std::make_shared(std::move(socket))->start(); + } + http_server(acceptor, socket); + }); +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + net::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/stackless-ssl/http_server_stackless_ssl.cpp new file mode 100644 index 0000000..a93d865 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -0,0 +1,539 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + yield stream_.async_shutdown( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + ctx_(ctx), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" + << "Example:\n" + << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/stackless/http_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/stackless/http_server_stackless.cpp new file mode 100644 index 0000000..b5f4a9e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/stackless/http_server_stackless.cpp @@ -0,0 +1,477 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" + << "Example:\n" + << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/sync-ssl/http_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/sync-ssl/http_server_sync_ssl.cpp new file mode 100644 index 0000000..e646fac --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -0,0 +1,374 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.handshake(ssl::stream_base::server, ec)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Perform the SSL shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync-ssl
\n" + << "Example:\n" + << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} + .detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/sync/http_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/sync/http_server_sync.cpp new file mode 100644 index 0000000..a5b6683 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/http/server/sync/http_server_sync.cpp @@ -0,0 +1,342 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync
\n" + << "Example:\n" + << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-local/websocket_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-local/websocket_client_async_local.cpp new file mode 100644 index 0000000..48083a0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-local/websocket_client_async_local.cpp @@ -0,0 +1,191 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(net::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; + + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr + << "Usage: websocket-client-async-local \n" + << "Example:\n" + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const* const host = argv[2]; + auto const* const port = argv[3]; + auto const* const text = argv[4]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..4f68861 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,257 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor{}), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..1535314 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,253 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(net::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..02a738a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,210 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(net::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); + })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..1b4f500 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,142 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); + + // Send the message + co_await stream.async_write(net::buffer(text)); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp new file mode 100644 index 0000000..01a8978 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -0,0 +1,227 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + fail(ec, "connect"); + return; + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro-ssl \n" + << "Example:\n" + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/coro/websocket_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/coro/websocket_client_coro.cpp new file mode 100644 index 0000000..2e63eea --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/coro/websocket_client_coro.cpp @@ -0,0 +1,190 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro \n" + << "Example:\n" + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..c19420f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,130 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..6fa5116 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async-local/websocket_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async-local/websocket_server_async_local.cpp new file mode 100644 index 0000000..4e0223f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async-local/websocket_server_async_local.cpp @@ -0,0 +1,231 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + stream_protocol::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, stream_protocol::endpoint endpoint) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; + } + // Create the session and run it + std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-async-local \n" + << "Example:\n" + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { + std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async-ssl/websocket_server_async_ssl.cpp new file mode 100644 index 0000000..f0828c4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -0,0 +1,284 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async/websocket_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async/websocket_server_async.cpp new file mode 100644 index 0000000..d22513c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/async/websocket_server_async.cpp @@ -0,0 +1,250 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" + << "Example:\n" + << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/awaitable/websocket_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/awaitable/websocket_server_awaitable.cpp new file mode 100644 index 0000000..5ee0a6b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/awaitable/websocket_server_awaitable.cpp @@ -0,0 +1,153 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = boost::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Echoes back all received WebSocket messages +namespace { +net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + co_await stream.async_accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + // Echo the message back + stream.text(stream.got_text()); + co_await stream.async_write(buffer.data()); + } +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(net::ip::tcp::endpoint endpoint) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = net::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" + << "Example:\n" + << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc(threads); + + // Spawn a listening port + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_listen(net::ip::tcp::endpoint{address, port}), [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/beast.hpp new file mode 100644 index 0000000..672c347 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/beast.hpp @@ -0,0 +1,29 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/chat_client.html b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/chat_client.html new file mode 100644 index 0000000..b571093 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/chat_client.html @@ -0,0 +1,71 @@ + + + + + + Boost.Beast WebSocket Chat Client + + +

Boost.Beast WebSocket Chat Client

+

+ Boost.Beast + Source Code +

+ Server URI: + +
+ Your Name:
+

+  
+ Message
+ + +
+ + + diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/http_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/http_session.cpp new file mode 100644 index 0000000..9568e58 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/http_session.cpp @@ -0,0 +1,329 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include +#include "http_session.hpp" +#include "websocket_session.hpp" + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +} // namespace + +http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +void http_session::run() { + do_read(); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, parser_->get(), + beast::bind_front_handler(&http_session::on_read, shared_from_this())); +} + +void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + boost::make_shared(stream_.release_socket(), state_) + ->run(parser_->release()); + return; + } + + // Handle request + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response + beast::async_write(stream_, std::move(msg), + [self, keep_alive](beast::error_code ec, std::size_t bytes) { + self->on_write(ec, bytes, keep_alive); + }); +} + +void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Read another request + do_read(); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/http_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/http_session.hpp new file mode 100644 index 0000000..4d07a02 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/http_session.hpp @@ -0,0 +1,55 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +#include +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +/** Represents an established HTTP connection + */ +class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + + struct send_lambda; + + void fail(beast::error_code ec, char const* what); + void do_read(); + void on_read(beast::error_code ec, std::size_t /*unused*/); + void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + +public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/listener.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/listener.cpp new file mode 100644 index 0000000..3c4e102 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/listener.cpp @@ -0,0 +1,101 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "http_session.hpp" +#include "listener.hpp" + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +listener::listener(net::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } +} + +void listener::run() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handle a connection +void listener::on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); + } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/listener.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/listener.hpp new file mode 100644 index 0000000..0613dd8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/listener.hpp @@ -0,0 +1,49 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" + +// Forward declaration +class shared_state; + +// Accepts incoming connections and launches the sessions +class listener : public boost::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec, tcp::socket socket); + +public: + listener(net::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/main.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/main.cpp new file mode 100644 index 0000000..ebf30a2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/main.cpp @@ -0,0 +1,89 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +//------------------------------------------------------------------------------ +/* + WebSocket chat server, multi-threaded + + This implements a multi-user chat room using WebSocket. The + `io_context` runs on any number of threads, specified at + the command line. + +*/ +//------------------------------------------------------------------------------ + +#include "listener.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" + << "Example:\n" + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto* doc_root = argv[3]; + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc; + + // Create and launch a listening port + boost::make_shared(ioc, tcp::endpoint{address, port}, + boost::make_shared(doc_root)) + ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&ioc](boost::system::error_code const&, int) { + // Stop the io_context. This will cause run() + // to return immediately, eventually destroying the + // io_context and any remaining handlers in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/net.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/net.hpp new file mode 100644 index 0000000..871df6b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/net.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +#include + +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/shared_state.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/shared_state.cpp new file mode 100644 index 0000000..8f29bbb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/shared_state.cpp @@ -0,0 +1,59 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "shared_state.hpp" +#include "websocket_session.hpp" + +shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + +void shared_state::join(websocket_session* session) { + const std::scoped_lock lock(mutex_); + sessions_.insert(session); +} + +void shared_state::leave(websocket_session* session) { + const std::scoped_lock lock(mutex_); + sessions_.erase(session); +} + +// Broadcast a message to all websocket client sessions +void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + + // Make a local list of all the weak pointers representing + // the sessions, so we can do the actual sending without + // holding the mutex: + std::vector> v; + { + const std::scoped_lock lock(mutex_); + v.reserve(sessions_.size()); + for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); + } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. + for (auto const& wp : v) { + if (const auto sp = wp.lock()) { + sp->send(ss); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/shared_state.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/shared_state.hpp new file mode 100644 index 0000000..661eae0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/shared_state.hpp @@ -0,0 +1,52 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP + +#include +#include +#include +#include +#include + +// Forward declaration +class websocket_session; + +// Represents the shared server state +class shared_state { + std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; + + // Keep a list of all the connected clients + std::unordered_set sessions_; + +public: + explicit shared_state(std::string doc_root); + + [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); + void send(std::string message); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/websocket_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/websocket_session.cpp new file mode 100644 index 0000000..3e592db --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/websocket_session.cpp @@ -0,0 +1,121 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "websocket_session.hpp" + +websocket_session::websocket_session(tcp::socket&& socket, + boost::shared_ptr const& state) + : ws_(std::move(socket)), state_(state) {} + +websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); +} + +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these + if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Read another message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + + net::post(ws_.get_executor(), + beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); +} + +void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? + if (queue_.size() > 1) { + return; + } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); +} + +void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any + if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/websocket_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/websocket_session.hpp new file mode 100644 index 0000000..9f0af26 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/chat-multi/websocket_session.hpp @@ -0,0 +1,81 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// Forward declaration +class shared_state; + +/** Represents an active WebSocket connection to the server + */ +class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; + std::vector> queue_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); + +public: + websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + + template + void run(http::request> req); + + // Send a message + void send(boost::shared_ptr const& ss); + +private: + void on_send(boost::shared_ptr const& ss); +}; + +template +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); + })); + + // Accept the websocket handshake + ws_.async_accept(req, + beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp new file mode 100644 index 0000000..35aa2ad --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -0,0 +1,262 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void do_session(websocket::stream>& ws, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + break; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" + << "Example:\n" + << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/coro/websocket_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/coro/websocket_server_coro.cpp new file mode 100644 index 0000000..386515b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/coro/websocket_server_coro.cpp @@ -0,0 +1,231 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + break; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(net::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" + << "Example:\n" + << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc(threads); + + // Spawn a listening port + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/fast/websocket_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/fast/websocket_server_fast.cpp new file mode 100644 index 0000000..1e3a1b3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/fast/websocket_server_fast.cpp @@ -0,0 +1,483 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, fast +// +//------------------------------------------------------------------------------ + +/* This server contains the following ports: + + Synchronous + Asynchronous + Coroutine + + This program is optimized for the Autobahn|Testsuite + benchmarking and WebSocket compliants testing program. + + See: + https://github.com/crossbario/autobahn-testsuite +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); +} + +// Adjust settings on the stream +template +void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + + websocket::permessage_deflate pmd; + pmd.client_enable = true; + pmd.server_enable = true; + pmd.compLevel = 3; + ws.set_option(pmd); + + ws.auto_fragment(false); + + // Autobahn|Testsuite needs this + ws.read_message_max(64 * 1024 * 1024); +} + +//------------------------------------------------------------------------------ + +void do_sync_session(websocket::stream& ws) { + beast::error_code ec; + + setup_stream(ws); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Sync"); + })); + + ws.accept(ec); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + beast::flat_buffer buffer; + + ws.read(buffer, ec); + if (ec == websocket::error::closed) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_sync_listen(net::io_context& ioc, tcp::endpoint endpoint) { + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; + for (;;) { + tcp::socket socket{ioc}; + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.accept(socket, ec)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + std::thread( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_sync_session, websocket::stream(std::move(socket)))) + .detach(); + } +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation + void run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&async_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&async_session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +// Accepts incoming connections and launches the sessions +class async_listener : public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + async_listener(net::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); + })); + + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); + if (ec == websocket::error::closed) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_coro_listen(net::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" + << "Example:\n" + " websocket-server-fast 0.0.0.0 8080 1\n" + " Connect to:\n" + " starting-port+0 for synchronous,\n" + " starting-port+1 for asynchronous,\n" + " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create sync port + std::thread( + beast::bind_front_handler(&do_sync_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 0u)})) + .detach(); + + // Create async port + std::make_shared(ioc, + tcp::endpoint{address, static_cast(port + 1u)}) + ->run(); + + // Create coro port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), + boost::asio::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp new file mode 100644 index 0000000..b8e584a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -0,0 +1,303 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless-ssl"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/stackless/websocket_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/stackless/websocket_server_stackless.cpp new file mode 100644 index 0000000..3f239bb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/stackless/websocket_server_stackless.cpp @@ -0,0 +1,270 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + net::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(net::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" + << "Example:\n" + << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp new file mode 100644 index 0000000..092eade --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -0,0 +1,131 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket, ssl::context& ctx) { + try { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed + if (se.code() != websocket::error::closed) { + std::cerr << "Error: " << se.code().message() << '\n'; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync-ssl
\n" + << "Example:\n" + << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread(&do_session, std::move(socket), std::ref(ctx)).detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/sync/websocket_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/sync/websocket_server_sync.cpp new file mode 100644 index 0000000..2a28e88 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/oracle/websocket/server/sync/websocket_server_sync.cpp @@ -0,0 +1,117 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket) { + try { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed + if (se.code() != websocket::error::closed) { + std::cerr << "Error: " << se.code().message() << '\n'; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync
\n" + << "Example:\n" + << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread(&do_session, std::move(socket)).detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp new file mode 100644 index 0000000..10d3933 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp @@ -0,0 +1,668 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +using executor_type = net::strand; +using stream_type = beast::tcp_stream::rebind_executor::other; +using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +/** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. +*/ +class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit task_group(net::any_io_executor exec) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; + task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + + @note `completion_token` must have an associated executor that matches + the one the child task runs on (e.g. via `net::bind_executor`). This is + because `emit`() can run on a different thread than the task, and + `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template + auto adapt(CompletionToken&& completion_token) { + auto const lg = std::scoped_lock{mtx_}; + auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: + remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + + // A mutex or timer failure during this upstream task teardown is fatal by design. + // NOLINTNEXTLINE(bugprone-exception-escape) + ~remover() { + if (tg_) { + auto const lg = std::scoped_lock{tg_->mtx_}; + if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); + } + } + } + }; + + return net::bind_cancellation_slot( + cs->slot(), + net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's + handler, if any. + + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { + auto const lg = std::scoped_lock{mtx_}; + for (auto& cs : css_) { + cs.emit(type); + } + } + + /** Starts an asynchronous wait on the task_group. + + The completion handler will be called when: + + - All the child tasks completed. + - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion + handler must be: + @code + void handler( + boost::system::error_code const& error // result of operation + ); + @endcode + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template > + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( + // The apparent recursion crosses an asynchronous completion boundary. + // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { + if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); + } + + if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; + } + + { + auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + + if (!std::exchange(scheduled, true)) { + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); + } + + self.complete(ec); + }, + completion_token, cv_); + } +}; + +template +net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { + auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + + while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + // Echo the message back + ws.text(ws.got_text()); + co_await ws.async_write(buffer.data()); + + // Clear the buffer + buffer.consume(buffer.size()); + } + + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; + } +} + +template +net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + + if (ec == http::error::end_of_stream) { + co_return; + } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + + co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); + if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } + + co_await beast::async_write(stream, std::move(res)); + } +} + +net::awaitable detect_session(stream_type stream, ssl::context& ctx, + beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), + net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be + // inherited by all child coroutines. + co_await net::this_coro::throw_if_cancelled(false); + + stream.expires_after(std::chrono::seconds(30)); + + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + + auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + + if (!ssl_stream.lowest_layer().is_open()) { + co_return; + } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; + } + } else { + co_await run_session(stream, buffer, doc_root); + + if (!stream.socket().is_open()) { + co_return; + } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +} + +net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + + if (ec == net::error::operation_aborted) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }))); + } +} + +net::awaitable handle_signals(task_group& task_group) { + auto const executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{executor, SIGINT, SIGTERM}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto sig = co_await signal_set.async_wait(); + + if (sig == SIGINT) { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( + net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); + + if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); + co_await task_group.async_wait(); + } + + std::cout << "Child tasks completed.\n"; + } else // SIGTERM + { + net::query(executor.get_inner_executor(), net::execution::context).stop(); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in listener: " << e.what() << "\n"; + } + } + }))); + + // Create and launch a signal handler coroutine + net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server-flex/advanced_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server-flex/advanced_server_flex.cpp new file mode 100644 index 0000000..543a23b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server-flex/advanced_server_flex.cpp @@ -0,0 +1,874 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class websocket_session { + websocket_session() = default; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( + websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, + derived().shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, + derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), + beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } + +public: + // Start the asynchronous operation + template + void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; + +public: + // Create the session + explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; + +public: + // Create the ssl_websocket_session + explicit ssl_websocket_session(ssl::stream&& stream) + : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream>& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +template +void make_websocket_session(beast::tcp_stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +template +void make_websocket_session(ssl::stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +protected: + beast::flat_buffer buffer; + +public: + // Construct the session +private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, + derived().shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream)) {} + + // Start the session + void run() { this->do_read(); } + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Called by the base class + beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the http_session + ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream), ctx) {} + + // Start the session + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( + ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Called by the base class + ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + +private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + explicit detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); + } + + void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( + stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(std::move(stream_), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector http_session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" + << "Example:\n" + << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&](beast::error_code const&, int) { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server/advanced_server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server/advanced_server.cpp new file mode 100644 index 0000000..c4576d5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/advanced/server/advanced_server.cpp @@ -0,0 +1,629 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, + shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection +class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +public: + // Take ownership of the socket + http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) { + static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + +private: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read(stream_, buffer_, *parser_, + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + std::make_shared(stream_.release_socket()) + ->do_accept(parser_->release()); + return; + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(acceptor_.get_executor(), + beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the http session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" + << "Example:\n" + << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&](beast::error_code const&, int) { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/common/root_certificates.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/common/root_certificates.hpp new file mode 100644 index 0000000..2e3fb7b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/common/root_certificates.hpp @@ -0,0 +1,3982 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP + +#include +#include + +/* + PLEASE READ + + These root certificates here are included just to make the + SSL client examples work. They are NOT intended to be + illustrative of best-practices for performing TLS certificate + verification. + + A REAL program which needs to verify the authenticity of a + server IP address resolved from a given DNS name needs to + consult the operating system specific certificate store + to validate the chain of signatures, compare the domain name + properly against the domain name in the certificate, check + the certificate revocation list, and probably do some other + things. + + ALL of these operations are entirely outside the scope of + both Boost.Beast and Boost.Asio. + + See (work in progress): + https://github.com/djarek/certify + + tl;dr: root_certificates.hpp should not be used in production code +*/ + +namespace ssl = boost::asio::ssl; // from + +namespace detail { + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(ctx.load_verify_file(path, ec)); + return; + } + + std::string cert = + "# ACCVRAIZ1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" + "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" + "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ\n" + "BgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwHUEtJQUNDVjENMAsGA1UECgwEQUND\n" + "VjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCb\n" + "qau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gMjmoY\n" + "HtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWo\n" + "G2ioPej0RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpA\n" + "lHPrzg5XPAOBOp0KoVdDaaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhr\n" + "IA8wKFSVf+DuzgpmndFALW4ir50awQUZ0m/A8p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D3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" + "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Actalis Authentication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" + "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" + "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv\n" + "UTufClrJwkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX\n" + "4ay8IMKx4INRimlNAJZaby/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9\n" + "KK3giq0itFZljoZUj5NDKd45RnijMCO6zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/\n" + "gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1fYVEiVRvjRuPjPdA1Yprb\n" + "rxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2oxgkg4YQ\n" + "51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2F\n" + "be8lEfKXGkJh90qX6IuxEAf6ZYGyojnP9zz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XH/JJU\n" + "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" + "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Commercial\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" + "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" + "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL\n" + "MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1\n" + "yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr\n" + "VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/\n" + "nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG\n" + "XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj\n" + "vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt\n" + "Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g\n" + "N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" + "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Networking\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBOZXR3b3JraW5nMB4XDTEwMDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SEHi3y\n" + "YJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbua\n" + "kCNrmreIdIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRL\n" + "QESxG9fhwoXA3hA/Pe24/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp\n" + "6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG\n" + "yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i\n" + "QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfO\n" + "tDIuUFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzu\n" + "QY0x2+c06lkh1QF612S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZ\n" + "Lgo/bNjR9eUJtGxUAArgFU2HdW23WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4u\n" + "olu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9/ZFvgrG+CJPbFEfxojfHRZ48\n" + "x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVz\n" + "dCBQcmVtaXVtMB4XDTEwMDEyOTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkG\n" + "A1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1U\n" + "cnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxBLf\n" + "qV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtnBKAQ\n" + "J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nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc\n" + "0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK+4w1IX2COPKpVJEZNZOUbWo6xbLQ\n" + "u4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF\n" + "u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH\n" + "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" + "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" + "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" + "KeC2uAloGRwYQw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" + "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" + "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" + "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" + "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" + "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" + "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" + "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" + "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" + "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK\n" + "gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ\n" + "W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg\n" + "1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K\n" + "8nu+NQWpEjTj82R0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U8uz/mtBzUF+\n" + "fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n" + "n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Atos TrustedRoot 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE\n" + "AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG\n" + "EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM\n" + "FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UEC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ridad de Certificacion Firmaprofesional CIF A62634068\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UE\n" + "BhMCRVMxQjBABgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1h\n" + "cHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEy\n" + "MzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIwQAYDVQQDDDlBdXRvcmlkYWQgZGUg\n" + "Q2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBBNjI2MzQwNjgwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDDUtd9\n" + "thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQM\n" + "cas9UX4PB99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefG\n" + "L9ItWY16Ck6WaVICqjaY7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15i\n" + "NA9wBj4gGFrO93IbJWyTdBSTo3OxDqqHECNZXyAFGUftaI6SEspd/NYrspI8IM/h\n" + "X68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyIplD9amML9ZMWGxmPsu2b\n" + "m8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctXMbScyJCy\n" + "Z/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirja\n" + "EbsXLZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/T\n" + "KI8xWVvTyQKmtFLKbpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAe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ERHrVkY8SFlcN7ONGCoQPHzPKTDKCOM/icz\n" + "Q0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQB\n" + "jLMi6Et8Vcad+qMUu2WFbm5PEn4KPJ2V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Baltimore CyberTrust Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" + "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" + "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" + "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" + "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" + "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" + "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" + "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" + "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" + "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" + "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" + "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" + "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" + "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" + "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" + "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" + "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" + "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" + "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" + "BQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1g1Lr\n" + "6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPV\n" + "L4O2fuPn9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC91\n" + "1K2GScuVr1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jv6ly0Us\n" + "H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ\n" + "I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7\n" + "5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" + "3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" + "Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 3 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" + "BQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRHsJ8Y\n" + "ZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3E\n" + "N3coTRiR5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9\n" + "tznDDgFHmV0ST9tD+leh7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX\n" + "0DJq1l1sDPGzbjniazEuOQAnFN44wOwZZoYS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BE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41\n" + "3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD\n" + "u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq\n" + "4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CA Disig Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV\n" + "BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu\n" + "MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy\n" + "MDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sxEzARBgNVBAcTCkJyYXRpc2xhdmEx\n" + "EzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERpc2lnIFJvb3QgUjIw\n" + "ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbCw3Oe\n" + "NcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNH\n" + "PWSb6WiaxswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3I\n" + "x2ymrdMxp7zo5eFm1tL7A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbe\n" + "QTg06ov80egEFGEtQX6sx3dOy1FU+16SGBsEWmjGycT6txOgmLcRK7fWV8x8nhfR\n" + "yyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqVg8NTEQxzHQuyRpDRQjrO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39pCXHR+3/H3Os\n" + "zMOl6W8KjptlwlCFtaOgUxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8x\n" + "L4ysEr3vQCj8KWefshNPZiTEUxnpHikV7+ZtsH8tZ/3zbBt1RqPlShfppNcL\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CFCA EV ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD\n" + "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx\n" + "MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j\n" + "aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJP\n" + "T1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnVBU03\n" + "sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpL\n" + "TIpTUnrD7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5\n" + "/ZOkVIBMUtRSqy5J35DNuF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp\n" + "7hZZLDRJGqgG16iI0gNyejLi6mhNbiyWZXvKWfry4t3uMCz7zEasxGPrb382KzRz\n" + "EpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7xzbh72fROdOXW3NiGUgt\n" + "hxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9fpy25IGvP\n" + "a931DfSCt/SyZi4QKPaXWnuWF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hyQN9Ky8+Z\n" + "AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ\n" + "5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB\n" + "gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV\n" + "BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw\n" + "MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl\n" + "YXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01P\n" + "RE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3\n" + "UcEbVASY06m/weaKXTuH+7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI\n" + "2GqGd0S7WWaXUF601CxwRM/aN5VCaTwwxHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8\n" + "Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV4EajcNxo2f8ESIl33rXp\n" + "+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA1KGzqSX+\n" + "DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5O\n" + "nKVIrLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW\n" + "/zAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6g\n" + "PKA6hjhodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9u\n" + "QXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAPpiem/Yb6dc5t3iuHXIY\n" + "SdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CPOGEIqB6BCsAv\n" + "IC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/\n" + "RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4\n" + "zJVSk/BwJVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd\n" + "BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB\n" + "ZQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" + "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" + "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" + "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" + "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" + "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" + "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" + "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB\n" + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" + "EkdyZ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BQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl\n" + "wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM\n" + "4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV\n" + "2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna\n" + "FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ\n" + "CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK\n" + "boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke\n" + "jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL\n" + "S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb\n" + "QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl\n" + "0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB\n" + "NVOFBkpdn627G190\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNV\n" + "BAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4X\n" + "DTA3MDYyOTE1MTMwNVoXDTI3MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQ\n" + "BgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwIQ2VydGlnbmEwggEiMA0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H8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw\n" + "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + "MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x\n" + "MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD\n" + "VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX\n" + "BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" + "ggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sO\n" + "ty3tRQgXstmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9M\n" + "CiBtnyN6tMbaLOQdLNyzKNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPu\n" + "I9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8JXrJhFwLrN1CTivngqIkicuQstDuI7pm\n" + "TLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16XdG+RCYyKfHx9WzMfgIh\n" + "C59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq4NYKpkDf\n" + "ePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3Yz\n" + "IoejwpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8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0gcWtSS6Cvu5zHbugRqh5jnxV/v\n" + "faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63\n" + "Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh\n" + "jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw\n" + "3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM\n" + "MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D\n" + "ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBU\n" + "cnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIyMTIwNzM3WhcNMjkxMjMxMTIwNzM3\n" + "WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMg\n" + "Uy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSIw\n" + "IAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0B\n" + "AQEFAAOCAQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rH\n" + "UV+rpDKmYYe2bg+G0jACl/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LM\n" + "TXPb865Px1bVWqeWifrzq2jUI4ZZJ88JJ7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVU\n" + "BBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4fOQtf/WsX+sWn7Et0brM\n" + "kUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0cvW0QM8x\n" + "AcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNV\n" + "HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15y\n" + "sHhE49wcrwn9I0j6vSrEuVUEtRCjjSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfL\n" + "I9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1mS1FhIrlQgnXdAIv94nYmem8\n" + "J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5ajZt3hrvJBW8qY\n" + "VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI\n" + "03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCB\n" + "gDELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMu\n" + "QS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIG\n" + "A1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29yayBDQSAyMCIYDzIwMTExMDA2MDgz\n" + "OTU2WhgPMjA0NjE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VHQ8BAf8EBAMC\n" + "AQYwDQYJKoZIhvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQ\n" + "F/xlhMcQSZDe28cmk4gmb3DWAl45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTf\n" + "CVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuAL55MYIR4PSFk1vtBHxgP58l1cb29\n" + "XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMoclm2q8KMZiYcdywm\n" + "djWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tMpkT/\n" + "WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jb\n" + "AoJnwTnbw3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksq\n" + "P/ujmv5zMnHCnsZy4YpoJ/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Ko\n" + "b7a6bINDd82Kkhehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnj\n" + "XALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P\n" + "5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbi\n" + "DrW5viSP\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Chambers of Commerce Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "M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MjNbMMeJL0eYD6MD\n" + "xvbxrN8y8NmBGuScvfaAFPDRLLmF9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QG\n" + "tjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcKzBIKinmwPQN/aUv0NCB9szTq\n" + "jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De\n" + "fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg\n" + "OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ\n" + "d0jQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Comodo AAA Services root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb\n" + "MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow\n" + "GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj\n" + "YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM\n" + "GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" + "ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua\n" + "BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe\n" + "3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4\n" + "YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR\n" + "rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm\n" + "ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU\n" + "oBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20v\n" + "QUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29t\n" + "b2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUF\n" + "AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q\n" + "GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz\n" + "Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2\n" + "G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi\n" + "l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3\n" + "smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Cybertrust Global Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBY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A2kaDAtE52Mlp3+yybh2hO0j9n0Hq0V+09+zv+mKts2o\n" + "omcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+TX3EJIrduPuoc\n" + "A06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW\n" + "WL1WMRJOEcgh4LMRkWXbtKaIOM5V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\n" + "ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM\n" + "HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03\n" + "UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42\n" + "tSHKXzlABF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9R\n" + "ySPocq60vFYJfxLLHLGvKZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsM\n" + "lFqVlNpQmvH/pStmMaTJOKDfHR+4CS7zp+hnUquVH+BGPtikw8paxTGA6Eian5Rp\n" + "/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUCAwEAAaOCARowggEWMA8G\n" + "A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ4PGEMA4G\n" + "A1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVj\n" + "dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUy\n" + "MENBJTIwMiUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRl\n" + "cmV2b2NhdGlvbmxpc3QwQ6BBoD+GPWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3Js\n" + "L2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAwOS5jcmwwDQYJKoZIhvcNAQEL\n" + "BQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm2H6NMLVwMeni\n" + "acfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0\n" + "o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K\n" + "zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8\n" + "PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y\n" + "Johw1+qRzT65ysCQblrGXnRl11z+o+I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 EV 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw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tDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05\n" + "nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNF\n" + "CSuGdXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na\n" + "xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX\n" + "KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DST Root CA X3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" + "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" + "DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" + "PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" + "Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + "AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" + "rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" + "OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" + "xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" + "7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" + "aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" + "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" + "SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" + "ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" + "AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" + "R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" + "JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" + "Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c\n" + "JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP\n" + "mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+\n" + "wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4\n" + "VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/\n" + "AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB\n" + "AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW\n" + "BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun\n" + "pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC\n" + "dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf\n" + "fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm\n" + "NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx\n" + "H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe\n" + "+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl\n" + "MQswCQYDVQQGEwJ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bYz+70CjTVW0z9\n" + "B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv\n" + "ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo\n" + "IhNzbM8m9Yop5w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg\n" + "RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq\n" + "hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf\n" + "Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q\n" + "RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD\n" + "AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY\n" + "JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv\n" + "6pZjamVFkpUBtA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" + "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" + "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" + "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" + "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" + "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" + "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" + "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" + "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" + "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n" + "MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI\n" + "2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx\n" + "1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ\n" + "q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz\n" + "tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ\n" + "vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP\n" + "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV\n" + "5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY\n" + "1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4\n" + "NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG\n" + "Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91\n" + "8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe\n" + "pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl\n" + "MrY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe\n" + "Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw\n" + "EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x\n" + "IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF\n" + "K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG\n" + "fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO\n" + "Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd\n" + "BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx\n" + "AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/\n" + "oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8\n" + "sycX\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert High Assurance EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n" + "ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n" + "LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug\n" + "RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm\n" + "+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW\n" + "PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM\n" + "xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB\n" + "Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3\n" + "hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg\n" + "EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA\n" + "FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec\n" + "nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z\n" + "eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF\n" + "hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2\n" + "Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe\n" + "vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep\n" + "+OkuE6N36B9K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Trusted Root G4\n" + "-----BEGIN CERTIFIC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bOUOUlFHdL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXK\n" + "chYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8oR7FwI+isX4KJpn15GkvmB0t\n" + "9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB\n" + "hjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD\n" + "ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2\n" + "SV1EY+CtnJYYZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd\n" + "+SeuMIW59mdNOj6PWTkiU0TryF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWc\n" + "fFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy7zBZLq7gcfJW5GqXb5JQbZaNaHqa\n" + "sjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iahixTXTBmyUEFxPT9N\n" + "cCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN5r5N\n" + "0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie\n" + "4u1Ki7wb/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI\n" + "r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1\n" + "/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm\n" + "gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# E-Tugra Certification Authority\n" + "-----BEGIN CER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cDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOS\n" + "Agu+TGbrIP65y7WZf+a2E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xl\n" + "nJ2lYJU6Un/10asIbvPuW/mIPX64b24D5EI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EE Certification Centre Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1\n" + "MQswCQYDVQQGEwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1\n" + "czEoMCYGA1UEAwwfRUUgQ2VydGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYG\n" + "CSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIwMTAxMDMwMTAxMDMwWhgPMjAzMDEy\n" + "MTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlBUyBTZXJ0aWZpdHNl\n" + "ZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRyZSBS\n" + "b290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEB\n" + "AQUAA4IBDwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUy\n" + "euuOF0+W2Ap7kaJjbMeMTC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvO\n" + "bntl8jixwKIy72KyaOBhU8E2lf/slLo2rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIw\n" + "WFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw93X2PaRka9ZP585ArQ/d\n" + "MtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtNP2MbRMNE\n" + "1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYD\n" + "VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/\n" + "zQas8fElyalL1BSZMEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYB\n" + "BQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEF\n" + "BQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+RjxY6hUFaTlrg4wCQiZrxTFGGV\n" + "v9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqMlIpPnTX/dqQG\n" + "E5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u\n" + "uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIW\n" + "iAYLtqZLICjU3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/v\n" + "GVCJYMzpJJUPwssd8m92kMfMdcGWxZ0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust.net Premium 2048 Secure Server CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML\n" + "RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp\n" + "bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5\n" + "IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0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zeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+\n" + "bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er\n" + "fF6adulZkMV8gzURZVE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\n" + "Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\n" + "KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\n" + "cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw\n" + "NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw\n" + "NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy\n" + "ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV\n" + "BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ\n" + "KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo\n" + "Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4\n" + "4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9\n" + "KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI\n" + "rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi\n" + "94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB\n" + "sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi\n" + "gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo\n" + "kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE\n" + "vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t\n" + "O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua\n" + "AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP\n" + "9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/\n" + "eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\n" + "0vdXcDazv/wor3ElhVsT/h5/WrQ8\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - EC1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG\n" + "A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3\n" + "d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu\n" + "dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq\n" + "RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy\n" + "MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD\n" + "VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0\n" + "L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g\n" + "Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD\n" + "ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi\n" + "A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt\n" + "ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH\n" + "Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O\n" + "BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC\n" + "R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX\n" + "hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEPjCCAyagAwIBAgIESlOMKDANBg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n" + "BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN\n" + "BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/\n" + "jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ\n" + "Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v\n" + "1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R\n" + "nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH\n" + "VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAw\n" + "gb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL\n" + "Ex9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykg\n" + "MjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMjAw\n" + "BgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEc0\n" + "MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1\n" + "c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDV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DRSVfg\n" + "p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZm\n" + "DRd9FBUb1Ov9H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5\n" + "COmSdI31R9KrO9b7eGZONn356ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ry\n" + "L3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd+PwyvzeG5LuOmCd+uh8W4XAR8gPf\n" + "JWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQHtZa37dG/OaG+svg\n" + "IHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBDF8Io\n" + "2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV\n" + "09tL7ECQ8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQ\n" + "XR4EzzffHqhmsYzmIGrv/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrq\n" + "T8p+ck0LcIymSLumoRT2+1hEmRSuqguTaaApJUqlyyvdimYHFngVV3Eb7PVHhPOe\n" + "MTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xl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QkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6Z\n" + "XPYfcX3v73svfuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZR\n" + "gyFmxhE+885H7pwoHyXa/6xmld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3\n" + "d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9bgsiG1eGZbYwE8na6SfZu6W0eX6Dv\n" + "J4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq4BjFbkerQUIpm/Zg\n" + "DdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWErtXvM\n" + "+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyy\n" + "F62ARPBopY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9\n" + "SQ98POyDGCBDTtWTurQ0sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdws\n" + "E3PYJ/HQcu51OyLemGhmW/HGY0dVHLqlCFF1pkgl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoIC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Sxm65FSWRQmx1WyRRK2EE46ajA2A\n" + "DDL24CejQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBTB8Sa6oC2uhYHP0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFuk\n" + "fCPAlaUs3L6JbyO5o91lAFJekazInXJ0glMLfalAvWhgxeG4VDvBNhcl2MG9AjEA\n" + "njWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOaKaqW04MjyaR7YbPMAuhd\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu\n" + "hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/l\n" + "xKvRHYqjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBSATNbrdP9JNqPV2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0\n" + "CMRw3J5QdCHojXohw0+WbhXRIjVhLfoIN+4Zba3bssx9BzT1YBkstTTZbyACMANx\n" + "sbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11xzPKwTdb+mciUqXWi4w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Global CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\n" + "YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG\n" + "EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg\n" + "R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9\n" + "9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq\n" + "fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\n" + "iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\n" + "1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\n" + "bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\n" + "MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\n" + "ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\n" + "uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\n" + "Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\n" + "tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\n" + "PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n" + "hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n" + "5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY\n" + "MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo\n" + "R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx\n" + "MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK\n" + "Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9\n" + "AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA\n" + "ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0\n" + "7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W\n" + "kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI\n" + "mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1\n" + "6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl\n" + "4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K\n" + "oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj\n" + "UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU\n" + "AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL\n" + "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj\n" + "KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2\n" + "MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV\n" + "BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw\n" + "NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV\n" + "BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH\n" + "MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL\n" + "So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal\n" + "tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG\n" + "CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT\n" + "qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz\n" + "rD6ogRLQy7rQkgu2npaqBA+K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB\n" + "mDELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsT\n" + "MChjKSAyMDA4IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s\n" + "eTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhv\n" + "cml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIzNTk1OVowgZgxCzAJ\n" + "BgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9Uc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ghLrGREt\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE\n" + "BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0\n" + "IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV\n" + "VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8\n" + "cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT\n" + "QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh\n" + "F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v\n" + "c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w\n" + "mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd\n" + "VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX\n" + "teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ\n" + "f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfRe\n" + "Bi9Fi1jUIxaS5BZuKGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+\n" + "nhutxx9z3SxPGWX9f5NAEC7S8O08ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB\n" + "/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY\n" + "MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG\n" + "9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc\n" + "aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX\n" + "IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn\n" + "ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z\n" + "uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN\n" + "Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja\n" + "QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW\n" + "koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9\n" + "ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt\n" + "DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm\n" + "bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA 2\n" + "-----BEGIN CERTI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dxzMk+MBB4zsslG8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAfBgNV\n" + "HSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8EBAMCAYYwDQYJ\n" + "KoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z\n" + "dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQ\n" + "L1EuxBRa3ugZ4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgr\n" + "Fg5fNuH8KrUwJM/gYwx7WBr+mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSo\n" + "ag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpqA1Ihn0CoZ1Dy81of398j9tx4TuaY\n" + "T1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz\n" + "GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m\n" + "1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV\n" + "OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH\n" + "6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX\n" + "QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB4TCCAYegAwIBAgIRKjikHJYK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G9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc\n" + "8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke\n" + "hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI\n" + "KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg\n" + "515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO\n" + "xwy8p2Fp8fc74SrL+SvzZpA3\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\n" + "A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\n" + "b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw\n" + "MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\n" + "YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT\n" + "aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ\n" + "jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp\n" + "xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp\n" + "1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG\n" + "snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ\n" + "U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8\n" + "9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E\n" + "BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B\n" + "AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz\n" + "yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE\n" + "38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP\n" + "AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\n" + "DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\n" + "HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1\n" + "MDgwMDAwWjBMMS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qlULRuJQ/7\n" + "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\n" + "MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\n" + "RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\n" + "gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\n" + "KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\n" + "QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\n" + "XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\n" + "LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\n" + "RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\n" + "jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n" + "6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\n" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\n" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\n" + "WD9f\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R6\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg\n" + "MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh\n" + "bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQx\n" + "MjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjET\n" + "MBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCAiIwDQYJ\n" + "KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQssgrRI\n" + "xutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1k\n" + "ZguSgMpE3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxD\n" + "aNc9PIrFsmbVkJq3MQbFvuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJw\n" + "LnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqMPKq0pPbzlUoSB239jL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lD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs\n" + "pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v\n" + "JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R\n" + "8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4\n" + "5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Global Chambersign Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD\n" + "aGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMxNDBaFw0zODA3MzEx\n" + "MjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3Vy\n" + "cmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAG\n" + "A1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAl\n" + "BgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZI\n" + "hvcNAQEBBQADggIPADCCAgoCggIBAMDfVtPkOpt2RbQT2//BthmLN0EYlVJH6xed\n" + "KYiONWwGMi5HYvNJBL99RDaxccy9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vdCAtIDIwMDiC\n" + "CQDJzdPp1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCow\n" + "KAYIKwYBBQUHAgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZI\n" + "hvcNAQEFBQADggIBAICIf3DekijZBZRG/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZ\n" + "UohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6ReAJ3spED8IXDneRRXoz\n" + "X1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/sdZ7LoR/x\n" + "fxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVz\n" + "a2Mg9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yyd\n" + "Yhz2rXzdpjEetrHHfoUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMd\n" + "SqlapskD7+3056huirRXhOukP9DuqqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9O\n" + "AP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETrP3iZ8ntxPjzxmKfFGBI/5rso\n" + "M0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVqc5iJWzouE4ge\n" + "v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z\n" + "09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh\n" + "MB8GA1UEChMYVGhlIEdvIERhZGR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JYXMP80kWNy\n" + "OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P\n" + "TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ\n" + "HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER\n" + "dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf\n" + "ReYNnyicsbkqWletNw+vHX/bvZ8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" + "EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp\n" + "ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz\n" + "NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH\n" + "EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE\n" + "AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw\n" + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD\n" + "E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH\n" + "/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy\n" + "DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh\n" + "GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR\n" + "tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA\n" + "AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE\n" + "FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX\n" + "WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu\n" + "9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr\n" + "gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo\n" + "2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n" + "LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n" + "4uJEvlz36hz1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions ECC RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN\n" + "BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl\n" + "bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv\n" + "b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ\n" + "BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj\n" + "YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5\n" + "MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0\n" + "dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg\n" + "QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa\n" + "jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC\n" + "MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi\n" + "C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep\n" + "lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof\n" + "TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1Ix\n" + "RDBCBgNVBAoTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1p\n" + "YyBhbmQgUm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OjWEopmr95fZi6hg8\n" + "TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7\n" + "dIsXRSZMFpGD/md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8Acys\n" + "Nnq/onN694/BtZqhFLKPM58N7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXI\n" + "l7WdmplNsDz4SgCbZN2fOUvRJ9e4\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix\n" + "DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k\n" + "IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT\n" + "N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9v\n" + "dENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAxMTIxWjCBpjELMAkG\n" + "A1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNh\n" + "ZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkx\n" + "QDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgUm9vdENBIDIwMTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" + "AQDC+Kk/G4n8PDwEXT2QNrCROnk8ZlrvbTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA\n" + "4yjsriFBzh/a/X0SWwGDD7mwX5nh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RGar9KC/ea\n" + "j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh\n" + "X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ\n" + "l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf\n" + "bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4\n" + "pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK\n" + "e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0\n" + "vm9qp/UsQu0yrbYhnr68\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsx\n" + "FjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3Qg\n" + "Um9vdCBDQSAxMB4XDTAzMDUxNTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkG\n" + "A1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdr\n" + "b25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1ApzQ\n" + "jVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEn\n" + "PzlTCeqrauh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjh\n" + "ZY4bXSNmO7ilMlHIhqqhqZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9\n" + "nnV0ttgCXjqQesBCNnLsak3c78QA3xMYV18meMjWCnl3v/evt3a5pQuEF10Q6m/h\n" + "q5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNVHRMBAf8ECDAGAQH/AgED\n" + "MA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7ih9legYsC\n" + "mEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI3\n" + "7piol7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clB\n" + "oiMBdDhViw+5LmeiIAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJs\n" + "EhTkYY2sEJCehFC78JZvRZ+K88psT/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpO\n" + "fMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilTc4afU9hDDl3WY4JxHYB0yvbi\n" + "AmvZWg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL\n" + "BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ\n" + "SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n\n" + "a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5\n" + "NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtvbmcxEjAQBgNVBAcT\n" + "CUhvbmcgS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LS6ZStS6LG\n" + "7BJ8dNVI0lkUmcDrudHr9EgwW62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCk\n" + "MpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWldy8joRTnU+kLBEUx3XZL7av9YROXr\n" + "gZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov+BS5gLNdTaqX4fnk\n" + "GMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDceqFS\n" + "3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJm\n" + "Ozj/2ZQw9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+\n" + "l6mc1X5VTMbeRRAc6uk7nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6c\n" + "JfTzPV4e0hz5sy229zdcxsshTrD3mUcYhcErulWuBurQB7Lcq9CClnXO0lD+mefP\n" + "L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa\n" + "LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG\n" + "mpv0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ISRG Root X1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" + "WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n" + "ZXQgU2VjdXJpdH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6brJFe+GnY+EgPbk6ZGQ\n" + "3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK\n" + "NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5\n" + "ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n" + "TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n" + "jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n" + "oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n" + "4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n" + "mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" + "emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Commercial Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu\n" + "VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw\n" + "MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw\n" + "JQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwggIiMA0GCSqG\n" + "SIb3DQ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CIOQ045U8U1mwF10A0Cj7oV+wh93\n" + "nAbowacYXVKV7cndJZ5t+qntozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3\n" + "+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmVYjzlVYA211QC//G5Xc7UI2/YRYRK\n" + "W2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUXfeu+h1sXIFRRk0pT\n" + "AwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/rokTLq\n" + "l1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG\n" + "4iZZRHUe2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZ\n" + "mUlO+KWA2yUPHGNiiskzZ2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A\n" + "7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7RcGzM7vRX+Bi6hG6H\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Public Sector Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu\n" + "VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN\n" + "MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0\n" + "MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTyP4o7\n" + "ekosMSqMjbCpwz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1yJX9dsXNw0H8G\n" + "lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW\n" + "mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df\n" + "WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5\n" + "+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ\n" + "tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA\n" + "GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv\n" + "8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Izenpe.com\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4\n" + "MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6\n" + "ZW5wZS5jb20wHhcNMDcxMjEzMTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYD\n" + "VQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5j\n" + "b20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ03rKDx6sp4boFmVq\n" + "scIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAKClaO\n" + "xdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6H\n" + "LmYRY2xU+zydcsC8Lv/Ct90NduM61/e0aL6i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ikuFgba56\n" + "awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8qhT/AQKM6WfxZSzwo\n" + "JNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Csg1lw\n" + "LDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCT\n" + "VyvehQP5aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGk\n" + "LhObNA5me0mrZJfQRsN5nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJb\n" + "UjWumDqtujWTI6cfSN01RpiyEGjkpTHCClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/\n" + "QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZoQ0iy2+tzJOeRf1SktoA+\n" + "naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1ZWrOZyGls\n" + "QyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# LuxTrust Global Root 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL\n" + "BQAwRjELMAkGA1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNV\n" + "BAMMFkx1eFRydXN0IEdsb2JhbCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUw\n" + "MzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEWMBQGA1UECgwNTHV4VHJ1c3QgUy5B\n" + "LjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBANeFl78RmOnwY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P9\n" + "BzZAcg4atmpZ1gDlaCDdLnINH2pkMSCEfUmmWjfrRcmF9dTHF5kH5ptV5AzoqbTO\n" + "jFu1EVzPig4N1qx3gf4ynCSecs5U89BvolbW7MM3LGVYvlcAGvI1+ut7MV3CwRI9\n" + "loGIlonBWVx65n9wNOeD4rHh4bhY79SV5GCc8JaXcozrhAIuZY+kt9J/Z93I055c\n" + "qqmkoCUUBpvsT34tC38ddfEz2O3OuHVtPlu5mB0xDVbYQw8wkbIEa91WvpWAVWe+\n" + "2M2D2RjuLg+GLZKecBPs3lHJQ3gCpU3I+V/EkVhGFndadKpAvAefMLmx9xIX3eP/\n" + "JEAdemrRTxgKqpAd60Ae36EeRJIQmvKN4dFLRp7oRUKX6kWZ8+xm1QL68qZKJKre\n" + "zrnK+T+Tb/mjuuqlPpmt/f97mfVl7vBZKGfXkJWkE4SphMHozs51k2MavDzq1WQf\n" + "LSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc7kGUnF4ZLvhFSZl0kbAEb+MEWrGrKqv+\n" + "x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6\n" + "oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Microsec e-Szigno Root CA 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\n" + "VQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0\n" + "ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0G\n" + "CSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTAeFw0wOTA2MTYxMTMwMThaFw0y\n" + "OTEyMzAxMTMwMThaMIGCM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ofyK/FFh+U9rNHHV4S9a67c\n" + "2Pm2G2JwCz02yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5t\n" + "HMN1Rq41Bab2XD0h7lbwyYIiLXpUq3DDfSJlgnCW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# NetLock Arany (Class Gold) Főtanúsítvány\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG\n" + "EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3\n" + "MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl\n" + "cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR\n" + "dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgxMjA2MTUwODIxWjCB\n" + "pzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxOZXRM\n" + "b2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlm\n" + "aWNhdGlvbiBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNz\n" + "IEdvbGQpIEbFkXRhbsO6c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAxCRec75LbRTDofTjl5Bu0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrT\n" + "lF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw/HpYzY6b7cNGbIRwXdrz\n" + "AZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAkH3B5r9s5\n" + "VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRG\n" + "ILdwfzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2\n" + "BJtr+UBdADTHLpl1neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAG\n" + "AQH/AgEEMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2M\n" + "U9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwWqZw8UQCgwBEIBaeZ5m8BiFRh\n" + "bvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTtaYtOUZcTh5m2C\n" + "+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC\n" + "bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2F\n" + "uLjbvrW5KfnaNwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2\n" + "XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Network Solutions Certificate Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi\n" + "MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu\n" + "MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp\n" + "dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJV\n" + "UzEhMB8GA1UEChMYTmV0d29yayBTb2x1d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JeRcQcT16ohZO9QHN\n" + "pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GA CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCB\n" + "ijELMAkGA1UEBhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHly\n" + "aWdodCAoYykgMjAwNTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl\n" + "ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQSBDQTAeFw0w\n" + "NTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYDVQQGEwJDSDEQMA4G\n" + "A1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIwIAYD\n" + "VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBX\n" + "SVNlS2V5IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAy0+zAJs9Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxR\n" + "VVuuk+g3/ytr6dTqvirdqFEr12bDYVxgAsj1znJ7O7jyTmUIms2kahnBAbtzptf2\n" + "w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbDd50kc3vkDIzh2TbhmYsF\n" + "mQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ/yxViJGg\n" + "4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t9\n" + "4B3RLoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYw\n" + "DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQw\n" + "EAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOx\n" + "SPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vImMMkQyh2I+3QZH4VFvbBsUfk2\n" + "ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4+vg1YFkCExh8\n" + "vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa\n" + "hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZi\n" + "Fj4A4xylNoEYokxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ\n" + "/L7fCg0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GB CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBt\n" + "MQswCQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUg\n" + "Rm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9i\n" + "YWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAwMzJaFw0zOTEyMDExNTEwMzFaMG0x\n" + "CzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBG\n" + "b3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh\n" + "bCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3\n" + "HEokKtaXscriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGx\n" + "WuR51jIjK+FTzJlFXHtPrby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX\n" + "1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNk\n" + "u7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4oQnc/nSMbsrY9gBQHTC5P\n" + "99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvgGUpuuy9r\n" + "M2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw\n" + "AwEB/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUB\n" + "BAMCAQAwDQYJKoZIhvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrgh\n" + "cViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5\n" + "gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3ZwLWoo4rO\n" + "ZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" + "aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic\n" + "Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GC CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw\n"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GFy\n" + "ZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh\n" + "Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYI\n" + "KwYBBQUHAgEWFmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3T\n" + "KbkGGew5Oanwl4Rqy+/fMIGuBgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rq\n" + "y+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1p\n" + "dGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD\n" + "VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL\n" + "MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk\n" + "fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8\n" + "7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R\n" + "cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y\n" + "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n" + "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n" + "SnQ2+Q==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 1 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL\n" + "BQAwSDELM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MBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB\n" + "BjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZIhvcNAQELBQAD\n" + "ggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC\n" + "MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2\n" + "cDMT/uFPpiN3GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUN\n" + "qXsCHKnQO18LwIE6PWThv6ctTr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5\n" + "YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP+V04ikkwj+3x6xn0dxoxGE1nVGwv\n" + "b2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh3jRJjehZrJ3ydlo2\n" + "8hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fawx/k\n" + "NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj\n" + "ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp\n" + "q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt\n" + "nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0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a6FJpEcwRTEL\n" + "MAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT\n" + "ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2f\n" + "BluornFdLwUvZ+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzn\n" + "g/iN/Ae42l9NLmeyhP3ZRPx3UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2Bl\n" + "fF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodmVjB3pjd4M1IQWK4/YY7yarHvGH5K\n" + "WWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK+JDSV6IZUaUtl0Ha\n" + "B0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrWIozc\n" + "hLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPR\n" + "TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD\n" + "mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z\n" + "ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y\n" + "4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza\n" + "8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVB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\n" + "BjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZIhvcNAQELBQAD\n" + "ggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66\n" + "AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RC\n" + "roijQ1h5fq7KpVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0Ga\n" + "W/ZZGYjeVYg3UQt4XAoeo0L9x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4n\n" + "lv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgzdWqTHBLmYF5vHX/JHyPLhGGfHoJE\n" + "+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6XU/IyAgkwo1jwDQHV\n" + "csaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+NwmNtd\n" + "dbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg\n" + "KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM\n" + "HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4\n" + "WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw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WhIstfTsEokt4YutUqKLsRixeT\n" + "mJlglFwjz1onl14LBQaTNx47aTbrqZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK\n" + "4SVhM7JZG+Ju1zdXtg2pEto=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00\n" + "MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286IxSR\n" + "/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNu\n" + "FoM7pmRLMon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXR\n" + "U7Ox7sWTaYI+FrUoRqHe6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+c\n" + "ra1AdHkrAj80//ogaX3T7mH1urPnMNA3I4ZyYUUpSFlob3emLoG+B01vr87ERROR\n" + "FHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3UVDmrJqMz6nWB2i3ND0/k\n" + "A9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f75li59wzw\n" + "eyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4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t/\n" + "ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx\n" + "NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv\n" + "bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49\n" + "AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA\n" + "VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku\n" + "WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP\n" + "MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX\n" + "5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ\n" + "ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg\n" + "h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority RSA R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNV\n" + "BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UE\n" + "CgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMB4XDTE3MDUzMTE4MTQzN1oXDTQy\n" + "MDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4G\n" + "A1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQD\n" + "DC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvq\n" + "M0fNTPl9fb69LT3w23jhhqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssuf\n" + "OePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7wcXHswxzpY6IXFJ3vG2fThVUCAtZJycxa\n" + "4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTOZw+oz12WGQvE43LrrdF9\n" + "HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+B6KjBSYR\n" + "aZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcA\n" + "b9ZhCBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rH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3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi\n" + "S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07\n" + "mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0\n" + "aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz\n" + "WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0\n" + "b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS\n" + "b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB\n" + "BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI\n" + "7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg\n" + "CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD\n" + "VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T\n" + "kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+\n" + "gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority RSA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz\n" + "OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv\n" + "bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2R\n" + "xFdHaxh3a3by/ZPkPQ/CFp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aX\n" + "qhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcC\n" + "C52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/geoeOy3ZExqysdBP+lSgQ3\n" + "6YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkpk8zruFvh\n" + "/l8lqjRYyMEjVJ0bmB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n2yIANwiieDhZNRnvDF5YTy7ykHN\n" + "XGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD\n" + "AgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsF\n" + "AAOCAQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw\n" + "8PRBEew/R40/cof5O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOG\n" + "nXkZ7/e7DDWQw4rtTw/1zBLZpD67oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCP\n" + "oky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul4+vJhaAlIDf7js4MNIThPIGy\n" + "d05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6+/NNIxuZMzSg\n" + "LvWpCz/UXeHPhJ/iGcJfitYgHuNztw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureSign RootCA11\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDEr\n" + "MCkGA1UEChMiSmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoG\n" + "A1UEAxMTU2VjdXJlU2lnbiBSb290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0\n" + "MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSswKQYDVQQKEyJKYXBhbiBDZXJ0aWZp\n" + "Y2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1cmVTaWduIFJvb3RD\n" + "QTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvLTJsz\n" + "i1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8\n" + "h9uuywGOwvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOV\n" + "MdrAG/LuYpmGYz+/3ZMqg6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9\n" + "UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rPO7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni\n" + "8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitAbpSACW22s293bzUIUPsC\n" + "h8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZXt94wDgYD\n" + "VR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB\n" + "AKChOBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xm\n" + "KbabfSVSSUOrTC4rbnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQ\n" + "X5Ucv+2rIrVls4W6ng+4reV6G4pQOh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWr\n" + "QbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01y8hSyn+B/tlr0/cR7SXf+Of5\n" + "pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061lgeLKBObjBmN\n" + "QSdJQO7e5iNEOdyhIta6A/I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureTrust CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI\n" + "MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x\n" + "FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4X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0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCsw\n" + "KaAnoCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsG\n" + "AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L\n" + "URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO\n" + "H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm\n" + "I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY\n" + "iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc\n" + "f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication RootCA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl\n" + "MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe\n" + "U2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoX\n" + "DTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRy\n" + "dXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3VyaXR5IENvbW11bmlj\n" + "YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV\n" + "OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr\n" + "zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM\n" + "VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ\n" + "hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO\n" + "ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw\n" + "awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs\n" + "OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF\n" + "coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc\n" + "okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8\n" + "t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy\n" + "1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/\n" + "SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY\n" + "MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t\n" + "dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjM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\n" + "\n"; + cert += + "# Sonera Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP\n" + "MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx\n" + "MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV\n" + "BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o\n" + "Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt\n" + "5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s\n" + "3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej\n" + "vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu\n" + "8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw\n" + "DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG\n" + "MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil\n" + "zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/\n" + "3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD\n" + "FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6\n" + "Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2\n" + "ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gRVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0y\n" + "MjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIg\n" + "TmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRlcmxhbmRlbiBFViBS\n" + "b290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkkSzrS\n" + "M4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nC\n" + "UiY4iKTWO0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3d\n" + "Z//BYY1jTw+bbRcwJu+r0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46p\n" + "rfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13l\n" + "pJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gVXJrm0w912fxBmJc+qiXb\n" + "j5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr08C+eKxC\n" + "KFhmpUZtcALXEPlLVPxdhk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OgftL2fiFX1ye8\n" + "FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGyeUN51q1veieQA6TqJIc/2b3Z6fJfUEkc\n" + "7uzXLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloX\n" + "DTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMCTkwxHjAcBgNVBAoMFVN0YWF0IGRl\n" + "ciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5lZGVybGFuZGVuIFJv\n" + "b3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4yolQP\n" + "cPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WW\n" + "IkYFsO2tx1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqX\n" + "xz8ecAgwoNzFs21v0IJyEavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFy\n" + "KJLZWyNtZrVtB0LrpjPOktvA9mxjeM3KTj215VKb8b475lRgsGYeCasH/lSJEULR\n" + "9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUurmkVLoR9BvUhTFXFkC4az\n" + "5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU51nus6+N8\n" + "6U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7\n" + "Ngzp07TKb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zDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM\n" + "94B7IWcnMFk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Services Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID7zCCAtegAwIBAgIBADANBgkqhkiG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I\n" + "bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB\n" + "ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z\n" + "qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n" + "iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n" + "0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n" + "sSi6\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Gold CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n" + "BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln\n" + "biBHb2xkIENBIC0gRzIwHhcNMDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBF\n" + "MQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMR8wHQYDVQQDExZT\n" + "d2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC\n" + "CgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUqt2/8\n" + "76LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+\n" + "bbqBHH5CjCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c\n" + "6bM8K8vzARO/Ws/BtQpgvd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqE\n" + "emA8atufK+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sywexcZdylU6oJxpmo/a\n" + "77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC\n" + "hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3\n" + "92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp\n" + "Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w\n" + "ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt\n" + "Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Silver CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE\n" + "BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWdu\n" + "IFNpbHZlciBDQSAtIEcyMB4XDTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0Nlow\n" + "RzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMY\n" + "U3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A\n" + "MIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644N0Mv\n" + "Fz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7br\n" + "YT7QbNHm+/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieF\n" + "nbAVlDLaYQ1HTWBCrpJH6INaU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qZ\n" + "IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8\n" + "aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X\n" + "em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR\n" + "dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/\n" + "OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+\n" + "hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy\n" + "tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgxMDAxMTA0MDE0WhcNMzMxMDAxMjM1\n" + "OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy\n" + "aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50\n" + "ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0G\n" + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUd\n" + "AqSzm1nzHoqvNK38DcLZSBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiC\n" + "FoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/FvudocP05l03Sx5iRUKrERLMjfTlH6VJi\n" + "1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx9702cu+fjOlbpSD8DT6Iavq\n" + "jnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGVWOHAD3bZ\n" + "wI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGj\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/\n" + "WSA2AHmgoCJrjNXyYdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhy\n" + "NsZt+U2e+iKo4YFWz827n+qrkRk4r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPAC\n" + "uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw\n" + "IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6\n" + "g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN\n" + "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" + "BSeOE6Fuwg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2Vz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7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT\n" + "91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml\n" + "e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p\n" + "TpPDpFQUWw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx\n" + "GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp\n" + "bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w\n" + "KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0\n" + "BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRpZmlrYXNpIC0gU3Vy\n" + "dW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYDVQQG\n" + "EwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXll\n" + "IEJpbGltc2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklU\n" + "QUsxLTArBgNVBAsTJEthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBT\n" + "TTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11IFNNIFNTTCBLb2sgU2VydGlmaWthc2kg\n" + "LSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr3UwM6q7\n" + "a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y86Ij5iySr\n" + "LqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INr\n" + "N3wcwv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2X\n" + "YacQuFWQfw4tJzh03+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/\n" + "iSIzL+aFCr2lqBs23tPcLG07xxO9WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4f\n" + "AJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQUZT/HiobGPN08VFw1+DrtUgxH\n" + "V8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh\n" + "AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPf\n" + "IPP54+M638yclNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4\n" + "lzwDGrpDxpa5RXI4s6ehlj2Re37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c\n" + "8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0jq5Rm+K37DwhuJi1/FwcJsoz7UMCf\n" + "lo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcx\n" + "EjAQBgNVBAoTCVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMT\n" + "VFd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AOCAgEAXzSBdu+WHdXltdkCY4QWwa6gcFGn90xHNcgL\n" + "1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn\n" + "LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WF\n" + "H6vPNOw/KP4M8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNo\n" + "RI2T9GRwoD2dKAXDOXC4Ynsg/eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+\n" + "nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlglPx4mI88k1HtQJAH32RjJMtOcQWh\n" + "15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryPA9gK8kxkRr05YuWW\n" + "6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3mi4TW\n" + "nsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5j\n" + "wa19hAM8EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWz\n" + "aGHQRiapIVJpLesux+t3zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmy\n" + "KwbQBM0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES\n" + "MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU\n" + "V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz\n" + "WhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJVEFJV0FO\n" + "LUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + "AQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFE\n" + "AcK0HMMxQhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HH\n" + "K3XLfJ+utdGdIzdjp9xCoi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeX\n" + "RfwZVzsrb+RH9JlF/h3x+JejiB03HFyP4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/z\n" + "rX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1ry+UPizgN7gr8/g+YnzAx\n" + "3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkq\n" + "hkiG9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeC\n" + "MErJk/9q56YAf4lCmtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdls\n" + "XebQ79NqZp4VKIV66IIArB6nCWlWQtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62D\n" + "lhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVYT0bf+215WfKEIlKuD8z7fDvn\n" + "aspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocnyYh0igzyXxfkZ\n" + "YiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Taiwan GRC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CWtFJaBYmOlXqYwZE8lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1Ud\n" + "DgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNVHRMEBTADAQH/MDkGBGcqBwAE\n" + "MTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg209yewDL7MTqK\n" + "UWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ\n" + "TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyf\n" + "qzvS/3WXy6TjZwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaK\n" + "ZEk9GhiHkASfQlK3T8v+R0F2Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFE\n" + "JPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlUD7gsL0u8qV1bYH+Mh6XgUmMqvtg7\n" + "hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6QzDxARvBMB1uUO07+1\n" + "EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+HbkZ6Mm\n" + "nD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WX\n" + "udpVBrkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz\n" + "ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe\n" + "LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl\n" + "pYYsfPQS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TeliaSonera Root CA v1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFODCCAyCgAwIBAgIRAJW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EwEB/wQFMAMBAf8wCwYD\n" + "VR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qWDNXr+nuqF+gTEjANBgkqhkiG\n" + "9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNmzqjMDfz1mgbl\n" + "dxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx\n" + "0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1Tj\n" + "TQpgcmLNkQfWpb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBed\n" + "Y2gea+zDTYa4EzAvXUYNR0PVG6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7\n" + "Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpcc41teyWRyu5FrgZLAMzTsVlQ2jqI\n" + "OylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOTJsjrDNYmiLbAJM+7\n" + "vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2qReW\n" + "t88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcn\n" + "HL/EVlP6Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVx\n" + "SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor ECA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1U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/uwyqNsatR5Nj3B5+1t4u/ukZMjgDfxT2\n" + "AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F\n" + "hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50\n" + "soIipX1TH0XsJ5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BI\n" + "WJZpTdwHjFGTot+fDz2LYLSCjaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1Wi\n" + "tJ/X5g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U\n" + "cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29y\n" + "IFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkxMjMxMTcyMzE2WjCB\n" + "pDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFuYW1h\n" + "IENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUG\n" + "A1UECwweVHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZU\n" + "cnVzdENvciBSb290Q2VydCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + "CgKCAQEAv463leLCJhJrMxnHQFgKq1mqjQCj/IDH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p\n" + "5KeXRKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu\n" + "1uwJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Trustis FPS Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBF\n" + "MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQL\n" + "ExNUcnVzdGlzIEZQUyBSb290IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTEx\n" + "MzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNVBAoTD1RydXN0aXMgTGltaXRlZDEc\n" + "MBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQAD\n" + "ggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQRUN+\n" + "AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihH\n" + "iTHcDnlkH5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjj\n" + "vSkCqPoc4Vu5g6hBSLwacY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA\n" + "0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zto3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlB\n" + "OrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEAAaNTMFEwDwYDVR0TAQH/\n" + "BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAdBgNVHQ4E\n" + "FgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01\n" + "GX2cGE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmW\n" + "zaD+vkAMXBJV+JOCyinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP4\n" + "1BIy+Q7DsdwyhEQsb8tGD+pmQQ9P8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZE\n" + "f1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHVl/9D7S3B2l0pKoU/rGXuhg8F\n" + "jZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYliB6XzCGcKQEN\n" + "ZetX2fNXlrtIzYE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Extended Validation Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBF\n" + "eHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMx\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNV\n" + "BAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrsiWog\n" + "D4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvS\n" + "sPGP2KxFRv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aop\n" + "O2z6+I9tTcg1367r3CTueUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dk\n" + "sHYf5BA1FxvyDr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A83vbsea0rWBmirSwiGpWO\n" + "vpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2C\n" + "xR9GUeOcGMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx\n" + "cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM\n" + "fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Global G2 Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH\n" + "bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0x\n" + "CzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlUcnVzdDEbMBkGA1UEAwwSVUNBIEds\n" + "b2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxeYr\n" + "b3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmToni9\n" + "kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzm\n" + "VHqUwCoV8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/R\n" + "VogvGjqNO7uCEeBHANBSh6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDc\n" + "C/Vkw85DvG1xudLeJ1uK6NjGruFZfc8oLTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIj\n" + "tm+3SJUIsUROhYw6AlQgL9+/V087OpAh18E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g7RE+xygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGy\n" + "YiGqhkCyLmTTX8jjfhFnRR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bX\n" + "UB+K+wb1whnw0A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + "VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo\n" + "I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng\n" + "o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G\n" + "A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB\n" + "zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW\n" + "RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB\n" + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw\n" + "MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV\n" + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU\n" + "aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B\n" + "3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY\n" + "tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/\n" + "Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2\n" + "VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47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\n" + "qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB\n" + "VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB\n" + "L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n" + "jjxDah2nGN59PRbxYvnKkKj9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjELMAkG\n" + "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJp\n" + "U2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwg\n" + "SW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2ln\n" + "biBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5\n" + "IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8Utpkmw4tXNherJI9/gHm\n" + "GUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGzrl0Bp3ve\n" + "fLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUw\n" + "AwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJ\n" + "aW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYj\n" + "aHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMW\n" + "kf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMDA2gAMGUCMGYhDBgmYFo4e1ZC\n" + "4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIxAJw9SDkjOVga\n" + "FRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\n" + "ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU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1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y\n" + "5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Universal Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB\n" + "vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MTgwNgYDVQQDEy9W\n" + "ZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJVUzEX\n" + "MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0\n" + "IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9y\n" + "IGF1dGhvcml6ZWQgdXNlIG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNh\n" + "bCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MI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vvBZIGcfK4mJO3\n" + "7M2CYfE45k+XmCpajQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Verisign Class 3 Public Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw\n" + "CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl\n" + "cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu\n" + "LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT\n" + "aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp\n" + "dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD\n" + "VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT\n" + "aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ\n" + "bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu\n" + "IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg\n" + "LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b\n" + "N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t\n" + "KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu\n" + "kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm\n" + "CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ\n" + "Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu\n" + "imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te\n" + "2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe\n" + "DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC\n" + "/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p\n" + "F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt\n" + "TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# XRamp Global CA Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB\n" + "gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk\n" + "MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY\n" + "UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx\n" + "NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3\n" + "dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2Vy\n" + "dm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uqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ\n" + "O+7ETPTsJ3xCwnR8gooJybQDJbw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# certSIGN ROOT CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYT\n" + "AlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBD\n" + "QTAeFw0wNjA3MDQxNzIwMDRaFw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJP\n" + "MREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTCC\n" + "ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7IJUqOtdu0KBuqV5Do\n" + "0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHHrfAQ\n" + "UySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5d\n" + "RdY4zTW2ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQ\n" + "OA7+j0xbm0bqQfWwCHTD0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwv\n" + "JoIQ4uNllAoEwF73XVv4EOLQunpL+943AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08C\n" + "AwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAcYwHQYDVR0O\n" + "BBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IBAQA+0hyJ\n" + "LjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecY\n" + "MnQ8SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ\n" + "44gx+FkagQnIl6Z0x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6I\n" + "Jd1hJyMctTEHBDa0GpC9oHRxUIltvBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNw\n" + "i/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7NzTogVZ96edhBiIL5VaZVDADlN\n" + "9u6wWk5JRFRYX0KD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ePKI Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe\n" + "MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0\n" + "ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMxMjdaMF4xCzAJBgNVBAYTAlRXMSMw\n" + "IQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEqMCgGA1UECwwhZVBL\n" + "SSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEF\n" + "AAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAH\n" + "SyZbCUNsIZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAh\n" + "ijHyl3SJCRImHJ7K2RKilTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3X\n" + "DZoTM1PRYfl61dd4s5oz9wCGzh1NlDivqOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1\n" + "TBnsZfZrxQWh7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FFLLk3dheLSClIKF5r8GrBQAuUB\n" + "o2M3IUxExJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS\n" + "/jQ6fbjpKdx2qcgw+BRxgMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z\n" + "Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE\n" + "W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D\n" + "hNQ+IIX3Sj0rnP0qCglN6oH4EZw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - C3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG\n" + "EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx\n" + "IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND\n" + "IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci\n" + "MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti\n" + "sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O\n" + "BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\n" + "Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c\n" + "3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J\n" + "0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n" + "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n" + "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n" + "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n" + "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n" + "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n" + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n" + "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n" + "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n" + "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n" + "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n" + "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n" + "+JbNR6iC8hZVdyR+EhCVBCyj\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - C1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkG\n" + "A1UEBhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEg\n" + "SW5jMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNpZ24gUm9v\n" + "dCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+upufGZ\n" + "BczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZ\n" + "HdPIWoU/Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH\n" + "3DspVpNqs8FqOp099cGXOFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvH\n" + "GPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4VI5b2P/AgNBbeCsbEBEV5f6f9vtKppa+c\n" + "xSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleoomslMuoaJuvimUnzYnu3Yy1\n" + "aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+XJGFehiq\n" + "TbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87\n" + "/kOXSTKZEhVb3xEp/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4\n" + "kqNPEjE2NuLe/gDEo2APJ62gsIq1NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrG\n" + "YQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT\n" + "+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo\n" + "WXzhriKi4gp6D/piq1JM4fHfyr6DDUI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - G1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD\n" + "VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU\n" + "ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH\n" + "MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO\n" + "MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv\n" + "Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN\n" + "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz\n" + "f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO\n" + "8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq\n" + "d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM\n" + "tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt\n" + "Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB\n" + "o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD\n" + "AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x\n" + "PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM\n" + "wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d\n" + "GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH\n" + "6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby\n" + "RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx\n" + "iN66zB+Afko=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB\n" + "qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV\n" + "BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw\n" + "NzE2MjM1OTU5WjCBqTELMAkGA1UEBh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09Y/\n" + "LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7\n" + "jVaMaA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp\n" + "IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi\n" + "BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw\n" + "MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh\n" + "d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig\n" + "YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v\n" + "dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/\n" + "BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6\n" + "papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K\n" + "DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3\n" + "KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox\n" + "XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCB\n" + "rjELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNV\n" + "BAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0wODA0MDIwMDAwMDBa\n" + "Fw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhhd3Rl\n" + "LCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9u\n" + "MTgwNgYDVQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXpl\n" + "ZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEcz\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr8nLPvb2FvdeHsbnndm\n" + "gcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2AtP0LMqmsywCPLLEHd5N/8\n" + "YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC+BsUa0Lf\n" + "b1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS9\n" + "9irY7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2S\n" + "zhkGcuYMXDhpxwTWvGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUk\n" + "OQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" + "HQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJKoZIhvcNAQELBQADggEBABpA\n" + "2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweKA3rD6z8KLFIW\n" + "oCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu\n" + "t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7c\n" + "KUGRIjxpp7sC8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fM\n" + "m7v/OeZWYdMKp8RcTGB7BXcmer/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZu\n" + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + + static_cast( + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); + if (ec) { + return; + } +} + +} // namespace detail + +// Load the root certificates into an ssl::context + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); +} + +inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); + if (ec) { + throw boost::system::system_error{ec}; + } +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/common/server_certificate.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/common/server_certificate.hpp new file mode 100644 index 0000000..ef15c16 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/common/server_certificate.hpp @@ -0,0 +1,138 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP + +#include +#include +#include +#include + +/* Load a signed certificate into the ssl context, and configure + the context for use with a server. + + For this to work with the browser or operating system, it is + necessary to import the "Beast Test CA" certificate into + the local certificate store, browser, or operating system + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. +*/ +inline void load_server_certificate(boost::asio::ssl::context& ctx) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { + ctx.use_certificate_chain_file(path); + ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), + boost::asio::ssl::context::pem); + return; + } + + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 + openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj + "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = + "-----BEGIN CERTIFICATE-----\n" + "MIIDlTCCAn2gAwIBAgIUOLxr3q7Wd/pto1+2MsW4fdRheCIwDQYJKoZIhvcNAQEL\n" + "BQAwWjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRQwEgYDVQQHDAtMb3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/kJLoppPqL0EE49uwyYQ1dKhXS2hk+IIfA9mBn8eAFb/0435A2fXutds\n" + "qhvwIOmAObCzcoKkz3sChbk4ToUTqbC0TmFAXI5Upz1wnADzjpbJrpegCA3pmvhT\n" + "7356drqnCGY9\n" + "-----END CERTIFICATE-----\n"; + + std::string const key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz0GwgnxSBhygx\n" + "BdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOTLppr5MKxqQHEpYdyDYGD1noBoz4T\n" + "iIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05P41c2F9pBEnUwUxIUG1Cb6AN0cZW\n" + "F/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATmWm9SJc2lsjWptbyIN6hFXLYPXTwn\n" + "YzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7rV+AiGTxUU35V0AzpJlmvct5aJV/\n" + "5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4lIzJ8yxzOzSStBPxvdrOobSSNlRZ\n" + "IlE7gnyNAgMBAAECggEAY0RorQmldGx9D7M+XYOPjsWLs1px0cXFwGA20kCgVEp1\n" + "kleBeHt93JqJsTKwOzN2tswl9/ZrnIPWPUpcbBlB40ggjzQk5k4jBY50Nk2jsxuV\n" + "9A9qzrP7AoqhAYTQjZe42SMtbkPZhEeOyvCqxBAi6csLhcv4eB4+In0kQo7dfvLs\n" + "Xu/3WhSsuAWqdD9EGnhD3n+hVTtgiasRe9318/3R9DzP+IokoQGOtXm+1dsfP0mV\n" + "8XGzQHBpUtJNn0yi6SC4kGEQuKkX33zORlSnZgT5VBLofNgra0THd7x3atOx1lbr\n" + "V0QizvCdBa6j6FwhOQwW8UwgOCnUbWXl/Xn4OaofMQKBgQDdRXSMyys7qUMe4SYM\n" + "Mdawj+rjv0Hg98/xORuXKEISh2snJGKEwV7L0vCn468n+sM19z62Axz+lvOUH8Qr\n" + "hLkBNqJvtIP+b0ljRjem78K4a4qIqUlpejpRLw6a/+44L76pMJXrYg3zdBfwzfwu\n" + "b9NXdwHzWoNuj4v36teGP6xOUwKBgQDQCT52XX96NseNC6HeK5BgWYYjjxmhksHi\n" + "stjzPJKySWXZqJpHfXI8qpOd0Sd1FHB+q1s3hand9c+Rxs762OXlqA9Q4i+4qEYZ\n" + "qhyRkTsl+2BhgzxmoqGd5gsVT7KV8XqtuHWLmetNEi+7+mGSFf2iNFnonKlvT1JX\n" + "4OQZC7ntnwKBgH/ORFmmaFxXkfteFLnqd5UYK5ZMvGKTALrWP4d5q2BEc7HyJC2F\n" + "+5lDR9nRezRedS7QlppPBgpPanXeO1LfoHSA+CYJYEwwP3Vl83Mq/Y/EHgp9rXeN\n" + "L+4AfjEtLo2pljjnZVDGHETIg6OFdunjkXDtvmSvnUbZBwG11bMnSAEdAoGBAKFw\n" + "qwJb6FNFM3JnNoQctnuuvYPWxwM1yjRMqkOIHCczAlD4oFEeLoqZrNhpuP8Ij4wd\n" + "GjpqBbpzyVLNP043B6FC3C/edz4Lh+resjDczVPaUZ8aosLbLiREoxE0udfWf2dU\n" + "oBNnrMwwcs6jrRga7Kr1iVgUSwBQRAxiP2CYUv7tAoGBAKdPdekPNP/rCnHkKIkj\n" + "o13pr+LJ8t+15vVzZNHwPHUWiYXFhG8Ivx7rqLQSPGcuPhNss3bg1RJiZAUvF6fd\n" + "e6QS4EZM9dhhlO2FmPQCJMrRVDXaV+9TcJZXCbclQnzzBus9pwZZyw4Anxo0vmir\n" + "nOMOU6XI4lO9Xge/QDEN4Y2R\n" + "-----END PRIVATE KEY-----\n"; + + std::string const dh = + "-----BEGIN DH PARAMETERS-----\n" + "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" + "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" + "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" + "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; + + ctx.set_password_callback( + [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + + ctx.set_options(boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + + ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + + ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), + boost::asio::ssl::context::file_format::pem); + + ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/http_examples.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/http_examples.hpp new file mode 100644 index 0000000..74cade2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/http_examples.hpp @@ -0,0 +1,949 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include + +/* This file contains the functions and classes found in the documentation + + They are compiled and run as part of the unit tests, so you can copy + the code and use it in your own projects as a starting point for + building a network application. +*/ + +// The documentation assumes the webcpp::beast::http namespace + +namespace boost::beast::http { + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_http_send_expect_100_continue + +/** Send a request with Expect: 100-continue + + This function will send a request with the Expect: 100-continue + field by first sending the header, then waiting for a successful + response from the server before continuing to send the body. If + a non-successful server response is received, the function + returns immediately. + + @param stream The remote HTTP server stream. + + @param buffer The buffer used for reading. + + @param req The request to send. This function modifies the object: + the Expect header field is inserted into the message if it does + not already exist, and set to "100-continue". + + @param ec Set to the error, if any occurred. +*/ +template +void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, + request>& req, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); + + // Create the serializer + request_serializer> sr{req}; + + // Send just the header + write_header(stream, sr, ec); + if (ec) { + return; + } + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); + if (ec) { + return; + } + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; + } + } + + // Server is OK with the request, send the body + write(stream, sr, ec); +} + +//] + +//[example_http_receive_expect_100_continue + +/** Receive a request, handling Expect: 100-continue if present. + + This function will read a request from the specified stream. + If the request contains the Expect: 100-continue field, a + status response will be delivered. + + @param stream The remote HTTP client stream. + + @param buffer The buffer used for reading. + + @param ec Set to the error, if any occurred. +*/ +template +void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); + if (ec) { + return; + } + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); + if (ec) { + return; + } + } + + // Read the rest of the message. + // + read(stream, buffer, parser, ec); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Send Child Process Output +// +//------------------------------------------------------------------------------ + +//[example_http_send_cgi_response + +/** Send the output of a child process as an HTTP response. + + The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. + + @param input A stream to read the child process output from. + + @param output A stream to write the HTTP response to. + + @param ec Set to the error, if any occurred. +*/ +template +void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. + response res; + + res.result(status::ok); + res.version(11); + res.set(field::server, "Beast"); + res.set(field::transfer_encoding, "chunked"); + + // No data yet, but we set more = true to indicate + // that it might be coming later. Otherwise the + // serializer::is_done would return true right after + // sending the header. + res.body().data = nullptr; + res.body().more = true; + + // Create the serializer. + response_serializer sr{res}; + + // Send the header immediately. + write_header(output, sr, ec); + if (ec) { + return; + } + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process + std::array buffer{}; + auto bytes_transferred = input.read_some(boost::asio::buffer(buffer), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer + res.body().data = nullptr; + + // `false` means no more data is coming + res.body().more = false; + } else { + if (ec) { + return; + } + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming + res.body().data = buffer.data(); + res.body().size = bytes_transferred; + res.body().more = true; + } + + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. + if (ec == error::need_buffer) { + ec = {}; + continue; + } + if (ec) { + return; + } + } while (!sr.is_done()); +} + +//] + +//-------------------------------------------------------------------------- +// +// Example: HEAD Request +// +//-------------------------------------------------------------------------- + +//[example_http_do_head_response + +/** Handle a HEAD request for a resource. + */ +template +void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; + + // Read the request + request req; + read(stream, buffer, req, ec); + if (ec) { + return; + } + + // Set up the response, starting with the common fields + response res; + res.version(11); + res.set(field::server, "test"); + + // Now handle request-specific fields + switch (req.method()) { + case verb::head: + case verb::get: { + // A HEAD request is handled by delivering the same + // set of headers that would be sent for a GET request, + // including the Content-Length, except for the body. + res.result(status::ok); + res.content_length(payload.size()); + + // For GET requests, we include the body + if (req.method() == verb::get) { + // We deliver the same payload for GET requests + // regardless of the target. A real server might + // deliver a file based on the target. + res.body() = payload; + } + break; + } + + default: { + // We return responses indicating an error if + // we do not recognize the request method. + res.result(status::bad_request); + res.set(field::content_type, "text/plain"); + res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; + res.prepare_payload(); + break; + } + } + + // Send the response + write(stream, res, ec); + if (ec) { + return; + } +} + +//] + +//[example_http_do_head_request + +/** Send a HEAD request for a resource. + + This function submits a HEAD request for the specified resource + and returns the response. + + @param res The response. This is an output parameter. + + @param stream The synchronous stream to use. + + @param buffer The buffer to use. + + @param target The request target. + + @param ec Set to the error, if any occurred. + + @throws std::invalid_argument if target is empty. +*/ +template +response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, + error_code& ec) { + // Do some type checking to be a good citizen + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. + if (target.empty()) { + throw std::invalid_argument("target may not be empty"); + } + + // Build the HEAD request for the target + request req; + req.version(11); + req.method(verb::head); + req.target(target); + req.set(field::user_agent, "test"); + + // A client MUST send a Host header field in all HTTP/1.1 request messages. + // https://tools.ietf.org/html/rfc7230#section-5.4 + req.set(field::host, "localhost"); + + // Now send it + write(stream, req, ec); + if (ec) { + return {}; + } + + // Create a parser to read the response. + // We use the `empty_body` type since + // a response to a HEAD request MUST NOT + // include a body. + response_parser p; + + // Inform the parser that there will be no body. + p.skip(true); + + // Read the message. Even though fields like + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); + if (ec) { + return {}; + } + + // Transfer ownership of the response to the caller. + return p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: HTTP Relay +// +//------------------------------------------------------------------------------ + +//[example_http_relay + +/** Relay an HTTP message. + + This function efficiently relays an HTTP message from a downstream + client to an upstream server, or from an upstream server to a + downstream client. After the message header is read from the input, + a user provided transformation function is invoked which may change + the contents of the header before forwarding to the output. This may + be used to adjust fields such as Server, or proxy fields. + + @param output The stream to write to. + + @param input The stream to read from. + + @param buffer The buffer to use for the input. + + @param transform The header transformation to apply. The function will + be called with this signature: + @code + template + void transform(message< + isRequest, Body, Fields>&, // The message to transform + error_code&); // Set to the error, if any + @endcode + + @param ec Set to the error if any occurred. + + @tparam isRequest `true` to relay a request. + + @tparam Fields The type of fields to use for the message. +*/ +template +void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, + Transform&& transform) { + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + std::array buf{}; + + // Create a parser with a buffer body to read from the input. + parser p; + + // Create a serializer from the message contained in the parser. + serializer sr{p.get()}; + + // Read just the header from the input + read_header(input, buffer, p, ec); + if (ec) { + return; + } + + // Apply the caller's header transformation + transform(p.get(), ec); + if (ec) { + return; + } + + // Send the transformed message to the output + write_header(output, sr, ec); + if (ec) { + return; + } + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf.data(); + p.get().body().size = buf.size(); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) { + ec = {}; + } + if (ec) { + return; + } + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = buf.size() - p.get().body().size; + p.get().body().data = buf.data(); + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } + + // Write everything in the buffer (which might be empty) + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) { + ec = {}; + } + if (ec) { + return; + } + } while (!p.is_done() && !sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Serialize to std::ostream +// +//------------------------------------------------------------------------------ + +//[example_http_write_ostream + +// The detail namespace means "not public" +namespace detail { + +// This helper is needed for C++11. +// When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +template +class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + +public: + write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer + template + void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + + // Keep a running total of how much we wrote + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence + for (auto it = boost::asio::buffer_sequence_begin(buffers); + it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream + if (buffer.size() > + static_cast(std::numeric_limits::max())) { + ec = make_error_code(errc::value_too_large); + return; + } + os_.write(reinterpret_cast(buffer.data()), + static_cast(buffer.size())); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } + + // Adjust our running total + bytes_transferred += buffer_size(buffer); + } + + // Inform the serializer of the amount we consumed + sr_.consume(bytes_transferred); + } +}; + +} // namespace detail + +/** Write a message to a `std::ostream`. + + This function writes the serialized representation of the + HTTP/1 message to the sream. + + @param os The `std::ostream` to write to. + + @param msg The message to serialize. + + @param ec Set to the error, if any occurred. +*/ +template +void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; + do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); + if (ec) { + return; + } + } while (!sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Parse from std::istream +// +//------------------------------------------------------------------------------ + +//[example_http_read_istream + +/** Read a message from a `std::istream`. + + This function attempts to parse a complete HTTP/1 message from the stream. + + @param is The `std::istream` to read from. + + @param buffer The buffer to use. + + @param msg The message to store the result. + + @param ec Set to the error, if any occurred. +*/ +template +void read_istream(std::istream& is, basic_flat_buffer& buffer, + message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are + // forwarded to the message constructor. Here, we use + // a move construction in case the caller has constructed + // their message in a non-default way. + // + parser p{std::move(msg)}; + + do { + // Extract whatever characters are presently available in the istream + if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream + buffer.commit( + static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); + } else if (buffer.size() == 0) { + // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream + if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + + // Try to get more from the istream. This might block. + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. + if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; + } + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); + if (ec) { + return; + } + break; + } + } + + // Write the data to the parser + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. + if (ec == error::need_more) { + ec = {}; + } + if (ec) { + return; + } + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); + } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Deferred Body Type +// +//------------------------------------------------------------------------------ + +//[example_http_defer_body + +/** Handle a form POST request, choosing a body type depending on the Content-Type. + + This reads a request from the input stream. If the method is POST, and + the Content-Type is "application/x-www-form-urlencoded " or + "multipart/form-data", a `string_body` is used to receive and store + the message body. Otherwise, a `dynamic_body` is used to store the message + body. After the request is received, the handler will be invoked with the + request. + + @param stream The stream to read from. + + @param buffer The buffer to use for reading. + + @param handler The handler to invoke when the request is complete. + The handler must be invokable with this signature: + @code + template + void handler(request&& req); + @endcode + + @throws system_error Thrown on failure. +*/ +template +void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + + // Read just the header. Otherwise, the empty_body + // would generate an error if body octets were received. + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb + if (req0.get().method() == verb::post && + (req0.get()[field::content_type] == "application/x-www-form-urlencoded" || + req0.get()[field::content_type] == "multipart/form-data")) { + request_parser req{std::move(req0)}; + read(stream, buffer, req); + handler(req.release()); + } else { + request_parser req{std::move(req0)}; + read(stream, buffer, req); + handler(req.release()); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Incremental Read +// +//------------------------------------------------------------------------------ + +//[example_incremental_read + +/* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. +*/ +template +void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); + if (ec) { + return; + } + while (!p.is_done()) { + std::array buf{}; + p.get().body().data = buf.data(); + p.get().body().size = buf.size(); + read(stream, buffer, p, ec); + if (ec == error::need_buffer) { + ec = {}; + } + if (ec) { + return; + } + os.write(buf.data(), static_cast(buf.size() - p.get().body().size)); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Read large response body +// +//------------------------------------------------------------------------------ + +//[example_read_large_response_body + +/* This function uses custom size limit of the resposne body. + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. +*/ +template +std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, + message>& msg, + std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); + if (ec) { + return bytes_transferred; + } + msg = p.release(); + return bytes_transferred; +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_chunk_parsing + +/** Read a message with a chunked body and print the chunks and extensions + */ +template +void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); + if (ec) { + return; + } + + // This container will hold the extensions for each chunk + chunk_extensions ce; + + // This string will hold the body of each chunk + std::string chunk; + + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = + [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk + string_view extensions, // The raw chunk-extensions string. Already validated. + error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); + if (ev) { + return; + } + + // See if the chunk is too big + if (size > std::numeric_limits::max()) { + ev = error::body_limit; + return; + } + + // Make sure we have enough storage, and + // reset the container for the upcoming chunk + chunk.reserve(static_cast(size)); + chunk.clear(); + }; + + // Set the callback. The function requires a non-const reference so we + // use a local variable, since temporaries can only bind to const refs. + p.on_chunk_header(header_cb); + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. + auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk + string_view body, // A buffer holding chunk body data + error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. + if (remain == body.size()) { + ec = error::end_of_chunk; + } + + // Append this piece to our container + chunk.append(body.data(), body.size()); + + // The return value informs the parser of how much of the body we + // consumed. We will indicate that we consumed everything passed in. + return body.size(); + }; + p.on_chunk_body(body_cb); + + while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); + if (!ec) { + continue; + } + if (ec != error::end_of_chunk) { + return; + } + ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; + if (!extension.second.empty()) { + os << " = " << extension.second << '\n' << std::flush; + } else { + os << '\n' << std::flush; + } + } + + // Now print the chunk body + os << "Chunk Body: " << chunk << '\n' << std::flush; + } + + // Get a reference to the parsed message, this is for convenience + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it + for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << '\n' << std::flush; + continue; + } + os << it->name() << ": " << it->value() << '\n' << std::flush; + } +} + +//] + +} // namespace boost::beast::http diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/ssl/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/ssl/client.cpp new file mode 100644 index 0000000..d127f81 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/ssl/client.cpp @@ -0,0 +1,138 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } + } +} + +net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) + if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set a callback to verify that the hostname in the server + // certificate matches the expected value + stream.set_verify_callback(ssl::host_name_verification("localhost")); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request + http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); + + // Read the response + beast::flat_buffer buf; + http::response res; + co_await http::async_read(stream, buf, res); + + // Print the response body + std::cout << res.body(); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); + } +} + +} // namespace + +int main() { + try { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful + ctx.set_verify_mode(ssl::verify_peer); + + // The servers's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Client certificate and private key (if server request for). + ctx.use_certificate_chain_file("client.crt"); + ctx.use_private_key_file("client.key", ssl::context::pem); + + net::co_spawn(ioc, request(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/ssl/server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/ssl/server.cpp new file mode 100644 index 0000000..e1f3c48 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/doc/ssl/server.cpp @@ -0,0 +1,132 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } + } +} + +net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + + // Read and discard a request + beast::flat_buffer buf; + http::request req; + co_await http::async_read(stream, buf, req); + + // Write the response + http::response res; + res.body() = "Hello!"; + co_await http::async_write(stream, res); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); + } +} + +net::awaitable acceptor(ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), + print_exception); + } +} + +} // namespace + +int main() { + try { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. + // Asio exposes the OpenSSL verification bitmask as signed integer constants. + // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Server certificate and private key. + ctx.use_certificate_chain_file("server.crt"); + ctx.use_private_key_file("server.key", ssl::context::pem); + + // DH parameters for DHE-based cipher suites + ctx.use_tmp_dh_file("dh4096.pem"); + + net::co_spawn(ioc, acceptor(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/echo-op/echo_op.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/echo-op/echo_op.cpp new file mode 100644 index 0000000..0b5f115 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/echo-op/echo_op.cpp @@ -0,0 +1,381 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; +namespace beast = webcpp::beast; + +namespace { + +//[example_core_echo_op_1 + +template +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] + -> net::async_result, void(beast::error_code)>::return_type; + +//------------------------------------------------------------------------------ + +//[example_core_echo_op_2 + +/** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending + in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + + - A line was read in and written back on the stream + + - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` + and `async_write_some` function. The program must ensure that no + other reads or writes are performed until this operation completes. + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the + first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the + requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is + responsible for ensuring that the lifetime of this object is + extended least until the completion handler is invoked. + + @param token The handler to be called when the operation completes. + The implementation takes ownership of the handler by performing a decay-copy. + The handler must be invocable with this signature: + @code + void handler( + beast::error_code error // Result of operation. + ); + @endcode + + Regardless of whether the asynchronous operation completes immediately or + not, the handler will not be invoked from within this function. Invocation + of the handler will be performed in a manner equivalent to using + `net::post`. +*/ +template +// Each documentation snippet presents the complete public declaration. +// NOLINTNEXTLINE(readability-redundant-declaration) +auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ + CompletionToken&& token) + -> net::async_result*/ + std::decay_t, + void(beast::error_code) /*< The completion handler signature goes here >*/ + >::return_type; +//] + +//[example_core_echo_op_3 + +template +class echo_op; + +// This example uses the Asio's stackless "fauxroutines", implemented +// using a macro-based solution. It makes the code easier to write and +// easier to read. This include file defines the necessary macros and types. +#include + +// Read a line and echo it back +// +template +// Stackless coroutine macros generate the branches in this operation. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + -> net::async_result, + void(beast::error_code)>::return_type /*< The completion handler + signature goes here >*/ +{ + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. + static_assert(beast::is_async_stream::value, + "AsyncStream type requirements not met"); + static_assert(net::is_dynamic_buffer::value, + "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, + // and creates the `async_result` object which becomes the + // return value of this initiating function. + + net::async_completion init(token); + + // The helper macro BOOST_ASIO_HANDLER_TYPE converts the completion + // token type into a concrete handler type of the correct signature. + + using handler_type = BOOST_ASIO_HANDLER_TYPE(CompletionToken, void(beast::error_code)); + + // The class template `async_base` holds the caller's completion + // handler for us, and provides all of the boilerplate for forwarding + // the associated allocator and associated executor from the caller's + // handler to our operation. It also maintains a `net::executor_work_guard` + // for the executor associated with the stream. This work guard is + // inexpensive, and prevents the execution context from running out + // of work. It is usually necessary although rarely it can be skipped + // depending on the operation (this echo example needs it because it + // performs more than one asynchronous operation in a row). + // We declare this type alias to make the code easier to read. + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ + beast::executor_type /*< The type of executor used by the stream to dispatch + asynchronous operations >*/ + >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + + // Asio operation state combines completion ownership with coroutine resume state. + // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream_state; + DynamicBuffer& buffer_state; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( + std::move( + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , + stream_state(stream), + buffer_state(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our + // asynchronous control flow. + (*this)({}, 0, false); + } + + // If a newline is present in the buffer sequence, this function returns + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + + static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + + const auto begin = + net::buffers_iterator::begin(buffers); + const auto end = + net::buffers_iterator::end(buffers); + const auto result = std::find(begin, end, '\n'); + + if (result == end) { + return 0; // not found + } + + return result + 1 - begin; + } + + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + + // Resume labels generated by the stackless coroutine form one state machine. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + + reenter(*this) { + for (;;) { + // Resume labels cannot cross an initialized local; it is assigned before use. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer_state.data()); + + // If we don't have the newline, then read more + if (pos == 0) { + // Resume labels cannot cross an initialized local; it is assigned before + // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, + buffer_state.capacity() - buffer_state.size()), + std::min(65536, // and over 65536 is too much. + buffer_state.max_size() - buffer_state.size())); + + // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + + yield stream_state.async_read_some(buffer_state.prepare(bytes_to_read), + std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. + + // Move the bytes read from the writable area to the + // readable area. + + buffer_state.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. + if (ec) { + break; + } + + // Keep looping until we get the newline + continue; + } + + // We have our newline, so send the first `pos` bytes of the + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + + yield net::async_write(stream_state, + beast::buffers_prefix(pos, buffer_state.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, + // and the `reenter` statement above will cause control to jump + // to the following line. The variable `pos` is no longer valid + // (remember that we returned from the function using `yield` above) + // but we can use `bytes_transferred` to know how much of the buffer + // to consume. With "real" coroutines this will be easier and more + // natural. + + buffer_state.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. + + break; + } + + // When a composed operation completes immediately, it must not + // directly invoke the completion handler otherwise it could + // lead to unfairness, starvation, or stack overflow. Therefore, + // if cont == false (meaning, that the call stack still includes + // the frame of the initiating function) then we need to use + // `net::post` to cause us to be called again after the initiating + // function. The function `async_base::invoke` takes care of + // calling the final completion handler, using post if the + // first argument is false, otherwise invoking it directly. + + this->complete(cont, ec); + } + } + }; + + // Create the composed operation and launch it. This is a constructor + // call followed by invocation of operator(). We use BOOST_ASIO_HANDLER_TYPE + // to convert the completion token into the correct handler type, + // allowing user-defined specializations of the async_result template + // to be used. + + echo_op(stream, buffer, std::move(init.completion_handler)); + + // This hook lets the caller see a return value when appropriate. + // For example this might return std::future if + // CompletionToken is net::use_future, or this might + // return an error code if CompletionToken specifies a coroutine. + + return init.result.get(); +} + +// Including this file undefines the macros used by the stackless fauxroutines. +#include + +//] + +struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { + if (ec) { + std::cerr << ": " << ec.message() << '\n'; + } + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" + << "Example:\n" + << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; + const endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); + acceptor.listen(); + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); + ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-local/http_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-local/http_client_async_local.cpp new file mode 100644 index 0000000..50cbf6e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-local/http_client_async_local.cpp @@ -0,0 +1,183 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* target, + int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, std::string{host} + ":" + port); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { + std::cerr << "Usage: http-client-async-local []\n" + << "Example:\n" + << " http-client-async-local /tmp/http.sock localhost 80 /\n" + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const* const host = argv[2]; + auto const* const port = argv[3]; + auto const* const target = argv[4]; + int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..1652f15 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,254 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor()), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..0bce32f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,251 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..dd5bc53 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/async/http_client_async.cpp @@ -0,0 +1,194 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..531734f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,198 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include "common/root_certificates.hpp" + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && ec != net::ssl::error::stream_truncated) { + throw boost::system::system_error(ec, "shutdown"); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..6a1b1a7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,154 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/body/json_body.hpp new file mode 100644 index 0000000..211d74b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/body/json_body.hpp @@ -0,0 +1,119 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(webcpp::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(webcpp::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/body/json_client.cpp new file mode 100644 index 0000000..0185145 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/body/json_client.cpp @@ -0,0 +1,75 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "json_body.hpp" + +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/coro-ssl/http_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/coro-ssl/http_client_coro_ssl.cpp new file mode 100644 index 0000000..00bcc7c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -0,0 +1,238 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, ssl::context& ctx, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream.async_shutdown(yield[ec]); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro-ssl []\n" + << "Example:\n" + << " http-client-coro-ssl www.example.com 443 /\n" + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/coro/http_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/coro/http_client_coro.cpp new file mode 100644 index 0000000..f6d84e4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/coro/http_client_coro.cpp @@ -0,0 +1,188 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro []\n" + << "Example:\n" + << " http-client-coro www.example.com 80 /\n" + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..9addcb9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/http_crawl.cpp @@ -0,0 +1,340 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, webcpp::asio::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Create and launch the worker threads. + std::vector workers; + workers.reserve(threads + 1); + for (int i = 0; i < threads; ++i) { + // Each worker will eventually add some data to the aggregated + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto reporting_work = + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + net::require(ioc.get_executor(), net::execution::outstanding_work.tracked); + + workers.emplace_back([&report, reporting_work] { + // We use a separate io_context for each worker because + // the asio resolver simulates asynchronous operation using + // a dedicated worker thread per io_context, and we want to + // do a lot of name resolutions in parallel. + webcpp::asio::io_context ioc; + std::make_shared(report, ioc)->run(); + ioc.run(); // lint-run: drives the application's network operations + }); + } + + // Add another thread to run the main io_context which + // is used to aggregate the statistics + workers.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + + // Now block until all threads exit + for (auto& worker : workers) { + worker.join(); + } + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..8286e24 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..c1d4a98 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..23aff1a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/methods/http_client_methods.cpp @@ -0,0 +1,213 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..b8f5ec8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,152 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + throw beast::system_error{ec}; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..db3a8c9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/client/sync/http_client_sync.cpp @@ -0,0 +1,119 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async-local/http_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async-local/http_server_async_local.cpp new file mode 100644 index 0000000..09411bf --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async-local/http_server_async_local.cpp @@ -0,0 +1,448 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-async-local \n" + << "Example:\n" + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { + std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async-ssl/http_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async-ssl/http_server_async_ssl.cpp new file mode 100644 index 0000000..1c643f2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async-ssl/http_server_async_ssl.cpp @@ -0,0 +1,533 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + void on_run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + do_read(); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" + << "Example:\n" + << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async/http_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async/http_server_async.cpp new file mode 100644 index 0000000..03427bd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/async/http_server_async.cpp @@ -0,0 +1,467 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" + << "Example:\n" + << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/awaitable/http_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/awaitable/http_server_awaitable.cpp new file mode 100644 index 0000000..3eeaaa7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/awaitable/http_server_awaitable.cpp @@ -0,0 +1,363 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +// Handles an HTTP server connection +net::awaitable do_session(beast::tcp_stream stream, + std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + co_await http::async_read(stream, buffer, req); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have + // dropped the connection already. +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" + << "Example:\n" + << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/coro-ssl/http_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/coro-ssl/http_server_coro_ssl.cpp new file mode 100644 index 0000000..5a13397 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -0,0 +1,494 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(ssl::stream& stream, + std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" + << "Example:\n" + << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/coro/http_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/coro/http_server_coro.cpp new file mode 100644 index 0000000..3e18c7d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/coro/http_server_coro.cpp @@ -0,0 +1,443 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn(acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio + // spawn/completion overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" + << "Example:\n" + << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/fast/fields_alloc.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/fast/fields_alloc.hpp new file mode 100644 index 0000000..7f23dab --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/fast/fields_alloc.hpp @@ -0,0 +1,167 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP +#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP + +#include +#include +#include +#include + +namespace detail { + +class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + + char* end() { return reinterpret_cast(this + 1) + size_; } + + explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} + +public: + static static_pool& construct(std::size_t size) { + auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + + static static_pool& share(static_pool& pool) { + ++pool.refs_; + return pool; + } + + void destroy() { + if ((--refs_) != 0u) { + return; + } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { + auto* last = p_ + n; + if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + } + ++count_; + auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { + if ((--count_) != 0u) { + return; + } + p_ = reinterpret_cast(this + 1); + } +}; + +} // namespace detail + +/** A non-thread-safe allocator optimized for @ref basic_fields. + + This allocator obtains memory from a pre-allocated memory block + of a given size. It does nothing in deallocate until all + previously allocated blocks are deallocated, upon which it + resets the internal memory block for re-use. + + To use this allocator declare an instance persistent to the + connection or session, and construct with the block size. + A good rule of thumb is 20% more than the maximum allowed + header size. For example if the application only allows up + to an 8,000 byte header, the block size could be 9,600. + + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. +*/ +template +struct fields_alloc { + detail::static_pool* pool; + +public: + using value_type = T; + using is_always_equal = std::false_type; + using pointer = T*; + using reference = T&; + using const_pointer = T const*; + using const_reference = T const&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template + struct rebind { + using other = fields_alloc; + }; + +#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) + // Workaround for g++ + // basic_string assumes that allocators are default-constructible + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 + fields_alloc() = default; +#endif + + explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + + fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template + explicit fields_alloc(fields_alloc const& other) + : pool(&detail::static_pool::share(*other.pool)) {} + + ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { + return static_cast(pool->alloc(n * sizeof(T))); + } + + void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template + void construct(U* ptr, Args&&... args) { + ::new (static_cast(ptr)) U(std::forward(args)...); + } + + template + void destroy(U* ptr) { + ptr->~U(); + } +#endif + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool == &rhs.pool_; + } + + template + friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { + return !(lhs == rhs); + } +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/fast/http_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/fast/http_server_fast.cpp new file mode 100644 index 0000000..3bb7dfc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/fast/http_server_fast.cpp @@ -0,0 +1,360 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include "fields_alloc.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +class http_worker { +public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + + // Retain the upstream borrowing constructor contract in this reference counterpart. + // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + + void start() { + accept(); + check_deadline(); + } + +private: + using alloc_t = fields_alloc; + // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. + tcp::acceptor& acceptor_; + + // The path to the root of the document directory. + std::string doc_root_; + + // The socket for the currently connected client. + tcp::socket socket_{acceptor_.get_executor()}; + + // The buffer for performing reads + beast::flat_static_buffer<8192> buffer_; + + // The allocator used for the fields in the request and reply. + alloc_t alloc_{8192}; + + // The parser for reading the requests + boost::optional> parser_; + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), + std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> + string_response_; + + // The string-based response serializer. + boost::optional>> + string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. + boost::optional>> + file_serializer_; + + void accept() { + // Clean up any previous connection. + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { + if (ec) { + accept(); + } else { + // Request must be fully processed within 60 seconds. + request_deadline_.expires_after(std::chrono::seconds(60)); + + read_request(); + } + }); + } + + void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. + // + // Arguments passed to the parser constructor are + // forwarded to the message object. A single argument + // is forwarded to the body constructor. + // + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { + if (ec) { + accept(); + } else { + process_request(parser_->get()); + } + }); + } + + void process_request(http::request> const& req) { + if (req.method() == http::verb::get) { + send_file(req.target()); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + + void send_bad_response(http::status status, std::string const& error) { + string_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); + }); + } + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open(full_path.c_str(), beast::file_mode::read, ec); + if (ec) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + file_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); + }); + } + + void check_deadline() { + // The deadline may have moved, so check it has really passed. + if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. + request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 6) { + std::cerr << "Usage: http_server_fast
" + "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " http_server_fast 0::0 80 . 100 block\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + std::string const doc_root = argv[3]; + int const num_workers = webcpp_fixture::integer(argv[4]); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; + for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) { + for (;;) { + ioc.poll(); + } + } else { + ioc.run(); // lint-run: drives the application's network operations + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/flex/http_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/flex/http_server_flex.cpp new file mode 100644 index 0000000..30de359 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/flex/http_server_flex.cpp @@ -0,0 +1,635 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP flex server (plain and SSL), asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; + +protected: + beast::flat_buffer buffer; + +public: + // Take ownership of the buffer +private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), + beast::bind_front_handler(&session::on_write, + derived().shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Read another request + do_read(); + } + + friend Derived; +}; + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_session(tcp::socket&& socket, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the session + ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( + ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake + async_detect_ssl(stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" + << "Example:\n" + << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/small/http_server_small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/small/http_server_small.cpp new file mode 100644 index 0000000..f5a7e60 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/small/http_server_small.cpp @@ -0,0 +1,223 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +namespace { +namespace my_program_state { +std::size_t request_count() { + static std::size_t count = 0; + return ++count; +} + +std::time_t now() { + return std::time(nullptr); +} +} // namespace my_program_state + +class http_connection : public std::enable_shared_from_this { +public: + explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { + read_request(); + check_deadline(); + } + +private: + // The socket for the currently connected client. + tcp::socket socket_; + + // The buffer for performing reads. + beast::flat_buffer buffer_{8192}; + + // The request message. + http::request request_; + + // The response message. + http::response response_; + + // The timer for putting a deadline on connection processing. + net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. + void read_request() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + if (!ec) { + self->process_request(); + } + }); + } + + // Determine what needs to be done with the request message. + void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + + if (request_.method() == http::verb::get) { + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); + } + + // Construct a response message based on the program state. + void create_response() { + if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + // Asynchronously transmit the response message. + void write_response() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.close(ec)); + } + }); + } +}; + +// "Loop" forever accepting new connections. +void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { + if (!ec) { + std::make_shared(std::move(socket))->start(); + } + http_server(acceptor, socket); + }); +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/stackless-ssl/http_server_stackless_ssl.cpp new file mode 100644 index 0000000..ceb474d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -0,0 +1,544 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + yield stream_.async_shutdown( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + ctx_(ctx), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" + << "Example:\n" + << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/stackless/http_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/stackless/http_server_stackless.cpp new file mode 100644 index 0000000..306d60e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/stackless/http_server_stackless.cpp @@ -0,0 +1,481 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" + << "Example:\n" + << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/sync-ssl/http_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/sync-ssl/http_server_sync_ssl.cpp new file mode 100644 index 0000000..89a0493 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -0,0 +1,379 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.handshake(ssl::stream_base::server, ec)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Perform the SSL shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync-ssl
\n" + << "Example:\n" + << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), std::ref(ctx), doc_root)} + .detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/sync/http_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/sync/http_server_sync.cpp new file mode 100644 index 0000000..42d2ab8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/http/server/sync/http_server_sync.cpp @@ -0,0 +1,346 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync
\n" + << "Example:\n" + << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-local/websocket_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-local/websocket_client_async_local.cpp new file mode 100644 index 0000000..afb2465 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-local/websocket_client_async_local.cpp @@ -0,0 +1,197 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; + + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr + << "Usage: websocket-client-async-local \n" + << "Example:\n" + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const* const host = argv[2]; + auto const* const port = argv[3]; + auto const* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..24d58b1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,262 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(ssl::context& ctx) : session(net::make_strand(net::system_executor{}), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..95c3132 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,258 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..c017118 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,216 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, tcp::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); + })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..65f8ac6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,148 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp::asio::ip::tcp::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); + + // Send the message + co_await stream.async_write(net::buffer(text)); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp new file mode 100644 index 0000000..a236de1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -0,0 +1,234 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + fail(ec, "connect"); + return; + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro-ssl \n" + << "Example:\n" + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/coro/websocket_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/coro/websocket_client_coro.cpp new file mode 100644 index 0000000..463c9d0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/coro/websocket_client_coro.cpp @@ -0,0 +1,196 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro \n" + << "Example:\n" + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..c6d2c67 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,137 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..8a747a4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,114 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const* const port = argv[2]; + auto const* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async-local/websocket_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async-local/websocket_server_async_local.cpp new file mode 100644 index 0000000..4fc36ca --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async-local/websocket_server_async_local.cpp @@ -0,0 +1,237 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; + } + // Create the session and run it + std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-async-local \n" + << "Example:\n" + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + auto const* const path = argv[1]; + auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { + std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async-ssl/websocket_server_async_ssl.cpp new file mode 100644 index 0000000..958cfc5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -0,0 +1,291 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async/websocket_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async/websocket_server_async.cpp new file mode 100644 index 0000000..ebf049b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/async/websocket_server_async.cpp @@ -0,0 +1,256 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" + << "Example:\n" + << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/awaitable/websocket_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/awaitable/websocket_server_awaitable.cpp new file mode 100644 index 0000000..d6f05d3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/awaitable/websocket_server_awaitable.cpp @@ -0,0 +1,160 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Echoes back all received WebSocket messages +namespace { +net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + co_await stream.async_accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + // Echo the message back + stream.text(stream.got_text()); + co_await stream.async_write(buffer.data()); + } +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" + << "Example:\n" + << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back( + [&ioc] { ioc.run(); }); // lint-run: drives the application's network operations + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/beast.hpp new file mode 100644 index 0000000..1a1c05e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/beast.hpp @@ -0,0 +1,36 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/chat_client.html b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/chat_client.html new file mode 100644 index 0000000..b571093 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/chat_client.html @@ -0,0 +1,71 @@ + + + + + + Boost.Beast WebSocket Chat Client + + +

Boost.Beast WebSocket Chat Client

+

+ Boost.Beast + Source Code +

+ Server URI: + +
+ Your Name:
+

+  
+ Message
+ + +
+ + + diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/http_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/http_session.cpp new file mode 100644 index 0000000..e9addf2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/http_session.cpp @@ -0,0 +1,336 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include +#include "http_session.hpp" +#include "websocket_session.hpp" + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +} // namespace + +http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +void http_session::run() { + do_read(); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, parser_->get(), + beast::bind_front_handler(&http_session::on_read, shared_from_this())); +} + +void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + boost::make_shared(stream_.release_socket(), state_) + ->run(parser_->release()); + return; + } + + // Handle request + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response + beast::async_write(stream_, std::move(msg), + [self, keep_alive](beast::error_code ec, std::size_t bytes) { + self->on_write(ec, bytes, keep_alive); + }); +} + +void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Read another request + do_read(); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/http_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/http_session.hpp new file mode 100644 index 0000000..e5e2c90 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/http_session.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +#include +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +/** Represents an established HTTP connection + */ +class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + + struct send_lambda; + + void fail(beast::error_code ec, char const* what); + void do_read(); + void on_read(beast::error_code ec, std::size_t /*unused*/); + void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + +public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/listener.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/listener.cpp new file mode 100644 index 0000000..b471a55 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/listener.cpp @@ -0,0 +1,107 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "http_session.hpp" +#include "listener.hpp" + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } +} + +void listener::run() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handle a connection +void listener::on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); + } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/listener.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/listener.hpp new file mode 100644 index 0000000..0070b26 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/listener.hpp @@ -0,0 +1,55 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" + +// Forward declaration +class shared_state; + +// Accepts incoming connections and launches the sessions +class listener : public boost::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec, tcp::socket socket); + +public: + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/main.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/main.cpp new file mode 100644 index 0000000..1659676 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/main.cpp @@ -0,0 +1,96 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +//------------------------------------------------------------------------------ +/* + WebSocket chat server, multi-threaded + + This implements a multi-user chat room using WebSocket. The + `io_context` runs on any number of threads, specified at + the command line. + +*/ +//------------------------------------------------------------------------------ + +#include "listener.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" + << "Example:\n" + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto* doc_root = argv[3]; + auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Create and launch a listening port + boost::make_shared(ioc, tcp::endpoint{address, port}, + boost::make_shared(doc_root)) + ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait([&ioc](boost::system::error_code const&, int) { + // Stop the io_context. This will cause run() + // to return immediately, eventually destroying the + // io_context and any remaining handlers in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for (auto& t : v) { + t.join(); + } + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/net.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/net.hpp new file mode 100644 index 0000000..8a95669 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/net.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +#include + +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/shared_state.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/shared_state.cpp new file mode 100644 index 0000000..e1146e4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/shared_state.cpp @@ -0,0 +1,66 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "shared_state.hpp" +#include "websocket_session.hpp" + +shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + +void shared_state::join(websocket_session* session) { + const std::scoped_lock lock(mutex_); + sessions_.insert(session); +} + +void shared_state::leave(websocket_session* session) { + const std::scoped_lock lock(mutex_); + sessions_.erase(session); +} + +// Broadcast a message to all websocket client sessions +void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + + // Make a local list of all the weak pointers representing + // the sessions, so we can do the actual sending without + // holding the mutex: + std::vector> v; + { + const std::scoped_lock lock(mutex_); + v.reserve(sessions_.size()); + for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); + } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. + for (auto const& wp : v) { + if (const auto sp = wp.lock()) { + sp->send(ss); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/shared_state.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/shared_state.hpp new file mode 100644 index 0000000..419eb01 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/shared_state.hpp @@ -0,0 +1,59 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP + +#include +#include +#include +#include +#include + +// Forward declaration +class websocket_session; + +// Represents the shared server state +class shared_state { + std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; + + // Keep a list of all the connected clients + std::unordered_set sessions_; + +public: + explicit shared_state(std::string doc_root); + + [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); + void send(std::string message); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/websocket_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/websocket_session.cpp new file mode 100644 index 0000000..7081002 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/websocket_session.cpp @@ -0,0 +1,128 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "websocket_session.hpp" + +websocket_session::websocket_session(tcp::socket&& socket, + boost::shared_ptr const& state) + : ws_(std::move(socket)), state_(state) {} + +websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); +} + +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these + if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Read another message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + + net::post(ws_.get_executor(), + beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); +} + +void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? + if (queue_.size() > 1) { + return; + } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); +} + +void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any + if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/websocket_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/websocket_session.hpp new file mode 100644 index 0000000..5c29651 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/chat-multi/websocket_session.hpp @@ -0,0 +1,88 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// Forward declaration +class shared_state; + +/** Represents an active WebSocket connection to the server + */ +class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; + std::vector> queue_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); + +public: + websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + + template + void run(http::request> req); + + // Send a message + void send(boost::shared_ptr const& ss); + +private: + void on_send(boost::shared_ptr const& ss); +}; + +template +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); + })); + + // Accept the websocket handshake + ws_.async_accept(req, + beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp new file mode 100644 index 0000000..00273b8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -0,0 +1,269 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void do_session(websocket::stream>& ws, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + break; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" + << "Example:\n" + << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/coro/websocket_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/coro/websocket_server_coro.cpp new file mode 100644 index 0000000..cead08a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/coro/websocket_server_coro.cpp @@ -0,0 +1,240 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + break; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" + << "Example:\n" + << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/fast/websocket_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/fast/websocket_server_fast.cpp new file mode 100644 index 0000000..5661a7e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/fast/websocket_server_fast.cpp @@ -0,0 +1,490 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, fast +// +//------------------------------------------------------------------------------ + +/* This server contains the following ports: + + Synchronous + Asynchronous + Coroutine + + This program is optimized for the Autobahn|Testsuite + benchmarking and WebSocket compliants testing program. + + See: + https://github.com/crossbario/autobahn-testsuite +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); +} + +// Adjust settings on the stream +template +void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + + websocket::permessage_deflate pmd; + pmd.client_enable = true; + pmd.server_enable = true; + pmd.compLevel = 3; + ws.set_option(pmd); + + ws.auto_fragment(false); + + // Autobahn|Testsuite needs this + ws.read_message_max(64 * 1024 * 1024); +} + +//------------------------------------------------------------------------------ + +void do_sync_session(websocket::stream& ws) { + beast::error_code ec; + + setup_stream(ws); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Sync"); + })); + + ws.accept(ec); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + beast::flat_buffer buffer; + + ws.read(buffer, ec); + if (ec == websocket::error::closed) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_sync_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) { + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; + for (;;) { + tcp::socket socket{ioc}; + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.accept(socket, ec)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + std::thread( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_sync_session, websocket::stream(std::move(socket)))) + .detach(); + } +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation + void run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&async_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&async_session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +// Accepts incoming connections and launches the sessions +class async_listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); + })); + + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); + if (ec == websocket::error::closed) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" + << "Example:\n" + " websocket-server-fast 0.0.0.0 8080 1\n" + " Connect to:\n" + " starting-port+0 for synchronous,\n" + " starting-port+1 for asynchronous,\n" + " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create sync port + std::thread( + beast::bind_front_handler(&do_sync_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 0u)})) + .detach(); + + // Create async port + std::make_shared(ioc, + tcp::endpoint{address, static_cast(port + 1u)}) + ->run(); + + // Create coro port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), + boost::asio::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp new file mode 100644 index 0000000..058793f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -0,0 +1,310 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless-ssl"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/stackless/websocket_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/stackless/websocket_server_stackless.cpp new file mode 100644 index 0000000..536a4f6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/stackless/websocket_server_stackless.cpp @@ -0,0 +1,276 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" + << "Example:\n" + << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for (auto i = threads - 1; i > 0; --i) { + v.emplace_back([&ioc] { + ioc.run(); // lint-run: drives the application's network operations + }); + } + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp new file mode 100644 index 0000000..dbe90bd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -0,0 +1,138 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket, ssl::context& ctx) { + try { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed + if (se.code() != websocket::error::closed) { + std::cerr << "Error: " << se.code().message() << '\n'; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync-ssl
\n" + << "Example:\n" + << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread(&do_session, std::move(socket), std::ref(ctx)).detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/sync/websocket_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/sync/websocket_server_sync.cpp new file mode 100644 index 0000000..1a313db --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/port/websocket/server/sync/websocket_server_sync.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket) { + try { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed + if (se.code() != websocket::error::closed) { + std::cerr << "Error: " << se.code().message() << '\n'; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync
\n" + << "Example:\n" + << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread(&do_session, std::move(socket)).detach(); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/README.md b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/README.md new file mode 100644 index 0000000..8a7b70a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/README.md @@ -0,0 +1,20 @@ +# Supplied stream counterparts + +These four explicit counterparts use a bidirectional stdin/stdout channel supplied by the host. They have no Unix socket path, connect or accept call, socket options, peer credentials, guest DNS, guest TCP, or guest TLS. stdout carries protocol bytes; stderr carries application output and diagnostics. + +| Upstream application | Retained application behavior | Executed profiles | +| --- | --- | --- | +| `http/client/async-local` | GET target, Host/User-Agent, complete response and partial-response failure | Native POSIX, WASIp2, WASIp3 | +| `http/server/async-local` | Original `mime_type`, `path_cat`, `handle_request`, file/empty/string bodies, HEAD, errors, keep-alive and pipelined overread | Native POSIX, WASIp2, WASIp3 | +| `websocket/client/async-local` | HTTP upgrade decorator, text request/reply, normal close handshake | Native POSIX, WASIp3 | +| `websocket/server/async-local` | Upgrade decorator, text/binary echo, ping/pong, peer close handshake | Native POSIX, WASIp3 | + +The supplied channel uses synchronous partial operations with readiness and cancellation. This is an explicit execution-model adaptation of the original asynchronous socket sessions, not asynchronous API parity. The WebSocket examples use the upstream protocol engine with an executor for its associated state. They do not run a socket reactor or receive network grants. WASIp2 lacks the supported guest WebSocket engine and is not declared for those two counterparts. + +`prepare.py ` extracts the immutable upstream HTTP server handler, preserving its author notice, and replaces `message_generator` with a variant of the same response body types. The variant lets the supplied stream write the selected body without requiring socket message-generator algorithms. Do not edit the generated server source manually. + +`test/applications/streams/driver.py` supplies both directions of the channel. HTTP tests check routing, HEAD and content length, traversal rejection, missing files, unsupported methods, large file contents, pipelining, and truncated responses. WebSocket tests check actual upgrade and close handshakes, a large text message, 128 KiB of binary content and ping/pong. Every process has an outer driver timeout. The native POSIX rows pass with exceptions on and off; WASIp2 HTTP rows pass with exceptions on and off; all WASIp3 rows pass with exceptions on and off in single mode and with exceptions off in cooperative mode. + +WASIp3 cooperative mode requires Wasmtime's component-model-threading feature because the SDK's cooperative libc may use context slot 1. It does not create a background thread in these applications. WASIp3 cooperative exceptions-on is outside the SDK's available runtime profiles. + +The standard-descriptor adapter is unavailable on Windows: its constructor reports a platform diagnostic, while the header and generic `supplied_stream` remain usable. Windows callers can provide nonblocking channel callbacks. These four stdio applications are excluded only on that native OS. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/http-client-async-local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/http-client-async-local.cpp new file mode 100644 index 0000000..b15076a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/http-client-async-local.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +// +// Explicit supplied-channel counterpart of http/client/async-local. +// The original GET/header construction and complete response are retained; +// readiness is driven by the host stream instead of a Unix socket executor. + +#include +#include +#include +#include + +int main(int argc, const char* const* argv) { + namespace http = webcpp::beast::http; + if (argc != 3) { + return 64; + } + webcpp::beast::wasi::stdio_stream channel; + http::request request{http::verb::get, argv[2], 11}; + request.set(http::field::host, argv[1]); + request.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + boost::system::error_code error; + webcpp::beast::wasi::write(channel, request, error); + if (error) { + return 1; + } + webcpp::beast::flat_buffer input; + http::response_parser parser; + webcpp::beast::wasi::read(channel, input, parser, error); + if (error) { + static_cast(std::fprintf(stderr, "read: %s\n", error.message().c_str())); + return 2; + } + const auto& response = parser.get(); + static_cast(std::fprintf(stderr, "status=%u\n", response.result_int())); + static_cast(std::fwrite(response.body().data(), 1, response.body().size(), stderr)); + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/http-server-async-local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/http-server-async-local.cpp new file mode 100644 index 0000000..006909b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/http-server-async-local.cpp @@ -0,0 +1,263 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +// Generated by streams/prepare.py. Edit the generator. +// The original routing/file handler uses an explicit supplied byte stream. +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = + std::variant, http::response, + http::response>; + +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); + for (auto& c : result) { + if (c == '/') { + c = path_separator; + } + } +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +application_response handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} +} // namespace + +int main() { + beast::wasi::stdio_stream channel; + beast::flat_buffer input; + for (;;) { + http::request_parser parser; + boost::system::error_code error; + beast::wasi::read(channel, input, parser, error); + if (error == http::error::end_of_stream) { + return 0; + } + if (error) { + static_cast(std::fprintf(stderr, "read: %s\n", error.message().c_str())); + return 1; + } + auto response = handle_request(".", parser.release()); + bool keep_alive = false; + std::visit( + [&](auto& message) { + keep_alive = message.keep_alive(); + beast::wasi::write(channel, message, error); + }, + response); + if (error) { + static_cast(std::fprintf(stderr, "write: %s\n", error.message().c_str())); + return 2; + } + if (!keep_alive) { + return 0; + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/mapping.json new file mode 100644 index 0000000..b40d816 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/mapping.json @@ -0,0 +1,87 @@ +{ + "schema": 1, + "applications": [ + { + "application": "http-client-async-local", + "source": "http/client/async-local/http_client_async_local.cpp", + "counterpart": "http-client-async-local.cpp", + "backend": "supplied-stdio", + "execution_model": "explicit synchronous partial operations", + "targets": [ + "native", + "wasip2", + "wasip3" + ], + "unsupported": [ + { + "target": "native-windows", + "reason": "The stdio adapter requires WASI resources or POSIX descriptor readiness; provide supplied_stream callbacks on Windows." + } + ], + "native_os": "POSIX" + }, + { + "application": "http-server-async-local", + "source": "http/server/async-local/http_server_async_local.cpp", + "counterpart": "http-server-async-local.cpp", + "backend": "supplied-stdio", + "execution_model": "explicit synchronous partial operations", + "targets": [ + "native", + "wasip2", + "wasip3" + ], + "unsupported": [ + { + "target": "native-windows", + "reason": "The stdio adapter requires WASI resources or POSIX descriptor readiness; provide supplied_stream callbacks on Windows." + } + ], + "native_os": "POSIX" + }, + { + "application": "websocket-client-async-local", + "source": "websocket/client/async-local/websocket_client_async_local.cpp", + "counterpart": "websocket-client-async-local.cpp", + "backend": "supplied-stdio", + "execution_model": "explicit synchronous partial operations", + "targets": [ + "native", + "wasip3" + ], + "unsupported": [ + { + "target": "wasip2", + "reason": "The guest WebSocket protocol engine is unavailable on WASIp2." + }, + { + "target": "native-windows", + "reason": "The stdio adapter requires WASI resources or POSIX descriptor readiness; provide supplied_stream callbacks on Windows." + } + ], + "native_os": "POSIX" + }, + { + "application": "websocket-server-async-local", + "source": "websocket/server/async-local/websocket_server_async_local.cpp", + "counterpart": "websocket-server-async-local.cpp", + "backend": "supplied-stdio", + "execution_model": "explicit synchronous partial operations", + "targets": [ + "native", + "wasip3" + ], + "unsupported": [ + { + "target": "wasip2", + "reason": "The guest WebSocket protocol engine is unavailable on WASIp2." + }, + { + "target": "native-windows", + "reason": "The stdio adapter requires WASI resources or POSIX descriptor readiness; provide supplied_stream callbacks on Windows." + } + ], + "native_os": "POSIX" + } + ] +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/prepare.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/prepare.py new file mode 100644 index 0000000..a417668 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/prepare.py @@ -0,0 +1,79 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Retain the original local HTTP server's routing and response-body choices.""" +from pathlib import Path +import re +import subprocess +import sys + +HERE = Path(__file__).resolve().parent +SOURCE = (HERE.parents[1] / 'upstream/http/server/async-local' / + 'http_server_async_local.cpp') +source = SOURCE.read_text() +notice = source[:source.index('//-----')] +match = re.search(r'beast::string_view\s+mime_type\(', source) +assert match is not None +start = match.start() +opening = source.index('{', source.index('\nhandle_request(')) +end, depth = opening + 1, 1 +while depth: + depth += (source[end] == '{') - (source[end] == '}') + end += 1 +handler = source[start:end].replace('http::message_generator', 'application_response') +handler = handler.replace('std::make_tuple(http::status::ok, req.version())}', + 'std::make_tuple(http::status::ok, req.version()),}') +text = '''// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +''' + notice + '''// Generated by streams/prepare.py. Edit the generator. +// The original routing/file handler uses an explicit supplied byte stream. +#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = std::variant, + http::response, http::response>; +namespace { +''' + handler + ''' +} // namespace +int main() { + beast::wasi::stdio_stream channel; + beast::flat_buffer input; + for (;;) { + http::request_parser parser; + boost::system::error_code error; + beast::wasi::read(channel, input, parser, error); + if (error == http::error::end_of_stream) return 0; + if (error) { + static_cast(std::fprintf(stderr, "read: %s\\n", error.message().c_str())); + return 1; + } + auto response = handle_request(".", parser.release()); + bool keep_alive = false; + std::visit([&](auto& message) { + keep_alive = message.keep_alive(); + beast::wasi::write(channel, message, error); + }, response); + if (error) { + static_cast(std::fprintf(stderr, "write: %s\\n", error.message().c_str())); + return 2; + } + if (!keep_alive) return 0; + } +} +''' +formatter = sys.argv[1] if len(sys.argv) > 1 else 'clang-format' +result = subprocess.run([formatter, '--assume-filename=http-server-async-local.cpp', + '-style={BasedOnStyle: InheritParentConfig, InsertBraces: true}'], + input=text, text=True, capture_output=True, check=True) +(HERE / 'http-server-async-local.cpp').write_text(result.stdout) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-channel.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-channel.hpp new file mode 100644 index 0000000..4e41bf6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-channel.hpp @@ -0,0 +1,110 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_EXAMPLE_SUPPLIED_WEBSOCKET_CHANNEL_HPP +#define WEBCPP_BEAST_EXAMPLE_SUPPLIED_WEBSOCKET_CHANNEL_HPP + +#include +#include +#include +#include +#include +#include + +#ifdef __wasip2__ +#include +#include +#include +#include + +namespace webcpp::asio::wasi { +inline void teardown(boost::beast::role_type /*unused*/, stdio_stream& /*unused*/, + boost::system::error_code& error) { + error.clear(); +} + +struct teardown_operation { + template + void operator()(Self& self) { + boost::asio::post(boost::asio::append(std::move(self), boost::system::error_code{})); + } + + template + void operator()(Self& self, boost::system::error_code error) { + self.complete(error); + } +}; + +template +void async_teardown(boost::beast::role_type /*role*/, stdio_stream& stream, Handler&& handler) { + boost::asio::async_compose( + teardown_operation{}, handler, stream.get_executor()); +} + +} // namespace webcpp::asio::wasi + +namespace supplied_example { +using channel = webcpp::asio::wasi::stdio_stream; +} +#else +namespace supplied_example { +// The executor exists for the upstream WebSocket object's associated state. +// This example performs explicit synchronous I/O on caller-provided CLI streams. +class channel { + boost::asio::io_context::executor_type executor_; + webcpp::beast::wasi::stdio_stream stream_; + +public: + using executor_type = boost::asio::io_context::executor_type; + + explicit channel(executor_type executor) : executor_(std::move(executor)) {} + + executor_type get_executor() noexcept { return executor_; } + + template + std::size_t read_some(const Buffers& buffers, boost::system::error_code& error) { + const auto count = stream_.read_some(buffers, error); + if (error == webcpp::beast::http::error::end_of_stream) { + error = boost::asio::error::eof; + } + return count; + } + + template + std::size_t write_some(const Buffers& buffers, boost::system::error_code& error) { + return stream_.write_some(buffers, error); + } + + template + std::size_t read_some(const Buffers& buffers) { + boost::system::error_code error; + const auto count = read_some(buffers, error); + if (error) { + boost::throw_exception(boost::system::system_error(error)); + } + return count; + } + + template + std::size_t write_some(const Buffers& buffers) { + boost::system::error_code error; + const auto count = write_some(buffers, error); + if (error) { + boost::throw_exception(boost::system::system_error(error)); + } + return count; + } +}; + +// The channel is borrowed: WebSocket close completes its handshake without +// inventing socket shutdown semantics or closing the caller's descriptors. +inline void teardown(boost::beast::role_type /*role*/, channel& /*stream*/, + boost::system::error_code& error) { + error.clear(); +} +} // namespace supplied_example +#endif // __wasip2__ +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-client-async-local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-client-async-local.cpp new file mode 100644 index 0000000..bf76f6e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-client-async-local.cpp @@ -0,0 +1,95 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +// +// Explicit supplied-channel counterpart of websocket/client/async-local. +// Retains the upgrade, request decorator, text echo and normal close handshake. + +#include +#include +#include +#include +#include "websocket-channel.hpp" +#ifdef __wasip2__ +#include +#include +#include +#endif + +int main(int argc, const char* const* argv) { + namespace beast = webcpp::beast; + namespace websocket = beast::websocket; + if (argc != 3) { + return 64; + } + boost::asio::io_context context; + websocket::stream stream(context.get_executor()); + stream.set_option(websocket::stream_base::decorator([](websocket::request_type& request) { + request.set(beast::http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); + })); +#ifdef __wasip2__ + int result = 1; + boost::asio::co_spawn( + context, + [&]() -> boost::asio::awaitable { + auto token = boost::asio::as_tuple(boost::asio::use_awaitable); + auto [handshake_error] = co_await stream.async_handshake(argv[1], "/", token); + if (handshake_error) { + co_return; + } + stream.text(true); + auto [write_error, written] = co_await stream.async_write( + boost::asio::buffer(argv[2], std::strlen(argv[2])), token); + if (write_error) { + result = 2; + co_return; + } + beast::flat_buffer reply; + auto [read_error, received] = co_await stream.async_read(reply, token); + if (read_error) { + result = 3; + co_return; + } + const auto output = boost::beast::buffers_to_string(reply.data()); + static_cast(std::fprintf(stderr, "%s\n", output.c_str())); + auto [close_error] = co_await stream.async_close(websocket::close_code::normal, token); + result = close_error ? 4 : 0; + }, + [&](const std::exception_ptr& error) { + if (error) { + result = 5; + } + }); + context.run(); // lint-run: drive supplied-channel readiness and protocol completions + return result; +#else + boost::system::error_code error; + stream.handshake(argv[1], "/", error); + if (error) { + return 1; + } + stream.text(true); + stream.write(boost::asio::buffer(argv[2], std::strlen(argv[2])), error); + if (error) { + return 2; + } + beast::flat_buffer reply; + stream.read(reply, error); + if (error) { + return 3; + } + const auto output = boost::beast::buffers_to_string(reply.data()); + static_cast(std::fprintf(stderr, "%s\n", output.c_str())); + stream.close(websocket::close_code::normal, error); + return error ? 4 : 0; +#endif +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-server-async-local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-server-async-local.cpp new file mode 100644 index 0000000..ebe420e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/streams/websocket-server-async-local.cpp @@ -0,0 +1,93 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +// +// Explicit supplied-channel counterpart of websocket/server/async-local. +// Retains server upgrade decoration, text/binary echo and normal peer close. + +#include +#include +#include +#include "websocket-channel.hpp" +#ifdef __wasip2__ +#include +#include +#include +#endif + +int main() { + namespace beast = webcpp::beast; + namespace websocket = beast::websocket; + boost::asio::io_context context; + websocket::stream stream(context.get_executor()); + stream.set_option(websocket::stream_base::decorator([](websocket::response_type& response) { + response.set(beast::http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); + })); +#ifdef __wasip2__ + int result = 1; + boost::asio::co_spawn( + context, + [&]() -> boost::asio::awaitable { + auto token = boost::asio::as_tuple(boost::asio::use_awaitable); + auto [accept_error] = co_await stream.async_accept(token); + if (accept_error) { + co_return; + } + for (;;) { + beast::flat_buffer input; + auto [read_error, received] = co_await stream.async_read(input, token); + if (read_error == websocket::error::closed) { + result = 0; + co_return; + } + if (read_error) { + result = 2; + co_return; + } + stream.text(stream.got_text()); + auto [write_error, written] = co_await stream.async_write(input.data(), token); + if (write_error) { + result = 3; + co_return; + } + } + }, + [&](const std::exception_ptr& error) { + if (error) { + result = 4; + } + }); + context.run(); // lint-run: drive supplied-channel readiness and protocol completions + return result; +#else + boost::system::error_code error; + stream.accept(error); + if (error) { + return 1; + } + for (;;) { + beast::flat_buffer input; + stream.read(input, error); + if (error == websocket::error::closed) { + return 0; + } + if (error) { + return 2; + } + stream.text(stream.got_text()); + stream.write(input.data(), error); + if (error) { + return 3; + } + } +#endif +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/host_crawl.cpp.in b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/host_crawl.cpp.in new file mode 100644 index 0000000..b569808 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/host_crawl.cpp.in @@ -0,0 +1,125 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace wasi = beast::wasi; + +namespace { +struct crawl_target { + std::string authority; + std::string path; +}; + +@REPORT@ + +// Retain the upstream worker's get-next, complete, aggregate and repeat algorithm. +// Host HTTP combines resolution, connect, write and read into one asynchronous exchange. +class worker : public std::enable_shared_from_this { + crawl_report& report_; + wasi::http_context& context_; + std::optional connection_; + http::request req_; + http::response res_; + +public: + worker(crawl_report& report, wasi::http_context& context) + : report_(report), context_(context) { + req_.version(11); + req_.method(http::verb::get); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + void run() { do_get_host(); } + + void do_get_host() { + const auto* host = report_.get_host(); + if (host == nullptr) { + return; + } + req_.target(host->path); + req_.set(http::field::host, host->authority); + connection_.emplace("http", host->authority); + res_ = {}; + wasi::transfer_options options; + options.body_limit = 65536; + options.expires_after(5000000000); + wasi::async_perform(context_, *connection_, req_, res_, + [self = shared_from_this()](boost::system::error_code ec, std::size_t) { + self->on_read(ec); + }, options); + } + + void on_read(boost::system::error_code ec) { + if (ec) { + // The host does not expose individual socket phases. An unsuccessful complete + // exchange increments Read; the other upstream phase counters remain unmeasured. + report_.aggregate([](crawl_report& report) { ++report.read_failures; }); + } else { + const auto code = res_.result_int(); + report_.aggregate([code](crawl_report& report) { + ++report.success; + ++report.status_codes[code]; + }); + } + connection_.reset(); + do_get_host(); + } +}; + +http::response invalid_targets() { + http::response response{http::status::bad_request, 11}; + response.body() = "Expected 1 to 32 lines containing an authority and an absolute path"; + response.prepare_payload(); + return response; +} + +http::response handle(const http::request& incoming) { + std::vector hosts; + std::istringstream input(incoming.body()); + std::string line; + while (std::getline(input, line)) { + const auto split = line.find(' '); + if (hosts.size() == 32 || split == std::string::npos || split == 0 || + split + 1 >= line.size() || line[split + 1] != '/' || line.size() > 2048) { + return invalid_targets(); + } + hosts.push_back({.authority = line.substr(0, split), .path = line.substr(split + 1)}); + } + if (hosts.empty()) { + return invalid_targets(); + } + wasi::http_context context; + crawl_report report(context, hosts); + // Two bounded asynchronous workers share one serialized host readiness/reporting queue. + // This preserves overlapping requests without claiming operating-system worker threads. + for (unsigned index = 0; index < 2; ++index) { + std::make_shared(report, context)->run(); + } + context.run(); + std::ostringstream output; + output << report; + http::response response{http::status::ok, 11}; + response.set("X-Crawl-Completed", std::to_string(report.completed())); + response.set("X-Crawl-Workers", "2"); + response.body() = output.str(); + response.prepare_payload(); + return response; +} +} // namespace + +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/normalize.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/normalize.py new file mode 100644 index 0000000..6fe29a9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/normalize.py @@ -0,0 +1,94 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Apply reviewed, reproducible static-analysis changes to the pinned application corpus.""" + +import argparse +import difflib +import json +import re +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +PATCH = ROOT / "normalization.patch" + + +def apply(): + if not PATCH.exists(): + return + lines = PATCH.read_text().splitlines(True) + cursor = 0 + while cursor < len(lines): + assert lines[cursor].startswith("--- a/") + name = lines[cursor][6:].rstrip("\n") + path = ROOT / name + assert path.resolve().is_relative_to(ROOT) + original = path.read_text().splitlines(True) + cursor += 2 + output, consumed = [], 0 + while cursor < len(lines) and not lines[cursor].startswith("--- a/"): + header = re.match(r"@@ -(\d+)(?:,\d+)? \+\d+(?:,\d+)? @@", lines[cursor]) + assert header is not None, lines[cursor] + start = int(header[1]) - 1 + output.extend(original[consumed:start]) + consumed = start + cursor += 1 + while cursor < len(lines) and lines[cursor][0] in " +-": + line = lines[cursor] + if line.startswith("--- a/"): + break + if line[0] in " -": + if original[consumed] != line[1:]: + raise ValueError(f"{name}: normalization context changed at {consumed + 1}") + consumed += 1 + if line[0] in " +": + output.append(line[1:]) + cursor += 1 + output.extend(original[consumed:]) + path.write_text("".join(output)) + + +def record(baseline, replacements): + changes = json.loads(replacements.read_text()) + for name, edits in changes.items(): + path = ROOT / name + assert path.resolve().is_relative_to(ROOT) + data = path.read_bytes() + end = len(data) + 1 + for edit in sorted(edits, key=lambda item: (item["offset"], item["length"]), reverse=True): + start, length = edit["offset"], edit["length"] + if start + length > end: + continue + data = data[:start] + edit["text"].encode() + data[start + length:] + end = start + path.write_bytes(data) + patch = [] + for original in sorted(baseline.rglob("*")): + if not original.is_file() or original.suffix not in (".cpp", ".hpp"): + continue + relative = original.relative_to(baseline) + destination = ROOT / relative + patch.extend(difflib.unified_diff(original.read_text().splitlines(True), + destination.read_text().splitlines(True), fromfile=f"a/{relative}", + tofile=f"b/{relative}")) + PATCH.write_text("".join(patch)) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--record", type=Path) + parser.add_argument("--baseline", type=Path) + args = parser.parse_args() + if args.record: + if args.baseline is None: + parser.error("--record requires the pristine generated --baseline directory") + record(args.baseline, args.record) + else: + apply() + + +if __name__ == "__main__": + main() diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare.py new file mode 100644 index 0000000..079d059 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare.py @@ -0,0 +1,291 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Reproduce fixture adaptations and namespace migration from immutable upstream.""" + +import argparse +import difflib +import json +import re +import subprocess +import sys +from pathlib import Path + +APPLICATIONS = Path(__file__).resolve().parents[1] +UPSTREAM = APPLICATIONS.parent / "upstream" +NOTICE = """// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +""" +JAM_NOTICE = "\n".join("#" + line[2:] if line.startswith("//") else line + for line in NOTICE.splitlines()) + "\n" + + +def write_changed(path, text): + if not path.exists() or path.read_text() != text: + path.write_text(text) + + +def normalize_comments(text): + def comment(match): + value = match[0] + value = re.sub(r"@(p|c|e|b)\s+([A-Za-z_][A-Za-z_0-9:]*)", r"`\2`", value) + value = re.sub(r"@n\b", "", value).replace("@li", "-") + value = value.replace("@AsyncWriteStream", "`AsyncWriteStream`") + value = value.replace("\\n", "\\\\n") + return value + return re.sub(r"/\*\*.*?\*/", comment, text, flags=re.S) + + +def require_backend(text): + return re.sub(r"#else\s*int\s+main\([^)]*\)\s*\{[^{}]*\}", + '#else\n#error "This application requires its declared Asio backend"', text) + + +def adapt_fixture(path, text): + if path.suffix == ".html": + return "\n" + text + if path.suffix not in (".cpp", ".hpp"): + return text + text = normalize_comments(text) + text = require_backend(text) + text = text.replace('"example/', '"') + if path.name == "fields_alloc.hpp": + text = text.replace("static_pool&\n share()", + "static static_pool&\n share(static_pool& pool)") + text = text.replace("++refs_;\n return *this;", + "++pool.refs_;\n return pool;") + text = text.replace("&other.pool_->share()", "&detail::static_pool::share(*other.pool_)") + if path.name == "root_certificates.hpp": + position = text.index("{", text.index("load_root_certificates(ssl::context& ctx,")) + 1 + text = text[:position] + """ + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { + ctx.load_verify_file(path, ec); + return; + } +""" + text[position:] + if path.name == "server_certificate.hpp": + position = text.index("{", text.index("load_server_certificate(")) + 1 + text = text[:position] + """ + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { + ctx.use_certificate_chain_file(path); + ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), + boost::asio::ssl::context::pem); + return; + } +""" + text[position:] + if path.name == "json_client.cpp": + text = text.replace('"postman-echo.com"', 'webcpp_fixture::host()') + text = text.replace('resolver.resolve(host, "80")', + 'resolver.resolve(host, webcpp_fixture::port())') + if path.name == "http_client_methods.cpp": + text = text.replace('"httpbin.cpp.al", "http"', + 'webcpp_fixture::host(), webcpp_fixture::port()') + text = text.replace('"httpbin.cpp.al"', 'webcpp_fixture::host()') + if path.name == "urls_large_data.cpp": + text = """#include "urls_large_data.hpp" +#include +std::vector const& urls_large_data() { + static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; + return hosts; +} +""" + if path.name == "http_crawl.cpp": + text = text.replace('"http",', 'webcpp_fixture::port(),') + if path.as_posix().startswith("doc/ssl/"): + text = text.replace('{}, 8080', + 'net::ip::make_address("127.0.0.1"), webcpp_fixture::port_number()') + text = text.replace('tcp::v4(), 8080', 'tcp::v4(), webcpp_fixture::port_number()') + # The fixture helper is explicit in both the oracle and the port. + text = re.sub(r"([^\n]*\bioc\.run\([^\n]*)", + r"\1 // lint-run: drives the application's network operations", text) + return NOTICE + '#include "fixture.hpp"\n' + text + + +def migrate(text): + replacements = { + "boost/beast/core.hpp": "webcpp/beast/core.hpp", + "boost/beast/http.hpp": "webcpp/beast/http.hpp", + "boost/beast/websocket.hpp": "webcpp/beast/websocket.hpp", + "boost/beast/ssl.hpp": "webcpp/beast/ssl.hpp", + "boost/beast.hpp": "webcpp/beast.hpp", + } + for before, after in replacements.items(): + text = text.replace(f"<{before}>", f"<{after}>") + text = text.replace("namespace beast = boost::beast", "namespace beast = webcpp::beast") + text = re.sub(r"namespace beast\s+= boost::beast", "namespace beast = webcpp::beast", text) + text = text.replace("boost::beast::", "webcpp::beast::") + text = text.replace("net::io_context", "webcpp::asio::io_context") + text = text.replace("net::ip::tcp", "webcpp::asio::ip::tcp") + text = text.replace("boost::asio::ip::tcp", "webcpp::asio::ip::tcp") + # Boost utilities without a webcpp facade remain in their original namespace. + additions = """#include +#include +#include +#include +#include +#include +""" + if "websocket" in text: + additions += "#include \n" + if "ssl::" in text: + additions += "#include \n" + return text.replace('#include "fixture.hpp"', additions + '#include "fixture.hpp"') + + +def prepare(formatter): + manifest = json.loads((APPLICATIONS / "manifest.json").read_text()) + deltas = [] + for original in sorted(UPSTREAM.rglob("*")): + if original.suffix not in (".cpp", ".hpp", ".html"): + continue + relative = original.relative_to(UPSTREAM) + before = original.read_text() + fixture = adapt_fixture(relative, before) + for variant, text in (("oracle", fixture), ("port", migrate(fixture))): + destination = APPLICATIONS / variant / relative + destination.parent.mkdir(parents=True, exist_ok=True) + if original.suffix in (".cpp", ".hpp"): + result = subprocess.run([formatter, f"--assume-filename={destination}"], + input=text, text=True, capture_output=True, check=True) + text = result.stdout + write_changed(destination, text) + if variant == "port": + deltas.extend(difflib.unified_diff(before.splitlines(True), text.splitlines(True), + fromfile=f"upstream/{relative}", tofile=f"port/{relative}")) + write_changed(APPLICATIONS / "adaptations.patch", "".join(deltas)) + prepare_jam(manifest) + prepare_host_handlers(manifest, formatter) + import prepare_wasip3 + prepare_wasip3.generate(formatter) + import prepare_browser + prepare_browser.generate(formatter) + import prepare_host_clients + prepare_host_clients.generate(formatter) + import prepare_noexcept + prepare_noexcept.generate(formatter) + subprocess.run([sys.executable, str(APPLICATIONS / "streams/prepare.py"), formatter], + check=True) + subprocess.run([sys.executable, str(APPLICATIONS / "host-extra/prepare.py"), + "--clang-format", formatter], check=True) + import normalize + normalize.apply() + print(f"Prepared {len(manifest['applications'])} oracle/port applications") + + +def prepare_jam(manifest): + lines = [JAM_NOTICE, + "# Fixtures read the environment fixed by their launching driver.\n" + "project : requirements msvc:_CRT_SECURE_NO_WARNINGS ;\n\n", + "import webcpp ;\nwebcpp.targets native ;\n", + "webcpp.original python3 ;\n"] + targets = [] + for row in manifest["applications"]: + for variant in ("oracle", "port"): + target = f"{variant}-{row['id']}" + targets.append(target) + sources = " ".join(f"../../example/applications/{variant}/{source}" + for source in row["sources"]) + requirement = "/webcpp/beast//tls" if row["tls"] else "/webcpp/beast//sockets" + context = " /webcpp//boost_context" if row["stackful"] else "" + lines.append(f"webcpp.drive {target} : {sources}\n" + f" : {requirement}{context} on\n" + f" ../../example/applications/{variant}\n" + " ../../example/applications multi\n" + " BOOST_ASIO_HAS_CO_AWAIT=1\n" + " BOOST_ASIO_HAS_STD_COROUTINE=1\n" + f" : driver.py : {row['id']} : native ;\n") + lines.append("webcpp.run documentation_snippets : documentation_snippets.cpp\n" + " : /webcpp/beast//sockets ../../example/applications\n" + " ../../example/applications/port : native wasip3 ;\n") + lines.append("webcpp.run context_unwind : context_unwind.cpp\n" + " : /webcpp//boost_context on ;\n") + lines.append("webcpp.lane applications :\n " + "\n ".join(targets) + "\n : native ;\n") + for project in ("host", "wasip3", "browser", "streams", "chat", "host-clients", + "noexcept", "browser-noexcept", "host-extra", "host-tls"): + lines.append(f"build-project {project} ;\n") + write_changed(APPLICATIONS.parents[1] / "test/applications/Jamfile", "".join(lines)) + + +def prepare_host_handlers(manifest, formatter): + host = APPLICATIONS / "host" + host.mkdir(exist_ok=True) + generated = [] + for row in manifest["applications"]: + if not row["server"]: + continue + source_path = UPSTREAM / row["entrypoint"] + source = source_path.read_text() + if "http::message_generator" not in source or "\nhandle_request(" not in source: + continue + start = re.search(r"beast::string_view\s+mime_type\(", source) + if start is None: + continue + handler = source.index("\nhandle_request(") + opening = source.index("{", handler) + depth = 1 + end = opening + 1 + while depth: + depth += (source[end] == "{") - (source[end] == "}") + end += 1 + body = source[start.start():end].replace("http::message_generator", "application_response") + # The host owns persistence. No physical connection fields are fabricated. + body = body.replace("res.keep_alive(req.keep_alive());", "") + prefix = NOTICE + """#include +#include +#include +#include +#include +namespace beast = webcpp::beast; +namespace http = beast::http; +using application_response = std::variant, + http::response, http::response>; +""" + text = prefix + body + """ +application_response handle(http::request request) { + return handle_request(".", std::move(request)); +} +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +""" + destination = host / f"{row['id']}.cpp" + result = subprocess.run([formatter, f"--assume-filename={destination}"], input=text, + text=True, capture_output=True, check=True) + write_changed(destination, result.stdout) + generated.append(row["id"]) + (host / "mapping.json").write_text(json.dumps({ + "applications": generated, + "adaptation": "Original mime_type, path_cat and handle_request; message_generator " + "replaced by std::variant; host owns persistence and server entrypoint.", + }, indent=2) + "\n") + project = APPLICATIONS.parents[1] / "test/applications/host" + project.mkdir(exist_ok=True) + lines = [JAM_NOTICE, "import webcpp ;\nwebcpp.targets wasip2 wasip3 ;\n", + "webcpp.original python3 : .. ;\n"] + for name in generated: + lines.append(f"webcpp.drive {name} : ../../../example/applications/host/{name}.cpp\n" + " : /webcpp/beast//beast /webcpp/wasi//host-http\n" + " -mexec-model=reactor\n" + f" : driver.py : {name} : wasip2 wasip3 ;\n") + lines.append("webcpp.lane applications-host :\n " + "\n ".join(generated) + + "\n : wasip2 wasip3 ;\n") + write_changed(project / "Jamfile", "".join(lines)) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--clang-format", required=True) + args = parser.parse_args() + prepare(args.clang_format) + + +if __name__ == "__main__": + main() diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_browser.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_browser.py new file mode 100644 index 0000000..d3f8ea2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_browser.py @@ -0,0 +1,198 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Keep original client state machines over browser-owned WebSocket and fetch.""" + +import difflib +import json +import re +import subprocess + +import prepare +import prepare_wasip3 + + +def closing(text, start, left="(", right=")"): + depth = 1 + cursor = start + 1 + while depth: + depth += (text[cursor] == left) - (text[cursor] == right) + cursor += 1 + return cursor + + +def adapt(relative, source): + text = prepare_wasip3.adapt(relative, source) + text = text.replace('#include "fixture_resolver.hpp"', + "#include ") + text = text.replace("webcpp_fixture::resolver", "webcpp::asio::ip::tcp::resolver") + text = text.replace("#include ", "#include ") + text = text.replace("#include ", "") + text = text.replace('#include "common/root_certificates.hpp"', "") + text = re.sub(r"namespace ssl\s*= boost::asio::ssl", "namespace ssl = webcpp::asio::ssl", text) + text = re.sub(r"namespace ssl\s*= net::ssl", "namespace ssl = webcpp::asio::ssl", text) + text = text.replace("ssl::stream<", "beast::ssl_stream<") + text = text.replace("beast::ssl_stream", "beast::ssl_stream") + text = text.replace("net::connect(beast::get_lowest_layer(ws), results)", + "beast::get_lowest_layer(ws).connect(results)") + text = re.sub(r"[\w.]+\.set\(\s*http::field::user_agent,.*?\);", "", text, flags=re.S) + text = text.replace("ssl::context::tlsv12_client", "ssl::context::tls_client") + text = text.replace("load_root_certificates(ctx);", + "// Browser trust store owns TLS authorities.") + text = text.replace("websocket::stream", "websocket::stream") + text = text.replace("net::connect(ws.next_layer(), results)", + "ws.next_layer().connect(results)") + while match := re.search(r"if\s*\(\s*!\s*SSL_set_tlsext_host_name", text): + call = text.index("(", text.index("SSL_set_tlsext_host_name", match.start())) + call_end = closing(text, call) + stream, host = text[call + 1:call_end - 1].split(",", 1) + stream = stream.replace(".native_handle()", "").strip() + start = text.index("{", call_end) + end = closing(text, start, "{", "}") + replacement = f"beast::set_server_name({stream}, {host.strip()}).value();" + text = text[:match.start()] + replacement + text[end:] + while match := re.search(r"[\w.]+\.set_option\(\s*websocket::stream_base::decorator", text): + start = text.index("(", match.start()) + end = closing(text, start) + text = text[:match.start()] + "/* Browser owns handshake User-Agent. */" + text[end + 1:] + text = text.replace("ec == net::error::eof || ec == ssl::error::stream_truncated", + "ec == net::error::eof") + text = text.replace("ec && ec != net::error::eof && ec != ssl::error::stream_truncated", "ec") + text = text.replace("ec != net::ssl::error::stream_truncated", "bool(ec)") + text = text.replace("ec != ssl::error::stream_truncated", "bool(ec)") + # Explicit tokens preserve the C++20 coroutine model on browser transports. + cursor = 0 + while True: + start = text.find("co_await ", cursor) + if start < 0: + break + stop = text.find(";", start) + expression = text[start:stop] + operation = re.search(r"async_\w+\s*\(", expression) + if operation: + opening = start + expression.index("(", operation.start()) + end = closing(text, opening) + text = text[:end - 1] + ", net::use_awaitable" + text[end - 1:] + cursor = end + len(", net::use_awaitable") + else: + cursor = stop + 1 + text = text.replace("net::as_tuple, net::use_awaitable", + "net::as_tuple(net::use_awaitable)") + if relative.name == "urls_large_data.cpp": + text = text.replace('"localhost"', '"127.0.0.1"') + if relative.name == "http_client_methods.cpp": + text = text.replace("beast::tcp_stream & stream", + "beast::browser::http_byte_stream & stream") + text = text.replace("beast::tcp_stream stream(ioc);", "beast::tcp_stream transport(ioc);\n" + "beast::browser::http_byte_stream stream(transport);") + text = text.replace("stream.connect(results);", "transport.connect(results);") + text = text.replace("stream.socket().shutdown", "transport.socket().shutdown") + text = text.replace('#include "fixture.hpp"', + '#include "fixture.hpp"\n' + '#include ') + text = re.sub(r"\bmain\s*\(", "application_main(", text) + return text + + +def wrapper(row): + name = row["id"] + host = '"localhost"' if row["tls"] else '"127.0.0.1"' + tls = "global(\"beastSecurePort\")" if row["tls"] else 'global("location")["port"]' + argument = '"Beast fixture echo"' if name.startswith("websocket-") else '"/http"' + expected = '"Beast fixture echo"' if name.startswith("websocket-") else '"fetch body"' + arguments = f'{{"{name}", {host}, port, {argument}}}' + if name == "json_client": + arguments, expected = '{"json_client"}', '"pure awesomeness"' + elif name == "http-crawl": + arguments, expected = '{"http-crawl", "2"}', '"Success : 3"' + methods = name == "http-client-methods" + if methods: + arguments, expected = '{"http-client-methods", method}', '"200 OK"' + begin = 'for (const auto* method : {"get", "head", "post", "put", "patch", "delete"}) {' \ + if methods else "{" + return f""" +#include +#include +#include +int main() {{ + const auto port = emscripten::val::{tls}.as(); + if (setenv("WEBCPP_BEAST_FIXTURE_HOST", {host}, 1) != 0) {{ + return 1; + }} + if (setenv("WEBCPP_BEAST_FIXTURE_PORT", port.c_str(), 1) != 0) {{ + return 1; + }} + {begin} + std::vector storage{arguments}; + std::vector arguments; + for (auto& value : storage) arguments.push_back(value.data()); + std::ostringstream output; + auto* original = std::cout.rdbuf(output.rdbuf()); + const auto result = application_main(static_cast(arguments.size()), arguments.data()); + std::cout.rdbuf(original); + std::cout << output.str(); + if (result != 0 || output.str().find({expected}) == std::string::npos) return 1; + }} + std::cout << "application {name}: passed\\n"; + return 0; +}} +""" + + +def generate(formatter): + manifest = json.loads((prepare.APPLICATIONS / "manifest.json").read_text()) + rows = [row for row in manifest["applications"] if not row["server"] and + not row["local_socket"] and not row["stackful"] and row["id"] != "doc-ssl-client"] + needed = {source for row in rows for source in row["sources"]} + needed |= {"http/client/body/json_body.hpp", "http/client/crawl/urls_large_data.hpp"} + entrypoints = {row["entrypoint"]: row for row in rows} + deltas = [] + for name in sorted(needed): + original = prepare.UPSTREAM / name + source = original.read_text() + text = adapt(original.relative_to(prepare.UPSTREAM), source) + if name in entrypoints: + text += wrapper(entrypoints[name]) + destination = prepare.APPLICATIONS / "browser" / name + destination.parent.mkdir(parents=True, exist_ok=True) + text = subprocess.run([formatter, f"--assume-filename={destination}"], input=text, + text=True, capture_output=True, check=True).stdout + prepare.write_changed(destination, text) + deltas.extend(difflib.unified_diff(source.splitlines(True), text.splitlines(True), + fromfile=f"upstream/{name}", tofile=f"browser/{name}")) + (prepare.APPLICATIONS / "browser.patch").write_text("".join(deltas)) + project = prepare.APPLICATIONS.parents[1] / "test/applications/browser" + project.mkdir(exist_ok=True) + lines = [prepare.JAM_NOTICE, "import webcpp ;\nwebcpp.targets emscripten ;\n", + "webcpp.original node : .. ;\n"] + for row in rows: + sources = " ".join("../../../example/applications/browser/" + source + for source in row["sources"]) + lines.append(f"webcpp.variants {row['id']} : {sources}\n" + " : /webcpp/beast//browser on\n" + " ../../../example/applications/browser\n" + " ../../../example/applications single\n" + " BOOST_ASIO_HAS_CO_AWAIT=1\n" + " BOOST_ASIO_HAS_STD_COROUTINE=1 ;\n" + f"webcpp.drive run-{row['id']} : .//{row['id']}\n" + f" : {row['id']}.variants.json 120\n" + f" : run.mjs : --program {row['id']} --expected " + f'"application {row["id"]}: passed"\n' + " : emscripten ;\n") + lines.append("webcpp.lane applications-browser :\n " + + "\n ".join("run-" + row["id"] for row in rows) + "\n : emscripten ;\n") + prepare.write_changed(project / "Jamfile", "".join(lines)) + (prepare.APPLICATIONS / "browser/mapping.json").write_text(json.dumps({ + "applications": [row["id"] for row in rows], + "adaptations": ["Browser owns DNS, HTTP framing, WebSocket wire protocol and TLS trust.", + "TLS fixture trusts an ephemeral CA only in a fresh Chromium profile.", + "No certificate exception is used; untrusted CA and trusted wrong-host " + "rejection controls accompany HTTPS/WSS exchanges.", + "Guest CA lists, TLS version pinning, and handshake User-Agent removed.", + "System executor and crawler threads use explicit io_context scheduling.", + "Awaitable clients retain co_await with explicit use_awaitable tokens.", + "Driver injects the local browser endpoint and validates response output."], + }, indent=2) + "\n") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_host_clients.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_host_clients.py new file mode 100644 index 0000000..870c807 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_host_clients.py @@ -0,0 +1,173 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Explicit host HTTP client counterparts, retaining each application's request semantics.""" + +import json +import re +import subprocess +from pathlib import Path + +import prepare + + +METHODS = ''' + const http::verb methods[] = {http::verb::get, http::verb::head, http::verb::post, + http::verb::put, http::verb::patch, http::verb::delete_}; + for (const auto method : methods) { + http::request request{method, "/fixture", 11}; + request.set(http::field::host, authority); + if (method == http::verb::post) request.body() = "Some random post data"; + if (method == http::verb::put) request.body() = "Some random put data"; + if (method == http::verb::delete_) request.body() = "Some random delete data"; + if (method == http::verb::patch) request.body() = "Some random patch data"; + request.prepare_payload(); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok) return failure(error); + if (method != http::verb::head && !request.body().empty() && + response.body() != request.body()) return failure(error); + ++completed; + } +''' + + +def crawl(source): + report = source[source.index("// This structure aggregates"): + source.index("// Performs HTTP GET requests")] + report = re.sub(r"net::strand<\s*net::io_context::executor_type> strand_;", + "wasi::http_context& context_;", report) + report = report.replace("std::atomic", "std::size_t") + report = report.replace("std::size_t index_;", "std::size_t index_ = 0;") + report = report.replace("std::vector", "std::vector") + report = re.sub(r"crawl_report\(net::io_context& ioc\)\s*:\s*" + r"strand_\(ioc.get_executor\(\)\)\s*, index_\(0\)\s*, " + r"hosts_\(urls_large_data\(\)\)", + "crawl_report(wasi::http_context& context, " + "const std::vector& hosts)\n" + ": context_(context), hosts_(hosts)", report) + report = re.sub(r"net::post\(\s*strand_,", "context_.get_executor().post(", report) + report = report.replace("[&, f]", "[this, f]") + report = report.replace(" });", " }, std::allocator{});") + report = report.replace("char const*\n get_host()", "crawl_target const*\n get_host()") + report = report.replace("return hosts_[n];", "return &hosts_[n];") + report = report.replace("if(n >= hosts_.size())\n return nullptr;", + "if(n >= hosts_.size()) { return nullptr; }") + report = re.sub(r"(for\(auto const& result : report.status_codes\))\s*(os <<.*?;\n)", + r"\1 { \2 }\n", report, flags=re.S) + report = report.replace("on the strand.", "on the serialized host queue.") + report = report.replace(" // Counts the number of timer failures", + " [[nodiscard]] std::size_t completed() const { return count_; }\n\n" + " // Counts the number of timer failures") + template = Path(__file__).with_name("host_crawl.cpp.in").read_text() + return template.replace("@REPORT@", report) + + +def generate(formatter): + manifest = json.loads((prepare.APPLICATIONS / "manifest.json").read_text()) + rows = [row for row in manifest["applications"] if not row["server"] and + not row["id"].startswith("websocket-")] + destination = prepare.APPLICATIONS / "host-clients/json_body.hpp" + destination.parent.mkdir(exist_ok=True) + body = (prepare.UPSTREAM / "http/client/body/json_body.hpp").read_text() + body = prepare.NOTICE + body.replace("", "") + body = subprocess.run([formatter, f"--assume-filename={destination}"], input=body, + text=True, capture_output=True, check=True).stdout + prepare.write_changed(destination, body) + for row in rows: + source = (prepare.UPSTREAM / row["entrypoint"]).read_text() + notice = source[:source.find("#include")] + includes = "" + operation = ''' + http::request request{http::verb::get, "/fixture", 11}; + request.set(http::field::host, authority); + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != "beast-application-fixture\\n") return failure(error); + ++completed; +''' + if row["id"] == "http-client-methods": + operation = METHODS + if row["id"] == "json_client": + includes = '#include "json_body.hpp"\n#include \n' + operation = ''' + http::request request{http::verb::post, "/post", 11}; + request.set(http::field::host, authority); + request.set(http::field::content_type, "application/json"); + request.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + request.prepare_payload(); + request.chunked(false); // Host owns framing for the original unsized JSON Body. + http::response response; + peer.perform(request, response, error); + if (error || response.result() != http::status::ok || + response.body() != request.body()) return failure(error); + ++completed; +''' + text = prepare.NOTICE + notice + ''' +#include +#include +''' + includes + ''' +namespace beast = webcpp::beast; +namespace http = beast::http; +http::response failure(boost::system::error_code error) { + http::response response{http::status::bad_gateway, 11}; + response.body() = "application peer exchange failed: " + error.message(); + response.prepare_payload(); + return response; +} +http::response handle(http::request incoming) { + const auto authority_field = incoming["X-Beast-Peer"]; + const std::string authority(authority_field.data(), authority_field.size()); + const auto scheme_field = incoming["X-Beast-Scheme"]; + const std::string scheme = scheme_field.empty() ? "http" : + std::string(scheme_field.data(), scheme_field.size()); + beast::wasi::client peer{scheme, authority}; + boost::system::error_code error; + unsigned completed = 0; +''' + operation + ''' + http::response result{http::status::ok, 11}; + result.body() = "completed=" + std::to_string(completed); + result.prepare_payload(); + return result; +} +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle) +''' + if row["id"] == "http-crawl": + text = prepare.NOTICE + notice + crawl(source) + destination = prepare.APPLICATIONS / "host-clients" / f"{row['id']}.cpp" + destination.parent.mkdir(exist_ok=True) + text = subprocess.run([formatter, f"--assume-filename={destination}"], input=text, + text=True, capture_output=True, check=True).stdout + prepare.write_changed(destination, text) + project = prepare.APPLICATIONS.parents[1] / "test/applications/host-clients" + project.mkdir(exist_ok=True) + lines = [prepare.JAM_NOTICE, "import webcpp ;\nwebcpp.targets wasip2 wasip3 ;\n", + "webcpp.original python3 : .. ;\n"] + for row in rows: + name = row["id"] + lines.append(f"webcpp.drive {name} : " + f"../../../example/applications/host-clients/{name}.cpp\n" + " : /webcpp/beast//wasi-http -mexec-model=reactor\n" + " ../../../example/applications\n" + f" : driver.py : {name} : wasip2 wasip3 ;\n") + lines.append("webcpp.lane applications-host-clients :\n " + + "\n ".join(row["id"] for row in rows) + "\n : wasip2 wasip3 ;\n") + prepare.write_changed(project / "Jamfile", "".join(lines)) + (prepare.APPLICATIONS / "host-clients/mapping.json").write_text(json.dumps({ + "applications": [row["id"] for row in rows], + "adaptations": ["Incoming host invocation replaces command-line launch.", + "Host HTTP perform replaces original socket scheduling and HTTP framing.", + "GET, six methods and JSON Body retained. Crawler preserves the upstream " + "report and two asynchronous get-next/complete/aggregate workers over " + "up to 32 distinct controlled authority/path pairs. Host HTTP combines " + "transport phases; complete exchange failures increment Read, while " + "the separate socket phase counters are unmeasured.", + "TLS/Unix transport become host-owned; the base fixture measures HTTP " + "payloads. Separate configured-host HTTPS fixtures verify CA trust, " + "hostname rejection, and the documentation client's mutual TLS.", + "Stackful source compatibility remains blocked without Boost.Context."], + }, indent=2) + "\n") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_noexcept.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_noexcept.py new file mode 100644 index 0000000..7363532 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_noexcept.py @@ -0,0 +1,146 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Preserve successful application flows with explicit fail-stop error semantics.""" + +import json +import re +import subprocess + +import prepare + + +def masked(text): + return re.sub(r'//[^\n]*|/\*.*?\*/|"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'', + lambda match: " " * len(match[0]), text, flags=re.S) + + +def end_block(text, opening): + depth = 1 + cursor = opening + 1 + while depth: + depth += (text[cursor] == "{") - (text[cursor] == "}") + cursor += 1 + return cursor + + +def observe_normal_close(text): + if "void do_session(" not in text or "ws.read(buffer);" not in text: + return text + text = text.replace('#include "failure.hpp"', + '#include "failure.hpp"\n#include "close_observation.hpp"') + return text.replace("ws.read(buffer);", """beast::error_code read_error; + ws.read(buffer, read_error); + if (read_error == websocket::error::closed) { + webcpp_fixture::observe_normal_close(); + return; + } + if (read_error) { + webcpp_fixture::fail_stop(); + }""") + + +def adapt(text, browser=False): + while match := re.search(r"\bcatch\s*\(", masked(text)): + opening = text.index("{", match.end()) + end = end_block(masked(text), opening) + text = text[:match.start()] + text[end:] + text = re.sub(r"\btry\s*(?=\{)", "", text) + text = re.sub(r"std::rethrow_exception\([^;]*\)", "webcpp_fixture::fail_stop()", text) + while match := re.search(r"\bthrow\b", masked(text)): + end = text.index(";", match.end()) + text = text[:match.start()] + "webcpp_fixture::fail_stop()" + text[end:] + text = text.replace('#include "fixture.hpp"', + '#include "fixture.hpp"\n#include "failure.hpp"') + if browser: + text = text.replace("resolver.resolve(", "webcpp_fixture::resolve(resolver, ") + text = text.replace("ctx.set_verify_mode(ssl::verify_peer);", + "{ boost::system::error_code verify_error; " + "ctx.set_verify_mode(ssl::verify_peer, verify_error); " + "if (verify_error) webcpp_fixture::fail_stop(); }") + return observe_normal_close(text) + + +def generate(formatter): + manifest = json.loads((prepare.APPLICATIONS / "manifest.json").read_text()) + variants = (("port", "noexcept-native"), ("wasip3", "noexcept-single"), + ("browser", "noexcept-browser")) + for original_variant, variant in variants: + for original in sorted((prepare.APPLICATIONS / original_variant).rglob("*")): + if original.suffix not in (".cpp", ".hpp"): + continue + relative = original.relative_to(prepare.APPLICATIONS / original_variant) + destination = prepare.APPLICATIONS / variant / relative + destination.parent.mkdir(parents=True, exist_ok=True) + text = adapt(original.read_text(), original_variant == "browser") + text = subprocess.run([formatter, f"--assume-filename={destination}"], input=text, + text=True, capture_output=True, check=True).stdout + prepare.write_changed(destination, text) + rows = [row for row in manifest["applications"] if not row["stackful"]] + project = prepare.APPLICATIONS.parents[1] / "test/applications/noexcept" + project.mkdir(exist_ok=True) + lines = [prepare.JAM_NOTICE, "import webcpp ;\nwebcpp.targets native wasip3 ;\n", + "webcpp.original python3 : .. ;\n"] + native, single, cooperative, checked = [], [], [], [] + for row in manifest["applications"]: + modes = [("wasip3", "checked")] + if not row["stackful"]: + modes += [("noexcept-native", "threaded"), ("noexcept-single", "single")] + if not row["local_socket"] and not row["stackful"]: + modes.append(("noexcept-single", "cooperative")) + for variant, mode in modes: + name = f"{mode}-{row['id']}" + groups = {"threaded": native, "single": single, "cooperative": cooperative, + "checked": checked} + groups[mode].append(name) + targets = ("wasip3" if mode == "cooperative" else "native" if + mode in ("threaded", "checked") or row["local_socket"] else "native wasip3") + sources = " ".join(f"../../../example/applications/{variant}/" + source + for source in row["sources"]) + library = "tls" if row["tls"] else "sockets" + threading = "multi" if mode in ("threaded", "cooperative") else "single" + exceptions = "on" if mode == "checked" else "off" + context = " /webcpp//boost_context" if row["stackful"] else "" + compile_budget = (" clang-wasip3:90\n" + if "wasip3" in targets else "") + lines.append(f"webcpp.drive {name} : {sources}\n" + f" : /webcpp/beast//{library}{context}\n" + f" {exceptions}\n" + f"{compile_budget}" + f" ../../../example/applications/{variant}\n" + f" ../../../example/applications {threading}\n" + " BOOST_ASIO_HAS_CO_AWAIT=1\n" + " BOOST_ASIO_HAS_STD_COROUTINE=1\n" + f" : ../driver.py : {row['id']} : {targets} ;\n") + lines.append("webcpp.lane applications-noexcept :\n " + "\n ".join(native) + + "\n : native ;\n") + lines.append("webcpp.lane applications-single-noexcept :\n " + "\n ".join(single) + + "\n : native wasip3 ;\n") + lines.append("webcpp.lane applications-cooperative-noexcept :\n " + + "\n ".join(cooperative) + "\n : wasip3 ;\n") + lines.append("webcpp.lane applications-single :\n " + "\n ".join(checked) + + "\n : native ;\n") + prepare.write_changed(project / "Jamfile", "".join(lines)) + browser = json.loads((prepare.APPLICATIONS / "browser/mapping.json").read_text()) + source_jam = (project.parent / "browser/Jamfile").read_text() + source_jam = source_jam.replace("applications/browser/", "applications/noexcept-browser/") + source_jam = source_jam.replace("../../../example/applications/browser\n", + "../../../example/applications/noexcept-browser\n") + source_jam = source_jam.replace("on", "off") + source_jam = source_jam.replace(": run.mjs :", ": ../browser/run.mjs :") + destination = project.parent / "browser-noexcept" + destination.mkdir(exist_ok=True) + prepare.write_changed(destination / "Jamfile", source_jam) + (prepare.APPLICATIONS / "noexcept-single/mapping.json").write_text(json.dumps({ + "applications": [row["id"] for row in rows], + "browser_applications": browser["applications"], + "adaptations": ["Explicit throw/rethrow sites terminate with a diagnostic and abort.", + "Catch blocks are removed; error_code paths and successful flows retained.", + "Sync WebSocket servers observe normal close " + "through error_code and return.", + "Boost.Context stackful source remains blocked in exception-off modes.", + "Single-thread variants additionally apply explicit WASIp3 scheduling."], + }, indent=2) + "\n") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_wasip3.py b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_wasip3.py new file mode 100644 index 0000000..be2488e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/tools/prepare_wasip3.py @@ -0,0 +1,147 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +"""Retain application operations with explicit WASIp3 fixture/scheduling substitutions.""" + +import difflib +import json +import re +import subprocess + +import prepare + + +def adapt(relative, source): + text = prepare.migrate(prepare.adapt_fixture(relative, source)) + text = text.replace('#include "fixture.hpp"', + '#include "fixture.hpp"\n#include "fixture_resolver.hpp"') + text = text.replace("webcpp::asio::ip::tcp::resolver", "webcpp_fixture::resolver") + text = text.replace("tcp::resolver", "webcpp_fixture::resolver") + text = text.replace("#include ", "") + text = text.replace("#include ", + "#include \n#include \n" + "#include \n" + "#include \n" + "#include \n#include \n" + "#include \n#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include ") + text = text.replace("auto const threads =", "[[maybe_unused]] auto const threads =") + text = text.replace("auto const threads =", "[[maybe_unused]] auto const threads =") + text = text.replace("#include ", "") + text = re.sub(r"net::signal_set signals\(.*?\n\s*\}\);", "", text, flags=re.S) + text = re.sub(r"(?m)^([ \t]*)std::vector v;.*?^\1ioc\.run\(\);", + r"\1ioc.run();", text, flags=re.S) + text = re.sub(r"for\s*\(auto& t : v\)\s*t.join\(\);", "", text) + if "system-executor" in relative.as_posix(): + text = text.replace("net::strand", + "net::strand") + text = text.replace("session(ssl::context& ctx)", + "session(webcpp::asio::io_context& ioc, ssl::context& ctx)") + text = re.sub(r"net::make_strand\(net::system_executor(?:\(\)|\{\})\)", + "net::make_strand(boost::asio::any_io_executor(ioc.get_executor()))", text) + text = text.replace("std::make_shared(ctx)", + "std::make_shared(ioc, ctx)") + text = text.replace("// The SSL context is required, and holds certificates", + "webcpp::asio::io_context ioc;\n" + "// The SSL context is required, and holds certificates") + text = text.replace("net::query(net::system_executor(), net::execution::context).join();", + "ioc.run(); // lint-run: explicit single-thread application executor") + if relative.name == "http_crawl.cpp": + start = text.index(" // Create and launch the worker threads.") + end = text.index(" std::cout <<", start) + text = text[:start] + """ + // Each worker preserves the original crawl state machine on one explicit executor. + for (int index = 0; index < threads; ++index) + std::make_shared(report, ioc)->run(); + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + +""" + text[end:] + if relative.name == "websocket_server_fast.cpp": + begin = text.index("void\ndo_sync_session(") + end = text.index("// Echoes back all received WebSocket messages", begin) + text = text[:begin] + text[end:] + text = re.sub(r"std::thread\(\s*beast::bind_front_handler\(\s*&do_sync_listen,.*?" + r"\.detach\(\);", + "std::make_shared(ioc, tcp::endpoint{address, port})->run();", + text, flags=re.S) + if relative.name == "advanced_server_flex_awaitable.cpp": + text = text.replace("auto signal_set = net::signal_set{ executor, SIGINT, SIGTERM };", + "auto deadline = net::steady_timer{executor};\n" + "deadline.expires_after(std::chrono::seconds(4));") + text = text.replace("auto sig = co_await signal_set.async_wait();", + "co_await deadline.async_wait();") + text = text.replace("if(sig == SIGINT)", "if(true)") + if "int main(" in text or "\nmain(" in text: + split = re.search(r"\bint\s+main\(", text) + assert split is not None + before, main = text[:split.start()], text[split.start():] + if "/sync" in relative.as_posix() and "/server/" in relative.as_posix(): + if "http/server" in relative.as_posix(): + args = ("socket, ctx, doc_root" if "ssl" in relative.as_posix() + else "socket, doc_root") + main = re.sub(r"std::thread\{std::bind\(.*?\)\}\.detach\(\);", + "do_session(" + args + ");", main, flags=re.S) + else: + args = ("std::move(socket), ctx" if "ssl" in relative.as_posix() + else "std::move(socket)") + main = re.sub(r"std::thread\(.*?\)\.detach\(\);", + "do_session(" + args + ");", main, flags=re.S) + main = main.replace("for(;;)", "for (unsigned accepted = 0; accepted < 1; ++accepted)") + text = before + main + return text + + +def generate(formatter): + manifest = json.loads((prepare.APPLICATIONS / "manifest.json").read_text()) + deltas = [] + for original in sorted(prepare.UPSTREAM.rglob("*")): + if original.suffix not in (".cpp", ".hpp"): + continue + relative = original.relative_to(prepare.UPSTREAM) + source = original.read_text() + destination = prepare.APPLICATIONS / "wasip3" / relative + destination.parent.mkdir(parents=True, exist_ok=True) + text = adapt(relative, source) + formatted = subprocess.run([formatter, f"--assume-filename={destination}"], + input=text, text=True, capture_output=True, check=True).stdout + prepare.write_changed(destination, formatted) + deltas.extend(difflib.unified_diff(source.splitlines(True), formatted.splitlines(True), + fromfile=f"upstream/{relative}", + tofile=f"wasip3/{relative}")) + (prepare.APPLICATIONS / "wasip3.patch").write_text("".join(deltas)) + rows = [row for row in manifest["applications"] if not row["local_socket"] and + not row["stackful"]] + project = prepare.APPLICATIONS.parents[1] / "test/applications/wasip3" + project.mkdir(exist_ok=True) + lines = [prepare.JAM_NOTICE, "import webcpp ;\nwebcpp.targets wasip3 ;\n", + "webcpp.original python3 : .. ;\n"] + for row in rows: + sources = " ".join("../../../example/applications/wasip3/" + source + for source in row["sources"]) + library = "tls" if row["tls"] else "sockets" + lines.append(f"webcpp.drive {row['id']} : {sources}\n" + f" : /webcpp/beast//{library} on\n" + " 90\n" + " ../../../example/applications/wasip3\n" + " ../../../example/applications single\n" + " BOOST_ASIO_HAS_CO_AWAIT=1\n" + " BOOST_ASIO_HAS_STD_COROUTINE=1\n" + f" : ../driver.py : {row['id']} : wasip3 ;\n") + lines.append("webcpp.lane applications-p3 :\n " + + "\n ".join(row["id"] for row in rows) + "\n : wasip3 ;\n") + prepare.write_changed(project / "Jamfile", "".join(lines)) + (prepare.APPLICATIONS / "wasip3/mapping.json").write_text(json.dumps({ + "applications": [row["id"] for row in rows], + "adaptations": [ + "Fixture resolver posts localhost; original asynchronous DNS remains blocked.", + "Worker pools, system_executor and detached sessions share an explicit io_context.", + "OS signal cancellation becomes an awaitable deadline or driver-controlled shutdown.", + "Sync server accepts one complete connection; driver bounds asynchronous listeners.", + ], + }, indent=2) + "\n") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3.patch b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3.patch new file mode 100644 index 0000000..3b45012 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3.patch @@ -0,0 +1,32268 @@ +--- upstream/advanced/server/advanced_server.cpp ++++ wasip3/advanced/server/advanced_server.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,89 +31,103 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include +-#include + #include + #include +-#include ++#include ++#include ++#include ++#include ++ ++#include + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -107,15 +139,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -126,9 +153,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -139,9 +164,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -152,19 +175,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -173,19 +194,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -195,10 +215,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -209,106 +227,71 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class websocket_session : public std::enable_shared_from_this +-{ ++class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- websocket_session(tcp::socket&& socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation +- template +- void +- do_accept(http::request> req) +- { ++ template ++ void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " advanced-server"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); ++ })); + + // Accept the websocket handshake + ws_.async_accept( +- req, +- beast::bind_front_handler( +- &websocket_session::on_accept, +- shared_from_this())); ++ req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + + private: +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + return; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &websocket_session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, ++ shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -322,13 +305,12 @@ + //------------------------------------------------------------------------------ + + // Handles an HTTP server connection +-class http_session : public std::enable_shared_from_this +-{ ++class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + +- static constexpr std::size_t queue_limit = 8; // max responses ++ static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can +@@ -337,35 +319,23 @@ + + public: + // Take ownership of the socket +- http_session( +- tcp::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- static_assert(queue_limit > 0, +- "queue limit must be positive"); ++ http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) { ++ static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- stream_.get_executor(), +- beast::bind_front_handler( +- &http_session::do_read, +- this->shared_from_this())); ++ net::dispatch(stream_.get_executor(), ++ beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + + private: +- void +- do_read() +- { ++ void do_read() { + // Construct a new parser for each message + parser_.emplace(); + +@@ -377,34 +347,26 @@ + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface +- http::async_read( +- stream_, +- buffer_, +- *parser_, +- beast::bind_front_handler( +- &http_session::on_read, +- shared_from_this())); +- } +- +- void +- on_read(beast::error_code ec, std::size_t bytes_transferred) +- { ++ http::async_read(stream_, buffer_, *parser_, ++ beast::bind_front_handler(&http_session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade +- if(websocket::is_upgrade(parser_->get())) +- { ++ if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. +- std::make_shared( +- stream_.release_socket())->do_accept(parser_->release()); ++ std::make_shared(stream_.release_socket()) ++ ->do_accept(parser_->release()); + return; + } + +@@ -416,9 +378,7 @@ + do_read(); + } + +- void +- queue_write(http::message_generator response) +- { ++ void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + +@@ -429,43 +389,30 @@ + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. +- void +- do_write() +- { +- if(! response_queue_.empty()) +- { ++ void do_write() { ++ if (!response_queue_.empty()) { + bool keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( +- stream_, +- std::move(response_queue_.front()), +- beast::bind_front_handler( +- &http_session::on_write, +- shared_from_this(), +- keep_alive)); +- } +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(response_queue_.front()), ++ beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); ++ } ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); + } + + // Resume the read if it has been paused +- if(response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) + do_read(); + + response_queue_.pop(); +@@ -473,9 +420,7 @@ + do_write(); + } + +- void +- do_close() +- { ++ void do_close() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -487,97 +432,69 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- acceptor_.get_executor(), +- beast::bind_front_handler( +- &listener::do_accept, +- this->shared_from_this())); ++ net::dispatch(acceptor_.get_executor(), ++ beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the http session and run it +- std::make_shared( +- std::move(socket), +- doc_root_)->run(); ++ std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection +@@ -587,58 +504,33 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: advanced-server
\n" << +- "Example:\n" << +- " advanced-server 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: advanced-server
\n" ++ << "Example:\n" ++ << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port +- std::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown +- net::signal_set signals(ioc, SIGINT, SIGTERM); +- signals.async_wait( +- [&](beast::error_code const&, int) +- { +- // Stop the `io_context`. This will cause `run()` +- // to return immediately, eventually destroying the +- // `io_context` and all of the sockets in it. +- ioc.stop(); +- }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for(auto& t : v) +- t.join(); + + return EXIT_SUCCESS; + } +--- upstream/advanced/server-flex/advanced_server_flex.cpp ++++ wasip3/advanced/server-flex/advanced_server_flex.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,93 +32,107 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ + #include + #include +-#include ++#include ++#include ++#include ++#include ++#include ++ ++#include + #include + #include + #include + #include +-#include + #include + #include + #include + #include + #include +-#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -110,16 +143,11 @@ + // + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. +-template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++template ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -130,9 +158,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -143,9 +169,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -156,19 +180,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -177,19 +199,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -199,10 +220,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -213,9 +232,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -233,7 +250,7 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +@@ -244,100 +261,69 @@ + // Echoes back all received WebSocket messages. + // This uses the Curiously Recurring Template Pattern so that + // the same code works with both SSL streams and regular sockets. +-template +-class websocket_session +-{ ++template ++class websocket_session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. +- Derived& +- derived() +- { +- return static_cast(*this); +- } ++ Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation +- template +- void +- do_accept(http::request> req) +- { ++ template ++ void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( +- websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { ++ websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " advanced-server-flex"); ++ std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake +- derived().ws().async_accept( +- req, +- beast::bind_front_handler( +- &websocket_session::on_accept, +- derived().shared_from_this())); ++ derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, ++ derived().shared_from_this())); + } + + private: +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- derived().ws().async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- derived().shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, ++ derived().shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + return; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), +- beast::bind_front_handler( +- &websocket_session::on_write, +- derived().shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -349,10 +335,8 @@ + + public: + // Start the asynchronous operation +- template +- void +- run(http::request> req) +- { ++ template ++ void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } +@@ -361,74 +345,46 @@ + //------------------------------------------------------------------------------ + + // Handles a plain WebSocket connection +-class plain_websocket_session +- : public websocket_session +- , public std::enable_shared_from_this +-{ ++class plain_websocket_session : public websocket_session, ++ public std::enable_shared_from_this { + websocket::stream ws_; + + public: + // Create the session +- explicit +- plain_websocket_session( +- beast::tcp_stream&& stream) +- : ws_(std::move(stream)) +- { +- } ++ explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class +- websocket::stream& +- ws() +- { +- return ws_; +- } ++ websocket::stream& ws() { return ws_; } + }; + + //------------------------------------------------------------------------------ + + // Handles an SSL WebSocket connection +-class ssl_websocket_session +- : public websocket_session +- , public std::enable_shared_from_this +-{ ++class ssl_websocket_session : public websocket_session, ++ public std::enable_shared_from_this { + websocket::stream> ws_; + + public: + // Create the ssl_websocket_session +- explicit +- ssl_websocket_session(ssl::stream&& stream) +- : ws_(std::move(stream)) +- { +- } ++ explicit ssl_websocket_session(ssl::stream&& stream) ++ : ws_(std::move(stream)) {} + + // Called by the base class +- websocket::stream>& +- ws() +- { +- return ws_; +- } ++ websocket::stream>& ws() { return ws_; } + }; + + //------------------------------------------------------------------------------ + +-template +-void +-make_websocket_session( +- beast::tcp_stream stream, +- http::request> req) +-{ +- std::make_shared( +- std::move(stream))->run(std::move(req)); ++template ++void make_websocket_session(beast::tcp_stream stream, ++ http::request> req) { ++ std::make_shared(std::move(stream))->run(std::move(req)); + } + +-template +-void +-make_websocket_session( +- ssl::stream stream, +- http::request> req) +-{ +- std::make_shared( +- std::move(stream))->run(std::move(req)); ++template ++void make_websocket_session(ssl::stream stream, ++ http::request> req) { ++ std::make_shared(std::move(stream))->run(std::move(req)); + } + + //------------------------------------------------------------------------------ +@@ -436,20 +392,15 @@ + // Handles an HTTP server connection. + // This uses the Curiously Recurring Template Pattern so that + // the same code works with both SSL streams and regular sockets. +-template +-class http_session +-{ ++template ++class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. +- Derived& +- derived() +- { +- return static_cast(*this); +- } +- +- static constexpr std::size_t queue_limit = 8; // max responses ++ Derived& derived() { return static_cast(*this); } ++ ++ static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can +@@ -461,17 +412,10 @@ + + public: + // Construct the session +- http_session( +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : doc_root_(doc_root) +- , buffer_(std::move(buffer)) +- { +- } +- +- void +- do_read() +- { ++ http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) ++ : doc_root_(doc_root), buffer_(std::move(buffer)) {} ++ ++ void do_read() { + // Construct a new parser for each message + parser_.emplace(); + +@@ -480,43 +424,33 @@ + parser_->body_limit(10000); + + // Set the timeout. +- beast::get_lowest_layer( +- derived().stream()).expires_after(std::chrono::seconds(30)); ++ beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( +- derived().stream(), +- buffer_, +- *parser_, +- beast::bind_front_handler( +- &http_session::on_read, +- derived().shared_from_this())); +- } +- +- void +- on_read(beast::error_code ec, std::size_t bytes_transferred) +- { ++ derived().stream(), buffer_, *parser_, ++ beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return derived().do_eof(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade +- if(websocket::is_upgrade(parser_->get())) +- { ++ if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. +- return make_websocket_session( +- derived().release_stream(), +- parser_->release()); ++ return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response +@@ -527,9 +461,7 @@ + do_read(); + } + +- void +- queue_write(http::message_generator response) +- { ++ void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + +@@ -540,43 +472,30 @@ + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. +- void +- do_write() +- { +- if(! response_queue_.empty()) +- { ++ void do_write() { ++ if (!response_queue_.empty()) { + bool keep_alive = response_queue_.front().keep_alive(); + +- beast::async_write( +- derived().stream(), +- std::move(response_queue_.front()), +- beast::bind_front_handler( +- &http_session::on_write, +- derived().shared_from_this(), +- keep_alive)); +- } +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::async_write(derived().stream(), std::move(response_queue_.front()), ++ beast::bind_front_handler(&http_session::on_write, ++ derived().shared_from_this(), keep_alive)); ++ } ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused +- if(response_queue_.size() == queue_limit) ++ if (response_queue_.size() == queue_limit) + do_read(); + + response_queue_.pop(); +@@ -588,50 +507,28 @@ + //------------------------------------------------------------------------------ + + // Handles a plain HTTP connection +-class plain_http_session +- : public http_session +- , public std::enable_shared_from_this +-{ ++class plain_http_session : public http_session, ++ public std::enable_shared_from_this { + beast::tcp_stream stream_; + + public: + // Create the session +- plain_http_session( +- beast::tcp_stream&& stream, +- beast::flat_buffer&& buffer, +- std::shared_ptr const& doc_root) +- : http_session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(stream)) +- { +- } ++ plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, ++ std::shared_ptr const& doc_root) ++ : http_session(std::move(buffer), doc_root), ++ stream_(std::move(stream)) {} + + // Start the session +- void +- run() +- { +- this->do_read(); +- } ++ void run() { this->do_read(); } + + // Called by the base class +- beast::tcp_stream& +- stream() +- { +- return stream_; +- } ++ beast::tcp_stream& stream() { return stream_; } + + // Called by the base class +- beast::tcp_stream +- release_stream() +- { +- return std::move(stream_); +- } ++ beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class +- void +- do_eof() +- { ++ void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -643,78 +540,48 @@ + //------------------------------------------------------------------------------ + + // Handles an SSL HTTP connection +-class ssl_http_session +- : public http_session +- , public std::enable_shared_from_this +-{ ++class ssl_http_session : public http_session, ++ public std::enable_shared_from_this { + ssl::stream stream_; + + public: + // Create the http_session +- ssl_http_session( +- beast::tcp_stream&& stream, +- ssl::context& ctx, +- beast::flat_buffer&& buffer, +- std::shared_ptr const& doc_root) +- : http_session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(stream), ctx) +- { +- } ++ ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, ++ std::shared_ptr const& doc_root) ++ : http_session(std::move(buffer), doc_root), ++ stream_(std::move(stream), ctx) {} + + // Start the session +- void +- run() +- { ++ void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( +- ssl::stream_base::server, +- buffer_.data(), +- beast::bind_front_handler( +- &ssl_http_session::on_handshake, +- shared_from_this())); ++ ssl::stream_base::server, buffer_.data(), ++ beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class +- ssl::stream& +- stream() +- { +- return stream_; +- } ++ ssl::stream& stream() { return stream_; } + + // Called by the base class +- ssl::stream +- release_stream() +- { +- return std::move(stream_); +- } ++ ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class +- void +- do_eof() +- { ++ void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( +- beast::bind_front_handler( +- &ssl_http_session::on_shutdown, +- shared_from_this())); ++ beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + + private: +- void +- on_handshake( +- beast::error_code ec, +- std::size_t bytes_used) +- { +- if(ec) ++ void on_handshake(beast::error_code ec, std::size_t bytes_used) { ++ if (ec) + return fail(ec, "handshake"); + + // Consume the portion of the buffer used by the handshake +@@ -723,10 +590,8 @@ + do_read(); + } + +- void +- on_shutdown(beast::error_code ec) +- { +- if(ec) ++ void on_shutdown(beast::error_code ec) { ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -736,167 +601,112 @@ + //------------------------------------------------------------------------------ + + // Detects SSL handshakes +-class detect_session : public std::enable_shared_from_this +-{ ++class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + + public: +- explicit +- detect_session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , ctx_(ctx) +- , doc_root_(doc_root) +- { +- } ++ explicit detect_session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- stream_.get_executor(), +- beast::bind_front_handler( +- &detect_session::on_run, +- this->shared_from_this())); +- } +- +- void +- on_run() +- { ++ net::dispatch(stream_.get_executor(), ++ beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); ++ } ++ ++ void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( +- stream_, +- buffer_, +- beast::bind_front_handler( +- &detect_session::on_detect, +- this->shared_from_this())); +- } +- +- void +- on_detect(beast::error_code ec, bool result) +- { +- if(ec) ++ stream_, buffer_, ++ beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); ++ } ++ ++ void on_detect(beast::error_code ec, bool result) { ++ if (ec) + return fail(ec, "detect"); + +- if(result) +- { ++ if (result) { + // Launch SSL session +- std::make_shared( +- std::move(stream_), +- ctx_, +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(std::move(stream_), ctx_, std::move(buffer_), ++ doc_root_) ++ ->run(); + return; + } + + // Launch plain session +- std::make_shared( +- std::move(stream_), +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) ++ ->run(); + } + }; + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the detector http_session and run it +- std::make_shared( +- std::move(socket), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection +@@ -906,24 +716,21 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: advanced-server-flex
\n" << +- "Example:\n" << +- " advanced-server-flex 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: advanced-server-flex
\n" ++ << "Example:\n" ++ << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -932,39 +739,16 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown +- net::signal_set signals(ioc, SIGINT, SIGTERM); +- signals.async_wait( +- [&](beast::error_code const&, int) +- { +- // Stop the `io_context`. This will cause `run()` +- // to return immediately, eventually destroying the +- // `io_context` and all of the sockets in it. +- ioc.stop(); +- }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for(auto& t : v) +- t.join(); + + return EXIT_SUCCESS; + } +--- upstream/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp ++++ wasip3/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // Copyright (c) 2024 Mohammad Nejati +@@ -14,90 +33,116 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include ++#include "common/server_certificate.hpp" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + #include +-#include +-#include ++#include ++#include ++#include ++#include + + #include + #include + #include + #include + #include +-#include ++ + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; +-namespace ssl = boost::asio::ssl; +- +-using executor_type = net::strand; +-using stream_type = typename beast::tcp_stream::rebind_executor::other; +-using acceptor_type = typename net::ip::tcp::acceptor::rebind_executor::other; ++namespace net = boost::asio; ++namespace ssl = boost::asio::ssl; ++ ++using executor_type = net::strand; ++using stream_type = typename beast::tcp_stream::rebind_executor::other; ++using acceptor_type = ++ typename webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -108,16 +153,11 @@ + // + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. +-template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++template ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -128,9 +168,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -141,9 +179,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -154,19 +190,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -175,19 +209,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -197,10 +230,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -211,70 +242,53 @@ + /** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. + */ +-class task_group +-{ ++class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + + public: + task_group(net::any_io_executor exec) +- : cv_{ std::move(exec), net::steady_timer::time_point::max() } +- { +- } ++ : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; +- task_group(task_group&&) = delete; ++ task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + +- @note @p completion_token must have an associated executor that matches +- the one the child task runs on (e.g. via @c net::bind_executor). This is +- because @c emit() can run on a different thread than the task, and +- @c co_spawn dispatches the cancellation to the handler's associated ++ ote `completion_token` must have an associated executor that matches ++ the one the child task runs on (e.g. via `net::bind_executor`). This is ++ because `emit`() can run on a different thread than the task, and ++ `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety +- @e Distinct @e objects: Safe.@n +- @e Shared @e objects: Safe. ++ `Distinct` `objects:` Safe. ++ `Shared` `objects:` Safe. + */ +- template +- auto +- adapt(CompletionToken&& completion_token) +- { +- auto lg = std::lock_guard{ mtx_ }; ++ template ++ auto adapt(CompletionToken&& completion_token) { ++ auto lg = std::lock_guard{mtx_}; + auto cs = css_.emplace(css_.end()); + +- class remover +- { ++ class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: +- remover( +- task_group* tg, +- decltype(css_)::iterator cs) +- : tg_{ tg } +- , cs_{ cs } +- { +- } ++ remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept +- : tg_{ std::exchange(other.tg_, nullptr) } +- , cs_{ other.cs_ } +- { +- } +- +- ~remover() +- { +- if(tg_) +- { +- auto lg = std::lock_guard{ tg_->mtx_ }; +- if(tg_->css_.erase(cs_) == tg_->css_.end()) ++ : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} ++ ++ ~remover() { ++ if (tg_) { ++ auto lg = std::lock_guard{tg_->mtx_}; ++ if (tg_->css_.erase(cs_) == tg_->css_.end()) + tg_->cv_.cancel(); + } + } +@@ -282,9 +296,7 @@ + + return net::bind_cancellation_slot( + cs->slot(), +- net::consign( +- std::forward(completion_token), +- remover{ this, cs })); ++ net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's +@@ -293,14 +305,12 @@ + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety +- @e Distinct @e objects: Safe.@n +- @e Shared @e objects: Safe. ++ `Distinct` `objects:` Safe. ++ `Shared` `objects:` Safe. + */ +- void +- emit(net::cancellation_type type) +- { +- auto lg = std::lock_guard{ mtx_ }; +- for(auto& cs : css_) ++ void emit(net::cancellation_type type) { ++ auto lg = std::lock_guard{mtx_}; ++ for (auto& cs : css_) + cs.emit(type); + } + +@@ -308,8 +318,8 @@ + + The completion handler will be called when: + +- @li All the child tasks completed. +- @li The operation was cancelled. ++ - All the child tasks completed. ++ - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion +@@ -321,86 +331,66 @@ + @endcode + + @par Thread Safety +- @e Distinct @e objects: Safe.@n +- @e Shared @e objects: Safe. ++ `Distinct` `objects:` Safe. ++ `Shared` `objects:` Safe. + */ +- template< +- typename CompletionToken = +- net::default_completion_token_t> +- auto +- async_wait( +- CompletionToken&& completion_token = +- net::default_completion_token_t{}) +- { +- return net:: +- async_compose( +- [this, scheduled = false]( +- auto&& self, boost::system::error_code ec = {}) mutable ++ template > ++ auto async_wait(CompletionToken&& completion_token = ++ net::default_completion_token_t{}) { ++ return net::async_compose( ++ [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { ++ if (!scheduled) ++ self.reset_cancellation_state(net::enable_total_cancellation()); ++ ++ if (!self.cancelled() && ec == net::error::operation_aborted) ++ ec = {}; ++ + { +- if(!scheduled) +- self.reset_cancellation_state( +- net::enable_total_cancellation()); +- +- if(!self.cancelled() && ec == net::error::operation_aborted) +- ec = {}; +- +- { +- auto lg = std::lock_guard{ mtx_ }; +- +- if(!css_.empty() && !ec) +- { +- scheduled = true; +- return cv_.async_wait(std::move(self)); +- } ++ auto lg = std::lock_guard{mtx_}; ++ ++ if (!css_.empty() && !ec) { ++ scheduled = true; ++ return cv_.async_wait(std::move(self)); + } +- +- if(!std::exchange(scheduled, true)) +- return net::post(net::append(std::move(self), ec)); +- +- self.complete(ec); +- }, +- completion_token, +- cv_); ++ } ++ ++ if (!std::exchange(scheduled, true)) ++ return net::post(net::append(std::move(self), ec)); ++ ++ self.complete(ec); ++ }, ++ completion_token, cv_); + } + }; + +-template +-net::awaitable +-run_websocket_session( +- Stream& stream, +- beast::flat_buffer& buffer, +- http::request req) +-{ ++template ++net::awaitable run_websocket_session(Stream& stream, ++ beast::flat_buffer& buffer, ++ http::request req) { + auto cs = co_await net::this_coro::cancellation_state; +- auto ws = websocket::stream{ stream }; ++ auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set( +- http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " advanced-server-flex"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); ++ })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + +- while(!cs.cancelled()) +- { ++ while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + +- if(ec == websocket::error::closed || ec == ssl::error::stream_truncated) ++ if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) + co_return; + +- if(ec) +- throw boost::system::system_error{ ec }; ++ if (ec) ++ throw boost::system::system_error{ec}; + + // Echo the message back + ws.text(ws.got_text()); +@@ -411,47 +401,37 @@ + } + + // A cancellation has been requested, gracefully close the session. +- auto [ec] = co_await ws.async_close( +- websocket::close_code::service_restart, net::as_tuple); +- +- if(ec && ec != ssl::error::stream_truncated) +- throw boost::system::system_error{ ec }; +-} +- +-template +-net::awaitable +-run_session( +- Stream& stream, +- beast::flat_buffer& buffer, +- beast::string_view doc_root) +-{ ++ auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); ++ ++ if (ec && ec != ssl::error::stream_truncated) ++ throw boost::system::system_error{ec}; ++} ++ ++template ++net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, ++ beast::string_view doc_root) { + auto cs = co_await net::this_coro::cancellation_state; + +- while(!cs.cancelled()) +- { ++ while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + +- auto [ec, _] = +- co_await http::async_read(stream, buffer, parser, net::as_tuple); +- +- if(ec == http::error::end_of_stream) ++ auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); ++ ++ if (ec == http::error::end_of_stream) + co_return; + +- if(websocket::is_upgrade(parser.get())) +- { ++ if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + +- co_await run_websocket_session( +- stream, buffer, parser.release()); ++ co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); +- if(!res.keep_alive()) +- { ++ if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } +@@ -460,19 +440,15 @@ + } + } + +-net::awaitable +-detect_session( +- stream_type stream, +- ssl::context& ctx, +- beast::string_view doc_root) +-{ ++net::awaitable detect_session(stream_type stream, ssl::context& ctx, ++ beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. +- co_await net::this_coro::reset_cancellation_state( +- net::enable_total_cancellation(), net::enable_terminal_cancellation()); ++ co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), ++ net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be +@@ -481,104 +457,83 @@ + + stream.expires_after(std::chrono::seconds(30)); + +- if(co_await beast::async_detect_ssl(stream, buffer)) +- { +- ssl::stream ssl_stream{ std::move(stream), ctx }; +- +- auto bytes_transferred = co_await ssl_stream.async_handshake( +- ssl::stream_base::server, buffer.data()); ++ if (co_await beast::async_detect_ssl(stream, buffer)) { ++ ssl::stream ssl_stream{std::move(stream), ctx}; ++ ++ auto bytes_transferred = ++ co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + +- if(!ssl_stream.lowest_layer().is_open()) ++ if (!ssl_stream.lowest_layer().is_open()) + co_return; + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) +- throw boost::system::system_error{ ec }; +- } +- else +- { ++ if (ec && ec != ssl::error::stream_truncated) ++ throw boost::system::system_error{ec}; ++ } else { + co_await run_session(stream, buffer, doc_root); + +- if(!stream.socket().is_open()) ++ if (!stream.socket().is_open()) + co_return; + +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); +- } +-} +- +-net::awaitable +-listen( +- task_group& task_group, +- ssl::context& ctx, +- net::ip::tcp::endpoint endpoint, +- beast::string_view doc_root) +-{ +- auto cs = co_await net::this_coro::cancellation_state; ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); ++ } ++} ++ ++net::awaitable listen(task_group& task_group, ssl::context& ctx, ++ webcpp::asio::ip::tcp::endpoint endpoint, ++ beast::string_view doc_root) { ++ auto cs = co_await net::this_coro::cancellation_state; + auto executor = co_await net::this_coro::executor; +- auto acceptor = acceptor_type{ executor, endpoint }; ++ auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. +- co_await net::this_coro::reset_cancellation_state( +- net::enable_total_cancellation()); +- +- while(!cs.cancelled()) +- { ++ co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); ++ ++ while (!cs.cancelled()) { + auto socket_executor = net::make_strand(executor.get_inner_executor()); +- auto [ec, socket] = +- co_await acceptor.async_accept(socket_executor, net::as_tuple); +- +- if(ec == net::error::operation_aborted) ++ auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); ++ ++ if (ec == net::error::operation_aborted) + co_return; + +- if(ec) +- throw boost::system::system_error{ ec }; ++ if (ec) ++ throw boost::system::system_error{ec}; + + net::co_spawn( +- socket_executor, +- detect_session(stream_type{ std::move(socket) }, ctx, doc_root), +- net::bind_executor( +- socket_executor, +- task_group.adapt( +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception& e) +- { +- std::cerr << "Error in session: " << e.what() << "\n"; +- } +- } +- }))); +- } +-} +- +-net::awaitable +-handle_signals(task_group& task_group) +-{ +- auto executor = co_await net::this_coro::executor; +- auto signal_set = net::signal_set{ executor, SIGINT, SIGTERM }; +- +- auto sig = co_await signal_set.async_wait(); +- +- if(sig == SIGINT) +- { ++ socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), ++ net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception& e) { ++ std::cerr << "Error in session: " << e.what() << "\n"; ++ } ++ } ++ }))); ++ } ++} ++ ++net::awaitable handle_signals(task_group& task_group) { ++ auto executor = co_await net::this_coro::executor; ++ auto deadline = net::steady_timer{executor}; ++ deadline.expires_after(std::chrono::seconds(4)); ++ ++ co_await deadline.async_wait(); ++ ++ if (true) { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( +- net::as_tuple(net::cancel_after(std::chrono::seconds{ 10 }))); +- +- if(ec == net::error::operation_aborted) // Timeout occurred ++ net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); ++ ++ if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); +@@ -586,90 +541,65 @@ + } + + std::cout << "Child tasks completed.\n"; +- } +- else // SIGTERM ++ } else // SIGTERM + { +- net::query( +- executor.get_inner_executor(), +- net::execution::context).stop(); +- } +-} +- +-int +-main(int argc, char* argv[]) +-{ ++ net::query(executor.get_inner_executor(), net::execution::context).stop(); ++ } ++} ++ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if(argc != 5) +- { ++ if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } +- auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const endpoint = net::ip::tcp::endpoint{ address, port }; +- auto const doc_root = beast::string_view{ argv[3] }; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(std::atoi(argv[2])); ++ auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; ++ auto const doc_root = beast::string_view{argv[3]}; ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{ threads }; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ ssl::context::tlsv12 }; ++ ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines +- task_group task_group{ ioc.get_executor() }; ++ task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto listener_executor = net::make_strand(ioc); +- net::co_spawn( +- listener_executor, +- listen(task_group, ctx, endpoint, doc_root), +- net::bind_executor( +- listener_executor, +- task_group.adapt( +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception& e) +- { +- std::cerr << "Error in listener: " << e.what() << "\n"; +- } +- } +- }))); ++ net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), ++ net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception& e) { ++ std::cerr << "Error in listener: " << e.what() << "\n"; ++ } ++ } ++ }))); + + // Create and launch a signal handler coroutine +- net::co_spawn( +- net::make_strand(ioc), handle_signals(task_group), net::detached); ++ net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back([&ioc] { ioc.run(); }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit +- for(auto& t : v) +- t.join(); + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/common/root_certificates.hpp ++++ wasip3/common/root_certificates.hpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -38,251 +56,253 @@ + tl;dr: root_certificates.hpp should not be used in production code + */ + +-namespace ssl = boost::asio::ssl; // from ++namespace ssl = boost::asio::ssl; // from + + namespace detail { + +-inline +-void +-load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) +-{ ++inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { ++ if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { ++ ctx.load_verify_file(path, ec); ++ return; ++ } ++ + std::string cert = + "# ACCVRAIZ1\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" +- "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" +- "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ\n" +- "BgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwHUEtJQUNDVjENMAsGA1UECgwEQUND\n" +- "VjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCb\n" +- "qau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gMjmoY\n" +-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+mWj2zs3gyLp\n" ++ "1txyM/1d8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B\n" ++ "9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok\n" ++ "RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" ++ "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# Actalis Authentication Root CA\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" +- "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" +- "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" +- "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" +- "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" +- "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB\n" +- "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv\n" +- "UTufClrJwkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX\n" +- "4ay8IMKx4INRimlNAJZaby/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9\n" +- "KK3giq0itFZljoZUj5NDKd45RnijMCO6zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/\n" +- "gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9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T6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX\n" ++ "X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok\n" ++ "fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R\n" ++ "K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU\n" ++ "ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU\n" ++ "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" ++ "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# AffirmTrust Commercial\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" +- "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" +- "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" +- "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" +- "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +- "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" +- "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" +- "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7e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xpH\n" ++ "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" ++ "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" ++ "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" ++ "KeC2uAloGRwYQw==\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# AffirmTrust Premium ECC\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" +- "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" +- "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" +- "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" +- "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" +- "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" +- "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" +- "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +- "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" +- "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" +- "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" +- "-----END CERTIFICATE-----\n" +- "\n"; ++ "-----BEGIN CERTIFICATE-----\n" ++ "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" ++ "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" ++ "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" ++ "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" ++ "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" ++ "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" ++ "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" ++ "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" ++ "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" ++ "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" ++ "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# Amazon Root CA 1\n" +- "-----BEGIN CERTIFICATE-----\n" +- "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" +- "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" +- "b24gUm9vdCBDQSAxMB4XD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8viTO96LXFvKWlJbYK8U90vv\n" ++ "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" ++ "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" ++ "rqXRfboQnoZsG4q5WTP468SQvvG5\n" ++ "-----END CERTIFICATE-----\n" ++ "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" +@@ -3933,30 +3953,23 @@ + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + +- ctx.add_certificate_authority( +- boost::asio::buffer(cert.data(), cert.size()), ec); +- if(ec) ++ ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); ++ if (ec) + return; + } + +-} // detail ++} // namespace detail + + // Load the root certificates into an ssl::context + +-inline +-void +-load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) +-{ ++inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); + } + +-inline +-void +-load_root_certificates(ssl::context& ctx) +-{ ++inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); +- if(ec) ++ if (ec) + throw boost::system::system_error{ec}; + } + +--- upstream/common/server_certificate.hpp ++++ wasip3/common/server_certificate.hpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -24,15 +42,20 @@ + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. + */ +-inline +-void +-load_server_certificate(boost::asio::ssl::context& ctx) +-{ ++inline void load_server_certificate(boost::asio::ssl::context& ctx) { ++ if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { ++ ctx.use_certificate_chain_file(path); ++ ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), ++ boost::asio::ssl::context::pem); ++ return; ++ } ++ + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 +- openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" ++ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj ++ "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = +@@ -98,28 +121,19 @@ + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; +- ++ + ctx.set_password_callback( +- [](std::size_t, +- boost::asio::ssl::context_base::password_purpose) +- { +- return "test"; +- }); ++ [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + +- ctx.set_options( +- boost::asio::ssl::context::default_workarounds | +- boost::asio::ssl::context::no_sslv2 | +- boost::asio::ssl::context::single_dh_use); ++ ctx.set_options(boost::asio::ssl::context::default_workarounds | ++ boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + +- ctx.use_certificate_chain( +- boost::asio::buffer(cert.data(), cert.size())); ++ ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + +- ctx.use_private_key( +- boost::asio::buffer(key.data(), key.size()), +- boost::asio::ssl::context::file_format::pem); ++ ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), ++ boost::asio::ssl::context::file_format::pem); + +- ctx.use_tmp_dh( +- boost::asio::buffer(dh.data(), dh.size())); ++ ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); + } + + #endif +--- upstream/doc/http_examples.hpp ++++ wasip3/doc/http_examples.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,8 +24,8 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include + #include ++#include + + /* This file contains the functions and classes found in the documentation + +@@ -17,7 +34,7 @@ + building a network application. + */ + +-// The documentation assumes the boost::beast::http namespace ++// The documentation assumes the webcpp::beast::http namespace + namespace boost { + namespace beast { + namespace http { +@@ -48,23 +65,13 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class SyncStream, +- class DynamicBuffer, +- class Body, class Allocator> +-void +-send_expect_100_continue( +- SyncStream& stream, +- DynamicBuffer& buffer, +- request>& req, +- error_code& ec) +-{ +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++template ++void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, ++ request>& req, error_code& ec) { ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); +@@ -74,7 +81,7 @@ + + // Send just the header + write_header(stream, sr, ec); +- if(ec) ++ if (ec) + return; + + // Read the response from the server. +@@ -82,10 +89,9 @@ + { + response res; + read(stream, buffer, res, ec); +- if(ec) +- return; +- if(res.result() != status::continue_) +- { ++ if (ec) ++ return; ++ if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; +@@ -112,40 +118,30 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class SyncStream, +- class DynamicBuffer> +-void +-receive_expect_100_continue( +- SyncStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++template ++void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); +- if(ec) ++ if (ec) + return; + + // Check for the Expect field value +- if(beast::iequals(parser.get()[field::expect], "100-continue")) +- { ++ if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); +- if(ec) ++ if (ec) + return; + } + +@@ -166,7 +162,7 @@ + + /** Send the output of a child process as an HTTP response. + +- The output of the child process comes from a @b SyncReadStream. Data ++ The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. +@@ -177,20 +173,13 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class SyncReadStream, +- class SyncWriteStream> +-void +-send_cgi_response( +- SyncReadStream& input, +- SyncWriteStream& output, +- error_code& ec) +-{ ++template ++void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, +- "SyncReadStream requirements not met"); ++ "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, +- "SyncWriteStream requirements not met"); ++ "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. +@@ -213,20 +202,17 @@ + + // Send the header immediately. + write_header(output, sr, ec); +- if(ec) ++ if (ec) + return; + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. +- do +- { ++ do { + // Read a buffer from the child process + char buffer[2048]; +- auto bytes_transferred = input.read_some( +- boost::asio::buffer(buffer, sizeof(buffer)), ec); +- if(ec == boost::asio::error::eof) +- { ++ auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); ++ if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer +@@ -234,10 +220,8 @@ + + // `false` means no more data is coming + res.body().more = false; +- } +- else +- { +- if(ec) ++ } else { ++ if (ec) + return; + + // Point to our buffer with the bytes that +@@ -247,22 +231,20 @@ + res.body().size = bytes_transferred; + res.body().more = true; + } +- ++ + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. +- if(ec == error::need_buffer) +- { ++ if (ec == error::need_buffer) { + ec = {}; + continue; + } +- if(ec) +- return; +- } +- while(! sr.is_done()); ++ if (ec) ++ return; ++ } while (!sr.is_done()); + } + + //] +@@ -276,21 +258,12 @@ + //[example_http_do_head_response + + /** Handle a HEAD request for a resource. +-*/ +-template< +- class SyncStream, +- class DynamicBuffer +-> +-void do_server_head( +- SyncStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++ */ ++template ++void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; +@@ -298,7 +271,7 @@ + // Read the request + request req; + read(stream, buffer, req, ec); +- if(ec) ++ if (ec) + return; + + // Set up the response, starting with the common fields +@@ -307,43 +280,39 @@ + res.set(field::server, "test"); + + // Now handle request-specific fields +- switch(req.method()) +- { +- case verb::head: +- case verb::get: +- { +- // A HEAD request is handled by delivering the same +- // set of headers that would be sent for a GET request, +- // including the Content-Length, except for the body. +- res.result(status::ok); +- res.content_length(payload.size()); +- +- // For GET requests, we include the body +- if(req.method() == verb::get) +- { +- // We deliver the same payload for GET requests +- // regardless of the target. A real server might +- // deliver a file based on the target. +- res.body() = payload; +- } +- break; +- } +- +- default: +- { +- // We return responses indicating an error if +- // we do not recognize the request method. +- res.result(status::bad_request); +- res.set(field::content_type, "text/plain"); +- res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; +- res.prepare_payload(); +- break; +- } ++ switch (req.method()) { ++ case verb::head: ++ case verb::get: { ++ // A HEAD request is handled by delivering the same ++ // set of headers that would be sent for a GET request, ++ // including the Content-Length, except for the body. ++ res.result(status::ok); ++ res.content_length(payload.size()); ++ ++ // For GET requests, we include the body ++ if (req.method() == verb::get) { ++ // We deliver the same payload for GET requests ++ // regardless of the target. A real server might ++ // deliver a file based on the target. ++ res.body() = payload; ++ } ++ break; ++ } ++ ++ default: { ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ res.result(status::bad_request); ++ res.set(field::content_type, "text/plain"); ++ res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; ++ res.prepare_payload(); ++ break; ++ } + } + + // Send the response + write(stream, res, ec); +- if(ec) ++ if (ec) + return; + } + +@@ -368,27 +337,17 @@ + + @throws std::invalid_argument if target is empty. + */ +-template< +- class SyncStream, +- class DynamicBuffer +-> +-response +-do_head_request( +- SyncStream& stream, +- DynamicBuffer& buffer, +- string_view target, +- error_code& ec) +-{ ++template ++response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, ++ error_code& ec) { + // Do some type checking to be a good citizen +- static_assert(is_sync_stream::value, +- "SyncStream requirements not met"); +- static_assert( +- boost::asio::is_dynamic_buffer::value, +- "DynamicBuffer requirements not met"); ++ static_assert(is_sync_stream::value, "SyncStream requirements not met"); ++ static_assert(boost::asio::is_dynamic_buffer::value, ++ "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. +- if(target.empty()) ++ if (target.empty()) + throw std::invalid_argument("target may not be empty"); + + // Build the HEAD request for the target +@@ -404,7 +363,7 @@ + + // Now send it + write(stream, req, ec); +- if(ec) ++ if (ec) + return {}; + + // Create a parser to read the response. +@@ -420,7 +379,7 @@ + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); +- if(ec) ++ if (ec) + return {}; + + // Transfer ownership of the response to the caller. +@@ -467,25 +426,15 @@ + + @tparam Fields The type of fields to use for the message. + */ +-template< +- bool isRequest, +- class SyncWriteStream, +- class SyncReadStream, +- class DynamicBuffer, +- class Transform> +-void +-relay( +- SyncWriteStream& output, +- SyncReadStream& input, +- DynamicBuffer& buffer, +- error_code& ec, +- Transform&& transform) +-{ ++template ++void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, ++ Transform&& transform) { + static_assert(is_sync_write_stream::value, +- "SyncWriteStream requirements not met"); ++ "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, +- "SyncReadStream requirements not met"); ++ "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + char buf[2048]; +@@ -498,24 +447,22 @@ + + // Read just the header from the input + read_header(input, buffer, p, ec); +- if(ec) ++ if (ec) + return; + + // Apply the caller's header transformation + transform(p.get(), ec); +- if(ec) ++ if (ec) + return; + + // Send the transformed message to the output + write_header(output, sr, ec); +- if(ec) ++ if (ec) + return; + + // Loop over the input and transfer it to the output +- do +- { +- if(! p.is_done()) +- { ++ do { ++ if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf; + p.get().body().size = sizeof(buf); +@@ -524,19 +471,17 @@ + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer +- if(ec == error::need_buffer) ++ if (ec == error::need_buffer) + ec = {}; +- if(ec) ++ if (ec) + return; + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = sizeof(buf) - p.get().body().size; + p.get().body().data = buf; +- p.get().body().more = ! p.is_done(); +- } +- else +- { ++ p.get().body().more = !p.is_done(); ++ } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } +@@ -545,12 +490,11 @@ + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer +- if(ec == error::need_buffer) ++ if (ec == error::need_buffer) + ec = {}; +- if(ec) +- return; +- } +- while(! p.is_done() && ! sr.is_done()); ++ if (ec) ++ return; ++ } while (!p.is_done() && !sr.is_done()); + } + + //] +@@ -568,24 +512,17 @@ + + // This helper is needed for C++11. + // When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +-template +-class write_ostream_helper +-{ ++template ++class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + + public: +- write_ostream_helper(Serializer& sr, std::ostream& os) +- : sr_(sr) +- , os_(os) +- { +- } ++ write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer +- template +- void +- operator()(error_code& ec, ConstBufferSequence const& buffers) const +- { ++ template ++ void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + +@@ -593,20 +530,16 @@ + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence +- for(auto it = boost::asio::buffer_sequence_begin(buffers); +- it != boost::asio::buffer_sequence_end(buffers); ++it) +- { ++ for (auto it = boost::asio::buffer_sequence_begin(buffers); ++ it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream +- os_.write( +- reinterpret_cast(buffer.data()), +- buffer.size()); ++ os_.write(reinterpret_cast(buffer.data()), buffer.size()); + + // If the std::ostream fails, convert it to an error code +- if(os_.fail()) +- { ++ if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } +@@ -620,7 +553,7 @@ + } + }; + +-} // detail ++} // namespace detail + + /** Write a message to a `std::ostream`. + +@@ -633,31 +566,21 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- bool isRequest, +- class Body, +- class Fields> +-void +-write_ostream( +- std::ostream& os, +- message& msg, +- error_code& ec) +-{ ++template ++void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; +- do +- { ++ do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); +- if(ec) +- return; +- } +- while(! sr.is_done()); ++ if (ec) ++ return; ++ } while (!sr.is_done()); + } + + //] +@@ -682,17 +605,9 @@ + + @param ec Set to the error, if any occurred. + */ +-template< +- class Allocator, +- bool isRequest, +- class Body> +-void +-read_istream( +- std::istream& is, +- basic_flat_buffer& buffer, +- message& msg, +- error_code& ec) +-{ ++template ++void read_istream(std::istream& is, basic_flat_buffer& buffer, ++ message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are +@@ -702,25 +617,19 @@ + // + parser p{std::move(msg)}; + +- do +- { ++ do { + // Extract whatever characters are presently available in the istream +- if(is.rdbuf()->in_avail() > 0) +- { ++ if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing +- auto const b = buffer.prepare( +- static_cast(is.rdbuf()->in_avail())); ++ auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream +- buffer.commit(static_cast(is.readsome( +- reinterpret_cast(b.data()), b.size()))); +- } +- else if(buffer.size() == 0) +- { +- // Our buffer is empty and we need more characters, ++ buffer.commit( ++ static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); ++ } else if (buffer.size() == 0) { ++ // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream +- if(! is.eof()) +- { ++ if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + +@@ -728,8 +637,7 @@ + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. +- if(is.fail() && ! is.eof()) +- { ++ if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; +@@ -737,12 +645,10 @@ + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); +- } +- else +- { ++ } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); +- if(ec) ++ if (ec) + return; + break; + } +@@ -752,15 +658,14 @@ + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. +- if(ec == error::need_more) ++ if (ec == error::need_more) + ec = {}; +- if(ec) ++ if (ec) + return; + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); +- } +- while(! p.is_done()); ++ } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +@@ -798,16 +703,8 @@ + + @throws system_error Thrown on failure. + */ +-template< +- class SyncReadStream, +- class DynamicBuffer, +- class Handler> +-void +-do_form_request( +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- Handler&& handler) +-{ ++template ++void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + +@@ -816,45 +713,42 @@ + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb +- switch(req0.get().method()) +- { +- case verb::post: +- { +- // If this is not a form upload then use a string_body +- if( req0.get()[field::content_type] != "application/x-www-form-urlencoded" && +- req0.get()[field::content_type] != "multipart/form-data") +- goto do_dynamic_body; +- +- // Commit to string_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } +- +- do_dynamic_body: +- default: +- { +- // Commit to dynamic_body as the body type. +- // As long as there are no body octets in the parser +- // we are constructing from, no exception is thrown. +- request_parser req{std::move(req0)}; +- +- // Finish reading the message +- read(stream, buffer, req); +- +- // Call the handler. It can take ownership +- // if desired, since we are calling release() +- handler(req.release()); +- break; +- } ++ switch (req0.get().method()) { ++ case verb::post: { ++ // If this is not a form upload then use a string_body ++ if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && ++ req0.get()[field::content_type] != "multipart/form-data") ++ goto do_dynamic_body; ++ ++ // Commit to string_body as the body type. ++ // As long as there are no body octets in the parser ++ // we are constructing from, no exception is thrown. ++ request_parser req{std::move(req0)}; ++ ++ // Finish reading the message ++ read(stream, buffer, req); ++ ++ // Call the handler. It can take ownership ++ // if desired, since we are calling release() ++ handler(req.release()); ++ break; ++ } ++ ++ do_dynamic_body: ++ default: { ++ // Commit to dynamic_body as the body type. ++ // As long as there are no body octets in the parser ++ // we are constructing from, no exception is thrown. ++ request_parser req{std::move(req0)}; ++ ++ // Finish reading the message ++ read(stream, buffer, req); ++ ++ // Call the handler. It can take ownership ++ // if desired, since we are calling release() ++ handler(req.release()); ++ break; ++ } + } + } + +@@ -871,30 +765,21 @@ + /* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. + */ +-template< +- bool isRequest, +- class SyncReadStream, +- class DynamicBuffer> +-void +-read_and_print_body( +- std::ostream& os, +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ ++template ++void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, ++ error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); +- if(ec) ++ if (ec) + return; +- while(! p.is_done()) +- { ++ while (!p.is_done()) { + char buf[512]; + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + read(stream, buffer, p, ec); +- if(ec == error::need_buffer) ++ if (ec == error::need_buffer) + ec = {}; +- if(ec) ++ if (ec) + return; + os.write(buf, sizeof(buf) - p.get().body().size); + } +@@ -904,7 +789,7 @@ + + //------------------------------------------------------------------------------ + // +-// Example: Read large response body ++// Example: Read large response body + // + //------------------------------------------------------------------------------ + +@@ -914,24 +799,15 @@ + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. + */ +-template< +- class SyncReadStream, +- class DynamicBuffer, +- bool isRequest, class Body, class Allocator> +-std::size_t +-read_large_response_body( +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- message>& msg, +- std::size_t body_limit, +- error_code& ec) +-{ ++template ++std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, ++ message>& msg, ++ std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); +- auto const bytes_transferred = +- http::read(stream, buffer, p, ec); +- if(ec) ++ auto const bytes_transferred = http::read(stream, buffer, p, ec); ++ if (ec) + return bytes_transferred; + msg = p.release(); + return bytes_transferred; +@@ -948,25 +824,17 @@ + //[example_chunk_parsing + + /** Read a message with a chunked body and print the chunks and extensions +-*/ +-template< +- bool isRequest, +- class SyncReadStream, +- class DynamicBuffer> +-void +-print_chunked_body( +- std::ostream& os, +- SyncReadStream& stream, +- DynamicBuffer& buffer, +- error_code& ec) +-{ ++ */ ++template ++void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, ++ error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); +- if(ec) ++ if (ec) + return; + + // This container will hold the extensions for each chunk +@@ -978,18 +846,17 @@ + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = +- [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk +- string_view extensions, // The raw chunk-extensions string. Already validated. +- error_code& ev) // We can set this to indicate an error ++ [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk ++ string_view extensions, // The raw chunk-extensions string. Already validated. ++ error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); +- if(ev) ++ if (ev) + return; + + // See if the chunk is too big +- if(size > (std::numeric_limits::max)()) +- { ++ if (size > (std::numeric_limits::max)()) { + ev = error::body_limit; + return; + } +@@ -1006,15 +873,14 @@ + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. +- auto body_cb = +- [&](std::uint64_t remain, // The number of bytes left in this chunk +- string_view body, // A buffer holding chunk body data +- error_code& ec) // We can set this to indicate an error ++ auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk ++ string_view body, // A buffer holding chunk body data ++ error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. +- if(remain == body.size()) ++ if (remain == body.size()) + ec = error::end_of_chunk; + + // Append this piece to our container +@@ -1026,23 +892,21 @@ + }; + p.on_chunk_body(body_cb); + +- while(! p.is_done()) +- { ++ while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); +- if(! ec) ++ if (!ec) + continue; +- else if(ec != error::end_of_chunk) ++ else if (ec != error::end_of_chunk) + return; + else + ec = {}; + + // We got a whole chunk, print the extensions: +- for(auto const& extension : ce) +- { ++ for (auto const& extension : ce) { + os << "Extension: " << extension.first; +- if(! extension.second.empty()) ++ if (!extension.second.empty()) + os << " = " << extension.second << std::endl; + else + os << std::endl; +@@ -1056,12 +920,10 @@ + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it +- for(auto const& name : token_list{msg[field::trailer]}) +- { ++ for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); +- if(it == msg.end()) +- { ++ if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << std::endl; + continue; +@@ -1072,6 +934,6 @@ + + //] + +-} // http +-} // beast +-} // boost ++} // namespace http ++} // namespace beast ++} // namespace boost +--- upstream/doc/ssl/client.cpp ++++ wasip3/doc/ssl/client.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2025 Mohammad Nejati + // +@@ -7,52 +25,54 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + #include +-#include +-#include ++#include ++#include ++#include ++#include + + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = net::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = net::ssl; + +-void +-print_exception(std::exception_ptr eptr) +-{ +- if(eptr) +- { +- try +- { ++void print_exception(std::exception_ptr eptr) { ++ if (eptr) { ++ try { + std::rethrow_exception(eptr); +- } +- catch(std::exception& e) +- { ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + } + +-net::awaitable +-request(ssl::context& ctx) +-{ ++net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{ {}, 8080 }; +- ssl::stream stream{ executor, ctx }; ++ webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; ++ ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) +- if(!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set a callback to verify that the hostname in the server +@@ -63,7 +83,7 @@ + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request +- http::request req{ http::verb::get, "/", 11 }; ++ http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); +@@ -78,26 +98,22 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error(ec); + } + +-int +-main() +-{ +- try +- { ++int main() { ++ try { + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data +- ssl::context ctx{ ssl::context::sslv23 }; ++ ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ +- ctx.set_options( +- ssl::context::no_sslv2 | ssl::context::default_workarounds | +- ssl::context::single_dh_use); ++ ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | ++ ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful +@@ -117,19 +133,15 @@ + + net::co_spawn(ioc, request(ctx), print_exception); + +- ioc.run(); +- } +- catch(std::exception& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/doc/ssl/server.cpp ++++ wasip3/doc/ssl/server.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2025 Mohammad Nejati + // +@@ -7,39 +25,42 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + #include +-#include +-#include ++#include ++#include ++#include ++#include + + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = net::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = net::ssl; + +-void +-print_exception(std::exception_ptr eptr) +-{ +- if(eptr) +- { +- try +- { ++void print_exception(std::exception_ptr eptr) { ++ if (eptr) { ++ try { + std::rethrow_exception(eptr); +- } +- catch(std::exception& e) +- { ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + } + +-net::awaitable +-handle_session(ssl::stream stream) +-{ ++net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + +@@ -55,46 +76,37 @@ + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); +- if(ec && ec != ssl::error::stream_truncated) ++ if (ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error(ec); + } + +-net::awaitable +-acceptor(ssl::context& ctx) +-{ ++net::awaitable acceptor(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- net::ip::tcp::endpoint endpoint{ {}, 8080 }; +- net::ip::tcp::acceptor acceptor{ executor, endpoint }; ++ webcpp::asio::ip::tcp::endpoint endpoint{net::ip::make_address("127.0.0.1"), ++ webcpp_fixture::port_number()}; ++ webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + +- for(;;) +- { +- net::co_spawn( +- executor, +- handle_session({ co_await acceptor.async_accept(), ctx }), +- print_exception); ++ for (;;) { ++ net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), ++ print_exception); + } + } + +-int +-main() +-{ +- try +- { ++int main() { ++ try { + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data +- ssl::context ctx{ ssl::context::sslv23 }; ++ ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ +- ctx.set_options( +- ssl::context::no_sslv2 | ssl::context::default_workarounds | +- ssl::context::single_dh_use); ++ ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | ++ ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. +- ctx.set_verify_mode( +- ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); ++ ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. +@@ -113,19 +125,15 @@ + + net::co_spawn(ioc, acceptor(ctx), print_exception); + +- ioc.run(); +- } +- catch(std::exception& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception& e) { + std::cerr << e.what() << std::endl; + } + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/echo-op/echo_op.cpp ++++ wasip3/echo-op/echo_op.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,30 +24,35 @@ + // Official repository: https://github.com/boostorg/beast + // + +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + #include + #include + #include + #include ++#include ++#include + + namespace net = boost::asio; +-namespace beast = boost::beast; ++namespace beast = webcpp::beast; + + //[example_core_echo_op_1 + +-template< +- class AsyncStream, +- class DynamicBuffer, +- class CompletionToken> +-auto +-async_echo (AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) +- +-//] +- -> +- typename net::async_result< +- typename std::decay::type, +- void(beast::error_code)>::return_type; ++template ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) ++ ++ //] ++ -> typename net::async_result::type, ++ void(beast::error_code)>::return_type; + + //------------------------------------------------------------------------------ + +@@ -39,15 +61,15 @@ + /** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending +- in a newline (`"\n"`) from the stream, and then write ++ in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + +- @li A line was read in and written back on the stream +- +- @li An error occurs. ++ - A line was read in and written back on the stream ++ ++ - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` +@@ -61,7 +83,7 @@ + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the +- requirements of AsyncReadStream and @AsyncWriteStream ++ requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is +@@ -82,24 +104,20 @@ + of the handler will be performed in a manner equivalent to using + `net::post`. + */ +-template< +- class AsyncStream, +- class DynamicBuffer, +- class CompletionToken> +-auto +-async_echo ( ++template ++auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ +- CompletionToken&& token) -> +- typename net::async_result< /*< `async_result` deduces the return type from the completion handler >*/ +- typename std::decay::type, +- void(beast::error_code) /*< The completion handler signature goes here >*/ +- >::return_type; ++ CompletionToken&& token) -> typename net:: ++ async_result*/ ++ typename std::decay::type, ++ void(beast::error_code) /*< The completion handler signature goes here >*/ ++ >::return_type; + //] + + //[example_core_echo_op_3 + +-template ++template + class echo_op; + + // This example uses the Asio's stackless "fauxroutines", implemented +@@ -109,27 +127,18 @@ + + // Read a line and echo it back + // +-template< +- class AsyncStream, +- class DynamicBuffer, +- class CompletionToken> +-auto +-async_echo( +- AsyncStream& stream, +- DynamicBuffer& buffer, +- CompletionToken&& token) -> +- typename net::async_result< +- typename std::decay::type, +- void(beast::error_code)>::return_type /*< The completion handler signature goes here >*/ ++template ++auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) -> ++ typename net::async_result::type, ++ void(beast::error_code)>::return_type /*< The completion handler ++ signature goes here >*/ + { + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. +- static_assert( +- beast::is_async_stream::value, +- "AsyncStream type requirements not met"); +- static_assert( +- net::is_dynamic_buffer::value, +- "DynamicBuffer type requirements not met"); ++ static_assert(beast::is_async_stream::value, ++ "AsyncStream type requirements not met"); ++ static_assert(net::is_dynamic_buffer::value, ++ "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, +@@ -156,29 +165,27 @@ + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ +- beast::executor_type /*< The type of executor used by the stream to dispatch asynchronous operations >*/ +- >; ++ beast::executor_type /*< The type of executor used by the stream to dispatch ++ asynchronous operations >*/ ++ >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + +- struct echo_op : base_type, boost::asio::coroutine +- { ++ struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream_; + DynamicBuffer& buffer_; + +- echo_op( +- AsyncStream& stream, +- DynamicBuffer& buffer, +- handler_type&& handler) ++ echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( +- std::move(handler), /*< The `async_base` helper takes ownership of the handler, >*/ +- stream.get_executor()) /*< and also needs to know which executor to use. >*/ +- , stream_(stream) +- , buffer_(buffer) +- { ++ std::move( ++ handler), /*< The `async_base` helper takes ownership of the handler, >*/ ++ stream.get_executor()) /*< and also needs to know which executor to use. >*/ ++ , ++ stream_(stream), ++ buffer_(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our +@@ -190,21 +197,19 @@ + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + +- std::size_t +- find_newline(typename DynamicBuffer::const_buffers_type const& buffers) +- { ++ std::size_t find_newline(typename DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + +- auto begin = net::buffers_iterator< +- typename DynamicBuffer::const_buffers_type>::begin(buffers); +- auto end = net::buffers_iterator< +- typename DynamicBuffer::const_buffers_type>::end(buffers); ++ auto begin = ++ net::buffers_iterator::begin(buffers); ++ auto end = ++ net::buffers_iterator::end(buffers); + auto result = std::find(begin, end, '\n'); + +- if(result == end) +- return 0; // not found ++ if (result == end) ++ return 0; // not found + + return result + 1 - begin; + } +@@ -212,38 +217,33 @@ + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + +- void +- operator()( +- beast::error_code ec, +- std::size_t bytes_transferred = 0, ++ void operator()( ++ beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + +- reenter(*this) +- { +- for(;;) +- { ++ reenter(*this) { ++ for (;;) { + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer_.data()); + + // If we don't have the newline, then read more +- if(pos == 0) +- { ++ if (pos == 0) { + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( +- std::max(512, // under 512 is too little, +- buffer_.capacity() - buffer_.size()), +- std::min(65536, // and over 65536 is too much. +- buffer_.max_size() - buffer_.size())); ++ std::max(512, // under 512 is too little, ++ buffer_.capacity() - buffer_.size()), ++ std::min(65536, // and over 65536 is too much. ++ buffer_.max_size() - buffer_.size())); + + // Read some data into our dynamic buffer_. We transfer + // ownership of the composed operation by using the +@@ -251,8 +251,8 @@ + // the function to return immediately after the initiating + // function returns. + +- yield stream_.async_read_some( +- buffer_.prepare(bytes_to_read), std::move(*this)); ++ yield stream_.async_read_some(buffer_.prepare(bytes_to_read), ++ std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. +@@ -263,7 +263,7 @@ + buffer_.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. +- if(ec) ++ if (ec) + break; + + // Keep looping until we get the newline +@@ -274,8 +274,8 @@ + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + +- yield net::async_write(stream_, +- beast::buffers_prefix(pos, buffer_.data()), std::move(*this)); ++ yield net::async_write(stream_, beast::buffers_prefix(pos, buffer_.data()), ++ std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, +@@ -330,27 +330,22 @@ + + //] + +-struct move_only_handler +-{ ++struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + +- void operator()(beast::error_code ec) +- { +- if(ec) ++ void operator()(beast::error_code ec) { ++ if (ec) + std::cerr << ": " << ec.message() << std::endl; + } + }; + +-int main(int argc, char** argv) +-{ +- if(argc != 3) +- { +- std::cerr +- << "Usage: echo-op
\n" +- << "Example:\n" +- << " echo-op 0.0.0.0 8080\n"; ++int main(int argc, char** argv) { ++ if (argc != 3) { ++ std::cerr << "Usage: echo-op
\n" ++ << "Example:\n" ++ << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + +@@ -358,12 +353,12 @@ + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + +- using endpoint_type = net::ip::tcp::endpoint; ++ using endpoint_type = webcpp::asio::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. +- net::io_context ioc; +- net::ip::tcp::acceptor acceptor{ioc}; ++ webcpp::asio::io_context ioc; ++ webcpp::asio::ip::tcp::acceptor acceptor{ioc}; + endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); +@@ -372,6 +367,6 @@ + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; + } +--- upstream/http/client/async/http_client_async.cpp ++++ wasip3/http/client/async/http_client_async.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,57 +30,44 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp_fixture::resolver resolver_; + beast::tcp_stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- explicit +- session(net::io_context& ioc) +- : resolver_(net::make_strand(ioc)) +- , stream_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) ++ : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); +@@ -73,36 +77,23 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ stream_.async_connect(results, ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -110,36 +101,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -149,7 +128,7 @@ + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -158,16 +137,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async []\n" << +- "Example:\n" << +- " http-client-async www.example.com 80 /\n" << +- " http-client-async www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async []\n" ++ << "Example:\n" ++ << " http-client-async www.example.com 80 /\n" ++ << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -176,14 +153,14 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/async-local/http_client_async_local.cpp ++++ wasip3/http/client/async-local/http_client_async_local.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -15,9 +32,9 @@ + //------------------------------------------------------------------------------ + + #include +-#include +-#include + #include ++#include ++#include + + #include + #include +@@ -26,49 +43,34 @@ + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- beast::basic_stream< +- stream_protocol, +- net::any_io_executor, +- beast::unlimited_rate_policy> stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++class session : public std::enable_shared_from_this { ++ beast::basic_stream ++ stream_; ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- explicit +- session(net::io_context& ioc) +- : stream_(ioc) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation +- void +- run( +- char const* path, +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* path, char const* host, char const* port, char const* target, ++ int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); +@@ -77,17 +79,12 @@ + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- stream_protocol::endpoint{path}, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ stream_.async_connect(stream_protocol::endpoint{path}, ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec) +- { +- if(ec) ++ void on_connect(beast::error_code ec) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -95,36 +92,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -134,7 +119,7 @@ + stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -143,16 +128,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 5 && argc != 6) +- { +- std::cerr << +- "Usage: http-client-async-local []\n" << +- "Example:\n" << +- " http-client-async-local /tmp/http.sock localhost 80 /\n" << +- " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; ++ if (argc != 5 && argc != 6) { ++ std::cerr << "Usage: http-client-async-local []\n" ++ << "Example:\n" ++ << " http-client-async-local /tmp/http.sock localhost 80 /\n" ++ << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; +@@ -162,26 +145,23 @@ + int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ +-std::cerr << +- "Local sockets not available on this platform" << std::endl; +-return EXIT_FAILURE; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; ++ return EXIT_FAILURE; + } + + #endif +--- upstream/http/client/async-ssl/http_client_async_ssl.cpp ++++ wasip3/http/client/async-ssl/http_client_async_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,65 +31,48 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp_fixture::resolver resolver_; + ssl::stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + public: +- explicit +- session( +- net::any_io_executor ex, +- ssl::context& ctx) +- : resolver_(ex) +- , stream_(ex, ctx) +- { +- } ++ explicit session(net::any_io_executor ex, ssl::context& ctx) ++ : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -88,19 +89,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -108,30 +101,21 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation +@@ -139,36 +123,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -179,14 +151,10 @@ + + // Gracefully close the stream + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -204,23 +172,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async-ssl []\n" << +- "Example:\n" << +- " http-client-async-ssl www.example.com 443 /\n" << +- " http-client-async-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async-ssl []\n" ++ << "Example:\n" ++ << " http-client-async-ssl www.example.com 443 /\n" ++ << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -229,7 +195,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -243,14 +209,11 @@ + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. +- std::make_shared( +- net::make_strand(ioc), +- ctx +- )->run(host, port, target, version); ++ std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp ++++ wasip3/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,73 +31,56 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp_fixture::resolver resolver_; + ssl::stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- session(net::strand strand, ssl::context& ctx) +- : resolver_(strand) +- , stream_(strand, ctx) +- { +- } ++ session(net::strand strand, ssl::context& ctx) ++ : resolver_(strand), stream_(strand, ctx) {} + + public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. +- explicit +- session(ssl::context& ctx) +- : session(net::make_strand(net::system_executor()), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* target, +- int version) +- { ++ void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -96,19 +97,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -116,30 +109,21 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { ++ if (ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation +@@ -147,36 +131,24 @@ + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -187,14 +159,10 @@ + + // Gracefully close the stream + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -212,23 +180,21 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-async-ssl-system-executor []\n" << +- "Example:\n" << +- " http-client-async-ssl-system-executor www.example.com 443 /\n" << +- " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-async-ssl-system-executor []\n" ++ << "Example:\n" ++ << " http-client-async-ssl-system-executor www.example.com 443 /\n" ++ << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -236,6 +202,7 @@ + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + ++ webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + +@@ -246,13 +213,12 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- std::make_shared(ctx)->run(host, port, target, version); +- ++ std::make_shared(ioc, ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. +- net::query(net::system_executor(), net::execution::context).join(); ++ ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; + } +--- upstream/http/client/awaitable/http_client_awaitable.cpp ++++ wasip3/http/client/awaitable/http_client_awaitable.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -16,9 +33,9 @@ + #include + #include + #include +-#include +-#include + #include ++#include ++#include + + #include + #include +@@ -26,17 +43,16 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; + + // Performs an HTTP GET and prints the response +-net::awaitable +-do_session(std::string host, std::string port, std::string target, int version) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string target, ++ int version) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = beast::tcp_stream{ executor }; ++ auto resolver = webcpp_fixture::resolver{executor}; ++ auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); +@@ -48,7 +64,7 @@ + co_await stream.async_connect(results); + + // Set up an HTTP GET request message +- http::request req{ http::verb::get, target, version }; ++ http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + +@@ -72,12 +88,12 @@ + + // Gracefully close the socket + beast::error_code ec; +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec); ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw boost::system::system_error(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -85,48 +101,39 @@ + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << "Usage: http-client-awaitable []\n" ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; ++ auto const host = argv[1]; ++ auto const port = argv[2]; + auto const target = argv[3]; +- auto const version = +- argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, target, version), +- // If the awaitable exists with an exception, it gets delivered here +- // as `e`. This can happen for regular errors, such as connection +- // drops. +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, target, version), ++ // If the awaitable exists with an exception, it gets delivered here ++ // as `e`. This can happen for regular errors, such as connection ++ // drops. ++ [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -135,9 +142,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp ++++ wasip3/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -18,11 +36,11 @@ + #include + #include + #include +-#include +-#include + #include ++#include ++#include + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + + #include + #include +@@ -30,32 +48,24 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; +-namespace ssl = boost::asio::ssl; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; ++namespace ssl = boost::asio::ssl; + + //------------------------------------------------------------------------------ + + // Performs an HTTP GET and prints the response +-net::awaitable +-do_session( +- std::string host, +- std::string port, +- std::string target, +- int version, +- ssl::context& ctx) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string target, int version, ++ ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = ssl::stream{ executor, ctx }; ++ auto resolver = webcpp_fixture::resolver{executor}; ++ auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification +@@ -77,7 +87,7 @@ + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message +- http::request req{ http::verb::get, target, version }; ++ http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + +@@ -122,38 +132,33 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec && ec != net::ssl::error::stream_truncated) ++ if (ec && ec != net::ssl::error::stream_truncated) + throw boost::system::system_error(ec, "shutdown"); + } + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr +- << "Usage: http-client-awaitable []\n" +- << "Example:\n" +- << " http-client-awaitable www.example.com 443 /\n" +- << " http-client-awaitable www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-awaitable []\n" ++ << "Example:\n" ++ << " http-client-awaitable www.example.com 443 /\n" ++ << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } +- auto const host = argv[1]; +- auto const port = argv[2]; ++ auto const host = argv[1]; ++ auto const port = argv[2]; + auto const target = argv[3]; +- auto const version = +- argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; ++ auto const version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates +- ssl::context ctx{ ssl::context::tlsv12_client }; ++ ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); +@@ -162,24 +167,19 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, target, version, ctx), +- // If the awaitable exists with an exception, it gets delivered here +- // as `e`. This can happen for regular errors, such as connection +- // drops. +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, target, version, ctx), ++ // If the awaitable exists with an exception, it gets delivered here ++ // as `e`. This can happen for regular errors, such as connection ++ // drops. ++ [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -188,9 +188,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/http/client/body/json_body.hpp ++++ wasip3/http/client/body/json_body.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -16,90 +33,68 @@ + #ifndef BOOST_BEAST_EXAMPLE_JSON_BODY + #define BOOST_BEAST_EXAMPLE_JSON_BODY + ++#include + #include ++#include + #include +-#include +-#include +-#include ++#include + + namespace json = boost::json; + +-struct json_body +-{ ++struct json_body { + using value_type = json::value; + +- struct writer +- { ++ struct writer { + using const_buffers_type = boost::asio::const_buffer; +- template +- writer( +- boost::beast::http::header const&, +- value_type const& body) +- { ++ ++ template ++ writer(webcpp::beast::http::header const&, value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer.reset(&body); + } + +- void +- init(boost::system::error_code& ec) +- { ++ void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } +- +- boost::optional> +- get(boost::system::error_code& ec) +- { ++ ++ boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer.read(buffer, sizeof(buffer)); +- return std::make_pair( +- boost::asio::const_buffer(len.data(), len.size()), +- !serializer.done()); ++ return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), ++ !serializer.done()); + } +- private: ++ ++ private: + json::serializer serializer; + // half of the probable networking buffer, let's leave some space for headers +- char buffer[32768]; ++ char buffer[32768]; + }; + +- struct reader +- { +- template +- reader( +- boost::beast::http::header&, +- value_type& body) +- : body(body) +- { +- } +- void +- init( +- boost::optional const& content_length, +- boost::system::error_code& ec) +- { +- +- // If we know the content-length, we can allocate a monotonic resource to increase the parsing speed. +- // We're using it rather then a static_resource, so a consumer can modify the resulting value. +- // It is also only assumption that the parsed json will be smaller than the serialize one, +- // it might not always be the case. ++ struct reader { ++ template ++ reader(webcpp::beast::http::header&, value_type& body) : body(body) {} ++ ++ void init(boost::optional const& content_length, ++ boost::system::error_code& ec) { ++ // If we know the content-length, we can allocate a monotonic resource to increase the ++ // parsing speed. We're using it rather then a static_resource, so a consumer can modify ++ // the resulting value. It is also only assumption that the parsed json will be smaller ++ // than the serialize one, it might not always be the case. + if (content_length) + parser.reset(json::make_shared_resource(*content_length)); + ec = {}; + } + +- template +- std::size_t +- put(ConstBufferSequence const& buffers, boost::system::error_code& ec) +- { ++ template ++ std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. +- return parser.write_some( +- static_cast(buffers.data()), buffers.size(), ec); ++ return parser.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + +- void +- finish(boost::system::error_code& ec) +- { ++ void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser.done()) +@@ -108,11 +103,10 @@ + ec = boost::json::error::incomplete; + } + +- private: ++ private: + json::stream_parser parser; + value_type& body; + }; + }; + +- + #endif--- upstream/http/client/body/json_client.cpp ++++ wasip3/http/client/body/json_client.cpp +@@ -1,31 +1,47 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + #include "json_body.hpp" +-#include + +-#include +-#include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + +-int main(int, char **) +-{ ++int main(int, char**) { + // Our test endpoint for testing the json +- const auto host = "postman-echo.com"; ++ const auto host = webcpp_fixture::host(); + const auto target = "/post"; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +- auto const results = resolver.resolve(host, "80"); ++ auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); +@@ -39,7 +55,7 @@ + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); +- ++ + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + +@@ -56,6 +72,5 @@ + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + +- + return 0; + } +--- upstream/http/client/coro/http_client_coro.cpp ++++ wasip3/http/client/coro/http_client_coro.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,48 +30,39 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-void +-do_session( +- std::string const& host, +- std::string const& port, +- std::string const& target, +- int version, +- net::io_context& ioc, +- net::yield_context yield) +-{ ++void do_session(std::string const& host, std::string const& port, std::string const& target, ++ int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout. +@@ -62,7 +70,7 @@ + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Set up an HTTP GET request message +@@ -75,7 +83,7 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted +@@ -86,7 +94,7 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -98,7 +106,7 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +@@ -106,16 +114,14 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-coro []\n" << +- "Example:\n" << +- " http-client-coro www.example.com 80 /\n" << +- " http-client-coro www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-coro []\n" ++ << "Example:\n" ++ << " http-client-coro www.example.com 80 /\n" ++ << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -124,32 +130,28 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(target), +- version, +- std::ref(ioc), +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, ++ std::ref(ioc), std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/coro-ssl/http_client_coro_ssl.cpp ++++ wasip3/http/client/coro-ssl/http_client_coro_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,53 +31,43 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include ++#include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Performs an HTTP GET and prints the response +-void +-do_session( +- std::string const& host, +- std::string const& port, +- std::string const& target, +- int version, +- net::io_context& ioc, +- ssl::context& ctx, +- net::yield_context yield) +-{ ++void do_session(std::string const& host, std::string const& port, std::string const& target, ++ int version, webcpp::asio::io_context& ioc, ssl::context& ctx, ++ net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) +- { ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; +@@ -70,7 +78,7 @@ + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout. +@@ -78,7 +86,7 @@ + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Set the timeout. +@@ -86,7 +94,7 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Set up an HTTP GET request message +@@ -99,7 +107,7 @@ + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted +@@ -110,7 +118,7 @@ + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Write the message to standard out +@@ -139,22 +147,20 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-coro-ssl []\n" << +- "Example:\n" << +- " http-client-coro-ssl www.example.com 443 /\n" << +- " http-client-coro-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-coro-ssl []\n" ++ << "Example:\n" ++ << " http-client-coro-ssl www.example.com 443 /\n" ++ << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -163,7 +169,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -175,30 +181,25 @@ + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(target), +- version, +- std::ref(ioc), +- std::ref(ctx), +- std::placeholders::_1), ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, ++ std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { ++ [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/client/crawl/http_crawl.cpp ++++ wasip3/http/client/crawl/http_crawl.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,15 +32,13 @@ + + #include "urls_large_data.hpp" + +-#include +-#include +-#include ++#include + #include + #include + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -31,62 +46,49 @@ + #include + #include + #include +-#include ++#include ++#include ++ ++#include + #include +-#include +- +-namespace chrono = std::chrono; // from +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++ ++namespace chrono = std::chrono; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // This structure aggregates statistics on all the sites +-class crawl_report +-{ +- net::strand< +- net::io_context::executor_type> strand_; ++class crawl_report { ++ net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + + public: +- crawl_report(net::io_context& ioc) +- : strand_(ioc.get_executor()) +- , index_(0) +- , hosts_(urls_large_data()) +- { +- } ++ crawl_report(webcpp::asio::io_context& ioc) ++ : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. +- template +- void +- aggregate(F const& f) +- { +- net::post( +- strand_, +- [&, f] +- { +- f(*this); +- if(count_ % 100 == 0) +- { +- std::cerr << +- "Progress: " << count_ << " of " << hosts_.size() << "\n"; +- //std::cerr << *this; +- } +- ++count_; +- }); ++ template ++ void aggregate(F const& f) { ++ net::post(strand_, [&, f] { ++ f(*this); ++ if (count_ % 100 == 0) { ++ std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; ++ // std::cerr << *this; ++ } ++ ++count_; ++ }); + } + + // Returns the next host to check +- char const* +- get_host() +- { ++ char const* get_host() { + auto const n = index_++; +- if(n >= hosts_.size()) ++ if (n >= hosts_.size()) + return nullptr; + return hosts_[n]; + } +@@ -113,25 +115,20 @@ + std::map status_codes; + }; + +-std::ostream& +-operator<<(std::ostream& os, crawl_report const& report) +-{ ++std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report +- os << +- "Crawl report\n" << +- " Failure counts\n" << +- " Timer : " << report.timer_failures << "\n" << +- " Resolve : " << report.resolve_failures << "\n" << +- " Connect : " << report.connect_failures << "\n" << +- " Write : " << report.write_failures << "\n" << +- " Read : " << report.read_failures << "\n" << +- " Success : " << report.success << "\n" << +- " Status codes\n" +- ; +- for(auto const& result : report.status_codes) +- os << +- " " << std::setw(3) << result.first << ": " << result.second << +- " (" << http::obsolete_reason(static_cast(result.first)) << ")\n"; ++ os << "Crawl report\n" ++ << " Failure counts\n" ++ << " Timer : " << report.timer_failures << "\n" ++ << " Resolve : " << report.resolve_failures << "\n" ++ << " Connect : " << report.connect_failures << "\n" ++ << " Write : " << report.write_failures << "\n" ++ << " Read : " << report.read_failures << "\n" ++ << " Success : " << report.success << "\n" ++ << " Status codes\n"; ++ for (auto const& result : report.status_codes) ++ os << " " << std::setw(3) << result.first << ": " << result.second << " (" ++ << http::obsolete_reason(static_cast(result.first)) << ")\n"; + os.flush(); + return os; + } +@@ -139,19 +136,17 @@ + //------------------------------------------------------------------------------ + + // Performs HTTP GET requests and aggregates the results into a report +-class worker : public std::enable_shared_from_this +-{ +- enum +- { ++class worker : public std::enable_shared_from_this { ++ enum { + // Use a small timeout to keep things lively + timeout = 5 + }; + + crawl_report& report_; +- net::strand ex_; +- tcp::resolver resolver_; ++ net::strand ex_; ++ webcpp_fixture::resolver resolver_; + beast::tcp_stream stream_; +- beast::flat_buffer buffer_; // (Must persist between reads) ++ beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +@@ -159,14 +154,8 @@ + worker(worker&&) = default; + + // Resolver and socket require an io_context +- worker( +- crawl_report& report, +- net::io_context& ioc) +- : report_(report) +- , ex_(net::make_strand(ioc.get_executor())) +- , resolver_(ex_) +- , stream_(ex_) +- { ++ worker(crawl_report& report, webcpp::asio::io_context& ioc) ++ : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); +@@ -175,20 +164,14 @@ + } + + // Start the asynchronous operation +- void +- run() +- { +- do_get_host(); +- } +- +- void +- do_get_host() +- { ++ void run() { do_get_host(); } ++ ++ void do_get_host() { + // Grab another host + auto const host = report_.get_host(); + + // nullptr means no more work +- if(! host) ++ if (!host) + return; + + // The Host HTTP field is required +@@ -196,26 +179,13 @@ + + // Set up an HTTP GET request message + // Look up the domain name +- resolver_.async_resolve( +- host, +- "http", +- beast::bind_front_handler( +- &worker::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.resolve_failures; +- }); ++ resolver_.async_resolve(host, webcpp_fixture::port(), ++ beast::bind_front_handler(&worker::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + return do_get_host(); + } + +@@ -223,23 +193,13 @@ + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup +- stream_.async_connect( +- results, +- beast::bind_front_handler( +- &worker::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) +- { +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.connect_failures; +- }); ++ stream_.async_connect(results, ++ beast::bind_front_handler(&worker::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, webcpp_fixture::resolver::results_type::endpoint_type) { ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + return do_get_host(); + } + +@@ -247,63 +207,34 @@ + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host +- http::async_write( +- stream_, +- req_, +- beast::bind_front_handler( +- &worker::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ http::async_write(stream_, req_, ++ beast::bind_front_handler(&worker::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.write_failures; +- }); ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + return do_get_host(); + } + + // Receive the HTTP response + res_ = {}; +- http::async_read( +- stream_, +- buffer_, +- res_, +- beast::bind_front_handler( +- &worker::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ http::async_read(stream_, buffer_, res_, ++ beast::bind_front_handler(&worker::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) +- { +- report_.aggregate( +- [](crawl_report& rep) +- { +- ++rep.read_failures; +- }); ++ if (ec) { ++ report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + return do_get_host(); + } + + auto const code = res_.result_int(); +- report_.aggregate( +- [code](crawl_report& rep) +- { ++ report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); +@@ -318,8 +249,7 @@ + } + }; + +-class timer +-{ ++class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; +@@ -327,78 +257,34 @@ + public: + using duration = clock_type::duration; + +- timer() +- : when_(clock_type::now()) +- { +- } +- +- duration +- elapsed() const +- { +- return clock_type::now() - when_; +- } ++ timer() : when_(clock_type::now()) {} ++ ++ duration elapsed() const { return clock_type::now() - when_; } + }; + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 2) +- { +- std::cerr << +- "Usage: http-crawl \n" << +- "Example:\n" << +- " http-crawl 100\n"; ++ if (argc != 2) { ++ std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } +- auto const threads = std::max(1, std::atoi(argv[1])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[1])); + + // The io_context is used to aggregate the statistics +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + timer t; + +- // Create and launch the worker threads. +- std::vector workers; +- workers.reserve(threads + 1); +- for(int i = 0; i < threads; ++i) +- { +- // Each worker will eventually add some data to the aggregated +- // report. Outstanding work is tracked in each worker to +- // represent the forthcoming delivery of this data by that +- // worker. +- auto reporting_work = net::require( +- ioc.get_executor(), +- net::execution::outstanding_work.tracked); +- +- workers.emplace_back( +- [&report, reporting_work] { +- // We use a separate io_context for each worker because +- // the asio resolver simulates asynchronous operation using +- // a dedicated worker thread per io_context, and we want to +- // do a lot of name resolutions in parallel. +- net::io_context ioc; +- std::make_shared(report, ioc)->run(); +- ioc.run(); +- }); +- } +- +- // Add another thread to run the main io_context which +- // is used to aggregate the statistics +- workers.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- +- // Now block until all threads exit +- for(std::size_t i = 0; i < workers.size(); ++i) +- workers[i].join(); +- +- std::cout << +- "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() << " seconds\n"; ++ // Each worker preserves the original crawl state machine on one explicit executor. ++ for (int index = 0; index < threads; ++index) ++ std::make_shared(report, ioc)->run(); ++ ioc.run(); // lint-run: advances every crawl worker and its aggregate report ++ ++ std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() ++ << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +--- upstream/http/client/crawl/urls_large_data.cpp ++++ wasip3/http/client/crawl/urls_large_data.cpp +@@ -1,10021 +1,24 @@ ++// Copyright (c) 2026 WebCpp.org + // +-// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) + // +-// Distributed under the Boost Software License, Version 1.0. (See accompanying +-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-// +-// Official repository: https://github.com/boostorg/beast +-// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. + + #include "urls_large_data.hpp" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + +-// Data from Alexa top 1 million sites +-// http://s3.amazonaws.com/alexa-static/top-1m.csv.zip +-// +-std::vector const& +-urls_large_data() +-{ +- static std::vector const urls ({ +- "google.com", +- "facebook.com", +- "youtube.com", +- "yahoo.com", +- "baidu.com", +- "wikipedia.org", +- "qq.com", +- "linkedin.com", +- "taobao.com", +- "twitter.com", +- "live.com", +- "amazon.com", +- "sina.com.cn", +- "google.co.in", +- "hao123.com", +- "blogspot.com", +- "weibo.com", +- "wordpress.com", +- "yandex.ru", +- "yahoo.co.jp", +- "tmall.com", +- "bing.com", +- "vk.com", +- "ebay.com", +- "360.cn", +- "google.de", +- "sohu.com", +- "pinterest.com", +- "google.co.uk", +- "ask.com", +- "google.fr", +- "msn.com", +- "163.com", +- "soso.com", +- "tumblr.com", +- "google.co.jp", +- "instagram.com", +- "mail.ru", +- "google.com.br", +- "microsoft.com", +- "paypal.com", +- "google.ru", +- "xvideos.com", +- "google.es", +- "imdb.com", +- "apple.com", +- "google.it", +- "adcash.com", +- "craigslist.org", +- "stackoverflow.com", +- "amazon.co.jp", +- "neobux.com", +- "google.com.hk", +- "imgur.com", +- "ifeng.com", +- "cnn.com", +- "google.com.mx", +- "xhamster.com", +- "xinhuanet.com", +- "gmw.cn", +- "reddit.com", +- "bbc.co.uk", +- "blogger.com", +- "google.ca", +- "fc2.com", +- "vube.com", +- "go.com", +- "akamaihd.net", +- "alipay.com", +- "about.com", +- "people.com.cn", +- "t.co", +- "googleusercontent.com", +- "wordpress.org", +- "odnoklassniki.ru", +- "alibaba.com", +- "google.com.tr", +- "aliexpress.com", +- "youku.com", +- "conduit.com", +- "huffingtonpost.com", +- "godaddy.com", +- "flickr.com", +- "pornhub.com", +- "google.com.au", +- "amazon.de", +- "blogspot.in", +- "kickass.to", +- "ebay.de", +- "netflix.com", +- "google.pl", +- "thepiratebay.se", +- "bp.blogspot.com", +- "adobe.com", +- "dailymotion.com", +- "china.com", +- "vimeo.com", +- "dailymail.co.uk", +- "cnet.com", +- "rakuten.co.jp", +- "espn.go.com", +- "ku6.com", +- "ebay.co.uk", +- "themeforest.net", +- "xnxx.com", +- "livejasmin.com", +- "indiatimes.com", +- "aol.com", +- "redtube.com", +- "dropbox.com", +- "amazonaws.com", +- "uol.com.br", +- "weather.com", +- "m2newmedia.com", +- "amazon.co.uk", +- "google.com.ar", +- "google.com.sa", +- "pixnet.net", +- "nytimes.com", +- "slideshare.net", +- "youporn.com", +- "google.com.eg", +- "buzzfeed.com", +- "wikimedia.org", +- "booking.com", +- "livejournal.com", +- "globo.com", +- "fiverr.com", +- "adf.ly", +- "secureserver.net", +- "mozilla.org", +- "google.com.pk", +- "google.com.tw", +- "google.nl", +- "yelp.com", +- "sogou.com", +- "ameblo.jp", +- "directrev.com", +- "clkmon.com", +- "hootsuite.com", +- "deviantart.com", +- "blogfa.com", +- "wikia.com", +- "outbrain.com", +- "flipkart.com", +- "wikihow.com", +- "etsy.com", +- "google.co.th", +- "soundcloud.com", +- "google.co.za", +- "avg.com", +- "w3schools.com", +- "theguardian.com", +- "stumbleupon.com", +- "espncricinfo.com", +- "livedoor.com", +- "forbes.com", +- "archive.org", +- "4shared.com", +- "foxnews.com", +- "files.wordpress.com", +- "answers.com", +- "bankofamerica.com", +- "chase.com", +- "google.co.ve", +- "mediafire.com", +- "torrentz.eu", +- "badoo.com", +- "salesforce.com", +- "aweber.com", +- "sourceforge.net", +- "bbc.com", +- "addthis.com", +- "liveinternet.ru", +- "china.com.cn", +- "indeed.com", +- "reference.com", +- "github.com", +- "skype.com", +- "hostgator.com", +- "google.gr", +- "bet365.com", +- "spiegel.de", +- "ask.fm", +- "so.com", +- "statcounter.com", +- "gameforge.com", +- "onet.pl", +- "naver.com", +- "google.com.co", +- "developunit.info", +- "google.com.vn", +- "google.co.id", +- "nicovideo.jp", +- "shutterstock.com", +- "walmart.com", +- "google.be", +- "mailchimp.com", +- "softonic.com", +- "stackexchange.com", +- "google.com.ng", +- "google.com.ua", +- "popads.net", +- "allegro.pl", +- "gamer.com.tw", +- "wordreference.com", +- "wellsfargo.com", +- "loading-delivery1.com", +- "zillow.com", +- "tripadvisor.com", +- "quikr.com", +- "pandora.com", +- "wsj.com", +- "goo.ne.jp", +- "bild.de", +- "tube8.com", +- "wix.com", +- "google.se", +- "coccoc.com", +- "google.ro", +- "suning.com", +- "photobucket.com", +- "weebly.com", +- "tianya.cn", +- "warriorforum.com", +- "telegraph.co.uk", +- "google.dz", +- "naver.jp", +- "php.net", +- "ups.com", +- "rambler.ru", +- "zedo.com", +- "reuters.com", +- "google.at", +- "media.tumblr.com", +- "taringa.net", +- "google.com.ph", +- "chinaz.com", +- "mashable.com", +- "blogspot.com.es", +- "hurriyet.com.tr", +- "google.com.pe", +- "bleacherreport.com", +- "gmx.net", +- "wp.pl", +- "goodreads.com", +- "leboncoin.fr", +- "rutracker.org", +- "lenta.ru", +- "babylon.com", +- "domaintools.com", +- "sharelive.net", +- "rediff.com", +- "google.ch", +- "comcast.net", +- "twitch.tv", +- "avito.ru", +- "kaskus.co.id", +- "nbcnews.com", +- "onclickads.net", +- "businessinsider.com", +- "ikea.com", +- "codecanyon.net", +- "ndtv.com", +- "usps.com", +- "google.cl", +- "doublepimp.com", +- "moz.com", +- "google.com.sg", +- "usatoday.com", +- "dmm.co.jp", +- "amazon.fr", +- "google.pt", +- "ucoz.ru", +- "rt.com", +- "milliyet.com.tr", +- "xuite.net", +- "samsung.com", +- "fedex.com", +- "uploaded.net", +- "pcpop.com", +- "google.com.bd", +- "bitly.com", +- "goodgamestudios.com", +- "ettoday.net", +- "baomihua.com", +- "39.net", +- "web.de", +- "rbc.ru", +- "9gag.com", +- "disqus.com", +- "snapdeal.com", +- "xcar.com.cn", +- "washingtonpost.com", +- "bloomberg.com", +- "scribd.com", +- "hp.com", +- "constantcontact.com", +- "4dsply.com", +- "gsmarena.com", +- "intuit.com", +- "meetup.com", +- "nih.gov", +- "americanexpress.com", +- "ehow.com", +- "infusionsoft.com", +- "google.cz", +- "mercadolivre.com.br", +- "myntra.com", +- "varzesh3.com", +- "mobile01.com", +- "hardsextube.com", +- "goal.com", +- "thefreecamsecret.com", +- "thefreedictionary.com", +- "douban.com", +- "iqiyi.com", +- "it168.com", +- "mama.cn", +- "tmz.com", +- "time.com", +- "olx.in", +- "microsoftonline.com", +- "hulu.com", +- "enet.com.cn", +- "speedtest.net", +- "orange.fr", +- "free.fr", +- "detik.com", +- "bluehost.com", +- "libero.it", +- "histats.com", +- "webmd.com", +- "eazel.com", +- "hudong.com", +- "extratorrent.cc", +- "google.co.kr", +- "chaturbate.com", +- "huanqiu.com", +- "cnzz.com", +- "daum.net", +- "xing.com", +- "force.com", +- "jrj.com.cn", +- "pchome.net", +- "cj.com", +- "youjizz.com", +- "delta-search.com", +- "techcrunch.com", +- "motherless.com", +- "tinyurl.com", +- "beeg.com", +- "kooora.com", +- "google.cn", +- "clickbank.com", +- "yandex.ua", +- "ad6media.fr", +- "google.no", +- "amazon.cn", +- "zippyshare.com", +- "acesse.com", +- "google.co.hu", +- "google.ae", +- "hdfcbank.com", +- "nba.com", +- "zendesk.com", +- "blogspot.co.uk", +- "bestbuy.com", +- "accuweather.com", +- "getresponse.com", +- "repubblica.it", +- "xywy.com", +- "ci123.com", +- "ebay.in", +- "in.com", +- "ign.com", +- "groupon.com", +- "yesky.com", +- "elpais.com", +- "marca.com", +- "kwejk.pl", +- "caijing.com.cn", +- "google.ie", +- "cloudfront.net", +- "intoday.in", +- "wideinfo.org", +- "pof.com", +- "kakaku.com", +- "bitauto.com", +- "life.com.tw", +- "xe.com", +- "goo.gl", +- "google.az", +- "feedly.com", +- "tagged.com", +- "amazon.in", +- "list-manage.com", +- "w3.org", +- "quora.com", +- "ixxx.com", +- "mysearchdial.com", +- "dell.com", +- "seznam.cz", +- "t-online.de", +- "plugrush.com", +- "nydailynews.com", +- "okcupid.com", +- "istockphoto.com", +- "snapdo.com", +- "abcnews.go.com", +- "target.com", +- "latimes.com", +- "mywebsearch.com", +- "joomla.org", +- "odesk.com", +- "surveymonkey.com", +- "elmundo.es", +- "siteadvisor.com", +- "aili.com", +- "uimserv.net", +- "ebay.com.au", +- "doubleclick.com", +- "zeobit.com", +- "google.co.il", +- "fbcdn.net", +- "ero-advertising.com", +- "issuu.com", +- "naukri.com", +- "gazeta.pl", +- "ck101.com", +- "udn.com", +- "google.dk", +- "ce.cn", +- "capitalone.com", +- "att.com", +- "drudgereport.com", +- "blackhatworld.com", +- "adrotator.se", +- "retailmenot.com", +- "justdial.com", +- "icicibank.com", +- "likes.com", +- "elance.com", +- "cntv.cn", +- "ameba.jp", +- "java.com", +- "lifehacker.com", +- "jabong.com", +- "gizmodo.com", +- "ebay.it", +- "lenovo.com", +- "hypergames.net", +- "google.fi", +- "doorblog.jp", +- "blogspot.de", +- "jimdo.com", +- "probux.com", +- "blogspot.it", +- "habrahabr.ru", +- "webmoney.ru", +- "irctc.co.in", +- "sahibinden.com", +- "github.io", +- "informer.com", +- "mysearchresults.com", +- "upworthy.com", +- "pch.com", +- "eyny.com", +- "canadaalltax.com", +- "b5m.com", +- "freelancer.com", +- "match.com", +- "searchfun.in", +- "adnxs.com", +- "sberbank.ru", +- "ig.com.br", +- "trulia.com", +- "subscene.com", +- "corriere.it", +- "livescore.com", +- "irs.gov", +- "twoo.com", +- "clixsense.com", +- "4399.com", +- "xda-developers.com", +- "iminent.com", +- "google.com.my", +- "onlinesbi.com", +- "empowernetwork.com", +- "zing.vn", +- "youdao.com", +- "systweak.com", +- "flipora.com", +- "ning.com", +- "engadget.com", +- "abril.com.br", +- "exoclick.com", +- "semrush.com", +- "commentcamarche.net", +- "shareasale.com", +- "vnexpress.net", +- "battle.net", +- "youm7.com", +- "digg.com", +- "rapidgator.net", +- "expedia.com", +- "twimg.com", +- "newegg.com", +- "lady8844.com", +- "xgo.com.cn", +- "pcgames.com.cn", +- "fotolia.com", +- "rednet.cn", +- "inspsearch.com", +- "lemonde.fr", +- "adultfriendfinder.com", +- "typepad.com", +- "mercadolibre.com.ar", +- "homedepot.com", +- "chip.de", +- "lefigaro.fr", +- "swagbucks.com", +- "taleo.net", +- "kinopoisk.ru", +- "oracle.com", +- "who.is", +- "2ch.net", +- "qtrax.com", +- "eonline.com", +- "sochi2014.com", +- "myfreecams.com", +- "pcbaby.com.cn", +- "gome.com.cn", +- "amazon.it", +- "timeanddate.com", +- "bestusefuldownloads.com", +- "foursquare.com", +- "telexfree.com", +- "gc.ca", +- "58.com", +- "hubspot.com", +- "backpage.com", +- "examiner.com", +- "ria.ru", +- "google.sk", +- "opensiteexplorer.org", +- "awesomehp.com", +- "sexlog.com", +- "gutefrage.net", +- "steampowered.com", +- "slate.com", +- "marketwatch.com", +- "beva.com", +- "shaadi.com", +- "v1.cn", +- "teensdigest.com", +- "blogspot.ru", +- "taboola.com", +- "citrixonline.com", +- "hatena.ne.jp", +- "seesaa.net", +- "houzz.com", +- "bodybuilding.com", +- "webs.com", +- "chexun.com", +- "ya.ru", +- "citibank.com", +- "viralnova.com", +- "2345.com", +- "ashleyrnadison.com", +- "verizonwireless.com", +- "55bbs.com", +- "theblaze.com", +- "123rf.com", +- "gotomeeting.com", +- "kijiji.ca", +- "linkbucks.com", +- "haber7.com", +- "pravda.com.ua", +- "altervista.org", +- "mihanblog.com", +- "terra.com.br", +- "soku.com", +- "urbandictionary.com", +- "mercadolibre.com.mx", +- "pixiv.net", +- "oneindia.in", +- "yellowpages.com", +- "hotels.com", +- "drtuber.com", +- "scoop.it", +- "blogspot.jp", +- "cbslocal.com", +- "movie4k.to", +- "cpmterra.com", +- "hubpages.com", +- "mobile.de", +- "yaolan.com", +- "etao.com", +- "hidemyass.com", +- "ca.gov", +- "dreamstime.com", +- "firedrive.com", +- "searchengines.ru", +- "m-w.com", +- "ebay.fr", +- "templatemonster.com", +- "evernote.com", +- "fastdailyfind.com", +- "amazon.es", +- "gateable.com", +- "hupu.com", +- "y8.com", +- "blogspot.com.tr", +- "tokobagus.com", +- "azlyrics.com", +- "website-unavailable.com", +- "r10.net", +- "wiktionary.org", +- "bongacams.com", +- "focus.de", +- "linksynergy.com", +- "steamcommunity.com", +- "vk.me", +- "sakura.ne.jp", +- "foxsports.com", +- "optmd.com", +- "tabelog.com", +- "narod.ru", +- "glassdoor.com", +- "outlook.com", +- "europa.eu", +- "viadeo.com", +- "leadpages.net", +- "ouedkniss.com", +- "facenama.com", +- "lpcloudsvr302.com", +- "agoda.com", +- "qvo6.com", +- "majesticseo.com", +- "mirror.co.uk", +- "google.com.kw", +- "filehippo.com", +- "moneycontrol.com", +- "duckduckgo.com", +- "npr.org", +- "coupons.com", +- "mynet.com", +- "allrecipes.com", +- "priceline.com", +- "liveleak.com", +- "jqw.com", +- "slickdeals.net", +- "webcrawler.com", +- "babytree.com", +- "amung.us", +- "tomshardware.com", +- "openadserving.com", +- "independent.co.uk", +- "kompas.com", +- "turbobit.net", +- "google.kz", +- "leo.org", +- "yandex.com.tr", +- "mp3skull.com", +- "nordstrom.com", +- "news.com.au", +- "traidnt.net", +- "wunderground.com", +- "cnbc.com", +- "jquery.com", +- "dict.cc", +- "persianblog.ir", +- "clarin.com", +- "all-free-download.com", +- "fhserve.com", +- "sape.ru", +- "asos.com", +- "addmefast.com", +- "lequipe.fr", +- "lapatilla.com", +- "ancestry.com", +- "stockstar.com", +- "monster.com", +- "people.com", +- "gawker.com", +- "howstuffworks.com", +- "tradedoubler.com", +- "over-blog.com", +- "cbc.ca", +- "fishcod.com", +- "yoka.com", +- "macys.com", +- "gazeta.ru", +- "free-tv-video-online.me", +- "google.bg", +- "google.lk", +- "southwest.com", +- "realtor.com", +- "custhelp.com", +- "bhaskar.com", +- "softpedia.com", +- "farsnews.com", +- "cy-pr.com", +- "theverge.com", +- "tudou.com", +- "youboy.com", +- "porn.com", +- "wetransfer.com", +- "virgilio.it", +- "mega.co.nz", +- "sfgate.com", +- "delta-homes.com", +- "squarespace.com", +- "watchseries.lt", +- "overstock.com", +- "nifty.com", +- "jvzoo.com", +- "lanacion.com.ar", +- "prntscr.com", +- "vesti.ru", +- "zimbio.com", +- "adscale.de", +- "google.co.nz", +- "yac.mx", +- "tickld.com", +- "kayak.com", +- "youth.cn", +- "jd.com", +- "shopclues.com", +- "allocine.fr", +- "cracked.com", +- "eventbrite.com", +- "behance.net", +- "youtube-mp3.org", +- "bankmellat.ir", +- "echo.msk.ru", +- "autohome.com.cn", +- "yandex.kz", +- "sex.com", +- "smh.com.au", +- "digikala.com", +- "mackolik.com", +- "rottentomatoes.com", +- "renren.com", +- "wired.com", +- "imageshack.us", +- "interia.pl", +- "zanox.com", +- "eastday.com", +- "fool.com", +- "chinabyte.com", +- "haberturk.com", +- "hespress.com", +- "wow.com", +- "jobrapido.com", +- "idnes.cz", +- "qinbei.com", +- "pr-cy.ru", +- "klikbca.com", +- "17ok.com", +- "gamefaqs.com", +- "immobilienscout24.de", +- "biblegateway.com", +- "espnfc.com", +- "ehowenespanol.com", +- "tabnak.ir", +- "avazutracking.net", +- "sapo.pt", +- "welt.de", +- "google.com.ec", +- "sears.com", +- "pcmag.com", +- "nownews.com", +- "kickstarter.com", +- "pixlr.com", +- "hongkiat.com", +- "chinatimes.com", +- "zoho.com", +- "reverso.net", +- "indianrail.gov.in", +- "privatehomeclips.com", +- "cbssports.com", +- "entrepreneur.com", +- "sporx.com", +- "bhphotovideo.com", +- "fatakat.com", +- "xunlei.com", +- "nikkei.com", +- "chron.com", +- "24h.com.vn", +- "basecamp.com", +- "airtel.in", +- "dealshark.com", +- "shopify.com", +- "babycenter.com", +- "letitbit.net", +- "nuvid.com", +- "yts.re", +- "aparat.com", +- "r2games.com", +- "prestashop.com", +- "alarabiya.net", +- "india.com", +- "magentocommerce.com", +- "heise.de", +- "sulekha.com", +- "mpnrs.com", +- "ibm.com", +- "cbsnews.com", +- "searchengineland.com", +- "mapquest.com", +- "ccb.com", +- "zappos.com", +- "rightmove.co.uk", +- "sahadan.com", +- "milanuncios.com", +- "wenku.baidu.com/user/reg", +- "ovh.net", +- "screencast.com", +- "ahrefs.com", +- "6.cn", +- "businessweek.com", +- "linternaute.com", +- "dafont.com", +- "bestblackhatforum.com", +- "streamcloud.eu", +- "as.com", +- "gtmetrix.com", +- "wmmail.ru", +- "spankwire.com", +- "google.com.do", +- "jeuxvideo.com", +- "digitalpoint.com", +- "amazon.ca", +- "mlb.com", +- "weheartit.com", +- "list.ru", +- "leagueoflegends.com", +- "56.com", +- "bloglovin.com", +- "payoneer.com", +- "nokia.com", +- "aizhan.com", +- "novinky.cz", +- "ustream.tv", +- "getbootstrap.com", +- "seekingalpha.com", +- "codwide.com", +- "vice.com", +- "usmagazine.com", +- "primewire.ag", +- "cam4.com", +- "thehindu.com", +- "deezer.com", +- "graphicriver.net", +- "dmm.com", +- "biglobe.ne.jp", +- "google.rs", +- "z5x.net", +- "tutsplus.com", +- "icicibank.co.in", +- "indiamart.com", +- "gap.com", +- "ensonhaber.com", +- "sitepoint.com", +- "rutor.org", +- "chinanews.com", +- "brainyquote.com", +- "keepvid.com", +- "censor.net.ua", +- "subito.it", +- "tablica.pl", +- "onlylady.com", +- "zulily.com", +- "squidoo.com", +- "change.org", +- "sh.st", +- "webhostingtalk.com", +- "9gag.tv", +- "nairaland.com", +- "gulfup.com", +- "staples.com", +- "gamespot.com", +- "woorank.com", +- "box.com", +- "infobae.com", +- "elegantthemes.com", +- "104.com.tw", +- "aftonbladet.se", +- "google.hr", +- "myegy.com", +- "noticias24.com", +- "eastmoney.com", +- "lowes.com", +- "xtube.com", +- "worldstarhiphop.com", +- "glispa.com", +- "verizon.com", +- "united.com", +- "linkwithin.com", +- "google.com.ly", +- "whitepages.com", +- "games.la", +- "dmoz.org", +- "imagebam.com", +- "careerbuilder.com", +- "sky.com", +- "instructables.com", +- "mercadolibre.com.ve", +- "makemytrip.com", +- "pinimg.com", +- "pingdom.com", +- "foodnetwork.com", +- "orf.at", +- "android.com", +- "wiocha.pl", +- "csdn.net", +- "appledaily.com.tw", +- "nike.com", +- "eluniversal.com.mx", +- "delta.com", +- "ezinearticles.com", +- "sueddeutsche.de", +- "woothemes.com", +- "comcast.com", +- "gismeteo.ru", +- "lotour.com", +- "nfl.com", +- "xbox.com", +- "almanar.com.lb", +- "disney.go.com", +- "ctrip.com", +- "forexfactory.com", +- "clicksvenue.com", +- "nhl.com", +- "ted.com", +- "gstatic.com", +- "forobeta.com", +- "ovh.com", +- "mystart.com", +- "maktoob.com", +- "nouvelobs.com", +- "hindustantimes.com", +- "billdesk.com", +- "1und1.de", +- "zhaopin.com", +- "weather.gov", +- "kioskea.net", +- "myspace.com", +- "firstpost.com", +- "picmonkey.com", +- "grooveshark.com", +- "exblog.jp", +- "pantip.com", +- "earthlink.net", +- "styletv.com.cn", +- "icloud.com", +- "manta.com", +- "google.by", +- "mediaset.it", +- "searchenginewatch.com", +- "japanpost.jp", +- "postimg.org", +- "mbc.net", +- "cheezburger.com", +- "workercn.cn", +- "directadvert.ru", +- "nationzoom.com", +- "caixa.gov.br", +- "gumtree.com", +- "51job.com", +- "viooz.co", +- "usbank.com", +- "wmtransfer.com", +- "fidelity.com", +- "gogetlinks.net", +- "office365.com", +- "pchome.com.tw", +- "feedburner.com", +- "mp3truck.net", +- "sfr.fr", +- "junglee.com", +- "keezmovies.com", +- "binarysystem4u.com", +- "way2sms.com", +- "oyunskor.com", +- "peyvandha.ir", +- "ticketmaster.com", +- "lacaixa.es", +- "video-one.com", +- "yomiuri.co.jp", +- "popcash.net", +- "nypost.com", +- "dubizzle.com", +- "wpmudev.org", +- "mgid.com", +- "google.lt", +- "zazzle.com", +- "nbcolympics.com", +- "battlefield.com", +- "avast.com", +- "jsfiddle.net", +- "namecheap.com", +- "css-tricks.com", +- "friv.com", +- "6park.com", +- "xhamstercams.com", +- "mysql.com", +- "dx.com", +- "thechive.com", +- "vsuch.com", +- "souq.com", +- "anyoption.com", +- "dantri.com.vn", +- "ebay.es", +- "abc.es", +- "whatsapp.com", +- "bitshare.com", +- "savefrom.net", +- "beytoote.com", +- "xiaomi.com", +- "prweb.com", +- "prothom-alo.com", +- "pagesjaunes.fr", +- "bbb.org", +- "eenadu.net", +- "tinypic.com", +- "whois.com", +- "sourtimes.org", +- "adk2.com", +- "criteo.com", +- "tistory.com", +- "ilyke.net", +- "ruten.com.tw", +- "skysports.com", +- "makeuseof.com", +- "p5w.net", +- "hh.ru", +- "nationalgeographic.com", +- "pornmd.com", +- "rakuten.ne.jp", +- "idealo.de", +- "telegraaf.nl", +- "barnesandnoble.com", +- "mynavi.jp", +- "4chan.org", +- "media-fire.org", +- "crunchbase.com", +- "bravotube.net", +- "myfitnesspal.com", +- "today.com", +- "mit.edu", +- "cnmo.com", +- "nu.nl", +- "tripadvisor.co.uk", +- "spotify.com", +- "homeway.com.cn", +- "dianping.com", +- "costco.com", +- "pastebin.com", +- "dhgate.com", +- "windowsphone.com", +- "stagram.com", +- "investopedia.com", +- "ninemsn.com.au", +- "excite.co.jp", +- "22find.com", +- "google.iq", +- "hi5.com", +- "ad4game.com", +- "kohls.com", +- "online.sh.cn", +- "geocities.jp", +- "investing.com", +- "haberler.com", +- "ft.com", +- "weblio.jp", +- "google.tn", +- "list-manage1.com", +- "hsbc.co.uk", +- "ppstream.com", +- "cloob.com", +- "korrespondent.net", +- "ucoz.com", +- "1and1.com", +- "mail.com", +- "fotostrana.ru", +- "accountonline.com", +- "forgeofempires.com", +- "dribbble.com", +- "city-data.com", +- "drupal.org", +- "tunein.com", +- "51fanli.com", +- "ibtimes.com", +- "intel.com", +- "polyvore.com", +- "cbs.com", +- "bab.la", +- "imobile.com.cn", +- "bestadbid.com", +- "eztv.it", +- "smashingmagazine.com", +- "skyrock.com", +- "copyscape.com", +- "cookpad.com", +- "smallseotools.com", +- "asus.com", +- "anysex.com", +- "nbcsports.com", +- "kinox.to", +- "mbank.com.pl", +- "500px.com", +- "sofanti.com", +- "marktplaats.nl", +- "cpanel.net", +- "hm.com", +- "chicagotribune.com", +- "ultimate-guitar.com", +- "infolinks.com", +- "merdeka.com", +- "yandex.by", +- "tribalfusion.com", +- "livedoor.biz", +- "prezi.com", +- "last.fm", +- "sznews.com", +- "junbi-tracker.com", +- "so-net.ne.jp", +- "cocolog-nifty.com", +- "ocn.ne.jp", +- "perezhilton.com", +- "yaplakal.com", +- "championat.com", +- "ebay.ca", +- "mangareader.net", +- "donanimhaber.com", +- "miniclip.com", +- "vcommission.com", +- "noaa.gov", +- "imagefap.com", +- "gumtree.com.au", +- "liveperson.net", +- "gfycat.com", +- "hollywoodreporter.com", +- "dropboxusercontent.com", +- "akhbarak.net", +- "sou300.com", +- "kicker.de", +- "livestream.com", +- "tribunnews.com", +- "kp.ru", +- "techradar.com", +- "315che.com", +- "dw.de", +- "codeproject.com", +- "newsru.com", +- "pconline.com.cn", +- "aa.com", +- "usaa.com", +- "asahi.com", +- "themetapicture.com", +- "quicksprout.com", +- "piriform.com", +- "888poker.com", +- "gittigidiyor.com", +- "nhk.or.jp", +- "statigr.am", +- "ipage.com", +- "gazzetta.it", +- "letv.com", +- "yourlust.com", +- "freepik.com", +- "trello.com", +- "mixi.jp", +- "livememe.com", +- "ew.com", +- "seosprint.net", +- "doisongphapluat.com", +- "autotrader.com", +- "docstoc.com", +- "viva.co.id", +- "livestrong.com", +- "inc.com", +- "hunantv.com", +- "bahn.de", +- "depositphotos.com", +- "rackspace.com", +- "flippa.com", +- "norton.com", +- "lynda.com", +- "teamviewer.com", +- "vip.com", +- "ksl.com", +- "solarmovie.so", +- "klout.com", +- "pikabu.ru", +- "vporn.com", +- "apache.org", +- "sportbox.ru", +- "correios.com.br", +- "toptenreviews.com", +- "ea.com", +- "thenextweb.com", +- "superuser.com", +- "delicious.com", +- "zoosk.com", +- "inbox.com", +- "kongregate.com", +- "starbaby.cn", +- "888casino.com", +- "brazzers.com", +- "sockshare.com", +- "megashare.info", +- "vistaprint.com", +- "porntube.com", +- "seriesyonkis.com", +- "20minutos.es", +- "jagran.com", +- "programme-tv.net", +- "elcomercio.pe", +- "blogspot.kr", +- "t411.me", +- "googleapis.com", +- "blog.com", +- "qingdaonews.com", +- "sedo.com", +- "itmedia.co.jp", +- "mtv.com", +- "ynet.co.il", +- "playstation.com", +- "pornhublive.com", +- "thedailybeast.com", +- "r7.com", +- "sabah.com.tr", +- "126.com", +- "topix.com", +- "liga.net", +- "marriott.com", +- "tvn24.pl", +- "sitesell.com", +- "netdna-cdn.com", +- "startimes.com", +- "hstpnetwork.com", +- "blogspot.com.au", +- "17u.cn", +- "subscribe.ru", +- "woot.com", +- "rozblog.com", +- "wimp.com", +- "vg.no", +- "t-mobile.com", +- "bmi.ir", +- "kankan.com", +- "tsn.ua", +- "gumtree.co.za", +- "googleadservices.com", +- "pnc.com", +- "cars.com", +- "soccerway.com", +- "o2.pl", +- "zeit.de", +- "zopim.com", +- "cloudflare.com", +- "givemesport.com", +- "statscrop.com", +- "gravatar.com", +- "flightradar24.com", +- "ubuntu.com", +- "salon.com", +- "ytimg.com", +- "trovigo.com", +- "sunporno.com", +- "libertagia.com", +- "mihanwebads.com", +- "shopathome.com", +- "cdiscount.com", +- "commbank.com.au", +- "elwatannews.com", +- "discovercard.com", +- "infowars.com", +- "blogimg.jp", +- "portaldosites.com", +- "fixya.com", +- "drom.ru", +- "fastpic.ru", +- "pbs.org", +- "kandao.com", +- "okwave.jp", +- "faz.net", +- "sbnation.com", +- "hilton.com", +- "duba.com", +- "homeshop18.com", +- "ultimasnoticias.com.ve", +- "bankrate.com", +- "megasesso.com", +- "studiopress.com", +- "sports.ru", +- "asriran.com", +- "etoro.com", +- "cafemom.com", +- "dhl.de", +- "indiegogo.com", +- "tdcanadatrust.com", +- "1tv.ru", +- "gogvo.com", +- "bt.com", +- "blogspot.tw", +- "zergnet.com", +- "garanti.com.tr", +- "privatbank.ua", +- "sanook.com", +- "travelocity.com", +- "networksolutions.com", +- "thqafawe3lom.com", +- "trklnks.com", +- "torchbrowser.com", +- "logmein.com", +- "williamhill.com", +- "zhihu.com", +- "auto.ru", +- "craigslist.ca", +- "olx.com.pk", +- "smi2.ru", +- "ukr.net", +- "dpreview.com", +- "boston.com", +- "folha.uol.com.br", +- "name.com", +- "ashemaletube.com", +- "slimspots.com", +- "envato.com", +- "6pm.com", +- "fandango.com", +- "sozcu.com.tr", +- "nikkeibp.co.jp", +- "aufeminin.com", +- "baiducontent.com", +- "buscape.com.br", +- "funnyordie.com", +- "337.com", +- "sakshi.com", +- "airasia.com", +- "samanyoluhaber.com", +- "picofile.com", +- "blackberry.com", +- "google.com.gt", +- "io9.com", +- "easyhits4u.com", +- "qianyan001.com", +- "flashx.tv", +- "zap2it.com", +- "dnsrsearch.com", +- "patch.com", +- "staticflickr.com", +- "clicksor.com", +- "mcafee.com", +- "zerohedge.com", +- "zara.com", +- "freelotto.com", +- "tutorialspoint.com", +- "qone8.com", +- "olx.com.br", +- "axisbank.com", +- "marketgid.com", +- "your-server.de", +- "game321.com", +- "harvard.edu", +- "indianexpress.com", +- "fatwallet.com", +- "nudevista.com", +- "paper.li", +- "opera.com", +- "serving-sys.com", +- "nowvideo.sx", +- "theatlantic.com", +- "cisco.com", +- "bookmyshow.com", +- "webmasterworld.com", +- "metro.co.uk", +- "leparisien.fr", +- "orbitz.com", +- "h2porn.com", +- "4cdn.org", +- "itar-tass.com", +- "nasa.gov", +- "macrumors.com", +- "google.si", +- "usnews.com", +- "premierleague.com", +- "largeporntube.com", +- "blogsky.com", +- "bufferapp.com", +- "zeroredirect1.com", +- "sendspace.com", +- "stanford.edu", +- "state.gov", +- "yjc.ir", +- "abc.net.au", +- "pornsharing.com", +- "4pda.ru", +- "52pk.net", +- "meituan.com", +- "mmgp.ru", +- "sponichi.co.jp", +- "masrawy.com", +- "whatismyipaddress.com", +- "onlinewebfind.com", +- "news24.com", +- "zdnet.com", +- "imagevenue.com", +- "gameaholic.com", +- "mediaplex.com", +- "clip.vn", +- "2mdn.net", +- "nmisr.com", +- "musica.com", +- "networkedblogs.com", +- "metrolyrics.com", +- "chacha.com", +- "internetdownloadmanager.com", +- "legacy.com", +- "wwe.com", +- "icbc.com.cn", +- "ny.gov", +- "chomikuj.pl", +- "alexa.com", +- "pcworld.com", +- "overthumbs.com", +- "adp.com", +- "ad2games.com", +- "adme.ru", +- "bidvertiser.com", +- "rtl.de", +- "sweetim.com", +- "gaana.com", +- "7k7k.com", +- "livingsocial.com", +- "netteller.com", +- "rakuten.com", +- "chess.com", +- "blackboard.com", +- "thekitchn.com", +- "ilfattoquotidiano.it", +- "20minutes.fr", +- "soufun.com", +- "nerdbux.com", +- "breitbart.com", +- "webtretho.com", +- "tvguide.com", +- "miralinks.ru", +- "weather.com.cn", +- "zalando.de", +- "dangdang.com", +- "bubblews.com", +- "thoughtcatalog.com", +- "114la.com", +- "msn.ca", +- "blogmura.com", +- "americanas.com.br", +- "elitedaily.com", +- "lightinthebox.com", +- "bizjournals.com", +- "yixun.com", +- "itau.com.br", +- "51.la", +- "doodle.com", +- "arabyonline.com", +- "opencart.com", +- "bomnegocio.com", +- "lego.com", +- "pclady.com.cn", +- "metacafe.com", +- "kimiss.com", +- "journaldunet.com", +- "gnavi.co.jp", +- "51auto.com", +- "clickey.com", +- "chekb.com", +- "searchnu.com", +- "diply.com", +- "walgreens.com", +- "descargar.es", +- "mirrorcreator.com", +- "pornerbros.com", +- "askmen.com", +- "shop.com", +- "inmotionhosting.com", +- "filmweb.pl", +- "kbb.com", +- "appround.biz", +- "aljazeera.com", +- "lumosity.com", +- "sweet-page.com", +- "pole-emploi.fr", +- "fishki.net", +- "rollingstone.com", +- "kapanlagi.com", +- "yandex.com", +- "cnblogs.com", +- "plaintube.com", +- "intentmedia.net", +- "about.me", +- "torrentz.in", +- "01net.com", +- "gyazo.com", +- "nic.ru", +- "juicyads.com", +- "trend.az", +- "askubuntu.com", +- "unam.mx", +- "tradus.com", +- "tigerdirect.com", +- "letras.mus.br", +- "imagetwist.com", +- "perfectmoney.is", +- "wpbeginner.com", +- "thepiratetrader.com", +- "victoriassecret.com", +- "images-amazon.com", +- "tusfiles.net", +- "chefkoch.de", +- "ojooo.com", +- "alphaporno.com", +- "betfair.com", +- "tympanus.net", +- "td.com", +- "4tube.com", +- "phonearena.com", +- "bankmandiri.co.id", +- "cox.net", +- "ozon.ru", +- "perfectgirls.net", +- "asana.com", +- "sprint.com", +- "berniaga.com", +- "vente-privee.com", +- "ing.nl", +- "finn.no", +- "atwiki.jp", +- "toysrus.com", +- "petflow.com", +- "reverbnation.com", +- "freeones.com", +- "abc.go.com", +- "bradesco.com.br", +- "yenisafak.com.tr", +- "profit-partner.ru", +- "redfin.com", +- "mangafox.me", +- "appnexus.com", +- "sxc.hu", +- "speedanalysis.net", +- "n-tv.de", +- "qidian.com", +- "teespring.com", +- "break.com", +- "nailedhard.com", +- "jalan.net", +- "authorize.net", +- "adultadworld.com", +- "sootoo.com", +- "roboform.com", +- "kotaku.com", +- "multitran.ru", +- "food.com", +- "twitpic.com", +- "pogo.com", +- "sabq.org", +- "priceminister.com", +- "lexpress.fr", +- "livetv.sx", +- "nikkansports.com", +- "securepaynet.net", +- "vodoumedia.com", +- "airbnb.com", +- "trafficholder.com", +- "rr.com", +- "expireddomains.net", +- "bandcamp.com", +- "wayfair.com", +- "tut.by", +- "maybank2u.com.my", +- "similarweb.com", +- "zol.com.cn", +- "247realmedia.com", +- "asp.net", +- "lonelyplanet.com", +- "seopult.ru", +- "whois.net", +- "academia.edu", +- "univision.com", +- "interfax.ru", +- "amarillasinternet.com", +- "miercn.com", +- "barclays.co.uk", +- "societe.com", +- "khabaronline.ir", +- "unity3d.com", +- "nyaa.se", +- "euronews.com", +- "verizon.net", +- "rutube.ru", +- "wetter.com", +- "imlive.com", +- "ggpht.com", +- "docin.com", +- "yify-torrents.com", +- "yhd.com", +- "citibank.co.in", +- "xdating.com", +- "roblox.com", +- "voyages-sncf.com", +- "189.cn", +- "identi.li", +- "bayt.com", +- "medicinenet.com", +- "wmaraci.com", +- "stern.de", +- "eluniversal.com", +- "zoopla.co.uk", +- "easyjet.com", +- "dhl.com", +- "freakshare.com", +- "rojadirecta.me", +- "sp.gov.br", +- "friendfeed.com", +- "beamtele.com", +- "searchenginejournal.com", +- "nocookie.net", +- "reliancenetconnect.co.in", +- "google.co.ma", +- "fanpop.com", +- "adk2.co", +- "tagesschau.de", +- "nate.com", +- "ole.com.ar", +- "index.hu", +- "aruba.it", +- "eltiempo.com", +- "resellerclub.com", +- "qip.ru", +- "xossip.com", +- "siteground.com", +- "royalbank.com", +- "advfn.com", +- "tebyan.net", +- "iciba.com", +- "bigcartel.com", +- "sciencedirect.com", +- "hepsiburada.com", +- "cpasbien.me", +- "alfabank.ru", +- "microsoftstore.com", +- "discogs.com", +- "onliner.by", +- "socialmediaexaminer.com", +- "seasonvar.ru", +- "tripadvisor.in", +- "360doc.com", +- "chinabroadcast.cn", +- "realestate.com.au", +- "avira.com", +- "herokuapp.com", +- "downloadsetup.net", +- "torcache.net", +- "uefa.com", +- "rg.ru", +- "qianlong.com", +- "hugedomains.com", +- "arstechnica.com", +- "fifa.com", +- "ryanair.com", +- "i.ua", +- "axisbank.co.in", +- "alimama.com", +- "wanggou.com", +- "radikal.com.tr", +- "echoroukonline.com", +- "unian.net", +- "slashdot.org", +- "dmv.org", +- "mayoclinic.org", +- "newsmax.com", +- "google.com.et", +- "icontact.com", +- "vanguardngr.com", +- "infojobs.net", +- "say-move.org", +- "ileehoo.com", +- "mirtesen.ru", +- "yam.com", +- "e-hentai.org", +- "wikimapia.org", +- "shop-pro.jp", +- "bukalapak.com", +- "jcpenney.com", +- "ilmeteo.it", +- "iltasanomat.fi", +- "telecomitalia.it", +- "kariyer.net", +- "shutterfly.com", +- "santabanta.com", +- "softlayer.com", +- "complex.com", +- "mamba.ru", +- "netshoes.com.br", +- "theweathernetwork.com", +- "politico.com", +- "advego.ru", +- "eroprofile.com", +- "mainichi.jp", +- "nta.go.jp", +- "sfimg.com", +- "ap.org", +- "webex.com", +- "hinet.net", +- "skyscrapercity.com", +- "affili.net", +- "adplxmd.com", +- "iltalehti.fi", +- "impress.co.jp", +- "jezebel.com", +- "extremetube.com", +- "digitaltrends.com", +- "one.com", +- "ranker.com", +- "qiwi.com", +- "collegehumor.com", +- "nbc.com", +- "boursorama.com", +- "watch32.com", +- "meetcheap.com", +- "forums.wordpress.com", +- "cvs.com", +- "kenh14.vn", +- "yallakora.com", +- "plurk.com", +- "xtool.ru", +- "airtel.com", +- "wp.com", +- "sftimes.co", +- "economist.com", +- "rapidshare.com", +- "redbox.com", +- "audible.com", +- "kissmetrics.com", +- "atpanel.com", +- "wargaming.net", +- "1337x.org", +- "shahrekhabar.com", +- "bdnews24.com", +- "tvrain.ru", +- "wykop.pl", +- "mts.ru", +- "nnm-club.me", +- "schwab.com", +- "elconfidencial.com", +- "modelmayhem.com", +- "zhidao.baidu.com/user/admin", +- "aastocks.com", +- "tiscali.it", +- "qadabra.com", +- "autoscout24.de", +- "vatanim.com.tr", +- "gotowebinar.com", +- "edmunds.com", +- "ebaumsworld.com", +- "megafilmeshd.net", +- "poste.it", +- "mcssl.com", +- "aljazeera.net", +- "netvibes.com", +- "sme.sk", +- "tesco.com", +- "525j.com.cn", +- "tf1.fr", +- "ccidnet.com", +- "ldblog.jp", +- "blockchain.info", +- "played.to", +- "nthwall.com", +- "justanswer.com", +- "clickbank.net", +- "fnac.com", +- "gmarket.co.kr", +- "clipconverter.cc", +- "nextmedia.com", +- "bb.com.br", +- "learntotradethemarket.com", +- "pornoid.com", +- "downloadha.com", +- "hellporno.com", +- "ooo-sex.com", +- "blocket.se", +- "tubeplus.me", +- "seek.com.au", +- "filestube.to", +- "ceneo.pl", +- "walmart.com.br", +- "sonymobile.com", +- "dyndns.org", +- "ulmart.ru", +- "vrbo.com", +- "sport.pl", +- "ashleymadison.com", +- "el-wlid.com", +- "boredpanda.com", +- "udemy.com", +- "mobogenie.com", +- "tubegalore.com", +- "theglobeandmail.com", +- "bancobrasil.com.br", +- "888.com", +- "adreactor.com", +- "zomato.com", +- "depositfiles.com", +- "moneysavingexpert.com", +- "dofus.com", +- "oanda.com", +- "sport1.de", +- "justhost.com", +- "longhoo.net", +- "otomoto.pl", +- "techrepublic.com", +- "westpac.com.au", +- "dreamhost.com", +- "ilsole24ore.com", +- "clubic.com", +- "gamme.com.tw", +- "doctissimo.fr", +- "isna.ir", +- "s2d6.com", +- "tdbank.com", +- "zwaar.net", +- "slando.ua", +- "segodnya.ua", +- "appannie.com", +- "bartarinha.ir", +- "egotastic.com", +- "ed.gov", +- "lg.com", +- "120ask.com", +- "hostmonster.com", +- "super.cz", +- "mercola.com", +- "bayproxy.me", +- "day.az", +- "dummies.com", +- "azet.sk", +- "huffingtonpost.co.uk", +- "okezone.com", +- "medu.ir", +- "lavanguardia.com", +- "espreso.tv", +- "nymag.com", +- "autotrader.co.uk", +- "socialmediatoday.com", +- "wn.com", +- "rtbpop.com", +- "99designs.com", +- "sanspo.com", +- "proboards.com", +- "virginmedia.com", +- "99acres.com", +- "blic.rs", +- "pingomatic.com", +- "prnewswire.com", +- "sony.com", +- "seobuilding.ru", +- "www.gov.uk", +- "jugem.jp", +- "watchtower.com", +- "seoprofiler.com", +- "centrum.cz", +- "techbrowsing.com", +- "almasryalyoum.com", +- "lolking.net", +- "nipic.com", +- "fanfiction.net", +- "bwin.com", +- "anyporn.com", +- "sulit.com.ph", +- "quickmeme.com", +- "carview.co.jp", +- "haizhangs.com", +- "airtelforum.com", +- "flirt4free.com", +- "billboard.com", +- "trademe.co.nz", +- "rapgenius.com", +- "pchouse.com.cn", +- "beforeitsnews.com", +- "peopleperhour.com", +- "basecamphq.com", +- "onlinedown.net", +- "bet365.es", +- "fucked-tube.com", +- "santander.co.uk", +- "speedbit.com", +- "gi-akademie.com", +- "google.com.pr", +- "winupdatevideos.com", +- "bizrate.com", +- "xxxbunker.com", +- "coursera.org", +- "zoominfo.com", +- "rarbg.com", +- "ahram.org.eg", +- "howtogeek.com", +- "focus.cn", +- "duden.de", +- "mufg.jp", +- "ex.ua", +- "titan24.com", +- "greatandhra.com", +- "qqbaobao.com", +- "rtve.es", +- "yandex.net", +- "yle.fi", +- "panoramio.com", +- "google.com.af", +- "scol.com.cn", +- "gamestop.com", +- "xiami.com", +- "webpagetest.org", +- "creativecommons.org", +- "archive.is", +- "timesjobs.com", +- "centurylink.com", +- "wowhead.com", +- "wordstream.com", +- "lloydsbank.co.uk", +- "incredibar.com", +- "vagalume.com.br", +- "installerapplicationusa.com", +- "shinobi.jp", +- "ruvr.ru", +- "natwest.com", +- "roulettebotplus.com", +- "wildberries.ru", +- "huaban.com", +- "buenosearch.com", +- "reg.ru", +- "tempo.co", +- "qvc.com", +- "mangahere.com", +- "tv.com", +- "boc.cn", +- "fnb.co.za", +- "made-in-china.com", +- "eleconomista.es", +- "ubuntuforums.org", +- "derstandard.at", +- "xml-sitemaps.com", +- "jang.com.pk", +- "jiayuan.com", +- "credit-agricole.fr", +- "androidcentral.com", +- "urbanspoon.com", +- "pornoxo.com", +- "regnum.ru", +- "bedbathandbeyond.com", +- "skladchik.com", +- "daily.co.jp", +- "n-mobile.net", +- "suntrust.com", +- "justjared.com", +- "vid2c.com", +- "gettyimages.com", +- "tubecup.com", +- "kinogo.net", +- "similarsites.com", +- "fling.com", +- "vine.co", +- "banglanews24.com", +- "pudelek.pl", +- "support.wordpress.com", +- "cox.com", +- "xkcd.com", +- "adbooth.com", +- "anz.com", +- "adxcore.com", +- "google.com.sv", +- "indeed.co.in", +- "scottrade.com", +- "v9.com", +- "isohunt.to", +- "srclick.ru", +- "gharreh.com", +- "zaman.com.tr", +- "monsterindia.com", +- "delfi.lt", +- "chewen.com", +- "empowernetwork.com/QUbsgqDwpjjbkpOgwgOeaw==", +- "state.tx.us", +- "segundamano.es", +- "utro.ru", +- "sitescout.com", +- "justclick.ru", +- "wnd.com", +- "cosmopolitan.com", +- "local.com", +- "anitube.se", +- "sport.es", +- "google.com.qa", +- "ads-id.com", +- "google.lv", +- "capitalone360.com", +- "hattrick.org", +- "qualtrics.com", +- "inagist.com", +- "filgoal.com", +- "incredibar-search.com", +- "adslgate.com", +- "directv.com", +- "ilivid.com", +- "warthunder.ru", +- "jasmin.com", +- "cyberciti.biz", +- "msn.co.jp", +- "canalblog.com", +- "boerse.bz", +- "tnaflix.com", +- "apa.az", +- "prchecker.info", +- "reclameaqui.com.br", +- "onlyworldnews.com", +- "submarino.com.br", +- "kuronekoyamato.co.jp", +- "paipai.com", +- "realitykings.com", +- "deadspin.com", +- "islamweb.net", +- "no-ip.com", +- "lostfilm.tv", +- "wattpad.com", +- "wav.tv", +- "citi.com", +- "buysellads.com", +- "prezentacya.ru", +- "forocoches.com", +- "donga.com", +- "drive2.ru", +- "netsuite.com", +- "privalia.com", +- "bidorbuy.co.za", +- "cmbchina.com", +- "searchresultsguide.com", +- "odatv.com", +- "skrill.com", +- "en.wordpress.com", +- "dojki.com", +- "unibet.com", +- "hotpepper.jp", +- "simplyhired.com", +- "vesti.ua", +- "ibtimes.co.uk", +- "creativebloq.com", +- "filmesonlinegratis.net", +- "videohive.net", +- "kmart.com", +- "metacritic.com", +- "rikunabi.com", +- "zozo.jp", +- "venturebeat.com", +- "1and1.es", +- "banesconline.com", +- "internethaber.com", +- "rae.es", +- "planetsuzy.org", +- "wpengine.com", +- "kizi.com", +- "armorgames.com", +- "argos.co.uk", +- "dtiblog.com", +- "diigo.com", +- "forever21.com", +- "flashscore.com", +- "vedomosti.ru", +- "ccavenue.com", +- "att.net", +- "esporte.uol.com.br", +- "empowernetwork.com/PXQ7Uz1Kyg+LR1APrG7pKQ==", +- "to8to.com", +- "hotwire.com", +- "all.biz", +- "info.com", +- "xhamster.com/user/video", +- "000webhost.com", +- "worldoftanks.ru", +- "dagbladet.no", +- "computerbild.de", +- "nasdaq.com", +- "chitika.com", +- "ipeen.com.tw", +- "abola.pt", +- "wiley.com", +- "lpcloudsvr303.com", +- "tinsao.net", +- "mehrnews.com", +- "hugesex.tv", +- "christian-dogma.com", +- "search.us.com", +- "garmin.com", +- "tgbus.com", +- "iherb.com", +- "torntv-tvv.org", +- "chosun.com", +- "kinozal.tv", +- "berkeley.edu", +- "techtarget.com", +- "labanquepostale.fr", +- "fitbit.com", +- "folkd.com", +- "theonion.com", +- "idealista.com", +- "oscar.go.com", +- "jiji.com", +- "anonym.to", +- "allabout.co.jp", +- "wufoo.com", +- "rantlifestyle.com", +- "google.com.bo", +- "28.com", +- "rocketnews24.com", +- "hotspotshield.com", +- "opentable.com", +- "admngronline.com", +- "naturalnews.com", +- "zeroredirect2.com", +- "ero-video.net", +- "dinamalar.com", +- "fl.ru", +- "mtsindia.in", +- "kapook.com", +- "theage.com.au", +- "allmyvideos.net", +- "dinodirect.com", +- "videodownloadconverter.com", +- "tripleclicks.com", +- "brassring.com", +- "fapdu.com", +- "cafepress.com", +- "infospace.com", +- "express.com.pk", +- "fumu.com", +- "infibeam.com", +- "etrade.com", +- "meneame.net", +- "seroundtable.com", +- "bigpoint.com", +- "chinadaily.com.cn", +- "myfonts.com", +- "ezdownloadpro.info", +- "codeplex.com", +- "xl.pt", +- "kaspersky.com", +- "khabarfarsi.com", +- "admitad.com", +- "flirchi.com", +- "dpstream.net", +- "miniinthebox.com", +- "samsclub.com", +- "charter.net", +- "techbang.com", +- "tiu.ru", +- "fanpage.it", +- "spokeo.com", +- "imageshack.com", +- "ijreview.com", +- "bc.vc", +- "lazada.co.id", +- "gofirstrow.eu", +- "uptobox.com", +- "newsnow.co.uk", +- "symantec.com", +- "editor.wix.com", +- "avaxhome.cc", +- "canalplus.fr", +- "copyblogger.com", +- "vetogate.com", +- "yahoo-mbga.jp", +- "manoramaonline.com", +- "ah-me.com", +- "elheddaf.com", +- "bitcointalk.org", +- "haqaik.com", +- "bbandt.com", +- "linguee.de", +- "blogspot.nl", +- "minus.com", +- "amarujala.com", +- "openclassrooms.com", +- "bigmir.net", +- "koramgame.com", +- "commonfloor.com", +- "gayromeo.com", +- "cleartrip.com", +- "kompasiana.com", +- "tankionline.com", +- "google.co.tz", +- "springer.com", +- "lifenews.ru", +- "sify.com", +- "tvoyauda4a.ru", +- "dfiles.ru", +- "technorati.com", +- "myorderbox.com", +- "fanatik.com.tr", +- "activesearchresults.com", +- "laposte.net", +- "whirlpool.net.au", +- "stockcharts.com", +- "leadimpact.com", +- "cardekho.com", +- "ryushare.com", +- "blog.jp", +- "fastcompany.com", +- "eurosport.fr", +- "emirates.com", +- "lb.ua", +- "serverfault.com", +- "forbes.ru", +- "bfmtv.com", +- "google.jo", +- "17173.com", +- "wikispaces.com", +- "tokopedia.com", +- "liberation.fr", +- "a10.com", +- "kdnet.net", +- "variety.com", +- "blog.me", +- "homeaway.com", +- "ameritrade.com", +- "adult-empire.com", +- "national.com.au", +- "haraj.com.sa", +- "timewarnercable.com", +- "casino.com", +- "sheknows.com", +- "google.com.uy", +- "abv.bg", +- "liputan6.com", +- "etxt.ru", +- "bigstockphoto.com", +- "strato.de", +- "cashtasks.com", +- "columbia.edu", +- "zdf.de", +- "pptv.com", +- "cricbuzz.com", +- "sharesuper.info", +- "radaronline.com", +- "pornolab.net", +- "google.ba", +- "opensubtitles.org", +- "abclocal.go.com", +- "ansa.it", +- "pbskids.org", +- "vz.ru", +- "iconfinder.com", +- "vitaminl.tv", +- "ntv.ru", +- "peliculasyonkis.com", +- "foto-hd.com", +- "paytm.com", +- "rantsports.com", +- "optimum.net", +- "postbank.de", +- "index.hr", +- "smugmug.com", +- "haivl.com", +- "arbeitsagentur.de", +- "dailycaller.com", +- "freshbooks.com", +- "genieo.com", +- "alnaddy.com", +- "britishairways.com", +- "20min.ch", +- "findthebest.com", +- "autoblog.com", +- "warez-bb.org", +- "iza.ne.jp", +- "filmaffinity.com", +- "megogo.net", +- "soccermanager.com", +- "dawanda.com", +- "parallels.com", +- "clickjogos.uol.com.br", +- "12306.cn", +- "jstv.com", +- "cliphunter.com", +- "pixabay.com", +- "milenio.com", +- "keybinary.com", +- "suumo.jp", +- "mediatakeout.com", +- "vodafone.in", +- "cheapoair.com", +- "seobook.com", +- "videoyoum7.com", +- "yr.no", +- "gofundme.com", +- "ixbt.com", +- "starbucks.com", +- "conferenceplus.com", +- "media1first.com", +- "sergey-mavrodi.com", +- "rafflecopter.com", +- "591.com.tw", +- "mangapanda.com", +- "huffingtonpost.fr", +- "tiboo.cn", +- "bancomer.com.mx", +- "handelsblatt.com", +- "hpylgr.com", +- "psu.edu", +- "bancomercantil.com", +- "sport-express.ru", +- "codepen.io", +- "foundationapi.com", +- "ow.ly", +- "vatgia.com", +- "kommersant.ru", +- "srvsinf.com", +- "telderi.ru", +- "mercadolibre.com.co", +- "hsbc.com.hk", +- "t3n.de", +- "magicbricks.com", +- "shopstyle.com", +- "mudah.my", +- "punchng.com", +- "therichest.com", +- "fansshare.com", +- "lepoint.fr", +- "vipzona.info", +- "globaltestmarket.com", +- "jqueryui.com", +- "bcsh.com", +- "mundodeportivo.com", +- "newyorker.com", +- "funnyjunk.com", +- "gongchang.com", +- "a8.net", +- "ecollege.com", +- "newhdplugin.net", +- "befuck.com", +- "elespectador.com", +- "drugs.com", +- "abplive.in", +- "feelcars.com", +- "psychologytoday.com", +- "instaforex.com", +- "strtsrv.com", +- "atpworldtour.com", +- "incruit.com", +- "starwoodhotels.com", +- "zone-telechargement.com", +- "songspk.name", +- "hatenablog.com", +- "enfemenino.com", +- "msnbc.com", +- "freebitco.in", +- "akairan.com", +- "discovery.com", +- "angieslist.com", +- "lesechos.fr", +- "transfermarkt.de", +- "sephora.com", +- "come.in", +- "dailykos.com", +- "deutsche-bank.de", +- "warriorplus.com", +- "awwwards.com", +- "lomadee.com", +- "365jia.cn", +- "lotterypost.com", +- "egrana.com.br", +- "rivals.com", +- "literotica.com", +- "myfreshnet.com", +- "ihg.com", +- "fazenda.gov.br", +- "tomnod.com", +- "filesharefanatic.com", +- "hotukdeals.com", +- "bitsnoop.com", +- "tenpay.com", +- "putlocker.bz", +- "ziddu.com", +- "ntvmsnbc.com", +- "surveyzrewardcenter.com", +- "aliyun.com", +- "media.net", +- "comdirect.de", +- "yoox.com", +- "hotelscombined.com", +- "vgsgaming-ads.com", +- "robokassa.ru", +- "webdesignerdepot.com", +- "rotoworld.com", +- "jmw.com.cn", +- "seloger.com", +- "dsdomination.com", +- "affiliatewindow.com", +- "abs-cbnnews.com", +- "bmo.com", +- "iconarchive.com", +- "funshion.com", +- "admin5.com", +- "playhe.com", +- "bigcommerce.com", +- "yodobashi.com", +- "bigfishgames.com", +- "onlinecreditcenter6.com", +- "homes.co.jp", +- "gameninja.com", +- "ebates.com", +- "banamex.com.mx", +- "google.com.lb", +- "2chblog.jp", +- "entertainment-factory.com", +- "asg.to", +- "walla.co.il", +- "mktmobi.com", +- "opensooq.com", +- "adam4adam.com", +- "expressen.se", +- "elephanttube.com", +- "ingdirect.es", +- "clicrbs.com.br", +- "seriespepito.com", +- "skyscanner.net", +- "shine.com", +- "appround.us", +- "washingtontimes.com", +- "nrk.no", +- "1stwebdesigner.com", +- "gucheng.com", +- "ghanaweb.com", +- "jzip.com", +- "rozetka.com.ua", +- "wiziwig.tv", +- "jobsdb.com", +- "kitco.com", +- "rpp.com.pe", +- "aljaras.com", +- "telecinco.es", +- "storify.com", +- "netease.com", +- "business-standard.com", +- "babble.com", +- "noticias.uol.com.br", +- "alice.it", +- "bizdec.ru", +- "voanews.com", +- "freejobalert.com", +- "origo.hu", +- "list-manage2.com", +- "gavick.com", +- "national-lottery.co.uk", +- "gazzetta.gr", +- "freevideodownloadforpc.com", +- "xmarks.com", +- "wikibooks.org", +- "sexad.net", +- "alc.co.jp", +- "emol.com", +- "careesma.in", +- "cdc.gov", +- "toshiba.com", +- "imgchili.net", +- "rbcroyalbank.com", +- "indowebster.com", +- "zynga.com", +- "telekom.com", +- "jiameng.com", +- "adsmarket.com", +- "utorrent.com", +- "aarp.org", +- "cityadspix.com", +- "ekstrabladet.dk", +- "doc88.com", +- "fetlife.com", +- "fh21.com.cn", +- "cambridge.org", +- "tune.pk", +- "auction.co.kr", +- "patheos.com", +- "search-results.com", +- "lds.org", +- "webrankinfo.com", +- "newsit.gr", +- "techtudo.com.br", +- "moviepilot.com", +- "mercador.ro", +- "nguoiduatin.vn", +- "tripadvisor.it", +- "lurkmore.to", +- "europapress.es", +- "uspto.gov", +- "excelsior.com.mx", +- "myvideo.de", +- "jetblue.com", +- "camfrog.com", +- "blick.ch", +- "batepapo.uol.com.br", +- "manager.co.th", +- "goibibo.com", +- "cornell.edu", +- "apetube.com", +- "nation.com", +- "allmusic.com", +- "naughtyamerica.com", +- "obozrevatel.com", +- "telegrafi.com", +- "neimanmarcus.com", +- "yabancidiziizle1.com", +- "globalewallet.com", +- "beeline.ru", +- "hinkhoj.com", +- "sitemeter.com", +- "almesryoon.com", +- "localmoxie.com", +- "grotal.com", +- "knowyourmeme.com", +- "qiwi.ru", +- "yieldmanager.com", +- "yimg.com", +- "horoscopedays.com", +- "gfy.com", +- "mxtoolbox.com", +- "searchgol.com", +- "inquirer.net", +- "hollywoodlife.com", +- "ebrun.com", +- "shopbop.com", +- "mysmartprice.com", +- "kijiji.it", +- "visual.ly", +- "mop.com", +- "1fichier.com", +- "prlog.org", +- "xjtour.com", +- "shorouknews.com", +- "thegioinet.net", +- "hln.be", +- "enom.com", +- "thaqafnafsak.com", +- "wahuu.com", +- "ganji.com", +- "russianpost.ru", +- "myplaycity.com", +- "dzone.com", +- "dns-shop.ru", +- "aif.ru", +- "ssisurveys.com", +- "uploadboy.com", +- "madpandatv.net", +- "pcauto.com.cn", +- "meinestadt.de", +- "tasnimnews.com", +- "rockettheme.com", +- "imesh.com", +- "home.pl", +- "lindaikeji.blogspot.com", +- "zamunda.net", +- "with2.net", +- "calameo.com", +- "myonlinearcade.com", +- "xcams.com", +- "unicredit.it", +- "clip2net.com", +- "mediatemple.net", +- "nosub.tv", +- "click.in", +- "alluc.to", +- "thestar.com.my", +- "niksalehi.com", +- "lastampa.it", +- "itv.com", +- "hihi2.com", +- "digitalocean.com", +- "tripadvisor.fr", +- "willhaben.at", +- "laodong.com.vn", +- "591hx.com", +- "tineye.com", +- "ptt.cc", +- "beatport.com", +- "infoseek.co.jp", +- "avangate.com", +- "indiaproperty.com", +- "books.com.tw", +- "nj.com", +- "avaaz.org", +- "wikitravel.org", +- "direct.gov.uk", +- "wangtu.com", +- "discover.com", +- "slon.ru", +- "startpage.com", +- "thestar.com", +- "meishichina.com", +- "finanzen.net", +- "estadao.com.br", +- "indeed.co.uk", +- "expansion.com", +- "irpopup.ir", +- "arvixe.com", +- "secureinternetbank.com", +- "csmonitor.com", +- "carwale.com", +- "mtime.com", +- "ceconline.com", +- "abchina.com", +- "cgbchina.com.cn", +- "mediotiempo.com", +- "vic.gov.au", +- "cnbeta.com", +- "alarab.net", +- "vietnamnet.vn", +- "gay.com", +- "watchmygf.net", +- "myanimelist.net", +- "bannersbroker.com", +- "asklaila.com", +- "heureka.cz", +- "grepolis.com", +- "meteofrance.com", +- "bol.com", +- "hasoffers.com", +- "bigrock.in", +- "ibanking-services.com", +- "nos.nl", +- "google.com.gh", +- "beppegrillo.it", +- "nhaccuatui.com", +- "hamariweb.com", +- "wikiquote.org", +- "evite.com", +- "jobdiagnosis.com", +- "17track.net", +- "baixing.com", +- "awempire.com", +- "healthgrades.com", +- "unifiedlayer.com", +- "thisav.com", +- "himado.in", +- "zcool.com.cn", +- "tsn.ca", +- "atlassian.net", +- "binary500.com", +- "alotporn.com", +- "dnaindia.com", +- "sherdog.com", +- "www.nhs.uk", +- "gruposantander.es", +- "quantcast.com", +- "usearchmedia.com", +- "merchantcircle.com", +- "blog.hu", +- "wallstcheatsheet.com", +- "iptorrents.com", +- "apsense.com", +- "redirsvc.com", +- "indiarailinfo.com", +- "mobile.ir", +- "xvideo-jp.com", +- "boxofficemojo.com", +- "scamadviser.com", +- "rotapost.ru", +- "someecards.com", +- "mydealz.de", +- "lvye.cn", +- "videoweed.es", +- "xlovecam.com", +- "pepperjamnetwork.com", +- "khabarpu.com", +- "mathrubhumi.com", +- "online-convert.com", +- "b92.net", +- "tiptopsoft.org", +- "el-balad.com", +- "qihoo.com", +- "iheart.com", +- "campaign-archive1.com", +- "photodune.net", +- "labnol.org", +- "kotobank.jp", +- "medium.com", +- "google.lu", +- "tm1111.com", +- "gigazine.net", +- "mypcbackup.com", +- "instantcheckmate.com", +- "seemorgh.com", +- "topky.sk", +- "puu.sh", +- "aeriagames.com", +- "whatismyip.com", +- "rising.cn", +- "scotiabank.com", +- "wo.com.cn", +- "yootheme.com", +- "channel4.com", +- "heavy-r.com", +- "omgpm.com", +- "milli.az", +- "bnpparibas.net", +- "vmware.com", +- "diretta.it", +- "skycn.com", +- "sap.com", +- "zyalt.livejournal.com", +- "bookryanair.com", +- "kkbox.com", +- "subtitleseeker.com", +- "abckj123.com", +- "mashreghnews.ir", +- "websitewelcome.com", +- "2ch-c.net", +- "health.com", +- "uproxx.com", +- "uast.ac.ir", +- "bol.uol.com.br", +- "feedsportal.com", +- "ip-adress.com", +- "sedty.com", +- "ilsistemabinario.com", +- "nabble.com", +- "hightail.com", +- "superjob.ru", +- "tokyo.jp", +- "hrblock.com", +- "china.cn", +- "tsetmc.com", +- "unfranchise.com.tw", +- "bhg.com", +- "htmlbook.ru", +- "stardoll.com", +- "crictime.com", +- "hsn.com", +- "royalmail.com", +- "globallshare.com", +- "wikiwiki.jp", +- "petardas.com", +- "usembassy.gov", +- "rakuten-bank.co.jp", +- "golem.de", +- "stepstone.de", +- "aucfan.com", +- "stubhub.com", +- "rbcdaily.ru", +- "ro2.biz", +- "huffingtonpost.ca", +- "timeout.com", +- "digitalspy.co.uk", +- "foreningssparbanken.se", +- "autodesk.com", +- "98ia.com", +- "gtbank.com", +- "runetki.com", +- "freshdesk.com", +- "ieee.org", +- "getpocket.com", +- "jutarnji.hr", +- "caisse-epargne.fr", +- "profitcentr.com", +- "51.com", +- "oi.com.br", +- "sina.com.tw", +- "fontspace.com", +- "dynamicdrive.com", +- "maduradas.com", +- "ligtv.com.tr", +- "sport24.gr", +- "stargazete.com", +- "bola.net", +- "template-help.com", +- "codecademy.com", +- "officedepot.com", +- "researchgate.net", +- "17u.com", +- "gfxtra.com", +- "weiphone.com", +- "shoutmeloud.com", +- "hc360.com", +- "lintas.me", +- "mk.ru", +- "wplocker.com", +- "thumbtack.com", +- "szn.cz", +- "yatra.com", +- "societegenerale.fr", +- "wyborcza.pl", +- "demotywatory.pl", +- "thomann.de", +- "imperiaonline.org", +- "magento.com", +- "skillpages.com", +- "cam4ads.com", +- "spiceworks.com", +- "homestead.com", +- "locanto.in", +- "hotelurbano.com", +- "sinaimg.cn", +- "chetxia.com", +- "menshealth.com", +- "ideacellular.com", +- "snopes.com", +- "newgrounds.com", +- "autosottocosto.com", +- "admob.com", +- "linguee.fr", +- "net-a-porter.com", +- "text.ru", +- "sharebeast.com", +- "televisionfanatic.com", +- "netlog.com", +- "lufthansa.com", +- "ngoisao.net", +- "3911.net", +- "worldssl.net", +- "rabobank.nl", +- "lvmama.com", +- "sharethis.com", +- "sambaporno.com", +- "mci.ir", +- "inosmi.ru", +- "joyreactor.cc", +- "cartfill.in", +- "cooltext.com", +- "qz.com", +- "onthe.io", +- "citilink.ru", +- "apartmenttherapy.com", +- "lloydsbank.com", +- "metroer.com", +- "koyotesoft.com", +- "subdivx.com", +- "alriyadh.com", +- "backlinkwatch.com", +- "coindesk.com", +- "porntube1.xxx", +- "zovi.com", +- "thestreet.com", +- "rtbstream.com", +- "etnet.com.hk", +- "creditkarma.com", +- "lifebuzz.com", +- "opodo.co.uk", +- "developpez.net", +- "tinydeal.com", +- "nature.com", +- "oxforddictionaries.com", +- "anchorfree.net", +- "tn.com.ar", +- "findicons.com", +- "joomlart.com", +- "hmrc.gov.uk", +- "btc-e.com", +- "extra.com.br", +- "ad.nl", +- "megafon.ru", +- "qafqazinfo.az", +- "shahvani.com", +- "googlecode.com", +- "milliyet.tv", +- "deadline.com", +- "grindtv.com", +- "logitech.com", +- "nzherald.co.nz", +- "ninisite.com", +- "webgains.com", +- "oschina.net", +- "webmasters.ru", +- "filmix.net", +- "seowhy.com", +- "met-art.com", +- "discart.ru", +- "keywordblocks.com", +- "vodly.to", +- "redvak.com", +- "tomshardware.co.uk", +- "2shared.com", +- "zoznam.sk", +- "icims.com", +- "virtapay.com", +- "blomaga.jp", +- "wasu.cn", +- "carsensor.net", +- "sportsdirect.com", +- "uservoice.com", +- "livescience.com", +- "gamebase.com.tw", +- "persiangig.com", +- "livesmi.com", +- "eharmony.com", +- "banorte.com", +- "radiojavan.com", +- "startv.com.tr", +- "coolmath-games.com", +- "downloadquick.net", +- "worldoftanks.eu", +- "filelist.ro", +- "fontsquirrel.com", +- "superpages.com", +- "yolasite.com", +- "funnie.st", +- "51cto.com", +- "goo-net.com", +- "builtwith.com", +- "shaparak.ir", +- "nuomi.com", +- "omegle.com", +- "poringa.net", +- "lan.com", +- "desi-tashan.com", +- "shabdkosh.com", +- "freedigitalphotos.net", +- "betradar.com", +- "womenshealthmag.com", +- "realsimple.com", +- "maxbounty.com", +- "bbva.es", +- "sweetpacks.com", +- "pinoy-ako.info", +- "jobstreet.com", +- "cafe24.com", +- "goldenbirds.biz", +- "anandtech.com", +- "mapion.co.jp", +- "rawstory.com", +- "streamate.com", +- "celebuzz.com", +- "freepornvs.com", +- "divyabhaskar.co.in", +- "lifehack.org", +- "holidaycheck.de", +- "quizlet.com", +- "zhibo8.cc", +- "askmefast.com", +- "manageflitter.com", +- "campaign-archive2.com", +- "cityheaven.net", +- "uniqlo.com", +- "seoclerks.com", +- "tecmundo.com.br", +- "the-binary-options-guide.com", +- "gigaom.com", +- "mywot.com", +- "playcast.ru", +- "tatadocomo.com", +- "csfd.cz", +- "ganool.com", +- "kaschpo.ru", +- "webdunia.com", +- "philly.com", +- "doctoroz.com", +- "jumei.com", +- "poponclick.com", +- "rueducommerce.fr", +- "fararu.com", +- "po.st", +- "nextag.com", +- "manhunt.net", +- "sistrix.com", +- "woman.ru", +- "appbank.net", +- "iobit.com", +- "joins.com", +- "vidtomp3.com", +- "un.org", +- "volusion.com", +- "lipsum.com", +- "afkarnews.ir", +- "goldenline.pl", +- "clickansave.net", +- "softgozar.com", +- "thefind.com", +- "mozzi.com", +- "wenxuecity.com", +- "up2c.com", +- "searchfunmoods.com", +- "cabelas.com", +- "coffetube.com", +- "otto.de", +- "webalta.ru", +- "tataindicom.com", +- "ctvnews.ca", +- "inlinkz.com", +- "kajabi.com", +- "greatergood.com", +- "whmcs.com", +- "telekom.de", +- "christianpost.com", +- "fiducia.de", +- "bancsabadell.com", +- "pirateproxy.net", +- "woobox.com", +- "google.cm", +- "noulinx.com", +- "nick.com", +- "moviehuts.com", +- "mvideo.ru", +- "couchtuner.eu", +- "wyborcza.biz", +- "tradeindia.com", +- "girlsgogames.com", +- "healthcare.gov", +- "videolan.org", +- "sky.it", +- "tuniu.com", +- "ime.nu", +- "n4g.com", +- "cyberforum.ru", +- "justin.tv", +- "createspace.com", +- "joemonster.org", +- "registro.br", +- "elkhabar.com", +- "open24news.tv", +- "irr.ru", +- "sanjesh.org", +- "standardbank.co.za", +- "neogaf.com", +- "doyo.cn", +- "am15.net", +- "ana.co.jp", +- "amd.com", +- "gidonlinekino.com", +- "sitetalk.com", +- "nesn.com", +- "arabseed.com", +- "ingbank.pl", +- "webpronews.com", +- "saavn.com", +- "yourdictionary.com", +- "mobile9.com", +- "jagranjosh.com", +- "www.net.cn", +- "computerbase.de", +- "3djuegos.com", +- "htc.com", +- "the-binary-theorem.com", +- "google.com.np", +- "n11.com", +- "vivastreet.com", +- "mthai.com", +- "seomastering.com", +- "mercadolibre.cl", +- "searchmetrics.com", +- "mentalfloss.com", +- "russia.tv", +- "ubi.com", +- "dwnews.com", +- "ecplaza.net", +- "trafficfactory.biz", +- "loopnet.com", +- "refinery29.com", +- "minecraftforum.net", +- "moviefone.com", +- "bom.gov.au", +- "google.com.bh", +- "eltiempo.es", +- "cuantarazon.com", +- "2258.com", +- "google.ee", +- "nwolb.com", +- "bezaat.com", +- "eelly.com", +- "icmwebserv.com", +- "techsmith.com", +- "timeweb.ru", +- "johnlewis.com", +- "independent.ie", +- "bankia.es", +- "dkb.de", +- "gilt.com", +- "duolingo.com", +- "3file.info", +- "cam4.de.com", +- "pcanalysis.net", +- "br.de", +- "vodlocker.com", +- "adfoc.us", +- "ymlp.com", +- "dailyfx.com", +- "business2community.com", +- "banki.ru", +- "yell.com", +- "smartresponder.ru", +- "yaske.to", +- "bokra.net", +- "mercadolibre.com", +- "viewster.com", +- "recipesfinder.com", +- "rei.com", +- "dogpile.com", +- "caf.fr", +- "sbrf.ru", +- "soha.vn", +- "voila.fr", +- "rp-online.de", +- "members.webs.com", +- "duvamis.com", +- "nazwa.pl", +- "google.com.ni", +- "ilovemobi.com", +- "retrogamer.com", +- "blogtalkradio.com", +- "utexas.edu", +- "sonyentertainmentnetwork.com", +- "dr.dk", +- "jjwxc.net", +- "service-public.fr", +- "care2.com", +- "musavat.com", +- "h12-media.com", +- "smartfren.com", +- "immowelt.de", +- "discuz.net", +- "m1905.com", +- "cas.sk", +- "bitcoinwisdom.com", +- "monografias.com", +- "mindbodygreen.com", +- "getfirebug.com", +- "godlikeproductions.com", +- "mydrivers.com", +- "voc.com.cn", +- "truecaller.com", +- "livemook.com", +- "i8ti.com", +- "agame.com", +- "kurir-info.rs", +- "urbanoutfitters.com", +- "shopping.uol.com.br", +- "2ip.ru", +- "91.com", +- "banquepopulaire.fr", +- "rappler.com", +- "mint.com", +- "jz123.cn", +- "zurb.com", +- "sport.cz", +- "justunfollow.com", +- "billionuploads.com", +- "thaivisa.com", +- "seitwert.de", +- "ciudad.com.ar", +- "archdaily.com", +- "jalopnik.com", +- "1news.az", +- "dailyfinance.com", +- "okitspace.com", +- "dn.se", +- "el-nacional.com", +- "larousse.fr", +- "mojo-themes.com", +- "draugiem.lv", +- "teamtreehouse.com", +- "xiu.com", +- "ennaharonline.com", +- "oricon.co.jp", +- "openoffice.org", +- "tny.cz", +- "forumfree.it", +- "youthwant.com.tw", +- "khamsat.com", +- "vitacost.com", +- "alrakoba.net", +- "marmiton.org", +- "yebhi.com", +- "the-binary-trader.biz", +- "dominos.com", +- "dice.com", +- "like4like.org", +- "tvmuse.com", +- "standardchartered.com", +- "bitbucket.org", +- "driveropti.net", +- "google.hn", +- "indiblogger.in", +- "torrenthound.com", +- "wolframalpha.com", +- "experienceproject.com", +- "nsw.gov.au", +- "olx.pt", +- "sciencedaily.com", +- "viglink.com", +- "plala.or.jp", +- "sxsw.com", +- "mileroticos.com", +- "namejet.com", +- "1hai.cn", +- "skroutz.gr", +- "bilibili.tv", +- "travelzoo.com", +- "saksfifthavenue.com", +- "get-a-fuck-tonight.com", +- "barclaycardus.com", +- "withgoogle.com", +- "whitehouse.gov", +- "oprah.com", +- "fishwrapper.com", +- "softbank.jp", +- "slutload.com", +- "latercera.cl", +- "100bestbuy.com", +- "nur.kz", +- "topit.me", +- "computerhope.com", +- "snob.ru", +- "rackcdn.com", +- "3158.cn", +- "artlebedev.ru", +- "yobt.com", +- "rai.it", +- "hs.fi", +- "tinhte.vn", +- "fotocasa.es", +- "nyu.edu", +- "dawn.com", +- "series.ly", +- "movshare.net", +- "fineartamerica.com", +- "westernunion.com", +- "leaseweb.com", +- "wayn.com", +- "ivi.ru", +- "bloomingdales.com", +- "pons.com", +- "rapidtrk.com", +- "bama.ir", +- "hackforums.net", +- "dfiles.eu", +- "intercambiosvirtuales.org", +- "sdo.com", +- "homes.com", +- "colissimo.fr", +- "discuss.com.hk", +- "afreeca.com", +- "rbc.ua", +- "novamov.com", +- "jungle.gr", +- "iol.co.za", +- "btcclicks.com", +- "mapsofindia.com", +- "propellerads.com", +- "fab.com", +- "princeton.edu", +- "reliancebroadband.co.in", +- "xdf.cn", +- "mako.co.il", +- "protothema.gr", +- "booloo.com", +- "livrariasaraiva.com.br", +- "efukt.com", +- "acrobat.com", +- "globovision.com", +- "xero.com", +- "sevenforums.com", +- "semalt.com", +- "audiojungle.net", +- "e1.ru", +- "quoka.de", +- "chinaiiss.com", +- "gonzoxxxmovies.com", +- "wallpaperswide.com", +- "fapvid.com", +- "trk4.com", +- "forosdelweb.com", +- "fark.com", +- "my.tv.sohu.com/user/video", +- "kaixin001.com", +- "ntvspor.net", +- "mobafire.com", +- "zigwheels.com", +- "filmifullizle.com", +- "8tracks.com", +- "readmanga.eu", +- "lelong.com.my", +- "planetromeo.com", +- "192.com", +- "republika.co.id", +- "in.gr", +- "televisao.uol.com.br", +- "kalerkantho.com", +- "usairways.com", +- "malaysiakini.com", +- "anonymouse.org", +- "xxxhost.me", +- "stuff.co.nz", +- "dek-d.com", +- "bbvanet.com.mx", +- "watchseries-online.eu", +- "malaysiaairlines.com", +- "policymic.com", +- "serviporno.com", +- "aprod.hu", +- "gelocal.it", +- "tradetracker.com", +- "cibc.com", +- "umich.edu", +- "smartshe.com", +- "sony.jp", +- "taobaocdn.com", +- "bestgfx.biz", +- "irib.ir", +- "aliimg.com", +- "esuteru.com", +- "healthline.com", +- "cnnamador.com", +- "sat.gob.mx", +- "childsafedownloadx.asia", +- "playmillion.com", +- "strawberrynet.com", +- "alnilin.com", +- "trustedreviews.com", +- "21cn.com", +- "persianv.com", +- "baomoi.com", +- "firestorage.jp", +- "google.co.ke", +- "admaimai.com", +- "sbnlife.com", +- "surveyrouter.com", +- "megaindex.ru", +- "intodns.com", +- "yiqifa.com", +- "mixcloud.com", +- "softonic.fr", +- "bakecaincontrii.com", +- "payu.in", +- "rakuten-card.co.jp", +- "almaany.com", +- "grantland.com", +- "ricardo.ch", +- "heavy.com", +- "niusnews.com", +- "canstockphoto.com", +- "acunn.com", +- "diythemes.com", +- "canalrcnmsn.com", +- "ngs.ru", +- "rassd.com", +- "groupon.co.in", +- "depositfiles.org", +- "mango.com", +- "theregister.co.uk", +- "worldfree4u.com", +- "f-lite.ru", +- "boingboing.net", +- "bangbros.com", +- "neteller.com", +- "tonicmovies.com", +- "p2up.ir", +- "cartoonnetwork.com", +- "lun.com", +- "nk.pl", +- "webry.info", +- "burningcamel.com", +- "mplife.com", +- "nationalreview.com", +- "williamhill.es", +- "sssc.cn", +- "col3negoriginal.lk", +- "yoast.com", +- "svyaznoy.ru", +- "chengdu.cn", +- "listverse.com", +- "lastminute.com", +- "guardianlv.com", +- "39yst.com", +- "bahseazad.ir", +- "debian.org", +- "tokyo-porn-tube.com", +- "ilbe.com", +- "upsocl.com", +- "balatarin.com", +- "charter97.org", +- "wpexplorer.com", +- "immi.gov.au", +- "yokamen.cn", +- "esmas.com", +- "hbr.org", +- "livechatinc.com", +- "crazyegg.com", +- "palcomp3.com", +- "calottery.com", +- "wistia.com", +- "locaweb.com.br", +- "techspot.com", +- "bit.ly", +- "yammer.com", +- "uscis.gov", +- "bramjnet.com", +- "linio.com.mx", +- "tharunaya.co.uk", +- "desirulez.net", +- "madmimi.com", +- "everydayhealth.com", +- "secondlife.com", +- "ceskatelevize.cz", +- "enter.ru", +- "glopart.ru", +- "woso.cn", +- "pitlap.info", +- "worldoftanks.com", +- "videarn.com", +- "dafiti.com.br", +- "segundamano.mx", +- "eamroomsnacks.com", +- "vulture.com", +- "humblebundle.com", +- "rockstargames.com", +- "wsodownloads.info", +- "yazete.com", +- "pcadvisor.co.uk", +- "07073.com", +- "modcloth.com", +- "attracta.com", +- "iol.pt", +- "travideos.com", +- "sparkpeople.com", +- "rankingsandreviews.com", +- "entekhab.ir", +- "goarticles.com", +- "wonderhowto.com", +- "kankanews.com", +- "rzb.ir", +- "p30download.com", +- "infojobs.it", +- "socialspark.com", +- "picstopin.com", +- "celebritynetworth.com", +- "tweakers.net", +- "gi-backoffice.com", +- "isbank.com.tr", +- "qiyou.com", +- "templatic.com", +- "cyberpresse.ca", +- "consumerreports.org", +- "focalprice.com", +- "linkpad.ru", +- "svd.se", +- "desitvforum.net", +- "bulbagarden.net", +- "showup.tv", +- "webgozar.com", +- "3dnews.ru", +- "spyfu.com", +- "bikhir.ma", +- "trovaprezzi.it", +- "autov.com.cn", +- "podnapisi.net", +- "tocmai.ro", +- "realitatea.net", +- "geico.com", +- "joydownload.com", +- "kddi.com", +- "unbounce.com", +- "meb.gov.tr", +- "anchorfree.us", +- "gumtree.pl", +- "dbs.com", +- "ebayimg.com", +- "ptcsolution.com", +- "clip.dj", +- "samplicio.us", +- "47news.jp", +- "todo1.com", +- "anspress.com", +- "24sata.hr", +- "cineblog01.tv", +- "sport-fm.gr", +- "unetenet.com", +- "tenki.jp", +- "jia.com", +- "filefactory.com", +- "onedio.com", +- "gendai.net", +- "nickjr.com", +- "finviz.com", +- "bytes.com", +- "inkthemes.com", +- "oriflame.com", +- "aporrea.org", +- "mazika2day.com", +- "baimao.com", +- "logme.in", +- "downloadactivate.com", +- "vista.ir", +- "duowan.com", +- "sinaapp.com", +- "proceso.com.mx", +- "xxxconnect.com", +- "dvdvideosoft.com", +- "nomorerack.com", +- "almubasher.com.sa", +- "afisha.ru", +- "clicksure.com", +- "11st.co.kr", +- "turkishairlines.com", +- "freekaamaal.com", +- "findwide.com", +- "sbisec.co.jp", +- "mythemeshop.com", +- "webnode.com", +- "cumhuriyet.com.tr", +- "morningstar.com", +- "trafficshop.com", +- "gopro.com", +- "jeevansathi.com", +- "dasoertliche.de", +- "markets.com", +- "absa.co.za", +- "ikman.lk", +- "fmworld.net", +- "hyatt.com", +- "virgin-atlantic.com", +- "tfl.gov.uk", +- "immonet.de", +- "haodf.com", +- "thewrap.com", +- "appgame.com", +- "hdwallpapers.in", +- "canon.com", +- "newsle.com", +- "jorudan.co.jp", +- "pcwelt.de", +- "coinbase.com", +- "yourgirlfriends.com", +- "djmaza.info", +- "findagrave.com", +- "lainformacion.com", +- "teacup.com", +- "ezilon.com", +- "redbubble.com", +- "guru.com", +- "brothersoft.com", +- "coinmarketcap.com", +- "mediabistro.com", +- "elfagr.org", +- "glavcom.ua", +- "jino.ru", +- "1e100.net", +- "g9g.com", +- "join.me", +- "ynet.com", +- "news247.gr", +- "rcom.co.in", +- "baby.ru", +- "argentglobalnetwork.com", +- "hsselite.com", +- "foxbusiness.com", +- "cookmates.com", +- "lidl.de", +- "timesofindia.com", +- "fakt.pl", +- "bgr.com", +- "ghatreh.com", +- "woxikon.de", +- "pontofrio.com.br", +- "gizmag.com", +- "signup.wordpress.com", +- "tre.it", +- "gardenweb.com", +- "alfalfalfa.com", +- "prcm.jp", +- "freemail.hu", +- "iteye.com", +- "katproxy.com", +- "kickassunblock.info", +- "wisegeek.com", +- "zaobao.com", +- "vpsdomain4.eu", +- "naij.com", +- "olx.co.za", +- "mihanstore.org", +- "gezinti.com", +- "vistaprint.in", +- "dastelefonbuch.de", +- "blackhatteam.com", +- "yummly.com", +- "minecraft.net", +- "justcloud.com", +- "biblehub.com", +- "argentinawarez.com", +- "gandul.info", +- "trialpay.com", +- "paruvendu.fr", +- "khanacademy.org", +- "topsy.com", +- "angelfire.com", +- "nseindia.com", +- "seositecheckup.com", +- "hostelworld.com", +- "zalukaj.tv", +- "animeflv.net", +- "laptopmag.com", +- "tripadvisor.de", +- "sec.gov", +- "tripadvisor.es", +- "oreilly.com", +- "kanald.com.tr", +- "halifax-online.co.uk", +- "extremetracking.com", +- "reimageplus.com", +- "jal.co.jp", +- "vuiviet.net", +- "yeslibertin.com", +- "pichunter.com", +- "empowernetwork.com/aI3zkH7s3g6tZH8TDmh8LA==", +- "reforma.com", +- "singlessalad.com", +- "upenn.edu", +- "1ting.com", +- "hsbc.com.mx", +- "sulia.com", +- "yepporn.com", +- "scrubtheweb.com", +- "e-autopay.com", +- "rechargeitnow.com", +- "ppomppu.co.kr", +- "zemtv.com", +- "gofeminin.de", +- "peoplestylewatch.com", +- "france24.com", +- "comodo.com", +- "openmace.net", +- "maultalk.com", +- "fancy.com", +- "vodafone.it", +- "pokerstrategy.com", +- "crunchyroll.com", +- "aipai.com", +- "3dcartstores.com", +- "leancy.com", +- "myblogguest.com", +- "papajohns.com", +- "tuolar.com", +- "junkmail.co.za", +- "nyc.gov", +- "rentalcars.com", +- "sovsport.ru", +- "marketo.com", +- "smbc.co.jp", +- "yale.edu", +- "pitchfork.com", +- "thetoptens.com", +- "joyme.com", +- "linuxquestions.org", +- "htmlgoodies.com", +- "laredoute.fr", +- "0427d7.se", +- "journaldesfemmes.com", +- "xici.net", +- "alwafd.org", +- "daniweb.com", +- "mtgox.com", +- "jetstar.com", +- "plotek.pl", +- "jobvite.com", +- "adage.com", +- "aukro.cz", +- "ford.com", +- "problogger.net", +- "518.com.tw", +- "blogbigtime.com", +- "nieuwsblad.be", +- "register.com", +- "24tv.ua", +- "aftenposten.no", +- "weightwatchers.com", +- "smartpassiveincome.com", +- "radiosvoboda.org", +- "web.com", +- "caixin.com", +- "digitalmarketer.com", +- "soup.io", +- "soft98.ir", +- "muzofon.com", +- "gao7.com", +- "freefilmshd.com", +- "hsbc.com", +- "xhamsterhq.com", +- "my.tv.sohu.com/user/reg", +- "trade65.com", +- "chow.com", +- "google.com.kh", +- "inps.it", +- "seesaa.jp", +- "hoovers.com", +- "peru21.pe", +- "sdpnoticias.com", +- "schema.org", +- "linode.com", +- "theknot.com", +- "blesk.cz", +- "google.ci", +- "loltrk.com", +- "vod.pl", +- "geenstijl.nl", +- "moneymakergroup.com", +- "tupaki.com", +- "huvrtech.com", +- "metafilter.com", +- "jumia.com.ng", +- "newsvine.com", +- "mylant.com", +- "accenture.com", +- "feedjit.com", +- "twipple.jp", +- "getgoodlinks.ru", +- "radiofarda.com", +- "informador.com.mx", +- "wisc.edu", +- "windows.net", +- "zamzar.com", +- "nationalpost.com", +- "epnet.com", +- "naaptol.com", +- "x-art.com", +- "ebookbrowsee.net", +- "marketingland.com", +- "thedailyshow.com", +- "s-oman.net", +- "theme-fusion.com", +- "immobiliare.it", +- "allvoices.com", +- "adroll.com", +- "francetvinfo.fr", +- "callandput.com", +- "entireweb.com", +- "instructure.com", +- "megacinema.fr", +- "djelfa.info", +- "flightaware.com", +- "magazineluiza.com.br", +- "ighome.com", +- "mature-beauty.com", +- "yuku.com", +- "peerfly.com", +- "hardware.fr", +- "dcinside.com", +- "telerik.com", +- "pengpeng.com", +- "gazetaexpress.com", +- "publico.es", +- "nwsource.com", +- "oneandone.co.uk", +- "qoo10.sg", +- "aboutus.org", +- "adsupplyads.com", +- "wa.gov", +- "google.co.cr", +- "benchmarkemail.com", +- "valuedealshopper.com", +- "hola.com", +- "mizuhobank.co.jp", +- "zzstream.li", +- "kriesi.at", +- "exist.ru", +- "nvidia.com", +- "giallozafferano.it", +- "jusbrasil.com.br", +- "konga.com", +- "avclub.com", +- "reed.co.uk", +- "advertig.com", +- "ripoffreport.com", +- "gooddrama.net", +- "pornyaz.com", +- "budsgunshop.com", +- "78.cn", +- "livesurf.ru", +- "99114.com", +- "pornorama.com", +- "marksandspencer.com", +- "vmall.com", +- "fatcow.com", +- "mylife.com", +- "irishtimes.com", +- "medicalnewstoday.com", +- "uiuc.edu", +- "groupon.it", +- "washington.edu", +- "addictinggames.com", +- "anonymz.com", +- "kindgirls.com", +- "jne.co.id", +- "guiamais.com.br", +- "lyricsfreak.com", +- "uloz.to", +- "tagesanzeiger.ch", +- "fashionandyou.com", +- "bollywoodhungama.com", +- "nationwide.co.uk", +- "kboing.com.br", +- "python.org", +- "theladbible.com", +- "eurosport.com", +- "webinarjam.com", +- "theme.wordpress.com", +- "myfxbook.com", +- "allwomenstalk.com", +- "ucla.edu", +- "opendns.com", +- "pornbb.org", +- "money.pl", +- "domain.com.au", +- "standaard.be", +- "wanelo.com", +- "express.co.uk", +- "exam8.com", +- "zum.com", +- "amtrak.com", +- "boots.com", +- "800notes.com", +- "fabfurnish.com", +- "amoureux.com", +- "ebizmba.com", +- "ujian.cc", +- "stargames.at", +- "panasonic.com", +- "ge.tt", +- "scout.com", +- "tiexue.net", +- "nanapi.jp", +- "eclipse.org", +- "searchquotes.com", +- "wetplace.com", +- "lpcloudbox300.com", +- "hollyscoop.com", +- "bdjobs.com", +- "larepublica.pe", +- "hizliresim.com", +- "yepme.com", +- "bitcoincharts.com", +- "bsnl.co.in", +- "ucwan87.net", +- "tianji.com", +- "hgtv.com", +- "cleanfiles.net", +- "moonsy.com", +- "tomsguide.com", +- "datpiff.com", +- "net.hr", +- "orange.pl", +- "bankrate.com.cn", +- "mafiashare.net", +- "giaoduc.net.vn", +- "sucuri.net", +- "ringcentral.com", +- "gamingwonderland.com", +- "freenet.de", +- "cian.ru", +- "gayboystube.com", +- "gog.com", +- "gruenderszene.de", +- "econsultancy.com", +- "aktuality.sk", +- "webrankstats.com", +- "j-cast.com", +- "popsugar.com", +- "mr-guangdong.com", +- "on.cc", +- "jb51.net", +- "lamoda.ru", +- "sprashivai.ru", +- "animoto.com", +- "winzip.com", +- "vanityfair.com", +- "svt.se", +- "noyapps.com", +- "mnn.com", +- "lancenet.com.br", +- "e-monsite.com", +- "gazeta.ua", +- "cari.com.my", +- "coub.com", +- "veoh.com", +- "kienthuc.net.vn", +- "eldorado.ru", +- "overclock.net", +- "meetic.fr", +- "tam.com.br", +- "alfemminile.com", +- "telmex.com", +- "newsbomb.gr", +- "funda.nl", +- "netcoc.com", +- "bhinneka.com", +- "layalina.com", +- "clubpenguin.com", +- "talktalk.co.uk", +- "dumpert.nl", +- "almastba.com", +- "clker.com", +- "adweek.com", +- "gigya.com", +- "disponivel.uol.com.br", +- "tomoson.com", +- "w.org", +- "rfi.fr", +- "imgbox.com", +- "omniture.com", +- "n24.de", +- "webdesignrazzi.com", +- "medscape.com", +- "playboy.com", +- "usda.gov", +- "cuevana.tv", +- "trenitalia.com", +- "explosm.net", +- "mail.uol.com.br", +- "delfi.lv", +- "elektroda.pl", +- "hulkshare.com", +- "kotak.com", +- "gi-akademie.ning.com", +- "yelp.de", +- "lrytas.lt", +- "couchsurfing.org", +- "drugstore.com", +- "ssa.gov", +- "seriescoco.com", +- "iran-tejarat.com", +- "hafiz.gov.sa", +- "intellicast.com", +- "sub.jp", +- "paginasamarillas.es", +- "anime44.com", +- "babyschool.com.cn", +- "advertisernets.com", +- "vpsdomain2.eu", +- "arcor.de", +- "video2mp3.net", +- "marthastewart.com", +- "hawahome.com", +- "articlesbase.com", +- "spanishdict.com", +- "meilishuo.com", +- "grammarly.com", +- "sportlemon.tv", +- "zend.com", +- "bigideamastermind.com", +- "hawaaworld.com", +- "pagseguro.uol.com.br", +- "keywordspy.com", +- "7search.com", +- "cnki.net", +- "aamaadmiparty.org", +- "javaplayer.info", +- "sidereel.com", +- "azcentral.com", +- "passportindia.gov.in", +- "memurlar.net", +- "bouyguestelecom.fr", +- "buenastareas.com", +- "ernmoneynow.com", +- "eurosport.ru", +- "blog.163.com", +- "pizzahut.com", +- "bossip.com", +- "webdeveloper.com", +- "add-anime.net", +- "pimptubed.com", +- "movistar.es", +- "megashare.sh", +- "empireavenue.com", +- "btemplates.com", +- "amkspor.com", +- "payza.com", +- "farfesh.com", +- "mcgraw-hill.com", +- "motor-talk.de", +- "purepeople.com", +- "i-gamer.net", +- "sotmarket.ru", +- "anthropologie.com", +- "google.org", +- "rai.tv", +- "wikidot.com", +- "canoe.ca", +- "orange.es", +- "umn.edu", +- "emag.ro", +- "webutations.org", +- "ykb.com", +- "canadapost.ca", +- "zhubajie.com", +- "nextcar.cn", +- "next.co.uk", +- "freemovie-hd.com", +- "telegraf.com.ua", +- "ajc.com", +- "xsrv.jp", +- "vanguard.com", +- "mybroadband.co.za", +- "999120.net", +- "panet.co.il", +- "bellemaison.jp", +- "fonearena.com", +- "playvid.com", +- "purdue.edu", +- "thesuperficial.com", +- "114so.cn", +- "irna.ir", +- "websitetonight.com", +- "edublogs.org", +- "provincial.com", +- "jahaniha.com", +- "heroturko.me", +- "dynadot.com", +- "txtsrving.info", +- "adclickxpress.com", +- "sammobile.com", +- "ebay.at", +- "yaplog.jp", +- "imtranslator.net", +- "fotor.com", +- "myvidster.com", +- "williamhill.it", +- "argaam.com", +- "zoomby.ru", +- "tcsbank.ru", +- "origin.com", +- "vov.vn", +- "wrapbootstrap.com", +- "imvu.com", +- "fbsbx.com", +- "elcorteingles.es", +- "cerdas.com", +- "google.com.om", +- "dramasonline.com", +- "businesswire.com", +- "serpbook.com", +- "santanderrio.com.ar", +- "meta.ua", +- "kenhgioitre.com", +- "watchcartoononline.com", +- "athome.co.jp", +- "2checkout.com", +- "moheet.com", +- "jeu.info", +- "ankieta-online.pl", +- "triberr.com", +- "wordtracker.com", +- "blogher.com", +- "colourlovers.com", +- "maalaimalar.com", +- "bakeca.it", +- "thepostgame.com", +- "beget.ru", +- "abebooks.com", +- "certified-toolbar.com", +- "publico.pt", +- "footmercato.net", +- "indiabix.com", +- "zakzak.co.jp", +- "hotfile.com", +- "virustotal.com", +- "usgs.gov", +- "tukif.com", +- "banglamail24.com", +- "graphicstock.com", +- "svpressa.ru", +- "sanalpazar.com", +- "logsoku.com", +- "loteriasyapuestas.es", +- "youjizzlive.com", +- "all-inkl.com", +- "arcot.com", +- "blogspot.fi", +- "inbox.lv", +- "anno-online.com", +- "tikona.in", +- "newsru.ua", +- "centerblog.net", +- "jahannews.com", +- "joxi.ru", +- "proxybay.eu", +- "2gis.ru", +- "indeed.fr", +- "novayagazeta.ru", +- "intelius.com", +- "hosteurope.de", +- "autoscout24.it", +- "postjoint.com", +- "pulsk.com", +- "biobiochile.cl", +- "homevv.com", +- "zapbux.com", +- "gsp.ro", +- "priyo.com", +- "jamnews.ir", +- "addtoany.com", +- "lookbook.nu", +- "e-travel.com", +- "themelock.com", +- "bestsocialfeed.com", +- "eqla3.com", +- "klm.com", +- "realtor.ca", +- "tv2.no", +- "jqueryrain.com", +- "seo-fast.ru", +- "academic.ru", +- "clicksia.com", +- "lpcloudbox30.com", +- "worldpay.com", +- "gogoanime.com", +- "photoshelter.com", +- "mlive.com", +- "wetteronline.de", +- "jkforum.net", +- "secure.ipage.com", +- "antena3.com", +- "elsevier.com", +- "thaiseoboard.com", +- "addic7ed.com", +- "rookee.ru", +- "jstor.org", +- "rajanews.com", +- "uline.com", +- "o2online.de", +- "fbdownloader.com", +- "wetpaint.com", +- "nnm.me", +- "50onred.com", +- "tvtropes.org", +- "philips.com", +- "watchseries.to", +- "perfectinter.net", +- "progressive.com", +- "stcn.com", +- "golsearch.com", +- "sarayanews.com", +- "screenrant.com", +- "macworld.com", +- "classifiedads.com", +- "ip138.com", +- "izlesene.com", +- "ovguide.com", +- "gametop.com", +- "urlm.co", +- "isitdownrightnow.com", +- "redhat.com", +- "stafaband.info", +- "biglion.ru", +- "twitterfeed.com", +- "ttnet.com.tr", +- "panasonic.jp", +- "loc.gov", +- "telstra.com.au", +- "jiathis.com", +- "perfil.com.ar", +- "inquisitr.com", +- "ratp.fr", +- "libertaddigital.com", +- "bni.co.id", +- "ycombinator.com", +- "paginegialle.it", +- "momoshop.com.tw", +- "theweek.com", +- "tuoitre.vn", +- "scriptmafia.org", +- "megavod.fr", +- "indiavisiontv.com", +- "history.com", +- "flyeralarm.com", +- "salespider.com", +- "ard.de", +- "dslreports.com", +- "tokyo-tube.com", +- "brazzersnetwork.com", +- "bonanza.com", +- "storenvy.com", +- "37signals.com", +- "jxnews.com.cn", +- "1sale.com", +- "allanalpass.com", +- "yiiframework.com", +- "kimsufi.com", +- "nastygal.com", +- "immoral.jp", +- "icq.com", +- "loxblog.com", +- "jcrew.com", +- "diamond.jp", +- "nissen.co.jp", +- "fxstreet.com", +- "15min.lt", +- "lifo.gr", +- "alef.ir", +- "iis.net", +- "giphy.com", +- "mypopup.ir", +- "bsnl.in", +- "distractify.com", +- "foro20.com", +- "chachaba.com", +- "fx-trend.com", +- "imanhua.com", +- "playxn.com", +- "gocomics.com", +- "lcl.fr", +- "hsw.cn", +- "ellislab.com", +- "persiantools.com", +- "coupondunia.in", +- "fengniao.com", +- "coinmill.com", +- "freelancer.in", +- "blogdetik.com", +- "data.com", +- "trafficjunky.net", +- "neverblue.com", +- "flvto.com", +- "lijit.com", +- "zaycev.net", +- "salamnews.org", +- "siliconrus.com", +- "dv37.com", +- "conrad.de", +- "ascii.jp", +- "yesfreeporn.com", +- "globalpost.com", +- "d4000.com", +- "dobreprogramy.pl", +- "hammihan.com", +- "wjunction.com", +- "liverpoolfc.tv", +- "nordea.fi", +- "mail2web.com", +- "songkick.com", +- "comicbookresources.com", +- "jwplayer.com", +- "moi.gov.sa", +- "iranecar.com", +- "kayako.com", +- "listal.com", +- "technet.com", +- "infonews.com", +- "fun698.com", +- "frys.com", +- "vectorstock.com", +- "vbox7.com", +- "leroymerlin.fr", +- "gpotato.eu", +- "gulfnews.com", +- "hot-sex-tube.com", +- "buzzle.com", +- "uludagsozluk.com", +- "onlinefastpaydayloan.com", +- "forumcommunity.net", +- "potins.net", +- "bwin.es", +- "lobstertube.com", +- "katestube.com", +- "endomondo.com", +- "navalny.livejournal.com", +- "wayport.net", +- "dealspl.us", +- "pixhost.org", +- "webopedia.com", +- "flagcounter.com", +- "hotnewhiphop.com", +- "matomy.com", +- "privat24.ua", +- "fuq.com", +- "readserver.net", +- "haiwainet.cn", +- "light-dark.net", +- "decolar.com", +- "tlbb8.com", +- "tomtom.com", +- "fontanka.ru", +- "tchibo.de", +- "slutfinder.com", +- "rbc.cn", +- "pepperfry.com", +- "freshersworld.com", +- "mob.org", +- "brobible.com", +- "phim3s.net", +- "parsiblog.com", +- "link-assistant.com", +- "smotri.com", +- "flyertalk.com", +- "iefimerida.gr", +- "pornyeah.com", +- "trustpilot.com", +- "wowslider.com", +- "sekindo.com", +- "shape.com", +- "pizap.com", +- "bluedart.com", +- "cmu.edu", +- "shueisha.co.jp", +- "royal-search.com", +- "123greetings.com", +- "albawabhnews.com", +- "holiday-weather.com", +- "4travel.jp", +- "lpcloudsvr203.com", +- "panorama.com.ve", +- "htcmania.com", +- "skorer.tv", +- "mymovies.it", +- "fileice.net", +- "1and1.fr", +- "legiaodosherois.com.br", +- "tomsguide.fr", +- "baymirror.com", +- "thesun.co.uk", +- "huffingtonpost.es", +- "61baobao.com", +- "juegos.com", +- "joyclub.de", +- "qatarairways.com", +- "ayosdito.ph", +- "translate.ru", +- "yithemes.com", +- "buyvip.com", +- "pearltrees.com", +- "thinkprogress.org", +- "twitcasting.tv", +- "lusongsong.com", +- "irecommend.ru", +- "aukro.ua", +- "eldiario.es", +- "pop-music.ir", +- "libertytimes.com.tw", +- "themalaysianinsider.com", +- "paddypower.it", +- "delfi.ee", +- "appthemes.com", +- "tdameritrade.com", +- "flashback.org", +- "tubelib.com", +- "claro.com.br", +- "jotform.com", +- "bigresource.com", +- "libsyn.com", +- "sendgrid.com", +- "silikonvadisi.tv", +- "geo.tv", +- "pricegrabber.com", +- "futhead.com", +- "testberichte.de", +- "skybet.com", +- "wpcentral.com", +- "lesnumeriques.com", +- "clientoo.com", +- "mathsisfun.com", +- "expert.ru", +- "maxptp.com", +- "mediaite.com", +- "regions.com", +- "fast-torrent.ru", +- "enlacespepito.com", +- "redtram.com", +- "benesse.ne.jp", +- "jappy.de", +- "wizzair.com", +- "adevarul.ro", +- "mhlw.go.jp", +- "dev-point.com", +- "ibtimes.co.in", +- "coinwarz.com", +- "slidesharecdn.com", +- "classmates.com", +- "tsite.jp", +- "niazerooz.com", +- "jma.go.jp", +- "motherjones.com", +- "easports.com", +- "elbotola.com", +- "tripadvisor.com.au", +- "rozee.pk", +- "vivanuncios.com.mx", +- "lashou.com", +- "theaustralian.com.au", +- "superstarmagazine.com", +- "zedge.net", +- "hardwarezone.com.sg", +- "yyets.com", +- "nowgamez.com", +- "blogspot.ch", +- "gq.com", +- "adidas.com", +- "uyan.cc", +- "dailydot.com", +- "xenforo.com", +- "ilmessaggero.it", +- "state.nj.us", +- "16888.com", +- "searchengines.guru", +- "nascar.com", +- "dnb.no", +- "smosh.com", +- "shinyinnovation.com", +- "who.int", +- "mybet.com", +- "yoo7.com", +- "xrea.com", +- "fotolog.net", +- "smartprix.com", +- "esquire.com", +- "google.com.cy", +- "santander.com.br", +- "realclearpolitics.com", +- "financereports24.com", +- "onlinesoccermanager.com", +- "noticiaaldia.com", +- "kelkoo.com", +- "drakulastream.eu", +- "vodafone.de", +- "bt.dk", +- "greenwichmeantime.com", +- "ufc.com", +- "webstatsdomain.org", +- "taoche.com", +- "thinkgeek.com", +- "caranddriver.com", +- "123-reg.co.uk", +- "translit.ru", +- "w3school.com.cn", +- "zwinky.com", +- "inboxdollars.com", +- "gratka.pl", +- "vecernji.hr", +- "taikang.com", +- "bolshoyvopros.ru", +- "urbita.com", +- "api.ning.com", +- "alltop.com", +- "readwrite.com", +- "medhelp.org", +- "totaljobs.com", +- "accorhotels.com", +- "prom.ua", +- "cuny.edu", +- "livemint.com", +- "berlin.de", +- "blogspot.hk", +- "orkut.com.br", +- "lzjl.com", +- "metric-conversions.org", +- "nationalrail.co.uk", +- "oxu.az", +- "mql5.com", +- "chinaluxus.com", +- "linguee.es", +- "saudiairlines.com", +- "standardmedia.co.ke", +- "alkislarlayasiyorum.com", +- "apk.tw", +- "lesoir.be", +- "whatculture.com", +- "indiewire.com", +- "pccomponentes.com", +- "paytm.in", +- "ebaypartnernetwork.com", +- "haivl.tv", +- "e-junkie.com", +- "tvp.pl", +- "ifilez.org", +- "aristeguinoticias.com", +- "bangkokpost.com", +- "whatmobile.com.pk", +- "prodavalnik.com", +- "arsenal.com", +- "buyma.com", +- "torrentday.com", +- "sammydress.com", +- "blogcu.com", +- "imore.com", +- "shitaraba.com", +- "pasadrexam2014.in", +- "songspk.at", +- "eforosh.com", +- "nocoty.pl", +- "koreus.com", +- "verticalresponse.com", +- "arte.tv", +- "ocnk.net", +- "cryptsy.com", +- "haaretz.com", +- "straitstimes.com", +- "2domains.ru", +- "usnetads.com", +- "pracuj.pl", +- "edreams.it", +- "sba.gov", +- "instabang.com", +- "domainnamesales.com", +- "teensnow.com", +- "visualwebsiteoptimizer.com", +- "blogos.com", +- "santander.com.mx", +- "solidfiles.com", +- "authorstream.com", +- "teslamotors.com", +- "tema.livejournal.com", +- "kolesa.kz", +- "startribune.com", +- "vevo.com", +- "clien.net", +- "3asq.com", +- "tvnet.lv", +- "mouthshut.com", +- "binary-machine.com", +- "adultwork.com", +- "hypebeast.com", +- "itrack.it", +- "network-tools.com", +- "brandsoftheworld.com", +- "comedycentral.com", +- "hotscripts.com", +- "meristation.com", +- "rlsbb.com", +- "uzai.com", +- "volkskrant.nl", +- "terra.com.mx", +- "howtoforge.com", +- "178.com", +- "wickedfire.com", +- "dilandau.eu", +- "seriales.us", +- "xataka.com", +- "hktdc.com", +- "express.pk", +- "surfcanyon.com", +- "buildhr.com", +- "ouest-france.fr", +- "stltoday.com", +- "alternet.org", +- "site5.com", +- "payserve.com", +- "society6.com", +- "douguo.com", +- "prosieben.de", +- "verywed.com", +- "enikos.gr", +- "tubewolf.com", +- "openrice.com", +- "blankrefer.com", +- "gouv.qc.ca", +- "torrentfreak.com", +- "craveonline.com", +- "unfollowers.com", +- "deser.pl", +- "quanjing.com", +- "runetki.tv", +- "yepi.com", +- "socialbakers.com", +- "webmotors.com.br", +- "mmo-champion.com", +- "globososo.com", +- "whois.sc", +- "sportskeeda.com", +- "socialblade.com", +- "jin115.com", +- "avjavjav.com", +- "thenewstribe.com", +- "pinkrod.com", +- "blox.pl", +- "mediamarkt.de", +- "vivo.com.br", +- "facilisimo.com", +- "sinarharian.com.my", +- "leguide.com", +- "voegol.com.br", +- "j.gs", +- "okgj.com", +- "revolveclothing.com", +- "lolinez.com", +- "go2cloud.org", +- "vmoptions.com", +- "myip.ms", +- "ay.gy", +- "liquidweb.com", +- "sbi.co.in", +- "alamaula.com", +- "reshareable.tv", +- "stirileprotv.ro", +- "siriusxm.com", +- "banvenez.com", +- "sergey-mavrodi-mmm.net", +- "ocj.com.cn", +- "elderscrollsonline.com", +- "webaslan.com", +- "dereferer.org", +- "newsbeast.gr", +- "778669.com", +- "yeucahat.com", +- "guitarcenter.com", +- "mercurynews.com", +- "channeladvisor.com", +- "go2000.com", +- "google.ge", +- "pandora.tv", +- "haqqin.az", +- "google.tt", +- "32d1d3b9c.se", +- "sexdatenow.net", +- "befunky.com", +- "micromaxinfo.com", +- "jquerymobile.com", +- "radikal.ru", +- "wigetmedia.com", +- "girlsplay.com", +- "pureleverage.com", +- "mathxl.com", +- "themefuse.com", +- "giga.de", +- "freevideo.cz", +- "stylebistro.com", +- "iwriter.com", +- "winporn.com", +- "tripadvisor.ca", +- "atresplayer.com", +- "igma.tv", +- "ravelry.com", +- "semana.com", +- "verycd.com", +- "sblo.jp", +- "fansided.com", +- "goalunited.org", +- "petfinder.com", +- "worthofweb.com", +- "memuruz.net", +- "njuskalo.hr", +- "yellowpages.ca", +- "91jm.com", +- "webconfs.com", +- "interpals.net", +- "erepublik.com", +- "akismet.com", +- "gaadi.com", +- "casasbahia.com.br", +- "techsupportalert.com", +- "bostonglobe.com", +- "uploadable.ch", +- "smartprofitsystem.com", +- "cimbclicks.com.my", +- "uwants.com", +- "gamestar.de", +- "neowin.net", +- "inilah.com", +- "toster.ru", +- "gosuslugi.ru", +- "windguru.cz", +- "3366.com", +- "beinsports.net", +- "vector.co.jp", +- "memecenter.com", +- "hotnews.ro", +- "webgame.web.id", +- "llnw.com", +- "jobstreet.co.id", +- "congratulations-you-won.com", +- "libertatea.ro", +- "app111.com", +- "scientificamerican.com", +- "strava.com", +- "iranjib.ir", +- "coneco.net", +- "fdrmx.com", +- "nps.gov", +- "businessinsider.in", +- "uniblue.com", +- "proporn.com", +- "dm5.com", +- "qld.gov.au", +- "nexusmods.com", +- "mandatory.com", +- "moskva.fm", +- "prosperityteam.com", +- "lent.az", +- "appbrain.com", +- "24smi.org", +- "avaxsearch.com", +- "gorillavid.in", +- "realgm.com", +- "favicon.cc", +- "astro.com", +- "joomlaforum.ru", +- "joystiq.com", +- "computerworld.com", +- "tvspielfilm.de", +- "centos.org", +- "bugun.com.tr", +- "amctv.com", +- "relianceada.com", +- "papystreaming.com", +- "clickindia.com", +- "sayyac.com", +- "q.gs", +- "bravoerotica.com", +- "bibsonomy.org", +- "netload.in", +- "shopatron.com", +- "iautos.cn", +- "banggood.com", +- "commerzbanking.de", +- "legacyclix.com", +- "intesasanpaolo.com", +- "awesomescreenshot.com", +- "desidime.com", +- "eporner.com", +- "alwatanvoice.com", +- "ok.ru", +- "europe1.fr", +- "karnaval.com", +- "tornn-tv.com", +- "frmtr.com", +- "pulscen.ru", +- "groupon.co.uk", +- "tradera.com", +- "comingsoon.net", +- "speckyboy.com", +- "cargurus.com", +- "citysearch.com", +- "brother.com", +- "acfun.tv", +- "jamejamonline.ir", +- "enterprise.com", +- "elotrolado.net", +- "userscripts.org", +- "confirmit.com", +- "compete.com", +- "auctiva.com", +- "potterybarn.com", +- "ivoox.com", +- "multiupload.nl", +- "glavnoe.ua", +- "p30world.com", +- "snapnames.com", +- "filmon.com", +- "flipkey.com", +- "rhhbschool.com", +- "worldbank.org", +- "proz.com", +- "docusign.net", +- "akakce.com", +- "empflix.com", +- "androidforums.com", +- "mos.ru", +- "contenko.com", +- "malwarebytes.org", +- "voyeurhit.com", +- "filmvz.com", +- "windowsazure.com", +- "rlslog.net", +- "zulagames.com", +- "onlinefinder.net", +- "blekko.com", +- "tvb.com", +- "mojomarketplace.com", +- "warnerbros.com", +- "rogers.com", +- "sparkasse.at", +- "bigcinema.tv", +- "mattcutts.com", +- "vemale.com", +- "pgatour.com", +- "bakusai.com", +- "lavozdegalicia.es", +- "style.com", +- "torrentino.com", +- "activeden.net", +- "sweetpacks-search.com", +- "pcstore.com.tw", +- "starmedia.com", +- "lycos.com", +- "uncomo.com", +- "caribbeancom.com", +- "googleping.com", +- "sondakika.com", +- "premiumwp.com", +- "tribune.com.pk", +- "sc.com", +- "91mobiles.com", +- "elle.com", +- "motortrend.com", +- "starsports.com", +- "otlan.com", +- "planetminecraft.com", +- "oregonlive.com", +- "publichd.se", +- "financialexpress.com", +- "huxiu.com", +- "hotwords.com", +- "asda.com", +- "impiego24.it", +- "tunisia-sat.com", +- "xojane.com", +- "shiftdelete.net", +- "hamshahrionline.ir", +- "mp3.es", +- "minutebuzz.com", +- "footlocker.com", +- "rusnovosti.ru", +- "defencenet.gr", +- "ndr.de", +- "blogosfera.uol.com.br", +- "quibids.com", +- "soft32.com", +- "davidwalsh.name", +- "blogun.ru", +- "webbirga.net", +- "dict.cn", +- "groupon.jp", +- "abovetopsecret.com", +- "contra.gr", +- "zn.ua", +- "jetbrains.com", +- "myus.com", +- "redbus.in", +- "creativemarket.com", +- "uainfo.org", +- "rtbf.be", +- "forexpf.ru", +- "mainlink.ru", +- "fantasti.cc", +- "usagc.org", +- "narutoget.com", +- "trendyol.com", +- "carsales.com.au", +- "fujitv.co.jp", +- "dardarkom.com", +- "corrieredellosport.it", +- "mcanime.net", +- "nolo.com", +- "beareyes.com.cn", +- "familysearch.org", +- "eprice.com.tw", +- "indonetwork.co.id", +- "geizhals.at", +- "watchfreemovies.ch", +- "siweiw.com", +- "elnuevoherald.com", +- "codecupdaters.com", +- "p1.com", +- "imhonet.ru", +- "spox.com", +- "spreadshirt.com", +- "bittorrent.com", +- "airberlin.com", +- "epicurious.com", +- "adverstitial.com", +- "researchnow.com", +- "lolnexus.com", +- "xbabe.com", +- "designmodo.com", +- "hamusoku.com", +- "radioshack.com", +- "teamliquid.net", +- "helpster.de", +- "globalsources.com", +- "fasttech.com", +- "dickssportinggoods.com", +- "j-sen.jp", +- "smashwords.com", +- "adversal.com", +- "musiciansfriend.com", +- "whoishostingthis.com", +- "ads8.com", +- "trend4pay.com", +- "tribune.com", +- "xsrving.com", +- "youngleafs.com", +- "gamersky.com", +- "podio.com", +- "state.pa.us", +- "iphoneogram.com", +- "datehookup.com", +- "hbs.edu", +- "ally.com", +- "mitbbs.com", +- "siasat.pk", +- "miratuserie.tv", +- "active.com", +- "ricardoeletro.com.br", +- "html.it", +- "minnano-av.com", +- "meetly.in", +- "denverpost.com", +- "supersport.com", +- "grupobancolombia.com", +- "freemake.com", +- "bankier.pl", +- "instapaper.com", +- "derwesten.de", +- "blogspot.hu", +- "tamindir.com", +- "play.pl", +- "warthunder.com", +- "team-bhp.com", +- "freepeople.com", +- "laposte.fr", +- "cnews.ru", +- "fayerwayer.com", +- "hitta.se", +- "hao123.com.eg", +- "it-ebooks.info", +- "freep.com", +- "newser.com", +- "lexilogos.com", +- "polldaddy.com", +- "auspost.com.au", +- "aib.ie", +- "cs.com.cn", +- "providesupport.com", +- "unblocksit.es", +- "twittercounter.com", +- "luisaviaroma.com", +- "imgbabes.com", +- "tharunee.lk", +- "nexon.com", +- "airliners.net", +- "srf.ch", +- "angel.co", +- "tokyo-sports.co.jp", +- "mt5.com", +- "down1oads.com", +- "vodonet.net", +- "axar.az", +- "taknaz.ir", +- "google.com.py", +- "ss.lv", +- "stuffgate.com", +- "giveawayoftheday.com", +- "climatempo.com.br", +- "xnxxmovies.com", +- "heartinternet.co.uk", +- "digikey.com", +- "zimbra.free.fr", +- "line.me", +- "talkingpointsmemo.com", +- "dyn.com", +- "exacttarget.com", +- "yourtango.com", +- "shopping.com", +- "king.com", +- "crackberry.com", +- "sm3na.com", +- "matchesfashion.com", +- "rk.com", +- "ems.com.cn", +- "xiaomi.cn", +- "hillnews.com", +- "geforce.com", +- "internetslang.com", +- "theoldreader.com", +- "digitaljournal.com", +- "aol.co.uk", +- "straightdope.com", +- "farfetch.com", +- "lupoporno.com", +- "ilgiornale.it", +- "binzhi.com", +- "loveplanet.ru", +- "sogi.com.tw", +- "googlevideo.com", +- "nintendo.com", +- "jreast.co.jp", +- "coinad.com", +- "keek.com", +- "chegg.com", +- "sparknotes.com", +- "mywapblog.com", +- "idlebrain.com", +- "boardgamegeek.com", +- "daserste.de", +- "nicozon.net", +- "ampnetzwerk.de", +- "agenziaentrate.gov.it", +- "apec.fr", +- "redbull.com", +- "listentoyoutube.com", +- "diepresse.com", +- "gohappy.com.tw", +- "morguefile.com", +- "dallasnews.com", +- "adxpansion.com", +- "almos3a.com", +- "updatetube.com", +- "lowyat.net", +- "lolipop.jp", +- "terafile.co", +- "eversave.com", +- "sportingnews.com", +- "517dv.com", +- "milfmovs.com", +- "myflorida.com", +- "brooonzyah.net", +- "cdn-cachefront.net", +- "ig.com", +- "indiapost.gov.in", +- "hangame.co.jp", +- "ithemes.com", +- "monova.org", +- "udmserve.net", +- "impactradius.com", +- "teasernet.com", +- "gmx.at", +- "mmotraffic.com", +- "citehr.com", +- "viator.com", +- "rt.ru", +- "japannetbank.co.jp", +- "zonealarm.com", +- "ebayclassifieds.com", +- "safecart.com", +- "proptp.net", +- "51hejia.com", +- "telkomsel.com", +- "deutschepost.de", +- "startpagina.nl", +- "alexaboostup.com", +- "istgah.com", +- "aufreeads.com", +- "thinkstockphotos.com", +- "similarsitesearch.com", +- "gossiplankanews.com", +- "venere.com", +- "javascriptkit.com", +- "square-enix.com", +- "tvtoday.de", +- "netaffiliation.com", +- "computrabajo.com.mx", +- "arioo.com", +- "fromdoctopdf.com", +- "lookany.com", +- "bleepingcomputer.com", +- "perfectmoney.com", +- "dorkly.com", +- "macmillandictionary.com", +- "fotka.pl", +- "porntubevidz.com", +- "rj.gov.br", +- "1.1.1.1", +- "ebay.be", +- "divxplanet.com", +- "cyworld.com", +- "biography.com", +- "p1.cn", +- "bazos.sk", +- "55.la", +- "lockerdome.com", +- "yola.com", +- "ccbill.com", +- "groupon.de", +- "okazii.ro", +- "izismile.com", +- "velvet.hu", +- "news-postseven.com", +- "ardmediathek.de", +- "sagawa-exp.co.jp", +- "sarzamindownload.com", +- "pdfonline.com", +- "gaaks.com", +- "azhibo.com", +- "pensador.uol.com.br", +- "surveygizmo.com", +- "familydoctor.com.cn", +- "lazada.vn", +- "guokr.com", +- "enjoydressup.com", +- "sky.de", +- "afp.com", +- "imujer.com", +- "livescore.net", +- "xinnet.com", +- "mypageresults.com", +- "safaribooksonline.com", +- "extremetech.com", +- "ecnavi.jp", +- "babyblog.ru", +- "practicalecommerce.com", +- "vidspot.net", +- "studymode.com", +- "nation.co.ke", +- "cpmrocket.com", +- "es.wix.com", +- "google.com.cu", +- "pravda.ru", +- "cda.pl", +- "appszoom.com", +- "selfhtml.org", +- "zmovie.tw", +- "dba.dk", +- "domain.com", +- "brightcove.com", +- "lol55.com", +- "textsale.ru", +- "casualclub.com", +- "gudvin.tv", +- "torrentreactor.net", +- "downloadcamp.com", +- "eset.com", +- "softonic.it", +- "internations.org", +- "retre.org", +- "3quan.com", +- "companieshouse.gov.uk", +- "hautelook.com", +- "edx.org", +- "ono.es", +- "jango.com", +- "7sur7.be", +- "spinrewriter.com", +- "hqxnxx.com", +- "elperiodico.com", +- "arabiaweather.com", +- "liansuo.com", +- "pcgamer.com", +- "offervault.com", +- "mytheresa.com", +- "memegenerator.net", +- "gsm.ir", +- "britannica.com", +- "mensfitness.com", +- "flaticon.com", +- "newrelic.com", +- "greatmmos.com", +- "ifixit.com", +- "aiyellow.com", +- "my.tv.sohu.com/user/card", +- "ce4arab.com", +- "news-us.jp", +- "slando.kz", +- "redflagdeals.com", +- "gsmhosting.com", +- "raiffeisen.at", +- "tagesspiegel.de", +- "epravda.com.ua", +- "bell.ca", +- "sleazyneasy.com", +- "dhnet.be", +- "webcars.com.cn", +- "freepik.es", +- "androidpolice.com", +- "cbr.ru", +- "thanhnien.com.vn", +- "shoptime.com.br", +- "dailytelegraph.com.au", +- "fastcodesign.com", +- "full-stream.net", +- "google.al", +- "creativecow.net", +- "centrum24.pl", +- "openstat.ru", +- "unfollowed.me", +- "brb.to", +- "babal.net", +- "ibotoolbox.com", +- "torrentdownloads.me", +- "miami.com", +- "mubasher.info", +- "patient.co.uk", +- "ayudawordpress.com", +- "makepolo.com", +- "exactseek.com", +- "echosign.com", +- "epson.com", +- "somo.vn", +- "tripadvisor.jp", +- "bikroy.com", +- "postimees.ee", +- "band.uol.com.br", +- "adopteunmec.com", +- "imgserve.net", +- "toofab.com", +- "neeu.com", +- "mailjet.com", +- "kinja.com", +- "qwertypay.com", +- "cosme.net", +- "dreammovies.com", +- "avvo.com", +- "wenyard.com", +- "dir.bg", +- "digital-photography-school.com", +- "peru.com", +- "thomsonreuters.com", +- "grazia.com.cn", +- "vivastreet.co.in", +- "officemax.com", +- "creditmutuel.fr", +- "themify.me", +- "ait-themes.com", +- "share-links.biz", +- "graphixshare.com", +- "theoutnet.com", +- "revolvermaps.com", +- "careers360.com", +- "tyroodr.com", +- "escapistmagazine.com", +- "ofreegames.com", +- "surveryewadcentrez.eu", +- "notebookcheck.net", +- "k2s.cc", +- "barstoolsports.com", +- "townhall.com", +- "mk.co.kr", +- "epochtimes.com", +- "arduino.cc", +- "blogcms.jp", +- "udacity.com", +- "habervaktim.com", +- "funweek.it", +- "techtunes.com.bd", +- "shopzilla.com", +- "sun-sentinel.com", +- "tfile.me", +- "novafile.com", +- "eurogamer.net", +- "thenewporn.com", +- "tuttosport.com", +- "sverve.com", +- "simplemachines.org", +- "nginx.org", +- "kepu.com.cn", +- "jxedt.com", +- "southparkstudios.com", +- "gusuwang.com", +- "utrace.de", +- "peperonity.de", +- "hvg.hu", +- "cairodar.com", +- "mappy.com", +- "kouclo.com", +- "my.tv.sohu.com/user/lucky", +- "lushstories.com", +- "stocktwits.com", +- "atlantico.fr", +- "baihe.com", +- "wowkeren.com", +- "v7n.com", +- "mozilla.com", +- "centurylink.net", +- "1001freefonts.com", +- "pubdirecte.com", +- "mercadolibre.com.pe", +- "vandelaydesign.com", +- "cpaelites.com", +- "wanyh.com", +- "propertyguru.com.sg", +- "esy.es", +- "torrentbutler.eu", +- "final.ir", +- "53.com", +- "clips4sale.com", +- "freerepublic.com", +- "huffingtonpost.de", +- "boards.ie", +- "fluege.de", +- "parents.com", +- "gimp.org", +- "adorocinema.com", +- "yelp.ca", +- "twicsy.com", +- "kuaibo.com", +- "gnu.org", +- "parsine.com", +- "jpc.com", +- "cloudapp.net", +- "expatriates.com", +- "sproutsocial.com", +- "natemat.pl", +- "livingrichwithcoupons.com", +- "x-ho.com", +- "adv-adserver.com", +- "downloadchop.com", +- "sagepub.com", +- "eleconomista.com.mx", +- "formula1.com", +- "quackit.com", +- "dlsite.com", +- "powned.tv", +- "stream-tv.me", +- "mindbodyonline.com", +- "mindmeister.com", +- "twitlonger.com", +- "ebay.ie", +- "deccanchronicle.com", +- "domaintuno.com", +- "thethirdmedia.com", +- "laiguana.tv", +- "flurry.com", +- "eloqua.com", +- "createsend.com", +- "hrloo.com", +- "interfax.com.ua", +- "admin.ch", +- "zgzcw.com", +- "bancoestado.cl", +- "fda.gov", +- "chinayes.com", +- "beslist.nl", +- "crossfit.com", +- "skai.gr", +- "covers.com", +- "antpoker.com", +- "perfectworld.com", +- "momdot.com", +- "1c-bitrix.ru", +- "feiren.com", +- "navitime.co.jp", +- "siliconindia.com", +- "warning.or.kr", +- "qatarliving.com", +- "uber.com", +- "ing-diba.de", +- "boldsky.com", +- "animeid.tv", +- "tom.com", +- "whatsmyserp.com", +- "ftbpro.com", +- "yobt.tv", +- "toluna.com", +- "burrp.com", +- "viber.com", +- "df.eu", +- "vatera.hu", +- "songmeanings.com", +- "smbc-card.com", +- "hip2save.com", +- "wmzona.com", +- "banamex.com", +- "chinaacc.com", +- "t-online.hu", +- "indianpornvideos.com", +- "runescape.com", +- "wapka.mobi", +- "115.com", +- "blogspot.no", +- "aksam.com.tr", +- "bankcomm.com", +- "giantbomb.com", +- "maxcdn.com", +- "topshop.com", +- "livescores.com", +- "rosbalt.ru", +- "gandi.net", +- "ioffer.com", +- "mihandownload.com", +- "eweb4.com", +- "britishcouncil.org", +- "cheetahmail.com", +- "vbulletin.com", +- "bradsdeals.com", +- "empowernetwork.com/commissionloophole", +- "vueling.com", +- "raventools.com", +- "yext.com", +- "everychina.com", +- "reduxmediia.com", +- "openstreetmap.org", +- "wed114.cn", +- "dzwww.com", +- "miibeian.gov.cn", +- "ufl.edu", +- "deseretnews.com", +- "presstv.ir", +- "copy.com", +- "fourhourworkweek.com", +- "buzztheme.net", +- "bollywoodlife.com", +- "redtubelive.com", +- "pengyou.com", +- "antaranews.com", +- "selectornews.com", +- "lavoz.com.ar", +- "avm.de", +- "flalottery.com", +- "jmp9.com", +- "baltimoresun.com", +- "mozillazine.org", +- "dnevnik.hr", +- "aebn.net", +- "mightydeals.com", +- "livescore.eu", +- "publipt.com", +- "xbmc.org", +- "scmp.com", +- "sbobet.com", +- "alpari.ru", +- "harborfreight.com", +- "linio.com.pe", +- "2500sz.com", +- "rdio.com", +- "bearshare.com", +- "thetrainline.com", +- "888poker.es", +- "filecrop.com", +- "twiends.com", +- "elnuevodia.com", +- "rasekhoon.net", +- "36.cn", +- "axeso5.com", +- "mzamin.com", +- "webmastersitesi.com", +- "thinkdigit.com", +- "lifescript.com", +- "experian.com", +- "adorama.com", +- "d1net.com", +- "torrentz.pro", +- "fullhdfilmizle.org", +- "space.com", +- "collider.com", +- "zalando.it", +- "slate.fr", +- "carmax.com", +- "recode.net", +- "gfan.com", +- "fonts.com", +- "honda.com", +- "ecwid.com", +- "debate.com.mx", +- "bmail.uol.com.br", +- "santandernet.com.br", +- "coderanch.com", +- "lyricsmode.com", +- "gametrailers.com", +- "3600.com", +- "designboom.com", +- "131.com", +- "finam.ru", +- "df.gob.mx", +- "85dcf732d593.se", +- "coches.net", +- "dhs.gov", +- "neurs.com", +- "poppen.de", +- "public-api.wordpress.com", +- "magnovideo.com", +- "squareup.com", +- "balagana.net", +- "goodsearch.com", +- "blog.ir", +- "ne10.uol.com.br", +- "di.se", +- "sinembargo.mx", +- "k618.cn", +- "eventim.de", +- "mysavings.com", +- "futureshop.ca", +- "spinding.com", +- "landsend.com", +- "oqenadserving.com", +- "here.com", +- "upi.com", +- "picresize.com", +- "abnamro.nl", +- "filenuke.com", +- "yxku.com", +- "mypearson.com", +- "dinakaran.com", +- "correos.es", +- "hotchatdirect.com", +- "markafoni.com", +- "gofuckbiz.com", +- "webfindpage.com", +- "cancan.ro", +- "hostgator.in", +- "latribune.fr", +- "adxite.com", +- "mofos.com", +- "bluewin.ch", +- "24ur.com", +- "dion.ne.jp", +- "vpsdomain3.eu", +- "newsweek.com", +- "oasgames.com", +- "mtv3.fi", +- "internetworld.de", +- "yatedo.com", +- "globaltimes.cn", +- "paddypower.com", +- "berlin1.de", +- "norwegian.com", +- "opteck.com", +- "zenfolio.com", +- "kakprosto.ru", +- "ecosia.org", +- "check24.de", +- "idbibank.co.in", +- "zoomit.ir", +- "notebooksbilliger.de", +- "torontosun.com", +- "egopay.com", +- "cnnexpansion.com", +- "emoneyspace.com", +- "rsport.ru", +- "fok.nl", +- "mql4.com", +- "inhabitat.com", +- "tqn.com", +- "noticierodigital.com", +- "wrike.com", +- "bazos.cz", +- "phonegap.com", +- "microlancer.com", +- "anipo.jp", +- "fotocommunity.de", +- "kuwo.cn", +- "chinacaipu.com", +- "terra.cl", +- "500px.org", +- "qantas.com.au", +- "advertising.com", +- "push2check.net", +- "livefyre.com", +- "philstar.com", +- "erail.in", +- "mywebgrocer.com", +- "der-postillon.com", +- "ru-board.com", +- "saramin.co.kr", +- "yjbys.com", +- "aaa.com", +- "flavorwire.com", +- "fcbarcelona.com", +- "lacentrale.fr", +- "googlegroups.com", +- "luck4.me", +- "catho.com.br", +- "centauro.com.br", +- "sia.az", +- "forumactif.com", +- "paltalk.com", +- "beyond.com", +- "occ.com.mx", +- "stamps.com", +- "getoffmyinternets.net", +- "mbok.jp", +- "cleveland.com", +- "ucdavis.edu", +- "tielabs.com", +- "hkgolden.com", +- "vandal.net", +- "lyst.com", +- "mrskin.com", +- "bunshun.jp", +- "netcarshow.com", +- "b1.org", +- "hromadske.tv", +- "sf-express.com", +- "pirateproxy.ca", +- "getcashforsurveys.com", +- "clikz4freakz.com", +- "adsupply.com", +- "truste.org", +- "boxuu.com", +- "webartex.ru", +- "usc.edu", +- "moo.com", +- "winkal.com", +- "deloitte.com", +- "xvideos-field5.com", +- "suomi24.fi", +- "flexmls.com", +- "weeklystandard.com", +- "debenhams.com", +- "mejortorrent.com", +- "vconnect.com", +- "ligatus.com", +- "skynewsarabia.com", +- "herschina.com", +- "92lux.cn", +- "care.com", +- "chip.com.tr", +- "tangdou.com", +- "vatanbilgisayar.com", +- "uppit.com", +- "metronews.fr", +- "parenting.com.tw", +- "meteo.gr", +- "meetgee.com", +- "ldlc.com", +- "ubs.com", +- "elcolombiano.com", +- "mafengwo.cn", +- "moodle.org", +- "asiaone.com", +- "huffingtonpost.it", +- "ipas2free.com", +- "casa.it", +- "kaiserpermanente.org", +- "listindiario.com", +- "treehugger.com", +- "payeer.com", +- "mypoints.com", +- "pjmedia.com", +- "foreca.com", +- "luxup.ru", +- "halifax.co.uk", +- "webinarjam.net", +- "webmeup.com", +- "webdesignledger.com", +- "rte.ie", +- "18andabused.com", +- "vbulletin.org", +- "apne.tv", +- "immoweb.be", +- "colonelcassad.livejournal.com", +- "atlassian.com", +- "investors.com", +- "globalbux.net", +- "wechat.com", +- "kanoon.ir", +- "mawaly.com", +- "self.com", +- "drive.ru", +- "autozone.com", +- "creditonebank.com", +- "fdj.fr", +- "hsbc.com.br", +- "desk.com", +- "dlvr.it", +- "wpml.org", +- "newmobilelife.com", +- "crosswalk.com", +- "thehun.com", +- "hobbyking.com", +- "tiantian.com", +- "hichina.com", +- "cyanogenmod.org", +- "horoscope.com", +- "bizsugar.com", +- "popularmechanics.com", +- "egaliteetreconciliation.fr", +- "eol.cn", +- "rzd.ru", +- "escalatenetwork.net", +- "yad2.co.il", +- "cna.com.tw", +- "zi-m.com", +- "leonardo.it", +- "ap.gov.in", +- "rakuten.de", +- "wallsave.com", +- "netzwelt.de", +- "bitrix24.ru", +- "techinasia.com", +- "bitstamp.net", +- "hostelbookers.com", +- "shoplocal.com", +- "200please.com", +- "tune-up.com", +- "mapy.cz", +- "dealnews.com", +- "livescore.co.uk", +- "seocentro.com", +- "rstyle.me", +- "neoseeker.com", +- "kaban.tv", +- "visualstudio.com", +- "cinetux.org", +- "groupon.com.br", +- "lastpass.com", +- "rincondelvago.com", +- "popsci.com", +- "2144.cn", +- "clickfair.com", +- "dsebd.org", +- "banesco.com", +- "spi0n.com", +- "blogspot.cz", +- "tnews.ir", +- "nme.com", +- "paperblog.com", +- "firstcry.com", +- "tophotels.ru", +- "liepin.com", +- "korabia.com", +- "ifttt.com", +- "aemet.es", +- "alot.com", +- "manutd.com", +- "edreams.es", +- "turkcell.com.tr", +- "eva.vn", +- "techpowerup.com", +- "vkrugudruzei.ru", +- "feed2all.eu", +- "thehindubusinessline.com", +- "express.de", +- "ixquick.com", +- "thrillist.com", +- "iqilu.com", +- "seriouseats.com", +- "edgesuite.net", +- "telexads.com", +- "alza.cz", +- "en-japan.com", +- "al.com", +- "dota2lounge.com", +- "totalping.com", +- "seocheki.net", +- "iceporn.com", +- "col3negoriginel.lk", +- "porsyar.com", +- "property24.com", +- "madamenoire.com", +- "markethealth.com", +- "alphacoders.com", +- "webempresa.com", +- "empireonline.com", +- "downforeveryoneorjustme.com", +- "lankadeepa.lk", +- "darty.com", +- "census.gov", +- "wapka.me", +- "kdslife.com", +- "jpost.com", +- "cricfree.tv", +- "7xxxtube.com", +- "businesscatalyst.com", +- "dilbert.com", +- "gaymaletube.com", +- "bellanaija.com", +- "renfe.es", +- "equifax.com", +- "pornmaki.com", +- "lolesports.com", +- "yunfan.com", +- "everybitcity.com", +- "9yao.com", +- "avantlink.com", +- "paginebianche.it", +- "xrosview.com", +- "newsday.com", +- "usportnews.com", +- "petapixel.com", +- "pistonheads.com", +- "lidovky.cz", +- "cvent.com", +- "adlandpro.com", +- "wikisource.org", +- "ename.com", +- "prosport.ro", +- "sharebuilder.com", +- "prisjakt.nu", +- "cw.com.tw", +- "datafilehost.com", +- "aircanada.com", +- "osu.edu", +- "linuxmint.com", +- "toyota.com", +- "google.am", +- "adobeconnect.com", +- "h33t.to", +- "companycheck.co.uk", +- "juno.com", +- "beitaichufang.com", +- "alaskaair.com", +- "tipsandtricks-hq.com", +- "yourstory.com", +- "wow-impulse.ru", +- "wishpond.com", +- "promosite.ru", +- "weddingwire.com", +- "icicidirect.com", +- "mouser.com", +- "shopstyle.co.uk", +- "sinemalar.com", +- "addurl.nu", +- "seccionamarilla.com.mx", +- "yllix.com", +- "motorola.com", +- "huawei.com", +- "mp3juices.com", +- "fitday.com", +- "pakwheels.com", +- "uploading.com", +- "snapwidget.com", +- "rsb.ru", +- "mturk.com", +- "libreoffice.org", +- "acer.com", +- "rd.com", +- "aa.com.tr", +- "glamour.com", +- "docnhat.net", +- "cnbb.com.cn", +- "piwik.org", +- "mycompanyadmin.com", +- "ohozaa.com", +- "fox.com", +- "mastercard.com.au", +- "microsofttranslator.com", +- "myhabit.com", +- "acesso.uol.com.br", +- "cqnews.net", +- "default-search.net", +- "juntadeandalucia.es", +- "carigold.com", +- "tweepi.com", +- "gamedog.cn", +- "videomega.tv", +- "softarchive.net", +- "akamai.com", +- "adorika.net", +- "zorpia.com", +- "bitdefender.com", +- "formstack.com", +- "al3abbarq.com", +- "ruelala.com", +- "andhrajyothy.com", +- "siteheart.com", +- "spankbang.com", +- "buxp.org", +- "subtlepatterns.com", +- "cucirca.eu", +- "apontador.com.br", +- "sbs.co.kr", +- "rong360.com", +- "billmelater.com", +- "nowdownload.ch", +- "pingmyurl.com", +- "main.jp", +- "allabolag.se", +- "fastspring.com", +- "20d625b48e.se", +- "wpzoom.com", +- "dl-protect.com", +- "onvista.de", +- "iberia.com", +- "learni.st", +- "minijuegos.com", +- "ae.com", +- "india-forums.com", +- "port.hu", +- "truelocal.com.au", +- "ziprecruiter.com", +- "toyokeizai.net", +- "24timezones.com", +- "tzetze.it", +- "the-village.ru", +- "ptcapusa.com", +- "indiaresults.com", +- "desjardins.com", +- "nchsoftware.com", +- "yasdl.com", +- "delo.ua", +- "baskino.com", +- "salary.com", +- "freecontact.com", +- "wumii.com", +- "ssc.nic.in", +- "synology.com", +- "nttdocomo.co.jp", +- "racing-games.com", +- "freeonlinegames.com", +- "aftabnews.ir", +- "zumi.pl", +- "efshop.com.tw", +- "hawamer.com", +- "eastbay.com", +- "izvestia.ru", +- "mosaiquefm.net", +- "twitchy.com", +- "slaati.com", +- "bookingbuddy.com", +- "networksolutionsemail.com", +- "etsystatic.com", +- "sina.com", +- "asiandatingbeauties.com", +- "blogs.com", +- "france3.fr", +- "healthcentral.com", +- "downloadatoz.com", +- "matthewwoodward.co.uk", +- "legalzoom.com", +- "phun.org", +- "campaignmonitor.com", +- "cifraclub.com.br", +- "hir24.hu", +- "twoplustwo.com", +- "hotshame.com", +- "arvixededicated.com", +- "designcrowd.com", +- "mrexcel.com", +- "blu-ray.com", +- "bundesliga.de", +- "comments.ua", +- "filmstarts.de", +- "3sk.tv", +- "donedeal.ie", +- "natunbarta.com", +- "forex-mmcis.com", +- "lifehacker.ru", +- "sitepronews.com", +- "tudogostoso.com.br", +- "titanfall.com", +- "brainpickings.org", +- "saharareporters.com", +- "vidto.me", +- "mlit.go.jp", +- "terapeak.com", +- "techweb.com.cn", +- "premiere.fr", +- "kanui.com.br", +- "asianetnews.tv", +- "cric.lk", +- "exxxtrasmall.com", +- "hiphopdx.com", +- "5617.com", +- "namepros.com", +- "humanmetrics.com", +- "allin1convert.com", +- "ox.ac.uk", +- "msecnd.net", +- "cathaypacific.com", +- "bet365affiliates.com", +- "tcs.com", +- "trafficestimate.com", +- "lmgtfy.com", +- "finance.ua", +- "find404.com", +- "pagesperso-orange.fr", +- "curbed.com", +- "tasteofhome.com", +- "ar15.com", +- "mydigitallife.info", +- "promiflash.de", +- "technobuffalo.com", +- "gamestorrents.com", +- "labirint.ru", +- "pclab.pl", +- "indiatvnews.com", +- "finya.de", +- "redmondpie.com", +- "rabota.ru", +- "share-online.biz", +- "packtpub.com", +- "techgig.com", +- "shaw.ca", +- "apkmania.co", +- "bet-at-home.com", +- "barclaycard.co.uk", +- "onefloorserve.com", +- "raiffeisen.ru", +- "t-nation.com", +- "mbalib.com", +- "staseraintv.com", +- "uswitch.com", +- "smartadserver.com", +- "bbcgoodfood.com", +- "elitetorrent.net", +- "backlinko.com", +- "naszemiasto.pl", +- "submitexpress.com", +- "savings.com", +- "gem.pl", +- "ahlamontada.com", +- "fotomac.com.tr", +- "gougou.com", +- "payamsara.com", +- "klix.ba", +- "doostiha.ir", +- "bibliocommons.com", +- "wealthyaffiliate.com", +- "emgn.com", +- "sifyitest.com", +- "washingtonexaminer.com", +- "rakuten-sec.co.jp", +- "mysurvey.com", +- "uuu9.com", +- "uscourts.gov", +- "showroomprive.com", +- "cargocollective.com", +- "hsoub.com", +- "afterbuy.de", +- "marunadanmalayali.com", +- "jumponhottie.com", +- "avon.com", +- "lazada.com.my", +- "51netu.com.cn", +- "ria.com", +- "sankakucomplex.com", +- "tvline.com", +- "devshed.com", +- "superherohype.com", +- "tv-series.me", +- "stylecraze.com", +- "wizards.com", +- "linkcollider.com", +- "xinjunshi.com", +- "bestchange.ru", +- "1111.com.tw", +- "fakenamegenerator.com", +- "newsmth.net", +- "noupe.com", +- "marketingprofs.com", +- "bluestacks.com", +- "jemtube.com", +- "bestbuy.ca", +- "backcountry.com", +- "designshack.net", +- "pond5.com", +- "highsnobiety.com", +- "rtl.fr", +- "pearsoncmg.com", +- "hellowork.go.jp", +- "koimoi.com", +- "soali.ir", +- "incentria.com", +- "vagas.com.br", +- "huaxi100.com", +- "cheaa.com", +- "lohaco.jp", +- "gov.on.ca", +- "fabthemes.com", +- "pipl.com", +- "comscore.com", +- "pcfinancial.ca", +- "craigslist.co.in", +- "michaels.com", +- "jibjab.com", +- "sankeibiz.jp", +- "dominos.co.in", +- "supermoney.eu", +- "itusozluk.com", +- "sdchina.com", +- "allkpop.com", +- "cam4.com.br", +- "stayfriends.de", +- "futbol24.com", +- "searchina.net", +- "sgcpanel.com", +- "informe21.com", +- "alsacreations.com", +- "crateandbarrel.com", +- "alliancewarfare.com", +- "filerio.in", +- "emailsrvr.com", +- "reventmedia.com", +- "vietcombank.com.vn", +- "rxlist.com", +- "acidcow.com", +- "orange.co.uk", +- "hellocoton.fr", +- "boldchat.com", +- "psychcentral.com", +- "surfline.com", +- "xxxkinky.com", +- "es.wordpress.com", +- "publika.az", +- "shufoo.net", +- "hertz.com", +- "businessweekly.com.tw", +- "virgula.uol.com.br", +- "linkis.com", +- "ixwebhosting.com", +- "usa.gov", +- "linguee.com", +- "yengo.com", +- "huffingtonpost.jp", +- "1x3x.com", +- "mediametrics.ru", +- "ec21.com", +- "80018.cn", +- "get-tune.net", +- "yupoo.com", +- "moviepilot.de", +- "ihned.cz", +- "fio.cz", +- "pubted.com", +- "cinemablend.com", +- "stooorage.com", +- "thevault.bz", +- "journaldugeek.com", +- "sommer-sommer.com", +- "travelchannel.com", +- "softonic.de", +- "petsmart.com", +- "ufxmarkets.com", +- "e24.no", +- "spirit.com", +- "dabi.ir", +- "admin5.net", +- "serialu.net", +- "vancouversun.com", +- "submanga.com", +- "sbicard.com", +- "affaritaliani.it", +- "idownloadblog.com", +- "castorama.fr", +- "sudouest.fr", +- "payscale.com", +- "serebii.net", +- "storypick.com", +- "jobkorea.co.kr", +- "gowildcasino.com", +- "hmetro.com.my", +- "parimatch.com", +- "51pinwei.com", +- "globalnews.ca", +- "mercadopago.com", +- "sixrevisions.com", +- "saisoncard.co.jp", +- "gov.kz", +- "gossip-tv.gr", +- "zbozi.cz", +- "aliorbank.pl", +- "huanqiuauto.com", +- "okaz.com.sa", +- "cplusplus.com", +- "mochimedia.com", +- "google.sn", +- "jquery-plugins.net", +- "peoplesmart.com", +- "mmafighting.com", +- "ponpare.jp", +- "porsche.com", +- "charter.com", +- "scrabblefinder.com", +- "unpcn.com", +- "loveaholics.com", +- "geocities.co.jp", +- "ladbrokes.com", +- "52che.com", +- "swansonvitamins.com", +- "sweetwater.com", +- "ali213.net", +- "savenkeep.com", +- "hotair.com", +- "orgasmatrix.com", +- "runrun.es", +- "filezilla-project.org", +- "looti.net", +- "pagesix.com", +- "twentytwowords.com", +- "gingersoftware.com", +- "youxiduo.com", +- "isimtescil.net", +- "rui.jp", +- "d1g.com", +- "2dbook.com", +- "zigzig.ir", +- "123telugu.com", +- "wdr.de", +- "hankyung.com", +- "pr.com", +- "search.ch", +- "iranproud.com", +- "raaga.com", +- "alt1040.com", +- "okpay.com", +- "recordchina.co.jp", +- "dreamincode.net", +- "bendibao.com", +- "creativelive.com", +- "socialoomph.com", +- "cssdeck.com", +- "taxactonline.com", +- "pb.com", +- "fnac.es", +- "ucsd.edu", +- "tmart.com", +- "whorush.com", +- "spicejet.com", +- "socialadr.com", +- "tutorialzine.com", +- "christianmingle.com", +- "torrentleech.org", +- "statefarm.com", +- "orkut.com", +- "whoscored.com", +- "truthaboutonlinesluts.com", +- "32red.com", +- "wp-themes.com", +- "adpost.com", +- "cnr.cn", +- "180upload.com", +- "snagajob.com", +- "textbroker.com", +- "freshome.com", +- "talkgold.com", +- "dudamobile.com", +- "weblancer.net", +- "newone.org", +- "nacion.com", +- "takepart.com", +- "voici.fr", +- "gizmodo.jp", +- "viki.com", +- "symbaloo.com", +- "topface.com", +- "businessdictionary.com", +- "adtech.info", +- "elandroidelibre.com", +- "fux.com", +- "21-sun.com", +- "cpmfx.com", +- "siemens.com", +- "edmodo.com", +- "notitarde.com", +- "babypips.com", +- "silkroad.com", +- "onextrapixel.com", +- "notdoppler.com", +- "walmart.ca", +- "marvel.com", +- "groupon.fr", +- "us1.com", +- "bunte.de", +- "findlaw.com", +- "topito.com", +- "carrefour.fr", +- "aawsat.com", +- "super.ae", +- "kicktipp.de", +- "simplyrecipes.com", +- "i-mobile.co.jp", +- "podrobnosti.ua", +- "snn.ir", +- "successfactors.com", +- "paixie.net", +- "wiwo.de", +- "glowgaze.com", +- "mapsofworld.com", +- "limetorrents.com", +- "plarium.com", +- "tvi.ua", +- "corel.com", +- "adhitprofits.com", +- "findthecompany.com", +- "noticiasaldiayalahora.co", +- "160by2.com", +- "jobberman.com", +- "rus.ec", +- "fujitsu.com", +- "ladepeche.fr", +- "pravda.sk", +- "wwtdd.com", +- "b9dm.com", +- "marathonbet.com", +- "sexlunch.com", +- "komputronik.pl", +- "gutenberg.org", +- "dizo.com.cn", +- "comunio.de", +- "naked.com", +- "gamesradar.com", +- "moneysupermarket.com", +- "cheaptickets.com", +- "assembla.com", +- "timesonline.co.uk", +- "mckinsey.com", +- "ebook3000.com", +- "videoblocks.com", +- "ruseller.com", +- "pideo.net", +- "joomlacode.org", +- "pciconcursos.com.br", +- "channelnewsasia.com", +- "cnnturk.com", +- "consultant.ru", +- "michigan.gov", +- "manoto1.com", +- "10010.com", +- "wholefoodsmarket.com", +- "globalgrind.com", +- "pichak.net", +- "morpakampus.com", +- "crazydomains.com.au", +- "uptodown.com", +- "polygon.com", +- "raspberrypi.org", +- "atmarkit.co.jp", +- "heftig.co", +- "informationweek.com", +- "trendhunter.com", +- "state.ny.us", +- "pornpros.com", +- "tnt.com", +- "sportal.bg", +- "spritzinc.com", +- "theladders.com", +- "lulu.com", +- "applesfera.com", +- "qoo10.jp", +- "notebookreview.com", +- "startertv.fr", +- "healthkart.com", +- "imgsin.com", +- "mp3olimp.net", +- "readms.com", +- "casadellibro.com", +- "nalog.ru", +- "4gamer.net", +- "jquery4u.com", +- "betfred.com", +- "3dwwwgame.com", +- "appleinsider.com", +- "dailystar.co.uk", +- "swalif.com", +- "hushmail.com", +- "worldtimebuddy.com", +- "sportschau.de", +- "mediatraffic.com", +- "gismeteo.ua", +- "record.com.mx", +- "putnik1.livejournal.com", +- "nextbigwhat.com", +- "vinescope.com", +- "jarchi.ir", +- "yidio.com", +- "dunyanews.tv", +- "hangseng.com", +- "interpark.com", +- "scholastic.com", +- "penny-arcade.com", +- "geilundlive.com", +- "budbi.com", +- "stop55.com", +- "jaidefinichon.com", +- "smartsheet.com", +- "vector.me", +- "farecompare.com", +- "vodafone.com.eg", +- "craftsy.com", +- "theresumator.com", +- "downloadab.com", +- "abendzeitung-muenchen.de", +- "dicio.com.br", +- "fobshanghai.com", +- "2dehands.be", +- "thethao247.vn", +- "cams.com", +- "gothamist.com", +- "moneynews.com", +- "zocdoc.com", +- "rol.ro", +- "nic.ar", +- "avenues.info", +- "cleverbridge.com", +- "usajobs.gov", +- "divxstage.eu", +- "jsticket.net", +- "himasoku.com", +- "thrivethemes.com", +- "orientaltrading.com", +- "premiumpress.com", +- "house365.com", +- "drugoi.livejournal.com", +- "monster.co.uk", +- "quickanddirtytips.com", +- "virtuemart.net", +- "huffpost.com", +- "real.com", +- "teacherspayteachers.com", +- "t24.com.tr", +- "zakon.kz", +- "shoppinglifestyle.com", +- "trendmicro.com", +- "surfingbird.ru", +- "cam.ac.uk", +- "navyfederal.org", +- "rateyourmusic.com", +- "bravenet.com", +- "polo.com", +- "cl.ly", +- "nanacast.com", +- "cnfol.com", +- "24option.com", +- "myscienceacademy.org", +- "getsoftfree.com", +- "cba.pl", +- "templateism.com", +- "actudesfinances.org", +- "1.254.254.254", +- "jobtalk.jp", +- "barbie.com", +- "rahnama.com", +- "gigporno.com", +- "buddypress.org", +- "corporationwiki.com", +- "enorth.com.cn", +- "thepioneerwoman.com", +- "cam4ultimate.com", +- "phpclasses.org", +- "uplus.metroer.com/~content", +- "komando.com", +- "iha.com.tr", +- "televisa.com", +- "tmtpost.com", +- "classifiedsgiant.com", +- "sportinglife.com", +- "askul.co.jp", +- "travelagency.travel", +- "jqueryscript.net", +- "rusfolder.com", +- "netcq.net", +- "irangrand.ir", +- "interaztv.com", +- "downvids.net", +- "mongodb.org", +- "nasgo.net", +- "thesitewizard.com", +- "songspk.cc", +- "travelandleisure.com", +- "d-h.st", +- "wasanga.com", +- "cgg.gov.in", +- "silverclix.com", +- "almogaz.com", +- "sexmob.es", +- "mistreci.com", +- "nukistream.com", +- "postaffiliatepro.com", +- "dish.com", +- "ulta.com", +- "worldcat.org", +- "crackle.com", +- "cineblog01.net", +- "parispornmovies.com", +- "avito.ma", +- "nethouse.ru", +- "elfinanciero.com.mx", +- "ab-in-den-urlaub.de", +- "pixeden.com", +- "thetimenow.com", +- "divar.ir", +- "coolrom.com", +- "akbank.com", +- "saturn.de", +- "dstv.com", +- "mttbsystem.com", +- "hujiang.com", +- "bash.im", +- "sextgem.com", +- "subaonet.com", +- "cnsnews.com", +- "informationng.com", +- "utoronto.ca", +- "hetzner.de", +- "vend-o.com", +- "cybozu.com", +- "autotimes.com.cn", +- "5giay.vn", +- "theepochtimes.com", +- "penesalud.com", +- "livenation.com", +- "qoinpro.com", +- "myway.com", +- "safe-swaps.com", +- "elephantjournal.com", +- "curse.com", +- "17zwd.com", +- "hitleap.com", +- "mec.gov.br", +- "freewebcams.com", +- "westelm.com", +- "imagegals.com", +- "streeteasy.com", +- "ekitan.com", +- "git-scm.com", +- "p30day.com", +- "kapaza.be", +- "svoboda.org", +- "google.mg", +- "timesofisrael.com", +- "roodo.com", +- "malwaretips.com", +- "dumpaday.com", +- "dha.com.tr", +- "diary.ru", +- "epa.gov", +- "jonloomer.com", +- "holidaylettings.co.uk", +- "oem.com.mx", +- "oxfordjournals.org", +- "3bmeteo.com", +- "iwebtool.com", +- "yinyuetai.com", +- "ixl.com", +- "rezultati.com", +- "51sole.com", +- "moudamepo.com", +- "macromill.com", +- "nzz.ch", +- "buzznet.com", +- "roku.com", +- "posta.com.tr", +- "letsbonus.com", +- "theoatmeal.com", +- "artofmanliness.com", +- "tubepornkiss.com", +- "aviny.com", +- "sabresonicweb.com", +- "tech-wd.com", +- "qbank.ru", +- "getsatisfaction.com", +- "prokerala.com", +- "ebc.com.br", +- "typiol.com", +- "photo.net", +- "rockpapershotgun.com", +- "netgear.com", +- "mg.co.za", +- "impressrd.jp", +- "jkbk.cn", +- "bakufu.jp", +- "lgmi.com", +- "tnt-online.ru", +- "frequency.com", +- "zip-codes.com", +- "sport.ro", +- "wolfram.com", +- "pgmediaserve.com", +- "icann.org", +- "twistedsifter.com", +- "mopo.de", +- "vogue.co.uk", +- "chatrandom.com", +- "checkpagerank.net", +- "colorzilla.com", +- "autobip.com", +- "laban.vn", +- "pricecheck.co.za", +- "notimex.com.mx", +- "pik.ba", +- "monster.de", +- "google.cd", +- "economia.uol.com.br", +- "vsnl.net.in", +- "futura-sciences.com", +- "appstorm.net", +- "icefilms.info", +- "dicelacancion.com", +- "hypovereinsbank.de", +- "piratestreaming.tv", +- "101domain.com", +- "google.mn", +- "rutgers.edu", +- "behindwoods.com", +- "downloadmaster.ru", +- "smartinsights.com", +- "wiziq.com", +- "ftc.gov", +- "animenewsnetwork.com", +- "tandfonline.com", +- "seagate.com", +- "famitsu.com", +- "onekingslane.com", +- "zalando.fr", +- "convio.com", +- "seochat.com", +- "qq163.com", +- "capital.gr", +- "tamin.ir", +- "phpfreaks.com", +- "cricketcountry.com", +- "ubersuggest.org", +- "ntv.co.jp", +- "olark.com", +- "1001fonts.com", +- "appsgeyser.com", +- "elsiglodetorreon.com.mx", +- "lyricsmint.com", +- "tovima.gr", +- "petco.com", +- "campograndenews.com.br", +- "amadeus.com", +- "tinychat.com", +- "astrology.com", +- "idg.se", +- "nordea.se", +- "gelbeseiten.de", +- "nrc.nl", +- "houseoffraser.co.uk", +- "hepsibahis3.com", +- "empowernetwork.com/almostasecret", +- "phpnuke.org", +- "xfwed.com", +- "gulte.com", +- "msi.com", +- "netfirms.com", +- "ovcanada.com", +- "smzdm.com", +- "wwwhatsnew.com", +- "mydomainadvisor.com", +- "newindianexpress.com", +- "luxtarget.com", +- "evz.ro", +- "otodom.pl", +- "linkin.net", +- "moneysavingmom.com", +- "uploadbaz.com", +- "egyup.com", +- "three.co.uk", +- "co-operativebank.co.uk", +- "redad.ru", +- "ipsosinteractive.com", +- "all-union.com", +- "trustlink.ru", +- "softango.com", +- "toucharcade.com", +- "tv2.dk", +- "thisissouthwales.co.uk", +- "jra.go.jp", +- "alfavita.gr", +- "ibigdan.livejournal.com", +- "gtarcade.com", +- "jc001.cn", +- "microcenter.com", +- "optimizepress.com", +- "beyebe.com", +- "muyzorras.com", +- "expedia.co.uk", +- "volvocars.com", +- "lyd.com.cn", +- "korben.info", +- "disput.az", +- "aeroflot.ru", +- "betanews.com", +- "avangard.ru", +- "wrzko.eu", +- "cakephp.org", +- "majorgeeks.com", +- "dreamteammoney.com", +- "foroactivo.com", +- "ut.ac.ir", +- "eonet.jp", +- "vn-zoom.com", +- "footytube.com", +- "expedia.de", +- "barneys.com", +- "lieyunwang.com", +- "gartner.com", +- "lazada.com.ph", +- "ourtime.com", +- "ohnotheydidnt.livejournal.com", +- "e-rewards.com", +- "updatestar.com", +- "cafef.vn", +- "cookinglight.com", +- "expressdownload.net", +- "shockmansion.com", +- "adserverpub.com", +- "ipko.pl", +- "gsa-online.de", +- "car.gr", +- "cqcounter.com", +- "thenews.com.pk", +- "gnc.com", +- "teambeachbody.com", +- "kobobooks.com", +- "cwan.com", +- "ca.com", +- "list.ly", +- "baijob.com", +- "gunbroker.com", +- "rtl.be", +- "myadvertisingpays.com", +- "mediapost.com", +- "groupalia.com", +- "anquan.org", +- "mixshowblast.com", +- "myscore.ru", +- "bancochile.cl", +- "a2hosting.com", +- "hayneedle.com", +- "myfc.ir", +- "aktifhaber.com", +- "eater.com", +- "anymeeting.com", +- "cylex.de", +- "sayidaty.net", +- "synonym.com", +- "comprendrechoisir.com", +- "prlog.ru", +- "solidtrustpay.com", +- "cinejosh.com", +- "yelp.co.uk", +- "olx.com.ar", +- "dihitt.com", +- "donkeymails.com", +- "chainreactioncycles.com", +- "wearehairy.com", +- "ebuyer.com", +- "bplans.com", +- "ponparemall.com", +- "readthedocs.org", +- "tehparadox.com", +- "source-wave.com", +- "tbs.co.jp", +- "redcoon.de", +- "francetv.fr", +- "freelogoservices.com", +- "ogone.com", +- "jeanmarcmorandini.com", +- "lasexta.com", +- "sponsoredreviews.com", +- "govome.com", +- "vecteezy.com", +- "alhayat.com", +- "cnhubei.com", +- "mumayi.com", +- "webfail.com", +- "eluniverso.com", +- "moddb.com", +- "gaiaonline.com", +- "gordonua.com", +- "liveadexchanger.com", +- "zhe800.com", +- "softonic.com.br", +- "cnyes.com", +- "cumlouder.com", +- "krakow.pl", +- "nullrefer.com", +- "zaluu.com", +- "diretube.com", +- "seattlepi.com", +- "eanswers.com", +- "gostorego.com", +- "play.com", +- "lenskart.com", +- "unblog.fr", +- "chatwork.com", +- "bronto.com", +- "jobisjob.co.in", +- "mercadolibre.com.uy", +- "overdrive.com", +- "runkeeper.com", +- "smartshopping.com", +- "getrichradio.com", +- "grader.com", +- "101greatgoals.com", +- "elbilad.net", +- "kopp-verlag.de", +- "ranksignals.com", +- "trome.pe", +- "jobstreet.com.my", +- "farnell.com", +- "fastmail.fm", +- "faithit.com", +- "blogdohotelurbano.com", +- "sencha.com", +- "daisycon.com", +- "random.org", +- "tportal.hr", +- "rkanr.com", +- "fc2-erodouga.com", +- "youngpornvideos.com", +- "bravoteens.com", +- "mobile.free.fr", +- "mitele.es", +- "edis.at", +- "questionablecontent.net", +- "indiangilma.com", +- "comunio.es", +- "bitnami.com", +- "sliptalk.com", +- "sourceforge.jp", +- "lyoness.net", +- "nespresso.com", +- "ultrafarma.com.br", +- "lik.cl", +- "jsoftj.com", +- "metoffice.gov.uk", +- "androidauthority.com", +- "360safe.com", +- "wikimart.ru", +- "tutu.ru", +- "truetwit.com", +- "xinruijunshi.com", +- "online-sweepstakes.com", +- "singaporeair.com", +- "cwtv.com", +- "politiken.dk", +- "alaan.tv", +- "tuttomercatoweb.com", +- "imagehost123.com", +- "drakensang.com", +- "frenchweb.fr", +- "syosetu.com", +- "zhifang.com", +- "viptube.com", +- "theme123.net", +- "statista.com", +- "51bi.com", +- "clickz.com", +- "kingworldnews.com", +- "qunar.com", +- "pimpandhost.com", +- "pagina12.com.ar", +- "xinmin.cn", +- "kidshealth.org", +- "pics.livejournal.com", +- "kabum.com.br", +- "anandabazar.com", +- "pnu.ac.ir", +- "scene7.com", +- "paperpkads.com", +- "mylikes.com", +- "longtailvideo.com", +- "firmy.cz", +- "bitcoinity.org", +- "inopressa.ru", +- "expat-blog.com", +- "governmentjobs.com", +- "airdroid.com", +- "mid-day.com", +- "frandroid.com", +- "webceo.com", +- "cadenaser.com", +- "minutouno.com", +- "onamae.com", +- "onlinekhabar.com", +- "williams-sonoma.com", +- "freewebsubmission.com", +- "vozforums.com", +- "bigpicture.ru", +- "mymodernmet.com", +- "presseportal.de", +- "licindia.in", +- "ismedia.jp", +- "depor.pe", +- "sing365.com", +- "v2cigs.com", +- "postimage.org", +- "gencat.cat", +- "west263.com", +- "alohatube.com", +- "eenadupratibha.net", +- "terra.com", +- "bri.co.id", +- "silktide.com", +- "anyang.gov.cn", +- "speedanalysis.com", +- "bitcoin.org", +- "toodledo.com", +- "topgear.com", +- "rtvslo.si", +- "hotpads.com", +- "nedsecure.co.za", +- "expedia.ca", +- "thairath.co.th", +- "gizbot.com", +- "naukrigulf.com", +- "guffins.com", +- "twilio.com", +- "avsforum.com", +- "sharpnews.ru", +- "inoreader.com", +- "stgeorge.com.au", +- "shoebuy.com", +- "sbwire.com", +- "bfm.ru", +- "dongtaiwang.com", +- "mandrillapp.com", +- "176.com", +- "olx.com", +- "trustpilot.co.uk", +- "tgju.org", +- "pap.fr", +- "iphonehacks.com", +- "gry-online.pl", +- "mp3xd.com", +- "viabcp.com", +- "bizcommunity.com", +- "chillingeffects.org", +- "thomasnet.com", +- "performersoft.com", +- "paymaster.ru", +- "comdotgame.com", +- "bseindia.com", +- "foodgawker.com", +- "clicktale.com", +- "dot.tk", +- "smbc-comics.com", +- "vvmembers.co", +- "c-sharpcorner.com", +- "acdcads.com", +- "goldporntube.com", +- "abakus-internet-marketing.de", +- "babbel.com", +- "fzg360.com", +- "99inf.com", +- "cduniverse.com", +- "autobild.de", +- "tvrage.com", +- "phoenix.edu", +- "hurriyetemlak.com", +- "va.gov", +- "maxmind.com", +- "lifehacker.jp", +- "nola.com", +- "niroensani.ir", +- "ihotelier.com", +- "mianbao.com", +- "powerball.com", +- "express.com", +- "freshdesignweb.com", +- "o2.co.uk", +- "utusan.com.my", +- "overclockers.ru", +- "fsiblog.com", +- "launchpad.net", +- "prizee.com", +- "alalam.ir", +- "imtalk.org", +- "vavel.com", +- "nyc.ny.us", +- "youmob.com", +- "dailythanthi.com", +- "ksu.edu.sa", +- "nlayer.net", +- "kurier.at", +- "expert-offers.com", +- "marry52.com", +- "cityads.ru", +- "darkorbit.com", +- "cio.com", +- "a9.com", +- "symfony.com", +- "crobo.com", +- "shatel.ir", +- "opposingviews.com", +- "myvoffice.com", +- "vkmag.com", +- "starpulse.com", +- "bls.gov", +- "lifebettering.com", +- "fanhuan.com", +- "upload7.ir", +- "infoplease.com", +- "suruga-ya.jp", +- "deredactie.be", +- "shangdu.com", +- "portail.free.fr", +- "smartaddons.com", +- "w3layouts.com", +- "wallstreet-online.de", +- "yapo.cl", +- "standard.co.uk", +- "atlas.sk", +- "seowizard.ru", +- "currys.co.uk", +- "nova.cz", +- "mygully.com", +- "favstar.fm", +- "themuse.com", +- "yudu.com", +- "urlopener.com", +- "ellentv.com", +- "imgsrc.ru", +- "km.ru", +- "guildwars2.com", +- "google.mu", +- "androidpit.de", +- "mrporter.com", +- "ttt4.com", +- "cbox.ws", +- "hf365.com", +- "1mobile.com", +- "punjabkesari.in", +- "msu.edu", +- "grasscity.com", +- "abduzeedo.com", +- "sublimetext.com", +- "jtb.co.jp", +- "mensxp.com", +- "myheritage.com", +- "onvasortir.com", +- "safeway.com", +- "comicvine.com", +- "cpubenchmark.net", +- "nn.ru", +- "animefreak.tv", +- "angularjs.org", +- "managewp.com", +- "ameli.fr", +- "merrjep.com", +- "christianbook.com", +- "nubiles.net", +- "klmty.net", +- "247sports.com", +- "aramex.com", +- "tubent.com", +- "cognitiveseo.com", +- "bankpasargad.com", +- "pingler.com", +- "compareja.com.br", +- "surveyzrewardcenter.eu", +- "allyes.com", +- "graaam.com", +- "poriborton.com", +- "seslisozluk.net", +- "shopyourway.com", +- "awd.ru", +- "wa.gov.au", +- "slrclub.com", +- "apollo.lv", +- "girls-ly.com", +- "totalfilm.com", +- "cam4.it", +- "gogecapital.com", +- "sketchup.com", +- "muscleandfitness.com", +- "m24.ru", +- "blinklist.com", +- "artisteer.com", +- "nettavisen.no", +- "enjin.com", +- "pc6.com", +- "citrix.com", +- "indgovtjobs.in", +- "phpbb.com", +- "laughingsquid.com", +- "fblife.com", +- "stansberryresearch.com", +- "hugefiles.net", +- "mp3monkey.net", +- "mcdonalds.com", +- "vodafone.co.uk", +- "t-mobile.de", +- "tp-link.com.cn", +- "iflscience.com", +- "nst.com.my", +- "zoom.com.br", +- "dsw.com", +- "tigerair.com", +- "doityourself.com", +- "bongdainfo.com", +- "imacros.net", +- "paperlesspost.com", +- "sprinthost.ru", +- "lovoo.net", +- "kadinlarkulubu.com", +- "championselect.net", +- "jcb.co.jp", +- "miui.com", +- "impots.gouv.fr", +- "linkshop.com.cn", +- "pando.com", +- "ckeditor.com", +- "arabylife.com", +- "ml.com", +- "sheldonsfans.com", +- "freecharge.in", +- "magicmovies.com", +- "laweekly.com", +- "highrisehq.com", +- "tr.gg", +- "vidbull.com", +- "diy.com", +- "yieldtraffic.com", +- "cima4u.com", +- "gendama.jp", +- "netpnb.com", +- "kannaway.com", +- "soft112.com", +- "die-boersenformel.com", +- "movie25.so", +- "footyroom.com", +- "dostor.org", +- "aol.de", +- "desimartini.com", +- "themeko.org", +- "danarimedia.com", +- "toroporno.com", +- "stylemepretty.com", +- "urlm.de", +- "demotivation.me", +- "gentside.com", +- "carfax.com", +- "huzhou.gov.cn", +- "hotline.ua", +- "fullmoneysystem.com", +- "pornomovies.com", +- "fsymbols.com", +- "blog.de", +- "clickpoint.com", +- "tv-asahi.co.jp", +- "flightstats.com", +- "sonico.com", +- "afamily.vn", +- "anadolu.edu.tr", +- "rs-online.com", +- "androidpit.com", +- "a-telecharger.com", +- "wikifeet.com", +- "nix.ru", +- "tvmao.com", +- "groupon.es", +- "hitfix.com", +- "weathernews.jp", +- "dig.do", +- "googledrive.com", +- "fodors.com", +- "melon.com", +- "testflightapp.com", +- "markt.de", +- "mahua.com", +- "sedo.co.uk", +- "tuenti.com", +- "comm100.com", +- "olx.co.id", +- "lefrecce.it", +- "gov.cl", +- "wplift.com", +- "unn.com.ua", +- "arizona.edu", +- "msn.com.cn", +- "k7x.com", +- "techz.vn", +- "jobomas.com", +- "extranetinvestment.com", +- "tengrinews.kz", +- "comicbookmovie.com", +- "4porn.com", +- "rubiconproject.com", +- "gametracker.com", +- "otcmarkets.com", +- "mismarcadores.com", +- "trojmiasto.pl", +- "cleverreach.com", +- "contactform7.com", +- "weloveshopping.com", +- "runnersworld.com", +- "falabella.com", +- "airtelbroadband.in", +- "twistys.com", +- "ebesucher.de", +- "belastingdienst.nl", +- "orlandosentinel.com", +- "th3professional.com", +- "duke.edu", +- "opensubtitles.us", +- "clickme.net", +- "infor.pl", +- "unesco.org", +- "socialfabric.us", +- "ename.net", +- "alternativeto.net", +- "rotahaber.com", +- "johnchow.com", +- "pervclips.com", +- "linkfeed.ru", +- "dtvideo.com", +- "kinoman.tv", +- "siteprice.org", +- "lacuerda.net", +- "amulyam.in", +- "mandghomebusiness.com", +- "infojobs.com.br", +- "hirufm.lk", +- "mybloggertricks.com", +- "athemes.com", +- "moikrug.ru", +- "fybersearch.com", +- "wine-searcher.com", +- "davidicke.com", +- "dotabuff.com", +- "sainsburys.co.uk", +- "ovaustralia.com", +- "updatesoftnow.com", +- "desarrolloweb.com", +- "elaph.com", +- "icc-cricket.com", +- "gaytube.com", +- "di.fm", +- "99wed.com", +- "c-and-a.com", +- "mlxchange.com", +- "realgfporn.com", +- "synxis.com", +- "optymalizacja.com", +- "ibtesama.com", +- "hankooki.com", +- "shiksha.com", +- "anoox.com", +- "seamless.com", +- "stripe.com", +- "ets.org", +- "fresherslive.com", +- "webcoinpay.net", +- "oscommerce.com", +- "gratisprogramas.org", +- "football365.com", +- "mkyong.com", +- "antichat.ru", +- "spamarrest.com", +- "ubc.ca", +- "36kr.com", +- "startv.in", +- "shoutcast.com", +- "heureka.sk", +- "entheosweb.com", +- "51wan.com", +- "madadsmedia.com", +- "parse.com", +- "ngacn.cc", +- "techbargains.com", +- "tvmovie.de", +- "cpmstar.com", +- "torproject.org", +- "residentadvisor.net", +- "genbeta.com", +- "hulu.jp", +- "pluralsight.com", +- "postini.com", +- "zombie.jp", +- "skimlinks.com", +- "liverail.com", +- "phys.org", +- "slashfilm.com", +- "livemaster.ru", +- "idwebgame.com", +- "pho.to", +- "dealfish.co.th", +- "s1979.com", +- "designfloat.com", +- "live365.com", +- "pbase.com", +- "eniro.se", +- "irannaz.com", +- "socialmonkee.com", +- "uidai.gov.in", +- "joomlashine.com", +- "allhyipmon.ru", +- "upbulk.com", +- "diapers.com", +- "flypgs.com", +- "hotmart.com.br", +- "globus-inter.com", +- "airfrance.fr", +- "t3.com", +- "unetepubli.com", +- "yahoo-help.jp", +- "iphones.ru", +- "95559.com.cn", +- "glamsham.com", +- "gophoto.it", +- "statmyweb.com", +- "aftermarket.pl", +- "forumotion.com", +- "iafd.com", +- "hotlog.ru", +- "drclix.com", +- "wawa-mania.ec", +- "nichepursuits.com", +- "imp.free.fr", +- "baofeng.com", +- "binsearch.info", +- "neswangy.net", +- "parperfeito.com.br", +- "theeroticreview.com", +- "sabayacafe.com", +- "maplestage.com", +- "icook.tw", +- "customerhub.net", +- "uid.me", +- "viperchill.com", +- "askfrank.net", +- "juegosjuegos.com", +- "debonairblog.com", +- "coingeneration.com", +- "onetravel.com", +- "slutroulette.com", +- "jetpack.me", +- "embedupload.com", +- "bancodevenezuela.com", +- "mysavingsmedia.net", +- "smallbiztrends.com", +- "emirates247.com", +- "bu.edu", +- "fineco.it", +- "netbarg.com", +- "gatech.edu", +- "zik.ua", +- "peliculascoco.com", +- "hkjc.com", +- "turkiyegazetesi.com.tr", +- "cooperativa.cl", +- "challenges.fr", +- "usingenglish.com", +- "vouchercodes.co.uk", +- "bonprix.de", +- "disneylatino.com", +- "townwork.net", +- "rentanything.com", +- "krypt.com", +- "wral.com", +- "globes.co.il", +- "designtaxi.com", +- "mp-success.com", +- "invisionpower.com", +- "liontravel.com", +- "classicrummy.com", +- "mt.co.kr", +- "inccel.com", +- "santander.cl", +- "afip.gov.ar", +- "yellowpages.com.au", +- "osclass.org", +- "couriermail.com.au", +- "stream.cz", +- "wizaz.pl", +- "linkresearchtools.com", +- "cam4.co.uk", +- "allafrica.com", +- "gezginler.net", +- "free-ebooks.net", +- "hopesandfears.com", +- "ticketmaster.com.mx", +- "ohio.gov", +- "liberoquotidiano.it", +- "neurs.net", +- "forumophilia.com", +- "odnako.org", +- "gamekult.com", +- "vh1.com", +- "zxart.cn", +- "mass.gov", +- "tv-tokyo.co.jp", +- "mundopromocion.com", +- "theme-junkie.com", +- "asu.edu", +- "lalibre.be", +- "pornokopilka.info", +- "fx678.com", +- "netbeans.org", +- "chinabidding.com.cn", +- "lunapic.com", +- "dramafever.com", +- "hbogo.com", +- "torrents.net", +- "woopra.com", +- "justfab.com", +- "fitnessmagazine.com", +- "tripadvisor.com.mx", +- "183.com.cn", +- "adscendmedia.com", +- "geek.com", +- "thepetitionsite.com", +- "skyscanner.ru", +- "morningpost.com.cn", +- "concursolutions.com", +- "camplace.com", +- "smarturl.it", +- "browsershots.org", +- "piktochart.com", +- "elcorreo.com", +- "collegeboard.org", +- "kasikornbank.com", +- "adsoftheworld.com", +- "fakku.net", +- "jpn.org", +- "sahafah.net", +- "rubias19.com", +- "fc2web.com", +- "redsurf.ru", +- "iproperty.com.my", +- "browsersafeguard.com", +- "mmajunkie.com", +- "bangkokbank.com", +- "ovi.com", +- "fap.to", +- "filmygyan.in", +- "edaily.vn", +- "affilorama.com", +- "valuecommerce.ne.jp", +- "softaculous.com", +- "exchanger.ru", +- "html-color-codes.info", +- "hd-xvideos.com", +- "realself.com", +- "geocaching.com", +- "mom.me", +- "stc.com.sa", +- "video-i365.com", +- "umd.edu", +- "jeffbullas.com", +- "kora.com", +- "cyberchimps.com", +- "popupads.ir", +- "chatango.com", +- "gearslutz.com", +- "fout.jp", +- "contactmusic.com", +- "linkcrypt.ws", +- "sophos.com", +- "forum-auto.com", +- "svtplay.se", +- "newsbusters.org", +- "fileswap.com", +- "phpfox.com", +- "denic.de", +- "riverisland.com", +- "encuentra24.com", +- "foxnewsinsider.com", +- "dtdc.com", +- "tayyar.org", +- "thepushbuttonmillionaire.com", +- "brokenlinkcheck.com", +- "ju51.com", +- "stihi.ru", +- "psdgraphics.com", +- "mommyfucktube.com", +- "mangocity.com", +- "routard.com", +- "whicdn.com", +- "socialtriggers.com", +- "e-bookspdf.org", +- "songspk3.in", +- "paginasamarillas.com", +- "webgame.in.th", +- "xxxdessert.com", +- "materiel.net", +- "skillshare.com", +- "tubepleasure.com", +- "paypal.de", +- "yeahmobi.com", +- "torrentz-proxy.com", +- "aircel.com", +- "openask.com", +- "trafficg.com", +- "anthem.com", +- "aleseriale.pl", +- "f-page.ru", +- "hrsmart.com", +- "cbengine.com", +- "startlap.com", +- "spamhaus.org", +- "trovit.com", +- "sporcle.com", +- "xs8.cn", +- "romwe.com", +- "powtoon.com", +- "cybozulive.com", +- "zbiornik.com", +- "cebit.de", +- "flipboard.com", +- "news.am", +- "wm-panel.com", +- "topnews.ru", +- "usp.br", +- "realmadrid.com", +- "fastdist.net", +- "unian.ua", +- "youtube.com/user/PewDiePie", +- "unc.edu", +- "tamu.edu", +- "ip2location.com", +- "americanapparel.net", +- "virtualedge.com", +- "vikatan.com", +- "goodlayers.com", +- "feedblitz.com", +- "dateinasia.com", +- "freepdfconvert.com", +- "iweb.com", +- "lachainemeteo.com", +- "aetna.com", +- "ti.com", +- "gratisjuegos.org", +- "webhostinghub.com", +- "preev.com", +- "holidayiq.com", +- "elpais.com.uy", +- "uchicago.edu", +- "telcel.com", +- "feebbo.com", +- "webhallen.com", +- "dmir.ru", +- "emailmg.ipage.com", +- "hrs.de", +- "propakistani.pk", +- "theme.co", +- "bigpara.com", +- "finishline.com", +- "fardanews.com", +- "nat.gov.tw", +- "stoloto.ru", +- "sermepa.es", +- "radaris.com", +- "softportal.com", +- "turkiye.gov.tr", +- "nnn.ru", +- "e-familynet.com", +- "wenkang.cn", +- "teamworkpm.net", +- "videohelp.com", +- "pixmania.com", +- "games.com", +- "guns.ru", +- "plus28.com", +- "pf.pl", +- "pbworks.com", +- "sedo.de", +- "freedownloadscenter.com", +- "backpackers.com.tw", +- "mycokerewards.com", +- "chinaunix.net", +- "invisionapp.com", +- "wordhippo.com", +- "unitezz.com", +- "yan.vn", +- "sonhoo.com", +- "spielaffe.de", +- "d.pr", +- "technologyreview.com", +- "democraticunderground.com", +- "molotok.ru", +- "watchever.de", +- "wdc.com", +- "torg.com", +- "ivillage.com", +- "portableapps.com", +- "ovh.es", +- "vse.kz", +- "alrajhibank.com.sa", +- "dhl-usa.com", +- "pingan.com", +- "excite.com", +- "cincodias.com", +- "marksdailyapple.com", +- "bter.com", +- "nationaljournal.com", +- "fao.org", +- "oddee.com", +- "digitalriver.com", +- "livescore.in", +- "siilu.com", +- "gofirstrowus.eu", +- "alquds.co.uk", +- "autoevolution.com", +- "zerx.ru", +- "trovit.it", +- "hvylya.org", +- "carters.com", +- "shejis.com", +- "radio-canada.ca", +- "vodafone.es", +- "sky.fm", +- "maturetube.com", +- "virtualtourist.com", +- "line25.com", +- "rzeczpospolita.pl", +- "megacurioso.com.br", +- "beliefnet.com", +- "eklablog.com", +- "hbo.com", +- "bsi.ir", +- "fastweb.it", +- "webrazzi.com", +- "telam.com.ar", +- "downloadming.me", +- "bluefly.com", +- "thewire.com", +- "erotube.org", +- "vt.edu", +- "jsbin.com", +- "ibosocial.com", +- "brides.com.cn", +- "jn.pt", +- "togetter.com", +- "olhardigital.uol.com.br", +- "ebookee.org", +- "socialgamenet.com", +- "romaniatv.net", +- "epweike.com", +- "pronto.com", +- "blog.pl", +- "top81.cn", +- "flagfox.wordpress.com", +- "unionbank.com", +- "visitkorea.or.kr", +- "blogspot.dk", +- "fermasosedi.ru", +- "inmobi.com", +- "abc.com.py", +- "iqoo.me", +- "17k.com", +- "onlineapplicationsdownloads.com", +- "komli.com", +- "tala.ir", +- "videopremium.me", +- "job.ru", +- "sunbiz.org", +- "tw116.com", +- "browserstack.com", +- "youtu.be", +- "yardbarker.com", +- "flvmplayer.com", +- "kulichki.net", +- "gravity.com", +- "levelclix.com", +- "kissanime.com", +- "insightexpressai.com", +- "colorhexa.com", +- "citizensbankonline.com", +- "hjenglish.com", +- "voeazul.com.br", +- "paraskhnio.gr", +- "es.tl", +- "busuu.com", +- "appsumo.com", +- "metacrawler.com", +- "ciku5.com", +- "android-hilfe.de", +- "laterooms.com", +- "google.com.bn", +- "gamefront.com", +- "rev2pub.com", +- "bharatiyamobile.com", +- "publicidees.com", +- "jossandmain.com", +- "babycentre.co.uk", +- "zetabux.com", +- "movieweb.com", +- "timescity.com", +- "dnevnik.ru", +- "nlcafe.hu", +- "magazine3k.com", +- "irancell.ir", +- "kalaydo.de", +- "e5.ru", +- "lecai.com", +- "sbs.com.au", +- "sierratradingpost.com", +- "girlfriendvideos.com", +- "ink361.com", +- "corporate-ir.net", +- "allgameshome.com", +- "povarenok.ru", +- "typo3.org", +- "turbosquid.com", +- "miniurls.co", +- "thinkwithgoogle.com", +- "haber3.com", +- "newsmeback.com", +- "sipse.com", +- "osxdaily.com", +- "9lessons.info", +- "cyclopaedia.net", +- "reallifecam.com", +- "gameblog.fr", +- "colourbox.com", +- "mixedmartialarts.com", +- "prostoporno.net", +- "chanel.com", +- "maxim.com", +- "cam4.es", +- "olx.com.mx", +- "newscientist.com", +- "netcombo.com.br", +- "serienjunkies.org", +- "shablol.com", +- "bnpparibasfortis.be", +- "canada.com", +- "timeslive.co.za", +- "cinematoday.jp", +- "21cineplex.com", +- "bodisparking.com", +- "cruisecritic.com", +- "vertoz.com", +- "glosbe.com", +- "nstarikov.ru", +- "epinions.com", +- "colbertnation.com", +- "marketglory.com", +- "emailmeform.com", +- "angloinfo.com", +- "filfan.com", +- "yougetsignal.com", +- "broker.to", +- "quickbux.net", +- "gottabemobile.com", +- "beyondtherack.com", +- "tripadvisor.ru", +- "jschina.com.cn", +- "registraduria.gov.co", +- "thisoldhouse.com", +- "appcelerator.com", +- "noticias24carabobo.com", +- "skelbiu.lt", +- "ru.wix.com", +- "iransong.com", +- "i-sux.com", +- "telerama.fr", +- "mydala.com", +- "pia.jp", +- "fusebux.com", +- "biquge.com", +- "microworkers.com", +- "onlywire.com", +- "fanbox.com", +- "ambitoweb.com", +- "tripadvisor.com.br", +- "postgresql.org", +- "telenet.be", +- "thegeekstuff.com", +- "primelocation.com", +- "ee.co.uk", +- "phoenixads.co.in", +- "brigitte.de", +- "360kad.com", +- "kathimerini.gr", +- "batoto.net", +- "babebuns.com", +- "webimpresion.com", +- "olx.com.ng", +- "which.co.uk", +- "f5haber.com", +- "cic.fr", +- "talkfusion.com", +- "ctrlq.org", +- "caracol.com.co", +- "wer-weiss-was.de", +- "invisionzone.com", +- "head-fi.org", +- "thingiverse.com", +- "manager-magazin.de", +- "bzwbk.pl", +- "f1news.ru", +- "tweetreach.com", +- "sj998.com", +- "streetdirectory.com", +- "asos.fr", +- "kalahari.com", +- "classiccars.com", +- "bitacoras.com", +- "bravotv.com", +- "beanfun.com", +- "bonappetit.com", +- "fashionara.com", +- "techdirt.com", +- "newlook.com", +- "iyinet.com", +- "mogujie.com", +- "carros.com.br", +- "starfall.com", +- "rp5.ru", +- "pocket-lint.com", +- "homeadvisor.com", +- "webhostbox.net", +- "cameraboys.com", +- "pricerunner.com", +- "worldcarfans.com", +- "meganovosti.net", +- "taxheaven.gr", +- "freewebsitetemplates.com", +- "mr90.ir", +- "cheapflights.co.uk", +- "bankinter.com", +- "euroresidentes.com", +- "bettycrocker.com", +- "filmey.com", +- "sheinside.com", +- "2ememain.be", +- "tu.tv", +- "kugou.com", +- "destructoid.com", +- "todoist.com", +- "karmaloop.com", +- "appadvice.com", +- "html5rocks.com", +- "osdir.com", +- "webisgreat.info", +- "dailyblogtips.com", +- "mca.gov.in", +- "e-estekhdam.com", +- "hlntv.com", +- "proprofs.com", +- "his-j.com", +- "im286.com", +- "mmorpg.com", +- "shooshtime.com", +- "terra.es", +- "lpcloudbox301.com", +- "tubepornstars.com", +- "tableausoftware.com", +- "soccersuck.com", +- "websurf.ru", +- "indiafreestuff.in", +- "pimei.com", +- "colatour.com.tw", +- "fssnet.co.in", +- "maxpark.com", +- "foodandwine.com", +- "apachefriends.org", +- "standardchartered.co.in", +- "waveapps.com", +- "gosong.net", +- "spring.me", +- "weatherbug.com", +- "iw33.com", +- "apserver.net", +- "thenationonlineng.net", +- "tjournal.ru", +- "greatschools.net", +- "3movs.com", +- "61.com", +- "directpaybiz.com", +- "w3snoop.com", +- "jsonline.com", +- "grainger.com", +- "prevention.com", +- "blizzard.com", +- "baseball-reference.com", +- "cjn.cn", +- "fasthosts.co.uk", +- "kym-cdn.com", +- "cuponation.in", +- "cam4.fr", +- "lalawan67.net", +- "videovantage.co", +- "elimparcial.com", +- "edlen24.com", +- "donya-e-eqtesad.com", +- "englishforums.com", +- "dom2.ru", +- "cinepolis.com", +- "healthtap.com", +- "astroawani.com", +- "autosport.com", +- "finalfantasyxiv.com", +- "valueclickmedia.com", +- "vitaminshoppe.com", +- "apartmentguide.com", +- "notjustok.com", +- "gratispeliculas.org", +- "intporn.com", +- "eroticbeauties.net", +- "egloos.com", +- "nujij.nl", +- "godvine.com", +- "punishtube.com", +- "wisegeek.org", +- "somuch.com", +- "taz.de", +- "zetaboards.com", +- "gravityforms.com", +- "telegraf.rs", +- "odn.ne.jp", +- "topeleven.com", +- "peekyou.com", +- "razerzone.com", +- "furaffinity.net", +- "mobikwik.com", +- "eventful.com", +- "sextube.fm", +- "treccani.it", +- "phatograph.com", +- "feedthebot.com", +- "netdoctor.co.uk", +- "collarme.com", +- "reformal.ru", +- "hemnet.se", +- "jacquieetmicheltv.net", +- "9ku.com", +- "kraloyun.com", +- "directadmin.com", +- "bongda.com.vn", +- "ddizi.org", +- "tedata.net", +- "fb.org", +- "pagemodo.com", +- "satu.kz", +- "nodejs.org", +- "tiberiumalliances.com", +- "wallst.com", +- "dezeen.com", +- "rense.com", +- "hawkhost.com", +- "vonage.com", +- "zjol.com.cn", +- "housefun.com.tw", +- "ad1.ru", +- "myredbook.com", +- "rarlab.com", +- "audiopoisk.com", +- "pbebank.com", +- "whocallsme.com", +- "playground.ru", +- "tnr.com", +- "firstdirect.com", +- "xinhua.jp", +- "gmane.org", +- "verseriesynovelas.com", +- "broadwayworld.com", +- "thefrisky.com", +- "rapmls.com", +- "skapiec.pl", +- "wholesale-dress.net", +- "alison.com", +- "n4hr.com", +- "prefiles.com", +- "vtc.vn", +- "coral.co.uk", +- "azyya.com", +- "smithsonianmag.com", +- "ticksy.com", +- "theync.com", +- "pcinpact.com", +- "eventbrite.co.uk", +- "buenosaires.gob.ar", +- "a5cee7.se", +- "bazingamob.com", +- "pp.cc", +- "shortnews.de", +- "responsinator.com", +- "filepost.com", +- "securefreedom.com", +- "notepad-plus-plus.org", +- "thekrazycouponlady.com", +- "apktops.ir", +- "nr2.ru", +- "timinternet.it", +- "man.lv", +- "forexpeacearmy.com", +- "plius.lt", +- "vcp.ir", +- "mysitecost.ru", +- "yourfiledownloader.com", +- "dealguardian.com", +- "sql.ru", +- "laravel.com", +- "shape5.com", +- "visa.com", +- "vocus.com", +- "stackthatmoney.com", +- "pornicom.com", +- "my.tv.sohu.com/user/cc128", +- "urban-rivals.com", +- "robotstxt.org", +- "colorlabsproject.com", +- "mg.gov.br", +- "local.ch", +- "adbooth.net", +- "se.pl", +- "al-akhbar.com", +- "he.net", +- "covoiturage.fr", +- "sakshieducation.com", +- "thisdaylive.com", +- "thestudentroom.co.uk", +- "pzy.be", +- "designyoutrust.com", +- "forbes.ua", +- "fandongxi.com", +- "expertreviews.co.uk", +- "dream-demo.com", +- "barchart.com", +- "ht.ly", +- "burbuja.info", +- "edgecastcdn.net", +- "amazinglytimedphotos.com", +- "value-domain.com", +- "shareaholic.com", +- "promptfile.com", +- "voetbalzone.nl", +- "ziare.com", +- "trafficbroker.com", +- "coolsport.tv", +- "vanguardia.com.mx", +- "makeshop.jp", +- "mobilism.org", +- "rebelmouse.com", +- "brisbanetimes.com.au", +- "publimetro.com.mx", +- "coolkora.com", +- "realsparrow.com", +- "honda.co.jp", +- "dealcatcher.com", +- "sinoptik.ua", +- "lefeng.com", +- "mamaclub.com", +- "bezuzyteczna.pl", +- "smn.gov.ar", +- "manhub.com", +- "pcgameshardware.de", +- "shipstation.com", +- "zive.cz", +- "disneystore.com", +- "despegar.com.mx", +- "addictivetips.com", +- "path.com", +- "pathofexile.com", +- "seitenreport.de", +- "pardot.com", +- "decathlon.fr", +- "flvrunner.com", +- "xat.com", +- "matchendirect.fr", +- "roem.ru", +- "wat.tv", +- "edline.net", +- "znds.com", +- "northwestern.edu", +- "friendscout24.de", +- "movoto.com", +- "dengiprosto.info", +- "dlisted.com", +- "sports.fr", +- "maxifoot.fr", +- "hubspot.net", +- "natalie.mu", +- "tabloidpulsa.co.id", +- "polki.pl", +- "gamasutra.com", +- "matomeantena.com", +- "adwords-community.com", +- "gallup.com", +- "redtubenacional.com", +- "mangastream.com", +- "zulutrade.com", +- "wunderlist.com", +- "taste.com.au", +- "myhosting.com", +- "totalbeauty.com", +- "8pic.ir", +- "sltrib.com", +- "88db.com", +- "minikoyuncu.com", +- "net4.in", +- "nuevoloquo.com", +- "cago365.com", +- "afip.gob.ar", +- "keep2share.cc", +- "kw.com", +- "terra.com.pe", +- "profi-forex.org", +- "filecloud.io", +- "peliculas4.com", +- "mysitemyway.com", +- "ilmattino.it", +- "geizhals.de", +- "sheershanews.com", +- "whatwpthemeisthat.com", +- "teknosa.com", +- "myshopping.com.au", +- "teamskeet.com", +- "gandalfporn.com", +- "2670.com", +- "peoplefinders.com", +- "elo7.com.br", +- "sofoot.com", +- "uhaul.com", +- "sagepay.com", +- "unb.br", +- "jhu.edu", +- "barrons.com", +- "hasznaltauto.hu", +- "winfxstrategy.com", +- "spamcop.net", +- "az.pl", +- "op.fi", +- "istruzione.it", +- "eveonline.com", +- "imgnip.com", +- "jjoobb.cn", +- "itesm.mx", +- "wptavern.com", +- "kproxy.com", +- "pulptastic.com", +- "quidco.com", +- "ekantipur.com", +- "joann.com", +- "whattoexpect.com", +- "tomshw.it", +- "internetbookshop.it", +- "followerwonk.com", +- "cisionpoint.com", +- "cint.com", +- "quondos.com", +- "suntimes.com", +- "saveinter.net", +- "eiga.com", +- "jdzj.com", +- "goldprice.org", +- "websitemagazine.com", +- "051jk.com", +- "inweb24.com", +- "gamgos.ae", +- "elog-ch.com", +- "trovit.com.mx", +- "webnode.cz", +- "ethnos.gr", +- "oodle.com", +- "subtitulos.es", +- "gameinformer.com", +- "9to5mac.com", +- "youwatch.org", +- "ibps.in", +- "biggerpockets.com", +- "sport24.co.za", +- "my.tv.sohu.com/user/cc133", +- "capsulecrm.com", +- "fuett.mx", +- "poznan.pl", +- "melateiran.com", +- "divxtotal.com", +- "aftabir.com", +- "cyberlink.com", +- "ulozto.cz", +- "jetswap.com", +- "premium.wix.com", +- "eprize.com", +- "huntington.com", +- "careerlink.vn", +- "allhyipmonitors.com", +- "autorambler.ru", +- "jamieoliver.com", +- "minube.com", +- "credomatic.com", +- "oddschecker.com", +- "listia.com", +- "mrrebates.com", +- "8684.cn", +- "kabam.com", +- "tripit.com", +- "gry.pl", +- "ecvv.com", +- "utanbaby.com", +- "lavoixdunord.fr", +- "just-eat.co.uk", +- "go-for-files.com", +- "afpbb.com", +- "mybb.com", +- "madmoizelle.com", +- "sensacine.com", +- "jtl-software.de", +- "worldtimeserver.com", +- "sunmaker.com", +- "marieforleo.com", +- "123sdfsdfsdfsd.ru", +- "duga.jp", +- "avery.com", +- "tvguide.co.uk", +- "salliemae.com", +- "zap.com.br", +- "my.tv.sohu.com/user/cc112", +- "bookmark4you.com", +- "twodollarclick.com", +- "encontreinarede.com", +- "joomshaper.com", +- "marinetraffic.com", +- "feedermatrix.com", +- "nowvideo.at", +- "millenium.org", +- "newalbumreleases.net", +- "frankkern.com", +- "onlineconversion.com", +- "ahlalhdeeth.com", +- "mediawiki.org", +- "xseo.in", +- "generation-nt.com", +- "naftemporiki.gr", +- "hardforum.com", +- "hornbunny.com", +- "my.tv.sohu.com/user/cc124", +- "housing.com", +- "vogue.es", +- "safemls.net", +- "cuisineaz.com", +- "estekhtam.com", +- "coqnu.com", +- "despegar.com.ar", +- "fedoraproject.org", +- "france2.fr", +- "autovit.ro", +- "tradetang.com", +- "levelupgames.uol.com.br", +- "dnforum.com", +- "homebank.kz", +- "carnival.com", +- "hzycsj.com", +- "army.mil", +- "bootsnipp.com", +- "istockimg.com", +- "po-kaki-to.com", +- "qiushibaike.com", +- "tsb.co.uk", +- "gzmama.com", +- "aitnews.com", +- "tripwiremagazine.com", +- "torrenty.org", +- "djangoproject.com", +- "chelseafc.com", +- "gamesgames.com", +- "herold.at", +- "baur.de", +- "kauppalehti.fi", +- "nrelate.com", +- "clickwebinar.com", +- "entropay.com", +- "gridserver.com", +- "virginia.gov", +- "tuan800.com", +- "trueactivist.com", +- "caras.uol.com.br", +- "fontawesome.io", +- "haodou.com", +- "reshareworthy.com", +- "royalcaribbean.com", +- "crakrevenue.com", +- "motika.com.mk", +- "xovi.de", +- "deutsche-startups.de", +- "inven.co.kr", +- "atrapalo.com", +- "ictv.ua", +- "muji.net", +- "kingplayer.com", +- "adworkmedia.com", +- "xjtu.edu.cn", +- "thenounproject.com", +- "professionali.ru", +- "xizhi.com", +- "boo-box.com", +- "customink.com", +- "groupon.my", +- "spartoo.com", +- "bannersdontwork.com", +- "ncore.cc", +- "reklama5.mk", +- "macrojuegos.com", +- "zenhabits.net", +- "te3p.com", +- "utah.gov", +- "telesurtv.net", +- "101.ru", +- "5yi.com", +- "lide.cz", +- "ancestry.co.uk", +- "sana.sy", +- "siteslike.com", +- "vg247.com", +- "tyzhden.ua", +- "ncsu.edu", +- "apherald.com", +- "taaza.com", +- "traffic-delivery.com", +- "uuyoyo.com", +- "hwupgrade.it", +- "game-debate.com", +- "jetpack.wordpress.com", +- "anycodes.com", +- "femina.hu", +- "zattoo.com", +- "acm.org", +- "comenity.net", +- "tarot.com", +- "azadliq.org", +- "advertiserdigital.com", +- "osym.gov.tr", +- "empornium.me", +- "netzero.net", +- "myfico.com", +- "nolix.ru", +- "cnwnews.com", +- "springpad.com", +- "ahangestan.in", +- "localbitcoins.com", +- "nikkei.co.jp", +- "youlikehits.com", +- "boyfriendtv.com", +- "wampserver.com", +- "elnorte.com", +- "codeschool.com", +- "si.edu", +- "nosis.com", +- "downloadhelper.net", +- "global-free-classified-ads.com", +- "flagmantube.com", +- "elnuevodiario.com.ni", +- "handelsbanken.se", +- "sverigesradio.se", +- "femjoy.com", +- "444.hu", +- "calcalist.co.il", +- "asiatech.ir", +- "tv.nu", +- "installmac.com", +- "programmableweb.com", +- "fotki.com", +- "vidivodo.com", +- "websquash.com", +- "selfgrowth.com", +- "wehkamp.nl", +- "amawebs.com", +- "3dlat.com", +- "comunidades.net", +- "streamin.to", +- "idbi.com", +- "cshtracker.com", +- "cdbaby.com", +- "mycommerce.com", +- "united-domains.de", +- "tradingview.com", +- "niniweblog.com", +- "avn.info.ve", +- "apa.tv", +- "pinnaclesports.com", +- "adafruit.com", +- "ipower.com", +- "lebuteur.com", +- "utah.edu", +- "mobeoffice.com", +- "lingualeo.com", +- "fuub.net", +- "tvmongol.com", +- "namasthetelangaana.com", +- "secretsearchenginelabs.com", +- "whowhatwear.com", +- "hiapk.com", +- "torrentz.sx", +- "php.su", +- "sodahead.com", +- "sbb.ch", +- "k12.ca.us", +- "jecontacte.com", +- "thehollywoodgossip.com", +- "pekao24.pl", +- "yourtest-india.com", +- "screwfix.com", +- "humoron.com", +- "yiwugou.com", +- "mulher.uol.com.br", +- "thehackernews.com", +- "shopmania.ro", +- "dlink.com", +- "despegar.com", +- "archlinux.org", +- "nielsen.com", +- "rosnet.ru", +- "appsapk.com", +- "funfarsi.ir", +- "4over.com", +- "subscribe.wordpress.com", +- "lewrockwell.com", +- "portalnet.cl", +- "antenam.info", +- "letribunaldunet.fr", +- "see-tube.com", +- "tureng.com", +- "topcashback.co.uk", +- "contactcars.com", +- "jeux.fr", +- "khan.co.kr", +- "ffffound.com", +- "gmail.com", +- "laprensa.com.ni", +- "jizzhut.com", +- "liilas.com", +- "muare.vn", +- "kting.cn", +- "heteml.jp", +- "genericsteps.com", +- "searchcompletion.com", +- "dwayir.com", +- "dicionarioinformal.com.br", +- "vcita.com", +- "fitsugar.com", +- "kleiderkreisel.de", +- "collective-evolution.com", +- "ethz.ch", +- "sendreach.com", +- "abidjan.net", +- "islamicfinder.org", +- "elong.com", +- "yonhapnews.co.kr", +- "seratnews.ir", +- "stream2watch.me", +- "content-watch.ru", +- "seotechnocrat.com", +- "todaoferta.uol.com.br", +- "toyota.jp", +- "purevid.com", +- "incredimail.com", +- "kia.com", +- "intensedebate.com", +- "kaufmich.com", +- "servis24.cz", +- "brusheezy.com", +- "rtbtraf.com", +- "tejiawang.com", +- "expedia.co.in", +- "food52.com", +- "top-channel.tv", +- "jpnn.com", +- "desitorrents.com", +- "faxingw.cn", +- "crutchfield.com", +- "seneweb.com", +- "usenet.nl", +- "aviasales.ru", +- "nesine.com", +- "appshopper.com", +- "dressupgamesite.com", +- "lowendtalk.com", +- "muslima.com", +- "v-webs.com", +- "linkomanija.net", +- "geniuzz.com", +- "caringbridge.org", +- "gooya.com", +- "dospy.com", +- "siol.net", +- "games.co.id", +- "archiveofourown.org", +- "rocketlawyer.com", +- "free-downloadz.net", +- "pastemagazine.com", +- "invest-system.net", +- "el-ahly.com", +- "todayhumor.co.kr", +- "racingpost.com", +- "stereogum.com", +- "soompi.com", +- "pof.com.br", +- "brainabundance.com", +- "fontpalace.com", +- "canon.jp", +- "eldeforma.com", +- "sacbee.com", +- "jobscore.com", +- "fashionista.com", +- "mywork.vn", +- "thisis50.com", +- "cubadebate.cu", +- "healthguru.com", +- "instatheme.com", +- "apotheken-umschau.de", +- "blizko.ru", +- "tinymce.com", +- "virtualbox.org", +- "tehran.ir", +- "pr.gov.br", +- "mlmleadsystempro.com", +- "resbux.com", +- "komonews.com", +- "childrensplace.com", +- "yoyopress.com", +- "cloudify.cc", +- "24livenewspaper.com", +- "w4.com", +- "islamway.net", +- "fantagazzetta.com", +- "imgspice.com", +- "bovada.lv", +- "payback.de", +- "peb.pl", +- "hotnigerianjobs.com", +- "dev7studios.com", +- "tejaratbank.net", +- "takuhai.jp", +- "travelmath.com", +- "cultofmac.com", +- "wakeupnow.com", +- "insidefacebook.com", +- "mediamarkt.es", +- "500wan.com", +- "rumah123.com", +- "contentmarketinginstitute.com", +- "ed.ac.uk", +- "phimvang.com", +- "womansday.com", +- "lookatme.ru", +- "citizensbank.com", +- "esam.ir", +- "phandroid.com", +- "canadiantire.ca", +- "serienjunkies.de", +- "bbspink.com", +- "yaranehkala.ir", +- "vesti.bg", +- "el-carabobeno.com", +- "smarty.net", +- "6tie.com", +- "antpedia.com", +- "p-world.co.jp", +- "camelcamelcamel.com", +- "sudu.cn", +- "priberam.pt", +- "infoworld.com", +- "myrecipes.com", +- "metrodeal.com", +- "widgetbox.com", +- "krone.at", +- "outfox.tv", +- "mymp4.in", +- "685wo.com", +- "sadanduseless.com", +- "cgd.pt", +- "mrmlsmatrix.com", +- "parenting.com", +- "tradepub.com", +- "linkvehicle.com", +- "mobiledia.com", +- "rghost.ru", +- "xxsy.net", +- "goanimate.com", +- "pikacn.com", +- "metropcs.com", +- "byu.edu", +- "bitelia.com", +- "designscrazed.com", +- "wpde.org", +- "paheal.net", +- "nulled.cc", +- "hmv.co.jp", +- "openx.com", +- "hyundai.com", +- "vvvdj.com", +- "reason.com", +- "livesports.pl", +- "polskieradio.pl", +- "oszone.net", +- "chinhphu.vn", +- "performancehorizon.com", +- "internetretailer.com", +- "skoob.com.br", +- "mediaworld.it", +- "imgrind.com", +- "bancopopular.es", +- "seogadget.ru", +- "m6.fr", +- "rongbay.com", +- "niazpardaz.com", +- "rewity.com", +- "ssense.com", +- "sky-fire.com", +- "flibusta.net", +- "eat24hours.com", +- "lotto.pl", +- "cnw.com.cn", +- "takvim.com.tr", +- "englishtown.com", +- "letudiant.fr", +- "peliculasmas.com", +- "askme.com", +- "linksmanagement.com", +- "webseoanalytics.com", +- "presse-citron.net", +- "eldiariodeamerica.com", +- "instantshift.com", +- "ampxchange.com", +- "xe.gr", +- "experts-exchange.com", +- "sportcategory.com", +- "sharecash.org", +- "linksys.com", +- "yninfo.com", +- "onlinelic.in", +- "aflamneek.com", +- "22.cn", +- "ubuntu-fr.org", +- "cjs.com.cn", +- "mp3clan.com", +- "grani.ru", +- "zen-cart.com", +- "shippingchina.com", +- "jsfor.net", +- "wanadoo.es", +- "zurker.com", +- "chotot.vn", +- "masaladesi.com", +- "insight.ly", +- "trivago.de", +- "neue-sexpartner.com", +- "boe.es", +- "military.com", +- "moonbasa.com", +- "langlaoda.com", +- "tnooz.com", +- "zacks.com", +- "liverpool.com.mx", +- "internic.net", +- "ecuavisa.com", +- "autonews.ru", +- "mcafeesecure.com", +- "peopleclick.com", +- "madthumbs.com", +- "hot-live-chat.com", +- "sugarcrm.com", +- "notonthehighstreet.com", +- "linio.com.co", +- "smartbrief.com", +- "auto-motor-und-sport.de", +- "kyivpost.com", +- "instantteleseminar.com", +- "dillards.com", +- "5i5j.com", +- "runtastic.com", +- "danawa.com", +- "ladunliadi.blogspot.com", +- "getnews.jp", +- "romedic.ro", +- "rodfile.com", +- "instyle.com", +- "swoodoo.com", +- "bannersnack.com", +- "evolife.cn", +- "ktonanovenkogo.ru", +- "office.com", +- "zamalekfans.com", +- "magiran.com", +- "ithome.com", +- "ktrmr.com", +- "spoonful.com", +- "olleh.com", +- "bgr.in", +- "industrialthemes.com", +- "adbkm.com", +- "tsa-algerie.com", +- "bloggang.com", +- "mojang.com", +- "geoiptool.com", +- "autocarindia.com", +- "ajansspor.com", +- "onmeda.de", +- "midwayusa.com", +- "alicdn.com", +- "sportdog.gr", +- "ideeli.com", +- "haspa.de", +- "gladbux.com", +- "porn-star.com", +- "experiandirect.com", +- "yicheshi.com", +- "acervoamador.com", +- "designwall.com", +- "balkanweb.com", +- "response.jp", +- "nettoos.com", +- "beruby.com", +- "manageyourloans.com", +- "kidstaff.com.ua", +- "indeed.co.za", +- "monoprice.com", +- "chsi.com.cn", +- "boorsekala.com", +- "mstaml.com", +- "trafficvance.com", +- "tatatele.in", +- "startbootstrap.com", +- "graphicburger.com", +- "ad-vid-webs.com", +- "jp.dk", +- "one.co.il", +- "athensvoice.gr", +- "payu2blog.com", +- "epidemz.net", +- "dondominio.com", +- "doviz.com", +- "disquscdn.com", +- "work.ua", +- "vsemayki.ru", +- "ikyu.com", +- "songlyrics.com", +- "onlinebank.com", +- "thebump.com", +- "travian.com.tr", +- "java2s.com", +- "twittmate.com", +- "ignou.ac.in", +- "relink.us", +- "4738.com", +- "printvenue.com", +- "tekstowo.pl", +- "natro.com", +- "dengi-tut.info", +- "freeservers.com", +- "inbound.org", +- "free-press-release.com", +- "mydirtyhobby.com", +- "gamefly.com", +- "overclockers.co.uk", +- "eci.nic.in", +- "196.1.211.6", +- "versus.com", +- "batdongsan.com.vn", +- "vrisko.gr", +- "albayan.ae", +- "trendcounter.com", +- "500.com", +- "pagomiscuentas.com", +- "wankoz.com", +- "duote.com", +- "javascript.ru", +- "chevrolet.com", +- "coach.com", +- "decidatriunfar.net", +- "rememberthemilk.com", +- "virginmobileusa.com", +- "google.com.jm", +- "ucm.es", +- "ninja.co.jp", +- "rqzao.com", +- "periodistadigital.com", +- "heritage.org", +- "momtubesex.xxx", +- "vocabulary.com", +- "kupujemprodajem.com", +- "e-cigarette-forum.com", +- "paxum.com", +- "ilpost.it", +- "abercrombie.com", +- "pearsonmylabandmastering.com", +- "echoecho.com", +- "expedia.co.jp", +- "ticketfly.com", +- "colostate.edu", +- "sjtu.edu.cn", +- "seobudget.ru", +- "gigabyte.com", +- "gsmspain.com", +- "misr5.com", +- "enterfactory.com", +- "ciao.de", +- "wuv.de", +- "dagospia.com", +- "slashgear.com", +- "urdupoint.com", +- "themepunch.com", +- "travian.com", +- "discuz.com", +- "pixroute.com", +- "otzovik.com", +- "ubergizmo.com", +- "edreams.fr", +- "internet-positif.org", +- "asmcentral.com", +- "copadomundo.uol.com.br", +- "adjal.com", +- "gotomypc.com", +- "partycity.com", +- "leggo.it", +- "blogosfere.it", +- "teamcoco.com", +- "pricedealsindia.com", +- "glennbeck.com", +- "allyou.com", +- "china.org.cn", +- "xitek.com", +- "photoshopessentials.com", +- "infopraca.pl", +- "boardingarea.com", +- "geni.com", +- "rotaban.ru", +- "foxtab.com", +- "sadistic.pl", +- "socialbro.com", +- "tradesparq.com", +- "itp.ne.jp", +- "swefilmer.com", +- "jobsite.co.uk", +- "topwar.ru", +- "yemeksepeti.com", +- "tokfm.pl", +- "businessinsider.com.au", +- "moe.gov.eg", +- "swedbank.lt", +- "jxgdw.com", +- "bayern.de", +- "alistapart.com", +- "bebinin.com", +- "annunci69.it", +- "plimus.com", +- "cuevana2.tv", +- "viamichelin.fr", +- "whatsmydns.net", +- "tarad.com", +- "hostgator.com.br", +- "hasbro.com", +- "hi-chic.com", +- "driverscollection.com", +- "onetad.com", +- "game2.com.cn", +- "elitepvpers.com", +- "tvuol.uol.com.br", +- "caclubindia.com", +- "diariocorreo.pe", +- "c-rewards.com", +- "business.gov.au", +- "chooseauto.com.cn", +- "timetrade.com", +- "alternate.de", +- "syracuse.com", +- "advanceautoparts.com", +- "shopware.de", +- "newpct.com", +- "proranktracker.com", +- "cex.io", +- "thebot.net", +- "tradekorea.com", +- "legifrance.gouv.fr", +- "cpan.org", +- "rightel.ir", +- "247wallst.com", +- "goldentowns.com", +- "bankifsccode.com", +- "color-hex.com", +- "consumerist.com", +- "juegosdiarios.com", +- "on24.com", +- "stockfreeimages.com", +- "m4.cn", +- "sponsoredtweets.com", +- "open.ac.uk", +- "bilyoner.com", +- "lexisnexis.com", +- "gsu.edu", +- "popscreen.com", +- "stiftung-warentest.de", +- "education.com", +- "leckerficken.de", +- "hostinger.ru", +- "staples.ca", +- "greenpeace.org", +- "mes-meilleurs-films.fr", +- "delish.com", +- "register.it", +- "idiva.com", +- "static.squarespace.com", +- "ololo.fm", +- "basketball-reference.com", +- "tro-ma-ktiko.blogspot.gr", +- "arabianbusiness.com", +- "avianca.com", +- "watchuseek.com", +- "6play.fr", +- "kora-online.tv", +- "armagedomfilmes.biz", +- "531314.com", +- "craigslist.co.uk", +- "inchallah.com", +- "bongdaso.com", +- "toprankblog.com", +- "k12.com", +- "itimes.com", +- "html.net", +- "utsandiego.com", +- "gyakorikerdesek.hu", +- "viddyhddownload.com", +- "wannonce.com", +- "qudong.com", +- "ibicn.com", +- "w3resource.com", +- "socialsecurity.gov", +- "tvn.pl", +- "momsexclipz.com", +- "fstoppers.com", +- "kafeteria.pl", +- "boulanger.fr", +- "guj.nic.in", +- "divaina.com", +- "desktopnexus.com", +- "topseda.ir", +- "payumoney.com", +- "klicktel.de", +- "foxtv.es", +- "cuatro.com", +- "publix.com", +- "astrosage.com", +- "kompass.com", +- "web-hosting.com", +- "nus.edu.sg", +- "jamiiforums.com", +- "lancers.jp", +- "peixeurbano.com.br", +- "buysub.com", +- "yp.com", +- "enstage.com", +- "6eat.com", +- "1ent.com.cn", +- "unionpaysecure.com", +- "pcgames.de", +- "ccidcom.com", +- "lavenir.net", +- "novaposhta.ua", +- "hotpornshow.com", +- "telebank.ru", +- "avaz.ba", +- "doit.com.cn", +- "setlinks.ru", +- "zagat.com", +- "sportmaster.ru", +- "utarget.ru", +- "lingualeo.ru", +- "compucalitv.com", +- "anastasiadate.com", +- "webmaster-rank.info", +- "fastcoexist.com", +- "lavasoft.com", +- "ppvguru.com", +- "greatist.com", +- "knack.be", +- "wowwiki.com", +- "ilcorsaronero.info", +- "jword.jp", +- "750g.com", +- "pantipmarket.com", +- "top.de", +- "photofunia.com", +- "dryicons.com", +- "alweeam.com.sa", +- "dnfight.com", +- "wpolityce.pl", +- "vimeocdn.com", +- "visit-x.net", +- "takungpao.com", +- "perfectworld.eu", +- "kat.ph", +- "hefei.cc", +- "cmse.ru", +- "virginia.edu", +- "fudan.edu.cn", +- "sethgodin.typepad.com", +- "caracaschronicles.com", +- "18qt.com", +- "be2.com.br", +- "rakuten.tw", +- "bukkit.org", +- "miss-no1.com", +- "nts.org.pk", +- "ulozto.net", +- "mixpanel.com", +- "glavred.info", +- "vui.vn", +- "mindspark.com", +- "worldmarket.com", +- "walmart.com.mx", +- "deperu.com", +- "taxact.com", +- "m5zn.com", +- "navy.mil", +- "hibapress.com", +- "cpasbien.com", +- "interjet.com.mx", +- "llbean.com", +- "kenrockwell.com", +- "japan-guide.com", +- "financialpost.com", +- "rankingsinstitute.com", +- "master-x.com", +- "pandawill.com", +- "marketingweek.co.uk", +- "freeforums.org", +- "ysear.ch", +- "pokerstars.com", +- "wired.co.uk", +- "amino.dk", +- "rapidcrush.com", +- "vivanuncios.com", +- "blogsvertise.com", +- "cwb.gov.tw", +- "piter.tv", +- "gistmania.com", +- "topdocumentaryfilms.com", +- "shoghlanty.com", +- "bankmillennium.pl", +- "burberry.com", +- "youporngay.com", +- "webresourcesdepot.com", +- "beachbody.com", +- "asstr.org", +- "pwc.com", +- "competitor.com", +- "rss2search.com", +- "vocuspr.com", +- "behindthename.com", +- "moniker.com", +- "jayde.com", +- "opensuse.org", +- "poemhunter.com", +- "toranoana.jp", +- "interaksyon.com", +- "aeon.co.jp", +- "gungho.jp", +- "fgov.be", +- "xpg.uol.com.br", +- "logic-immo.com", +- "worldsex.com", +- "watchonlineseries.eu", +- "google.co.mz", +- "discas.net", +- "chmail.ir", +- "consumercomplaints.in", +- "allstate.com", +- "twelveskip.com", +- "ibibo.com", +- "noelshack.com", +- "bonprix.ru", +- "directupload.net", +- "equipobimlatino.com", +- "weather2umbrella.com", +- "aibang.com", +- "blog.wordpress.com", +- "turner.com", +- "mediapart.fr", +- "bloog.pl", +- "monotaro.com", +- "online.net", +- "bodmillenium.com", +- "distancesfrom.com", +- "naosalvo.com.br", +- "ap7am.com", +- "focus.ua", +- "cokeandpopcorn.ch", +- "qwant.com", +- "megaplan.ru", +- "sinhvienit.net", +- "dream-marriage.com", +- "voicefive.com", +- "forex.com.cn", +- "xabbs.com", +- "netmums.com", +- "tuxboard.com", +- "cs-cart.com", +- "bitcoin.it", +- "boblil.com", +- "nirsoft.net", +- "neopets.com", +- "spin.com", +- "costco.ca", +- "mirraw.com", +- "ara.cat", +- "klamm.de", +- "glam.com", +- "guenstiger.de", +- "citruspay.com", +- "dnslink.com", +- "guyism.com", +- "shopotam.ru", +- "tim.it", +- "3suisses.fr", +- "gooroops.com", +- "kau.edu.sa", +- "ukbusinessforums.co.uk", +- "gree.jp", +- "komikid.com", +- "redakcja.pl", +- "qpic.cn", +- "voyeurweb.com", +- "mathworks.com", +- "monster.fr", +- "seniat.gob.ve", +- "computrabajo.com.co", +- "xilu.com", +- "madrid.org", +- "ostraining.com", +- "bharian.com.my", +- "telegram.org", +- "sumofus.org", +- "whosdatedwho.com", +- "moreofit.com", +- "meetic.it", +- "femina.mk", +- "itworld.com", +- "indiaglitz.com", +- "cheatcc.com", +- "filmfanatic.com", +- "the-bux.net", +- "very.co.uk", +- "fetishshrine.com", +- "speakingtree.in", +- "iu.edu", +- "modern.az", +- "tak.ru", +- "internetmarketingninjas.com", +- "example.com", +- "sportgeza.hu", +- "wrestlezone.com", +- "jameda.de", +- "caikuu.com", +- "gioco.it", +- "yourtv.com.au", +- "euro.com.pl", +- "anz.co.nz", +- "daft.ie", +- "tirerack.com", +- "vivareal.com.br", +- "definebabe.com", +- "ittefaq.com.bd", +- "lastfm.es", +- "zocalo.com.mx", +- "dpd.de", +- "somethingawful.com", +- "virgin.com", +- "shtyle.fm", +- "viralforest.com", +- "dntrck.com", +- "its-mo.com", +- "q.cc", +- "kinghost.net", +- "elpais.com.co", +- "joomlaspanish.org", +- "sopitas.com", +- "wallbase.cc", +- "cpalead.com", +- "torrentfunk.com", +- "bizcom.com.ru", +- "quizony.com", +- "rcgroups.com", +- "spring.io", +- "kuaidi100.com", +- "xatakandroid.com", +- "mlstatic.com", +- "borsaat.com", +- "jagobd.com", +- "cosmiq.de", +- "crucial.com", +- "cdstm.cn", +- "betclic.fr", +- "telewebion.com", +- "exhentai.org", +- "gnezdo.ru", +- "cebupacificair.com", +- "fusionmls.com", +- "shafaf.ir", +- "ticketmaster.co.uk", +- "adslzone.net", +- "k8.cn", +- "recipdonor.com", +- "in.gov", +- "mforos.com", +- "asscj.com", +- "linkconnector.com", +- "ohfreesex.com", +- "cntraveler.com", +- "scambioetico.org", +- "ladenzeile.de", +- "ntn24.com", +- "beyazperde.com", +- "motherearthnews.com", +- "yupptv.com", +- "220tube.com", +- "fizzle.co", +- "lakii.com", +- "deutsche-wirtschafts-nachrichten.de", +- "saaid.net", +- "bimlatino.com", +- "verisign.com", +- "funpatogh.com", +- "matadornetwork.com", +- "seatguru.com", +- "lululemon.com", +- "uzise.com", +- "networkworld.com", +- "hottube.me", +- "jobsdb.com.hk", +- "life.hu", +- "bonusvid.com", +- "incometaxindiaefiling.gov.in", +- "ey.com", +- "alraimedia.com", +- "allposters.com", +- "authorityroi.com", +- "bmwusa.com", +- "ebaystatic.com", +- "entertainmentcrave.com", +- "ehow.com.br", +- "prisonplanet.com", +- "elnashra.com", +- "email.cz", +- "yes123.com.tw", +- "uitzendinggemist.nl", +- "mindtools.com", +- "atv.com.tr", +- "shoes.net.cn", +- "joomlaportal.de", +- "themoneyconverter.com", +- "meteomedia.com", +- "bankaustria.at", +- "advertise.com", +- "trafficswarm.com", +- "aztecaporno.com", +- "fourseasons.com", +- "movie-blog.org", +- "govdelivery.com", +- "didigames.com", +- "invideo.biz", +- "linux.org.ru", +- "omelete.uol.com.br", +- "babybus.cn", +- "oursogo.com", +- "ero-an.com", +- "mediafax.ro", +- "football.ua", +- "sii.cl", +- "dreamamateurs.com", +- "cheaperthandirt.com", +- "iplocation.net", +- "insideview.com", +- "hihe.vn", +- "stop-sex.com", +- "fubiz.net", +- "url.org", +- "greenmangaming.com", +- "pornup.me", +- "indofeed.com", +- "forumhouse.ru", +- "restaurant.com", +- "key.com", +- "windstream.net", +- "brightedge.com", +- "foreignpolicy.com", +- "noticiasdatv.uol.com.br", +- "logopond.com", +- "datemule.com", +- "webrootanywhere.com", +- "stomp.com.sg", +- "trthaber.com", +- "bitterstrawberry.com", +- "turbo.az", +- "kbs.co.kr", +- "joblo.com", +- "seatimes.com.vn", +- "kuwait.tt", +- "258.com", +- "kp.ua", +- "moviesmobile.net", +- "flamingtext.com", +- "youngt.com", +- "etradenow.cn", +- "copart.com", +- "tuanweihui.com", +- "zinkwaphd.com", +- "adsl.free.fr", +- "infomaniak.ch", +- "re-direcciona.me", +- "mejorenvo.com", +- "instantservice.com", +- "harpersbazaar.com", +- "colorado.edu", +- "belboon.com", +- "telelistas.net", +- "photofans.cn", +- "51seer.com", +- "danjur.com", +- "wunderweib.de", +- "extratorrentlive.com", +- "serpfox.com", +- "androidkade.com", +- "raja.ir", +- "tampabay.com", +- "ser-mujer.org", +- "imasters.com.br", +- "coachfactory.com", +- "mojopages.com", +- "makezine.com", +- "forexschoolonline.com", +- "bochk.com", +- "siamsport.co.th", +- "mdpr.jp", +- "serialssolutions.com", +- "videosexarchive.com", +- "enlnks.com", +- "cision.com", +- "scratchinginfo.com", +- "skidrowgames.net", +- "optimizely.com", +- "video2brain.com", +- "ariva.de", +- "audiomack.com", +- "pimproll.com", +- "house.gov", +- "acs.org", +- "pijamasurf.com", +- "autoc-one.jp", +- "southcn.com", +- "vesti.az", +- "300mbfilms.com", +- "speedmystream.com", +- "wooservers.com", +- "siteliner.com", +- "tinmoi.vn", +- "extremepornvideos.com", +- "cqsq.com", +- "hello-today.com", +- "turkcealtyazi.org", +- "tvyo.com", +- "dealmoon.com", +- "openenglish.com", +- "golfchannel.com", +- "irancloob.com", +- "ebs.in", +- "portalcorreio.uol.com.br", +- "beemp3s.org", +- "condenast.com", +- "mtwebcenters.com.tw", +- "hatelabo.jp", +- "pathci.net", +- "mamsy.ru", +- "noticiasdelmundo.org", +- "guru3d.com", +- "logomaker.com", +- "adhitz.com", +- "swiki.jp", +- "turnitin.com", +- "patoghu.com", +- "carnaval.uol.com.br", +- "cancer.org", +- "clickprime8.com", +- "fahrinfo-berlin.de", +- "unisender.com", +- "flashkhor.com", +- "goodfon.ru", +- "ethiotube.net", +- "cunbang.com", +- "ti-da.net", +- "1phads.com", +- "bien.hu", +- "home77.com", +- "mbabycare.com", +- "vudu.com", +- "fantasy8.com", +- "landrover.com", +- "opencartforum.ru", +- "antena3.ro", +- "getapp.com", +- "torlock.com", +- "wind.it", +- "expatads.com", +- "bloglines.com", +- "sexytube.me", +- "frontier.com", +- "asandownload.com", +- "groupon.pl", +- "storesonlinepro.com", +- "brands4friends.de", +- "infogr.am", +- "webeffector.ru", +- "google.com.mm", +- "ppchero.com", +- "privacystar.com", +- "ocregister.com", +- "liex.ru", +- "kopatheme.com", +- "toggl.com", +- "raywenderlich.com", +- "hecha.cn", +- "vpls.net", +- "manpianyi.com", +- "1881.no", +- "scbeasy.com", +- "plex.tv", +- "selfridges.com", +- "anumex.com", +- "postplanner.com", +- "thisiscolossal.com", +- "you-will-date.com", +- "idealist.org", +- "emarketer.com", +- "anibis.ch", +- "dansmovies.com", +- "footballitarin.com", +- "fragrantica.com", +- "10minutemail.com", +- "ntu.edu.tw", +- "clasicooo.com", +- "onsugar.com", +- "vr-zone.com", +- "walkerplus.com", +- "easymobilerecharge.com", +- "cz001.com.cn", +- "sportsseoul.com", +- "inazumanews2.com", +- "marketingdirecto.com", +- "chartboost.com", +- "unblocked.co", +- "rhymezone.com", +- "portalinmobiliario.com", +- "afrointroductions.com", +- "transunion.com", +- "panorama.it", +- "powershow.com", +- "avval.ir", +- "onlinemeetingnow.com", +- "xoom.com", +- "wnbc.com", +- "tlen.pl", +- "jetairways.com", +- "vtb24.ru", +- "offcn.com", +- "crx7601.com", +- "adverts.ie", +- "kasserver.com", +- "minhavida.com.br", +- "jkpj.com", +- "123contactform.com", +- "imgtiger.com", +- "folha.com.br", +- "npcgo.com", +- "semprot.com", +- "moonfruit.com", +- "jizzbell.com", +- "online-stopwatch.com", +- "allhiphop.com", +- "hackaday.com", +- "digitalplayground.com", +- "careers24.com", +- "cwq.com", +- "wondershare.com", +- "filesend.to", +- "puromarketing.com", +- "workopolis.com", +- "mudainodocument.com", +- "home.ne.jp", +- "shorte.st", +- "tanea.gr", +- "sporza.be", +- "vgorode.ua", +- "google.co.zm", +- "argumentua.com", +- "3m.com", +- "komputerswiat.pl", +- "bongdaplus.vn", +- "supersonicads.com", +- "soundclick.com", +- "lollipop-network.com", +- "lpcloudsvr304.com", +- "313.cn", +- "rtl2.de", +- "ts.cn", +- "mglradio.com", +- "diynetwork.com", +- "komikcaps.net", +- "all-that-is-interesting.com", +- "ultipro.com", +- "frombar.com", +- "sitedeals.nl", +- "codingforums.com", +- "kansascity.com", +- "twtrland.com", +- "cengage.com", +- "lolspotsarticles.com", +- "jackthreads.com", +- "jobstreet.com.sg", +- "diffen.com", +- "eme2000.com", +- "superbru.com", +- "droid-life.com", +- "itb-berlin.de", +- "estibot.com", +- "yourepeat.com", +- "112.ua", +- "70e.com", +- "grid.mk", +- "cromaretail.com", +- "jobstreet.com.ph", +- "gloadmarket.com", +- "gemius.com", +- "huuto.net", +- "vogue.it", +- "divxonline.info", +- "mytoys.de", +- "cashnhits.com", +- "minkchan.com", +- "talabat.com", +- "helpareporter.com", +- "grandascent.com", +- "catalunyacaixa.com", +- "sparwelt.de", +- "tvboxnow.com", +- "imagecurl.org", +- "coocan.jp", +- "eatingwell.com", +- "truelife.com", +- "binaryoptionsbrands.com", +- "foxsportsla.com", +- "jjshouse.com", +- "makaan.com", +- "yamaha.com", +- "activerain.com", +- "excelforum.com", +- "mobinnet.ir", +- "kasikornbankgroup.com", +- "googleplex.com", +- "medianama.com", +- "fullsail.edu", +- "makeupandbeauty.com", +- "marketwired.com", +- "beachbodycoach.com", +- "taloussanomat.fi", +- "youngliving.us", +- "dana.ir", +- "adsgostar.com", +- "esquire.com.cn", +- "meyerweb.com", +- "positivemed.com", +- "harvestapp.com", +- "tim.com.br", +- "sumorobo.net", +- "zbigz.com", +- "schulferien.org", +- "quzhao.com", +- "tsinghua.edu.cn", +- "vogue.com", +- "ecrater.com", +- "internetbs.net", +- "oper.ru", +- "kingstone.com.tw", +- "olympic.org", +- "code.org", +- "wp.tv", +- "adchakra.net", +- "passarela.com.br", +- "damn.com", +- "spn.com.cn", +- "sacitaslan.com", +- "uplod.ir", +- "kununu.com", +- "englishclub.com", +- "ibood.com", +- "buzzfed.com", +- "peopledaily.com.cn", +- "vivastreet.it", +- "adshostnet.com", +- "npmjs.org", +- "lovethatsex.com", +- "garena.tw", +- "hq-sex-tube.com", +- "tvsubtitles.net", +- "trademarkia.com", +- "96down.com", +- "morhipo.com", +- "chuguoqu.com", +- "free-css.com", +- "getsecuredfiles.com", +- "justia.com", +- "paypal-community.com", +- "wezoner.com", +- "google-analytics.com", +- "outsideonline.com", +- "simplymeasured.com", +- "wattsupwiththat.com", +- "vancl.com", +- "leadership.ng", +- "plaisio.gr", +- "fastcocreate.com", +- "fewo-direkt.de", +- "dedecms.com", +- "bostonherald.com", +- "elmundo.com.ve", +- "idhostinger.com", +- "animaljam.com", +- "infoq.com", +- "exler.ru", +- "leprosorium.ru", +- "avis.com", +- "ulusalpost.com", +- "namnak.com", +- "goindigo.in", +- "activeboard.com", +- "fatsecret.com", +- "4umf.com", +- "porn-w.org", +- "sarkariexam.co.in", +- "patagonia.com", +- "3u5.net", +- "roshd.ir", +- "netechangisme.com", +- "ojogo.pt", +- "ujipin.com", +- "topuniversities.com", +- "consequenceofsound.net", +- "no-ip.biz", +- "webdesignerwall.com", +- "fin24.com", +- "openculture.com", +- "pbh2.com", +- "dota2.com", +- "secureupload.eu", +- "alfajertv.com", +- "canlidizihdtv.com", +- "muffingroup.com", +- "imageforum.com", +- "paris.fr", +- "kaufda.de", +- "pelis24.com", +- "ixian.cn", +- "ebenpagan.com", +- "sportsauthority.com", +- "wish.com", +- "ganeshaspeaks.com", +- "meritnation.com", +- "ijie.com", +- "vodafone.com.tr", +- "trovit.es", +- "farsisubtitle.com", +- "musawvir.com", +- "resellerratings.com", +- "soyentrepreneur.com", +- "samakal.net", +- "dietnavi.com", +- "55tuan.com", +- "elcomercio.com", +- "hereisthecity.com", +- "buienradar.nl", +- "arenabg.com", +- "indiansexstories.net", +- "slideboom.com", +- "findsection.net", +- "rankrecon.com", +- "e-radio.gr", +- "cnn.co.jp", +- "gucci.com", +- "natura.net", +- "googlesyndication.com", +- "advancedwebranking.com", +- "lib.ru", +- "sfora.pl", +- "uci.edu", +- "haaretz.co.il", +- "ing.be", +- "yokboylebirsey.com.tr", +- "myfact.tv", +- "yenibiris.com", +- "stuff.tv", +- "dn.pt", +- "whydontyoutrythis.com", +- "nediyor.com", +- "worldoftanks.asia", +- "megamillions.com", +- "elemanonline.net", +- "computrabajo.com.pe", +- "arxiv.org", +- "livescore.tv", +- "aintitcool.com", +- "girlschannel.net", +- "madbid.com", +- "tadawul.com.sa", +- "liqpay.com", +- "softonic.jp", +- "alhilal.com", +- "bizpowa.com", +- "thatguywiththeglasses.com", +- "yemeneconomist.com", +- "pazar3.mk", +- "repai.com", +- "1jux.net", +- "solvusoft.com", +- "yotpo.com", +- "cuantocabron.com", +- "ba.gov.br", +- "arin.net", +- "loginza.ru", +- "homebank.ro", +- "0755car.com", +- "carscoops.com", +- "antarvasna.com", +- "tizag.com", +- "offerpop.com", +- "techmeme.com", +- "ipress.ua", +- "emuparadise.me", +- "sexvidx.com", +- "whatseek.com", +- "become.co.jp", +- "snapfish.com", +- "gsis.gr", +- "speedyshare.com", +- "uncrate.com", +- "doda.jp", +- "straighttalk.com", +- "rsjoomla.com", +- "vozpopuli.com", +- "gotprint.net", +- "finansbank.com.tr", +- "chinatrust.com.tw", +- "stratoserver.net", +- "icnetwork.co.uk", +- "getpopcornti.me", +- "pornper.com", +- "3dmgame.com", +- "squirt.org", +- "mbusa.com", +- "katespade.com", +- "skat.dk", +- "radiko.jp", +- "dexonline.ro", +- "bicaps.net", +- "bitsoma.com", +- "brasil247.com", +- "alittlemarket.com", +- "bd-pratidin.com", +- "amorincontro.com", +- "bigxvideos.com", +- "nissan.co.jp", +- "incomediary.com", +- "theranking.com", +- "el7l.co", +- "webcamtoy.com", +- "steamgifts.com", +- "miles-and-more.com", +- "szonline.net", +- "blocked-website.com", +- "kaztorka.org", +- "avforums.com", +- "indulgy.com", +- "extendcp.co.uk", +- "yonkis.com", +- "ad1111.com", +- "unionbankph.com", +- "job.com", +- "samanepay.com", +- "aceona.com", +- "kar.nic.in", +- "tipico.com", +- "sa.ae", +- "froma.com", +- "songza.com", +- "calciomercato.com", +- "besaba.com", +- "x-rates.com", +- "arsys.es", +- "sisal.it", +- "amateur.tv", +- "designyourway.net", +- "alpha.gr", +- "nimble.com", +- "livefreefun.com", +- "wipo.int", +- "webssearches.com", +- "vodjk.com", +- "91tiger.com", +- "swisscom.com", +- "tuvaro.com", +- "parsonline.net", +- "uolhost.com.br", +- "cnwest.com", +- "roksa.pl", +- "socialmention.com", +- "unibytes.com", +- "screamingfrog.co.uk", +- "owncloud.org", +- "jacquielawson.com", +- "openclipart.org", +- "zimbra.com", +- "poczta-polska.pl", +- "hayah.cc", +- "ringtonematcher.com", +- "emai.com", +- "wealink.com", +- "celebzen.com", +- "pichost.me", +- "rediffmail.com", +- "dinos.co.jp", +- "netvasco.com.br", +- "meilele.com", +- "career.ru", +- "signupgenius.com", +- "screencast-o-matic.com", +- "nav.no", +- "reactiongifs.com", +- "italki.com", +- "mo.gov", +- "bandsintown.com", +- "elwatan.com", +- "jdate.com", +- "quiente.net", +- "skynet.be", +- "googlekeywordtool.com", +- "nubilefilms.com", +- "memedeportes.com", +- "rewardingzonez.com", +- "litmus.com", +- "iyaxin.com", +- "collegeconfidential.com", +- "semperplugins.com", +- "sofort.com", +- "ineedhits.com", +- "live24.gr", +- "acronymfinder.com", +- "jobui.com", +- "9show.com", +- "thedirty.com", +- "tsutaya.co.jp", +- "9787.com", +- "brighthouse.com", +- "boxingscene.com", +- "indeed.com.br", +- "morazzia.com", +- "privatejobshub.blogspot.in", +- "searchenginepeople.com", +- "pozdravok.ru", +- "watchstore.com.cn", +- "rts.ch", +- "pluska.sk", +- "villagevoice.com", +- "sprintrade.com", +- "conversionxl.com", +- "evsuite.com", +- "bci.cl", +- "lampsplus.com", +- "gossipcop.com", +- "valuecommerce.com", +- "zalora.co.id", +- "fastshop.com.br", +- "hockeysfuture.com", +- "bootply.com", +- "chinavasion.com", +- "menards.com", +- "kinobar.net", +- "tokyodisneyresort.jp", +- "knownhost.com", +- "ozbargain.com.au", +- "olx.com.ve", +- "sgk.gov.tr", +- "berliner-sparkasse.de", +- "bancogalicia.com.ar", +- "joomla-master.org", +- "augsburger-allgemeine.de", +- "kroger.com", +- "pulse.ng", +- "putlocker.com", +- "jrtj.com", +- "tapuz.co.il", +- "madhyamam.com", +- "donews.com", +- "showhaber.com", +- "allxnxx.com", +- "uned.es", +- "adsharebux.com", +- "d-addicts.com", +- "banki.ir", +- "levi.com", +- "e97527f0.se", +- "entertainmentwise.com", +- "xvideos-field.com", +- "naver.net", +- "urbia.de", +- "fashionsfriend.com", +- "emuch.net", +- "yelp.fr", +- "metatube.com", +- "sina.com.hk", +- "omb100.com", +- "grameenphone.com", +- "stylebook.de", +- "funny-games.biz", +- "googlewebmastercentral.blogspot.com", +- "vogella.com", +- "surveymonkey.net", +- "forex4you.org", +- "mex.tl", +- "online-fish-games.com", +- "millenniumbcp.pt", +- "fileom.com", +- "friendorfollow.com", +- "downloads.nl", +- "typekit.com", +- "gongkong.com", +- "iqoption.com", +- "tori.fi", +- "smartsource.com", +- "1616.net", +- "1shoppingcart.com", +- "novosti.rs", +- "yofond.com", +- "idokep.hu", +- "motor.ru", +- "xbiao.com", +- "colorcombos.com", +- "pway.cn", +- "egynews.net", +- "elshaab.org", +- "telus.com", +- "olx.com.co", +- "cctvcj.com", +- "kpopstarz.com", +- "razorsocial.com", +- "ncrypt.in", +- "zonetheme.com", +- "gumroad.com", +- "e-shop.gr", +- "kugli.com", +- "levif.be", +- "bookfi.org", +- "globalresearch.ca", +- "sas.com", +- "cloudaccess.net", +- "uplooder.net", +- "exposedwebcams.com", +- "1prime.ru", +- "webappers.com", +- "crocko.com", +- "remax.com", +- "ikco.com", +- "dinside.no", +- "winbank.gr", +- "mijnwoordenboek.nl", +- "weatherzone.com.au", +- "allday2.com", +- "sunat.gob.pe", +- "getit.in", +- "entrance-exam.net", +- "i2ya.com", +- "tlife.gr", +- "qyer.com", +- "calibre-ebook.com", +- "internetcorkboard.com", +- "unitedhyipleague.com", +- "spyrestudios.com", +- "metal-archives.com", +- "aeromexico.com", +- "cv-library.co.uk", +- "bdr1.net", +- "aremo.com.br", +- "blip.tv", +- "afilio.com.br", +- "renewalcoupons.com", +- "proxfree.com", +- "magix.com", +- "jobs.net", +- "souism.com", +- "adtcstrk.com", +- "goodhousekeeping.com", +- "lastfm.ru", +- "sharecare.com", +- "porn.xxx", +- "deathandtaxesmag.com", +- "unocero.com", +- "wer-kennt-wen.de", +- "hotfrog.com", +- "intraship.de", +- "press24.mk", +- "yournewscorner.com", +- "rbc.com", +- "eventure.com", +- "minglebox.com", +- "legendas.tv", +- "drp.su", +- "voicefrom.me", +- "venezuelaaldia.com", +- "cooks.com", +- "numbeo.com", +- "chilehardware.cl", +- "cryptocointalk.com", +- "venusfactor.com", +- "recruitmentcareer.in", +- "larazon.es", +- "sptechs.com", +- "asx.com.au", +- "ahlife.com", +- "st001.com", +- "actudesfinances.info", +- "talkarcades.com", +- "nitori-net.jp", +- "chinahr.com", +- "websitetestlink.com", +- "hypem.com", +- "demorgen.be", +- "sharefile.com", +- "prensalibre.com", +- "eldia.com.ar", +- "billiger.de", +- "3docean.net", +- "streamsend.com", +- "tuaw.com", +- "portafolio.co", +- "trivago.com", +- "olxpix.com", +- "geotrust.com", +- "torrentgun.net", +- "enha.kr", +- "pcastuces.com", +- "t.cn", +- "dimsemenov.com", +- "cam4.nl", +- "basspro.com", +- "macupdate.com", +- "strawpoll.me", +- "elintransigente.com", +- "homeaway.co.uk", +- "my.ecwid.com", +- "graphpaperpress.com", +- "architonic.com", +- "flowplayer.org", +- "syshl.com", +- "18schoolgirlz.com" +- }); +- +- return urls; ++std::vector const& urls_large_data() { ++ static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; ++ return hosts; + } +--- upstream/http/client/crawl/urls_large_data.hpp ++++ wasip3/http/client/crawl/urls_large_data.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -12,7 +29,6 @@ + + #include + +-std::vector const& +-urls_large_data(); ++std::vector const& urls_large_data(); + + #endif +--- upstream/http/client/methods/http_client_methods.cpp ++++ wasip3/http/client/methods/http_client_methods.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,27 +32,23 @@ + + //[example_http_client_methods + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from +- ++using tcp = webcpp::asio::ip::tcp; // from + + // perform a get request +-void do_get(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_get(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); +@@ -43,11 +56,8 @@ + } + + // perform a head request +-void do_head(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_head(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); +@@ -68,106 +78,84 @@ + res = p.release(); + } + +- + // perform a patch request +-void do_patch(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_patch(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // perform a put request +-void do_put(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_put(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; +- req.prepare_payload(); // set content-length based on the body ++ req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); + } + + // perform a post request +-void do_post(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_post(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // perform a delete request +-void do_delete(beast::tcp_stream & stream, +- http::request & req, +- beast::flat_buffer buffer, +- http::response & res) +-{ ++void do_delete(beast::tcp_stream& stream, http::request& req, ++ beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; +- req.prepare_payload(); // set content-length based on the body +- http::write(stream, req); +- http::read(stream, buffer, res); +-} +- ++ req.prepare_payload(); // set content-length based on the body ++ http::write(stream, req); ++ http::read(stream, buffer, res); ++} + + // Performs an HTTP request against httpbin.cpp.al and prints request & response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 2) +- { +- std::cerr << +- "Usage: http-client-method \n" << +- "Example:\n" << +- " http-client-method get\n" << +- " http-client-method post\n"; ++ if (argc != 2) { ++ std::cerr << "Usage: http-client-method \n" ++ << "Example:\n" ++ << " http-client-method get\n" ++ << " http-client-method post\n"; + return EXIT_FAILURE; + } + +- for (char * c = argv[1]; *c != '\0'; c++) ++ for (char* c = argv[1]; *c != '\0'; c++) + *c = static_cast(std::tolower(*c)); + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +- auto const results = resolver.resolve("httpbin.cpp.al", "http"); ++ auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + +- + // Set up an HTTP GET request message + http::request req; +- req.set(http::field::host, "httpbin.cpp.al"); ++ req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); +- + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; +@@ -187,20 +175,16 @@ + do_post(stream, req, buffer, res); + else if (method == "delete") + do_delete(stream, req, buffer, res); +- else +- { ++ else { + std::cerr << "Unknown method: " << method << std::endl; + return EXIT_FAILURE; + } + + // Write the message to standard out +- std::cout << "Request send:\n-----------------------------\n" +- << req << std::endl; +- ++ std::cout << "Request send:\n-----------------------------\n" << req << std::endl; + + // Write the message to standard out +- std::cout << "\n\nResponse received:\n-----------------------------\n" +- << res << std::endl; ++ std::cout << "\n\nResponse received:\n-----------------------------\n" << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; +@@ -209,13 +193,11 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/client/sync/http_client_sync.cpp ++++ wasip3/http/client/sync/http_client_sync.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,33 +32,30 @@ + + //[example_http_client + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from + namespace net = boost::asio; // from +-using tcp = net::ip::tcp; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-sync []\n" << +- "Example:\n" << +- " http-client-sync www.example.com 80 /\n" << +- " http-client-sync www.example.com 80 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-sync []\n" ++ << "Example:\n" ++ << " http-client-sync www.example.com 80 /\n" ++ << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -50,10 +64,10 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name +@@ -89,13 +103,11 @@ + // not_connected happens sometimes + // so don't bother reporting it. + // +- if(ec && ec != beast::errc::not_connected) ++ if (ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/client/sync-ssl/http_client_sync_ssl.cpp ++++ wasip3/http/client/sync-ssl/http_client_sync_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,36 +31,33 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + +-#include +-#include +-#include + #include + #include + #include ++#include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = net::ssl; // from +-using tcp = net::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = net::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Performs an HTTP GET and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4 && argc != 5) +- { +- std::cerr << +- "Usage: http-client-sync-ssl []\n" << +- "Example:\n" << +- " http-client-sync-ssl www.example.com 443 /\n" << +- " http-client-sync-ssl www.example.com 443 / 1.0\n"; ++ if (argc != 4 && argc != 5) { ++ std::cerr << "Usage: http-client-sync-ssl []\n" ++ << "Example:\n" ++ << " http-client-sync-ssl www.example.com 443 /\n" ++ << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -51,7 +66,7 @@ + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); +@@ -62,16 +77,14 @@ + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + +- // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ // These objects perform our I/O ++ webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(stream.native_handle(), host)) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification +@@ -127,11 +140,9 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec != net::ssl::error::stream_truncated) ++ if (ec != net::ssl::error::stream_truncated) + throw beast::system_error{ec}; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/async/http_server_async.cpp ++++ wasip3/http/server/async/http_server_async.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,83 +30,97 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include ++#include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -101,15 +132,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -120,9 +146,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -133,9 +157,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -146,19 +168,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -167,19 +187,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -189,10 +208,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -203,15 +220,12 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -219,31 +233,20 @@ + + public: + // Take ownership of the stream +- session( +- tcp::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- } ++ session(tcp::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), +- beast::bind_front_handler( +- &session::do_read, +- shared_from_this())); +- } +- +- void +- do_read() +- { ++ beast::bind_front_handler(&session::do_read, shared_from_this())); ++ } ++ ++ void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -253,56 +256,39 @@ + + // Read a request + http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, shared_from_this(), keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); +@@ -312,9 +298,7 @@ + do_read(); + } + +- void +- do_close() +- { ++ void do_close() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -326,90 +310,63 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- return; // To avoid infinite loop +- } +- else +- { ++ return; // To avoid infinite loop ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket), +- doc_root_)->run(); ++ std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection +@@ -419,41 +376,27 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-async
\n" << +- "Example:\n" << +- " http-server-async 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-async
\n" ++ << "Example:\n" ++ << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port +- std::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/async-local/http_server_async_local.cpp ++++ wasip3/http/server/async-local/http_server_async_local.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -17,83 +34,97 @@ + #include + #include + #include +-#include +-#include + #include + #include ++#include ++#include + + #include + #include + #include + #include + #include +-#include ++ + #include + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -105,15 +136,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -124,9 +150,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -137,9 +161,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -150,19 +172,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -171,19 +191,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -193,10 +212,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -207,50 +224,34 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session : public std::enable_shared_from_this +-{ +- beast::basic_stream< +- stream_protocol, +- net::any_io_executor, +- beast::unlimited_rate_policy> stream_; ++class session : public std::enable_shared_from_this { ++ beast::basic_stream ++ stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + + public: + // Take ownership of the stream +- session( +- stream_protocol::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- } ++ session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), +- beast::bind_front_handler( +- &session::do_read, +- shared_from_this())); +- } +- +- void +- do_read() +- { ++ beast::bind_front_handler(&session::do_read, shared_from_this())); ++ } ++ ++ void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -260,56 +261,39 @@ + + // Read a request + http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, shared_from_this(), keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); +@@ -319,9 +303,7 @@ + do_read(); + } + +- void +- do_close() +- { ++ void do_close() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); +@@ -333,56 +315,33 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- stream_protocol::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc), std::move(endpoint)) +- , doc_root_(doc_root) +- { +- } ++ listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, stream_protocol::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, stream_protocol::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- return; // To avoid infinite loop +- } +- else +- { ++ return; // To avoid infinite loop ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket), +- doc_root_)->run(); ++ std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection +@@ -392,50 +351,33 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: http-server-async-local \n" << +- "Example:\n" << +- " http-server-async-local /tmp/http.sock . 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: http-server-async-local \n" ++ << "Example:\n" ++ << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + std::remove(path); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- stream_protocol::endpoint{path}, +- doc_root)->run(); ++ std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -443,12 +385,9 @@ + + #else + +-int +-main(int, char*[]) +-{ +-std::cerr << +- "Local sockets not available on this platform" << std::endl; +-return EXIT_FAILURE; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; ++ return EXIT_FAILURE; + } + + #endif +--- upstream/http/server/async-ssl/http_server_async_ssl.cpp ++++ wasip3/http/server/async-ssl/http_server_async_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,86 +31,100 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -104,15 +136,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -123,9 +150,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -136,9 +161,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -149,19 +172,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -170,19 +191,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -192,10 +212,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -206,9 +224,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -226,15 +242,14 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -242,58 +257,38 @@ + + public: + // Take ownership of the socket +- explicit +- session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket), ctx) +- , doc_root_(doc_root) +- { +- } ++ explicit session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch( +- stream_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); +- } +- +- void +- on_run() +- { ++ net::dispatch(stream_.get_executor(), ++ beast::bind_front_handler(&session::on_run, shared_from_this())); ++ } ++ ++ void on_run() { + // Set the timeout. +- beast::get_lowest_layer(stream_).expires_after( +- std::chrono::seconds(30)); ++ beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -303,58 +298,39 @@ + + // Read a request + http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return do_close(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, +- this->shared_from_this(), +- keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); +@@ -364,23 +340,17 @@ + do_read(); + } + +- void +- do_close() +- { ++ void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( +- beast::bind_front_handler( +- &session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -390,94 +360,64 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(ioc) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- return; // To avoid infinite loop +- } +- else +- { ++ return; // To avoid infinite loop ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection +@@ -487,24 +427,21 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-async-ssl
\n" << +- "Example:\n" << +- " http-server-async-ssl 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-async-ssl
\n" ++ << "Example:\n" ++ << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -513,22 +450,10 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/awaitable/http_server_awaitable.cpp ++++ wasip3/http/server/awaitable/http_server_awaitable.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -17,82 +34,96 @@ + #include + #include + #include +-#include +-#include + #include + #include ++#include ++#include + + #include + #include + #include + #include + #include +-#include ++ + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; +-namespace net = boost::asio; ++namespace beast = webcpp::beast; ++namespace http = beast::http; ++namespace net = boost::asio; + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -104,15 +135,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -123,9 +149,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -136,9 +160,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -149,19 +171,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -170,19 +190,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -192,10 +211,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -204,16 +221,12 @@ + } + + // Handles an HTTP server connection +-net::awaitable +-do_session( +- beast::tcp_stream stream, +- std::shared_ptr doc_root) +-{ ++net::awaitable do_session(beast::tcp_stream stream, ++ std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + +@@ -230,8 +243,7 @@ + // Send the response + co_await beast::async_write(stream, std::move(msg)); + +- if(!keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -239,7 +251,7 @@ + } + + // Send a TCP shutdown +- stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); ++ stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have +@@ -247,89 +259,63 @@ + } + + // Accepts incoming connections and launches the sessions +-net::awaitable +-do_listen(net::ip::tcp::endpoint endpoint, std::shared_ptr doc_root) +-{ ++net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, ++ std::shared_ptr doc_root) { + auto executor = co_await net::this_coro::executor; +- auto acceptor = net::ip::tcp::acceptor{ executor, endpoint }; +- +- for(;;) +- { +- net::co_spawn( +- executor, +- do_session( +- beast::tcp_stream{ co_await acceptor.async_accept() }, +- doc_root), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error in session: " << e.what() << "\n"; +- } +- } +- }); ++ auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; ++ ++ for (;;) { ++ net::co_spawn(executor, ++ do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception const& e) { ++ std::cerr << "Error in session: " << e.what() << "\n"; ++ } ++ } ++ }); + } + } + +-int +-main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if(argc != 5) +- { ++ if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" +- << "Example:\n" +- << " http-server-awaitable 0.0.0.0 8080 . 1\n"; ++ << "Example:\n" ++ << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } +- auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); ++ auto const address = net::ip::make_address(argv[1]); ++ auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{ threads }; ++ webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port +- net::co_spawn( +- ioc, +- do_listen(net::ip::tcp::endpoint{ address, port }, doc_root), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error: " << e.what() << std::endl; +- } +- } +- }); ++ net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception const& e) { ++ std::cerr << "Error: " << e.what() << std::endl; ++ } ++ } ++ }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back([&ioc] { ioc.run(); }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/http/server/coro/http_server_coro.cpp ++++ wasip3/http/server/coro/http_server_coro.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,83 +30,97 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include ++#include ++#include ++#include + #include +-#include +-#include +-#include + #include +-#include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -101,15 +132,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -120,9 +146,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -133,9 +157,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -146,19 +168,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -167,19 +187,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -189,10 +208,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -203,42 +220,33 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + +- + // Handles an HTTP server connection +-void +-do_session( +- beast::tcp_stream& stream, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, ++ net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages +- for(;;) +- { ++ for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle the request +- http::message_generator msg = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -246,11 +254,10 @@ + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -266,105 +273,80 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else +- boost::asio::spawn( +- acceptor.get_executor(), +- std::bind( +- &do_session, +- beast::tcp_stream(std::move(socket)), +- doc_root, +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ boost::asio::spawn(acceptor.get_executor(), ++ std::bind(&do_session, beast::tcp_stream(std::move(socket)), ++ doc_root, std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-coro
\n" << +- "Example:\n" << +- " http-server-coro 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-coro
\n" ++ << "Example:\n" ++ << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- tcp::endpoint{address, port}, +- doc_root, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, ++ std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/coro-ssl/http_server_coro_ssl.cpp ++++ wasip3/http/server/coro-ssl/http_server_coro_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,86 +31,100 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -104,15 +136,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -123,9 +150,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -136,9 +161,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -149,19 +172,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -170,19 +191,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -192,10 +212,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -206,9 +224,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -226,19 +242,15 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-void +-do_session( +- ssl::stream& stream, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_session(ssl::stream& stream, ++ std::shared_ptr const& doc_root, net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + +@@ -247,28 +259,26 @@ + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle the request +- http::message_generator res = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); +@@ -276,10 +286,9 @@ + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -291,7 +300,7 @@ + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -300,76 +309,62 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_session, +- ssl::stream( +- std::move(socket), ctx), +- doc_root, +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ std::bind(&do_session, ssl::stream(std::move(socket), ctx), ++ doc_root, std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-coro-ssl
\n" << +- "Example:\n" << +- " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-coro-ssl
\n" ++ << "Example:\n" ++ << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -379,35 +374,22 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- std::ref(ctx), +- tcp::endpoint{address, port}, +- doc_root, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ std::bind(&do_listen, std::ref(ioc), std::ref(ctx), ++ tcp::endpoint{address, port}, doc_root, std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/fast/fields_alloc.hpp ++++ wasip3/http/server/fast/fields_alloc.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -17,56 +34,37 @@ + + namespace detail { + +-struct static_pool +-{ ++struct static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + +- char* +- end() +- { +- return reinterpret_cast(this + 1) + size_; ++ char* end() { return reinterpret_cast(this + 1) + size_; } ++ ++ explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} ++ ++public: ++ static static_pool& construct(std::size_t size) { ++ auto p = new char[sizeof(static_pool) + size]; ++ return *(::new (p) static_pool{size}); + } + +- explicit +- static_pool(std::size_t size) +- : size_(size) +- , p_(reinterpret_cast(this + 1)) +- { ++ static static_pool& share(static_pool& pool) { ++ ++pool.refs_; ++ return pool; + } + +-public: +- static +- static_pool& +- construct(std::size_t size) +- { +- auto p = new char[sizeof(static_pool) + size]; +- return *(::new(p) static_pool{size}); +- } +- +- static_pool& +- share() +- { +- ++refs_; +- return *this; +- } +- +- void +- destroy() +- { +- if(--refs_) ++ void destroy() { ++ if (--refs_) + return; + this->~static_pool(); + delete[] reinterpret_cast(this); + } + +- void* +- alloc(std::size_t n) +- { ++ void* alloc(std::size_t n) { + auto last = p_ + n; +- if(last >= end()) ++ if (last >= end()) + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + ++count_; + auto p = p_; +@@ -74,16 +72,14 @@ + return p; + } + +- void +- dealloc() +- { +- if(--count_) ++ void dealloc() { ++ if (--count_) + return; + p_ = reinterpret_cast(this + 1); + } + }; + +-} // detail ++} // namespace detail + + /** A non-thread-safe allocator optimized for @ref basic_fields. + +@@ -101,9 +97,8 @@ + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. + */ +-template +-struct fields_alloc +-{ ++template ++struct fields_alloc { + detail::static_pool* pool_; + + public: +@@ -116,9 +111,8 @@ + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + +- template +- struct rebind +- { ++ template ++ struct rebind { + using other = fields_alloc; + }; + +@@ -129,76 +123,41 @@ + fields_alloc() = default; + #endif + +- explicit +- fields_alloc(std::size_t size) +- : pool_(&detail::static_pool::construct(size)) +- { ++ explicit fields_alloc(std::size_t size) : pool_(&detail::static_pool::construct(size)) {} ++ ++ fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ ++ template ++ fields_alloc(fields_alloc const& other) : pool_(&detail::static_pool::share(*other.pool_)) {} ++ ++ ~fields_alloc() { pool_->destroy(); } ++ ++ value_type* allocate(size_type n) { ++ return static_cast(pool_->alloc(n * sizeof(T))); + } + +- fields_alloc(fields_alloc const& other) +- : pool_(&other.pool_->share()) +- { ++ void deallocate(value_type*, size_type) { pool_->dealloc(); } ++ ++#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 ++ template ++ void construct(U* ptr, Args&&... args) { ++ ::new (static_cast(ptr)) U(std::forward(args)...); + } + +- template +- fields_alloc(fields_alloc const& other) +- : pool_(&other.pool_->share()) +- { +- } +- +- ~fields_alloc() +- { +- pool_->destroy(); +- } +- +- value_type* +- allocate(size_type n) +- { +- return static_cast( +- pool_->alloc(n * sizeof(T))); +- } +- +- void +- deallocate(value_type*, size_type) +- { +- pool_->dealloc(); +- } +- +-#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 +- template +- void +- construct(U* ptr, Args&&... args) +- { +- ::new(static_cast(ptr)) U( +- std::forward(args)...); +- } +- +- template +- void +- destroy(U* ptr) +- { ++ template ++ void destroy(U* ptr) { + ptr->~U(); + } + #endif + +- template +- friend +- bool +- operator==( +- fields_alloc const& lhs, +- fields_alloc const& rhs) +- { ++ template ++ friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool_ == &rhs.pool_; + } + +- template +- friend +- bool +- operator!=( +- fields_alloc const& lhs, +- fields_alloc const& rhs) +- { +- return ! (lhs == rhs); ++ template ++ friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { ++ return !(lhs == rhs); + } + }; + +--- upstream/http/server/fast/http_server_fast.cpp ++++ wasip3/http/server/fast/http_server_fast.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) + // +@@ -15,10 +32,18 @@ + + #include "fields_alloc.hpp" + +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + #include +-#include + #include + #include + #include +@@ -26,69 +51,85 @@ + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + +-class http_worker +-{ ++class http_worker { + public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + +- http_worker(tcp::acceptor& acceptor, const std::string& doc_root) : +- acceptor_(acceptor), +- doc_root_(doc_root) +- { +- } +- +- void start() +- { ++ http_worker(tcp::acceptor& acceptor, const std::string& doc_root) ++ : acceptor_(acceptor), doc_root_(doc_root) {} ++ ++ void start() { + accept(); + check_deadline(); + } + + private: + using alloc_t = fields_alloc; +- //using request_body_t = http::basic_dynamic_body>; ++ // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. +@@ -110,49 +151,43 @@ + boost::optional> parser_; + + // The timer putting a time limit on requests. +- net::steady_timer request_deadline_{ +- acceptor_.get_executor(), (std::chrono::steady_clock::time_point::max)()}; ++ net::steady_timer request_deadline_{acceptor_.get_executor(), ++ (std::chrono::steady_clock::time_point::max)()}; + + // The string-based response message. +- boost::optional>> string_response_; ++ boost::optional>> ++ string_response_; + + // The string-based response serializer. +- boost::optional>> string_serializer_; ++ boost::optional>> ++ string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. +- boost::optional>> file_serializer_; +- +- void accept() +- { ++ boost::optional>> ++ file_serializer_; ++ ++ void accept() { + // Clean up any previous connection. + beast::error_code ec; + socket_.close(ec); + buffer_.consume(buffer_.size()); + +- acceptor_.async_accept( +- socket_, +- [this](beast::error_code ec) +- { +- if (ec) +- { +- accept(); +- } +- else +- { +- // Request must be fully processed within 60 seconds. +- request_deadline_.expires_after( +- std::chrono::seconds(60)); +- +- read_request(); +- } +- }); +- } +- +- void read_request() +- { ++ acceptor_.async_accept(socket_, [this](beast::error_code ec) { ++ if (ec) { ++ accept(); ++ } else { ++ // Request must be fully processed within 60 seconds. ++ request_deadline_.expires_after(std::chrono::seconds(60)); ++ ++ read_request(); ++ } ++ }); ++ } ++ ++ void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. +@@ -164,50 +199,33 @@ + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // +- parser_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); +- +- http::async_read( +- socket_, +- buffer_, +- *parser_, +- [this](beast::error_code ec, std::size_t) +- { +- if (ec) +- accept(); +- else +- process_request(parser_->get()); +- }); +- } +- +- void process_request(http::request> const& req) +- { +- switch (req.method()) +- { +- case http::verb::get: +- send_file(req.target()); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- send_bad_response( +- http::status::bad_request, +- "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); +- break; +- } +- } +- +- void send_bad_response( +- http::status status, +- std::string const& error) +- { +- string_response_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); ++ parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); ++ ++ http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { ++ if (ec) ++ accept(); ++ else ++ process_request(parser_->get()); ++ }); ++ } ++ ++ void process_request(http::request> const& req) { ++ switch (req.method()) { ++ case http::verb::get: send_file(req.target()); break; ++ ++ default: ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ send_bad_response( ++ http::status::bad_request, ++ "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); ++ break; ++ } ++ } ++ ++ void send_bad_response(http::status status, std::string const& error) { ++ string_response_.emplace(std::piecewise_construct, std::make_tuple(), ++ std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); +@@ -218,52 +236,34 @@ + + string_serializer_.emplace(*string_response_); + +- http::async_write( +- socket_, +- *string_serializer_, +- [this](beast::error_code ec, std::size_t) +- { +- socket_.shutdown(tcp::socket::shutdown_send, ec); +- string_serializer_.reset(); +- string_response_.reset(); +- accept(); +- }); +- } +- +- void send_file(beast::string_view target) +- { ++ http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { ++ socket_.shutdown(tcp::socket::shutdown_send, ec); ++ string_serializer_.reset(); ++ string_response_.reset(); ++ accept(); ++ }); ++ } ++ ++ void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". +- if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) +- { +- send_bad_response( +- http::status::not_found, +- "File not found\r\n"); ++ if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) { ++ send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; +- full_path.append( +- target.data(), +- target.size()); ++ full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; +- file.open( +- full_path.c_str(), +- beast::file_mode::read, +- ec); +- if(ec) +- { +- send_bad_response( +- http::status::not_found, +- "File not found\r\n"); ++ file.open(full_path.c_str(), beast::file_mode::read, ec); ++ if (ec) { ++ send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + +- file_response_.emplace( +- std::piecewise_construct, +- std::make_tuple(), +- std::make_tuple(alloc_)); ++ file_response_.emplace(std::piecewise_construct, std::make_tuple(), ++ std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); +@@ -274,47 +274,34 @@ + + file_serializer_.emplace(*file_response_); + +- http::async_write( +- socket_, +- *file_serializer_, +- [this](beast::error_code ec, std::size_t) +- { +- socket_.shutdown(tcp::socket::shutdown_send, ec); +- file_serializer_.reset(); +- file_response_.reset(); +- accept(); +- }); +- } +- +- void check_deadline() +- { ++ http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { ++ socket_.shutdown(tcp::socket::shutdown_send, ec); ++ file_serializer_.reset(); ++ file_response_.reset(); ++ accept(); ++ }); ++ } ++ ++ void check_deadline() { + // The deadline may have moved, so check it has really passed. +- if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) +- { ++ if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. +- request_deadline_.expires_at( +- (std::chrono::steady_clock::time_point::max)()); +- } +- +- request_deadline_.async_wait( +- [this](beast::error_code) +- { +- check_deadline(); +- }); ++ request_deadline_.expires_at((std::chrono::steady_clock::time_point::max)()); ++ } ++ ++ request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } + }; + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 6) +- { +- std::cerr << "Usage: http_server_fast
{spin|block}\n"; ++ if (argc != 6) { ++ std::cerr << "Usage: http_server_fast
" ++ "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; +@@ -328,23 +315,21 @@ + int num_workers = std::atoi(argv[4]); + bool spin = (std::strcmp(argv[5], "spin") == 0); + +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; +- for (int i = 0; i < num_workers; ++i) +- { ++ for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) +- for (;;) ioc.poll(); ++ for (;;) ++ ioc.poll(); + else +- ioc.run(); +- } +- catch (const std::exception& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/flex/http_server_flex.cpp ++++ wasip3/http/server/flex/http_server_flex.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,85 +31,98 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include +-#include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -103,15 +134,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -122,9 +148,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -135,9 +159,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -148,19 +170,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -169,19 +189,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -191,10 +210,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -205,9 +222,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -225,7 +240,7 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +@@ -234,16 +249,11 @@ + // Handles an HTTP server connection. + // This uses the Curiously Recurring Template Pattern so that + // the same code works with both SSL streams and regular sockets. +-template +-class session +-{ ++template ++class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. +- Derived& +- derived() +- { +- return static_cast(*this); +- } ++ Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; +@@ -253,78 +263,49 @@ + + public: + // Take ownership of the buffer +- session( +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : doc_root_(doc_root) +- , buffer_(std::move(buffer)) +- { +- } +- +- void +- do_read() +- { ++ session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) ++ : doc_root_(doc_root), buffer_(std::move(buffer)) {} ++ ++ void do_read() { + // Set the timeout. +- beast::get_lowest_layer( +- derived().stream()).expires_after(std::chrono::seconds(30)); ++ beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( +- derived().stream(), +- buffer_, +- req_, +- beast::bind_front_handler( +- &session::on_read, +- derived().shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ derived().stream(), buffer_, req_, ++ beast::bind_front_handler(&session::on_read, derived().shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + return derived().do_eof(); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send the response +- send_response( +- handle_request(*doc_root_, std::move(req_))); +- } +- +- void +- send_response(http::message_generator&& msg) +- { ++ send_response(handle_request(*doc_root_, std::move(req_))); ++ } ++ ++ void send_response(http::message_generator&& msg) { + bool keep_alive = msg.keep_alive(); + + // Write the response +- beast::async_write( +- derived().stream(), +- std::move(msg), +- beast::bind_front_handler( +- &session::on_write, +- derived().shared_from_this(), +- keep_alive)); +- } +- +- void +- on_write( +- bool keep_alive, +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ beast::async_write(derived().stream(), std::move(msg), ++ beast::bind_front_handler(&session::on_write, ++ derived().shared_from_this(), keep_alive)); ++ } ++ ++ void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); +@@ -336,49 +317,30 @@ + }; + + // Handles a plain HTTP connection +-class plain_session +- : public session +- , public std::enable_shared_from_this +-{ ++class plain_session : public session, ++ public std::enable_shared_from_this { + beast::tcp_stream stream_; + + public: + // Create the session +- plain_session( +- tcp::socket&& socket, +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(socket)) +- { +- } ++ plain_session(tcp::socket&& socket, beast::flat_buffer buffer, ++ std::shared_ptr const& doc_root) ++ : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class +- beast::tcp_stream& +- stream() +- { +- return stream_; +- } ++ beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), +- beast::bind_front_handler( +- &session::do_read, +- shared_from_this())); +- } +- +- void +- do_eof() +- { ++ beast::bind_front_handler(&session::do_read, shared_from_this())); ++ } ++ ++ void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +@@ -388,62 +350,37 @@ + }; + + // Handles an SSL HTTP connection +-class ssl_session +- : public session +- , public std::enable_shared_from_this +-{ ++class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + + public: + // Create the session +- ssl_session( +- tcp::socket&& socket, +- ssl::context& ctx, +- beast::flat_buffer buffer, +- std::shared_ptr const& doc_root) +- : session( +- std::move(buffer), +- doc_root) +- , stream_(std::move(socket), ctx) +- { +- } ++ ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, ++ std::shared_ptr const& doc_root) ++ : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class +- ssl::stream& +- stream() +- { +- return stream_; +- } ++ ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self]() { + // Set the timeout. +- beast::get_lowest_layer(self->stream_).expires_after( +- std::chrono::seconds(30)); ++ beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( +- ssl::stream_base::server, +- self->buffer_.data(), +- beast::bind_front_handler( +- &ssl_session::on_handshake, +- self)); ++ ssl::stream_base::server, self->buffer_.data(), ++ beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + +- void +- on_handshake( +- beast::error_code ec, +- std::size_t bytes_used) +- { +- if(ec) ++ void on_handshake(beast::error_code ec, std::size_t bytes_used) { ++ if (ec) + return fail(ec, "handshake"); + + // Consume the portion of the buffer used by the handshake +@@ -452,23 +389,17 @@ + do_read(); + } + +- void +- do_eof() +- { ++ void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( +- beast::bind_front_handler( +- &ssl_session::on_shutdown, +- shared_from_this())); +- } +- +- void +- on_shutdown(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); ++ } ++ ++ void on_shutdown(beast::error_code ec) { ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -478,153 +409,103 @@ + //------------------------------------------------------------------------------ + + // Detects SSL handshakes +-class detect_session : public std::enable_shared_from_this +-{ ++class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + + public: +- detect_session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , ctx_(ctx) +- , doc_root_(doc_root) +- { +- } ++ detect_session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector +- void +- run() +- { ++ void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake +- async_detect_ssl( +- stream_, +- buffer_, +- beast::bind_front_handler( +- &detect_session::on_detect, +- shared_from_this())); +- } +- +- void +- on_detect(beast::error_code ec, bool result) +- { +- if(ec) ++ async_detect_ssl(stream_, buffer_, ++ beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); ++ } ++ ++ void on_detect(beast::error_code ec, bool result) { ++ if (ec) + return fail(ec, "detect"); + +- if(result) +- { ++ if (result) { + // Launch SSL session +- std::make_shared( +- stream_.release_socket(), +- ctx_, +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), ++ doc_root_) ++ ->run(); + return; + } + + // Launch plain session +- std::make_shared( +- stream_.release_socket(), +- std::move(buffer_), +- doc_root_)->run(); ++ std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) ++ ->run(); + } + }; + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the detector session and run it +- std::make_shared( +- std::move(socket), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection +@@ -634,24 +515,21 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-flex
\n" << +- "Example:\n" << +- " http-server-flex 0.0.0.0 8080 .\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-flex
\n" ++ << "Example:\n" ++ << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -660,22 +538,10 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/small/http_server_small.cpp ++++ wasip3/http/server/small/http_server_small.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) + // +@@ -13,50 +30,50 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + #include +-#include + #include + #include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from +- +-namespace my_program_state +-{ +- std::size_t +- request_count() +- { +- static std::size_t count = 0; +- return ++count; +- } +- +- std::time_t +- now() +- { +- return std::time(0); +- } +-} +- +-class http_connection : public std::enable_shared_from_this +-{ ++#include ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from ++ ++namespace my_program_state { ++std::size_t request_count() { ++ static std::size_t count = 0; ++ return ++count; ++} ++ ++std::time_t now() { ++ return std::time(0); ++} ++} // namespace my_program_state ++ ++class http_connection : public std::enable_shared_from_this { + public: +- http_connection(tcp::socket socket) +- : socket_(std::move(socket)) +- { +- } ++ http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. +- void +- start() +- { ++ void start() { + read_request(); + check_deadline(); + } +@@ -75,92 +92,69 @@ + http::response response_; + + // The timer for putting a deadline on connection processing. +- net::steady_timer deadline_{ +- socket_.get_executor(), std::chrono::seconds(60)}; ++ net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. +- void +- read_request() +- { ++ void read_request() { + auto self = shared_from_this(); + +- http::async_read( +- socket_, +- buffer_, +- request_, +- [self](beast::error_code ec, +- std::size_t bytes_transferred) +- { +- boost::ignore_unused(bytes_transferred); +- if(!ec) +- self->process_request(); +- }); ++ http::async_read(socket_, buffer_, request_, ++ [self](beast::error_code ec, std::size_t bytes_transferred) { ++ boost::ignore_unused(bytes_transferred); ++ if (!ec) ++ self->process_request(); ++ }); + } + + // Determine what needs to be done with the request message. +- void +- process_request() +- { ++ void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + +- switch(request_.method()) +- { +- case http::verb::get: +- response_.result(http::status::ok); +- response_.set(http::field::server, "Beast"); +- create_response(); +- break; +- +- default: +- // We return responses indicating an error if +- // we do not recognize the request method. +- response_.result(http::status::bad_request); +- response_.set(http::field::content_type, "text/plain"); +- beast::ostream(response_.body()) +- << "Invalid request-method '" +- << std::string(request_.method_string()) +- << "'"; +- break; ++ switch (request_.method()) { ++ case http::verb::get: ++ response_.result(http::status::ok); ++ response_.set(http::field::server, "Beast"); ++ create_response(); ++ break; ++ ++ default: ++ // We return responses indicating an error if ++ // we do not recognize the request method. ++ response_.result(http::status::bad_request); ++ response_.set(http::field::content_type, "text/plain"); ++ beast::ostream(response_.body()) ++ << "Invalid request-method '" << std::string(request_.method_string()) << "'"; ++ break; + } + + write_response(); + } + + // Construct a response message based on the program state. +- void +- create_response() +- { +- if(request_.target() == "/count") +- { ++ void create_response() { ++ if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" +- << "Request count\n" +- << "\n" +- << "

Request count

\n" +- << "

There have been " +- << my_program_state::request_count() +- << " requests so far.

\n" +- << "\n" +- << "\n"; +- } +- else if(request_.target() == "/time") +- { ++ << "Request count\n" ++ << "\n" ++ << "

Request count

\n" ++ << "

There have been " << my_program_state::request_count() ++ << " requests so far.

\n" ++ << "\n" ++ << "\n"; ++ } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); +- beast::ostream(response_.body()) +- << "\n" +- << "Current time\n" +- << "\n" +- << "

Current time

\n" +- << "

The current time is " +- << my_program_state::now() +- << " seconds since the epoch.

\n" +- << "\n" +- << "\n"; +- } +- else +- { ++ beast::ostream(response_.body()) << "\n" ++ << "Current time\n" ++ << "\n" ++ << "

Current time

\n" ++ << "

The current time is " << my_program_state::now() ++ << " seconds since the epoch.

\n" ++ << "\n" ++ << "\n"; ++ } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; +@@ -168,62 +162,43 @@ + } + + // Asynchronously transmit the response message. +- void +- write_response() +- { ++ void write_response() { + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + +- http::async_write( +- socket_, +- response_, +- [self](beast::error_code ec, std::size_t) +- { +- self->socket_.shutdown(tcp::socket::shutdown_send, ec); +- self->deadline_.cancel(); +- }); ++ http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { ++ self->socket_.shutdown(tcp::socket::shutdown_send, ec); ++ self->deadline_.cancel(); ++ }); + } + + // Check whether we have spent enough time on this connection. +- void +- check_deadline() +- { ++ void check_deadline() { + auto self = shared_from_this(); + +- deadline_.async_wait( +- [self](beast::error_code ec) +- { +- if(!ec) +- { +- // Close socket to cancel any outstanding operation. +- self->socket_.close(ec); +- } +- }); ++ deadline_.async_wait([self](beast::error_code ec) { ++ if (!ec) { ++ // Close socket to cancel any outstanding operation. ++ self->socket_.close(ec); ++ } ++ }); + } + }; + + // "Loop" forever accepting new connections. +-void +-http_server(tcp::acceptor& acceptor, tcp::socket& socket) +-{ +- acceptor.async_accept(socket, +- [&](beast::error_code ec) +- { +- if(!ec) +- std::make_shared(std::move(socket))->start(); +- http_server(acceptor, socket); +- }); +-} +- +-int +-main(int argc, char* argv[]) +-{ +- try +- { ++void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { ++ acceptor.async_accept(socket, [&](beast::error_code ec) { ++ if (!ec) ++ std::make_shared(std::move(socket))->start(); ++ http_server(acceptor, socket); ++ }); ++} ++ ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if(argc != 3) +- { ++ if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; +@@ -235,16 +210,14 @@ + auto const address = net::ip::make_address(argv[1]); + unsigned short port = static_cast(std::atoi(argv[2])); + +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/stackless/http_server_stackless.cpp ++++ wasip3/http/server/stackless/http_server_stackless.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,84 +30,98 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include +-#include ++#include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -102,15 +133,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -121,9 +147,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -134,9 +158,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -147,19 +169,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -168,19 +188,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -190,10 +209,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -204,17 +221,12 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -223,40 +235,26 @@ + + public: + // Take ownership of the socket +- explicit +- session( +- tcp::socket&& socket, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket)) +- , doc_root_(doc_root) +- { +- } ++ explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) ++ : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(stream_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop(beast::error_code ec, std::size_t bytes_transferred) +- { ++ net::dispatch( ++ stream_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- reenter(*this) +- { +- for(;;) +- { ++ reenter(*this) { ++ for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; +@@ -265,39 +263,33 @@ + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request +- yield http::async_read(stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::loop, +- shared_from_this())); +- +- if(ec == http::error::end_of_stream) +- { ++ yield http::async_read( ++ stream_, buffer_, req_, ++ beast::bind_front_handler(&session::loop, shared_from_this())); ++ ++ if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + yield { + // Handle request +- http::message_generator msg = +- handle_request(*doc_root_, std::move(req_)); ++ http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( +- stream_, +- std::move(msg), +- beast::bind_front_handler( +- &session::loop, shared_from_this())); ++ stream_, std::move(msg), ++ beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive_) +- { ++ if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -311,99 +303,72 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , socket_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ++ acceptor_(net::make_strand(ioc)), ++ socket_(net::make_strand(ioc)), ++ doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen(net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- beast::bind_front_handler( +- &listener::loop, +- shared_from_this())); +- if(ec) +- { ++ socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket_), +- doc_root_)->run(); ++ std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand +@@ -412,46 +377,32 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-stackless
\n" << +- "Example:\n" << +- " http-server-stackless 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-stackless
\n" ++ << "Example:\n" ++ << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port +- std::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/stackless-ssl/http_server_stackless_ssl.cpp ++++ wasip3/http/server/stackless-ssl/http_server_stackless_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,88 +31,102 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include + #include ++#include + #include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -106,15 +138,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -125,9 +152,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -138,9 +163,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -151,19 +174,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -172,19 +193,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -194,10 +214,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -208,9 +226,7 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to +@@ -228,17 +244,14 @@ + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + +- if(ec == net::ssl::error::stream_truncated) ++ if (ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; +@@ -247,53 +260,37 @@ + + public: + // Take ownership of the socket +- explicit +- session( +- tcp::socket&& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +- : stream_(std::move(socket), ctx) +- , doc_root_(doc_root) +- { +- } ++ explicit session(tcp::socket&& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) ++ : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(stream_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop(beast::error_code ec, std::size_t bytes_transferred) +- { ++ net::dispatch( ++ stream_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- reenter(*this) +- { ++ reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, +- std::bind( +- &session::loop, shared_from_this(), +- std::placeholders::_1, 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "handshake"); + +- for(;;) +- { ++ for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + +@@ -304,20 +301,18 @@ + // Read a request + yield http::async_read( + stream_, buffer_, req_, +- beast::bind_front_handler( +- &session::loop, shared_from_this())); ++ beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + yield { + // Handle request +- http::message_generator msg = +- handle_request(*doc_root_, std::move(req_)); ++ http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); +@@ -325,14 +320,12 @@ + // Send the response + beast::async_write( + stream_, std::move(msg), +- beast::bind_front_handler( +- &session::loop, shared_from_this())); ++ beast::bind_front_handler(&session::loop, shared_from_this())); + } + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive_) +- { ++ if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -344,117 +337,82 @@ + + // Perform the SSL shutdown + yield stream_.async_shutdown( +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- std::shared_ptr const& doc_root) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- , socket_(net::make_strand(ioc)) +- , doc_root_(doc_root) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ std::shared_ptr const& doc_root) ++ : ioc_(ioc), ++ ctx_(ctx), ++ acceptor_(net::make_strand(ioc)), ++ socket_(net::make_strand(ioc)), ++ doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- std::bind( +- &listener::loop, +- shared_from_this(), +- std::placeholders::_1)); +- if(ec) +- { ++ socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it +- std::make_shared( +- std::move(socket_), +- ctx_, +- doc_root_)->run(); ++ std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand +@@ -463,29 +421,26 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: http-server-stackless-ssl
\n" << +- "Example:\n" << +- " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: http-server-stackless-ssl
\n" ++ << "Example:\n" ++ << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -494,22 +449,10 @@ + load_server_certificate(ctx); + + // Create and launch a listening port +- std::make_shared( +- ioc, +- ctx, +- tcp::endpoint{address, port}, +- doc_root)->run(); ++ std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/http/server/sync/http_server_sync.cpp ++++ wasip3/http/server/sync/http_server_sync.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,81 +30,94 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include +-#include + #include + #include + #include + #include + #include +-#include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if (base.empty()) +- return std::string(path); ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) ++ return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -99,15 +129,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -118,9 +143,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -131,9 +154,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -144,19 +165,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -165,19 +184,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -187,10 +205,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -201,36 +217,28 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-void +-do_session( +- tcp::socket& socket, +- std::shared_ptr const& doc_root) +-{ ++void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle request +- http::message_generator msg = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -238,10 +246,9 @@ + // Send the response + beast::write(socket, std::move(msg), ec); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -256,17 +263,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: http-server-sync
\n" << +- "Example:\n" << +- " http-server-sync 0.0.0.0 8080 .\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: http-server-sync
\n" ++ << "Example:\n" ++ << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -274,12 +277,11 @@ + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -287,14 +289,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread{std::bind( +- &do_session, +- std::move(socket), +- doc_root)}.detach(); ++ do_session(socket, doc_root); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/http/server/sync-ssl/http_server_sync_ssl.cpp ++++ wasip3/http/server/sync-ssl/http_server_sync_ssl.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,84 +31,97 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ + #include + #include + #include ++#include + #include + #include + #include + #include + #include +-#include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -102,15 +133,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -121,9 +147,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -134,9 +158,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -147,19 +169,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -168,19 +188,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == beast::errc::no_such_file_or_directory) ++ if (ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -190,10 +209,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -204,19 +221,13 @@ + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handles an HTTP server connection +-void +-do_session( +- tcp::socket& socket, +- ssl::context& ctx, +- std::shared_ptr const& doc_root) +-{ ++void do_session(tcp::socket& socket, ssl::context& ctx, ++ std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket +@@ -224,25 +235,23 @@ + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::server, ec); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + +- for(;;) +- { ++ for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); +- if(ec == http::error::end_of_stream) ++ if (ec == http::error::end_of_stream) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Handle request +- http::message_generator msg = +- handle_request(*doc_root, std::move(req)); ++ http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -250,11 +259,10 @@ + // Send the response + beast::write(stream, std::move(msg), ec); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; +@@ -263,7 +271,7 @@ + + // Perform the SSL shutdown + stream.shutdown(ec); +- if(ec) ++ if (ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +@@ -271,17 +279,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: http-server-sync-ssl
\n" << +- "Example:\n" << +- " http-server-sync-ssl 0.0.0.0 8080 .\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: http-server-sync-ssl
\n" ++ << "Example:\n" ++ << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +@@ -289,7 +293,7 @@ + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -299,8 +303,7 @@ + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -308,15 +311,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread{std::bind( +- &do_session, +- std::move(socket), +- std::ref(ctx), +- doc_root)}.detach(); ++ do_session(socket, ctx, doc_root); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/client/async/websocket_client_async.cpp ++++ wasip3/websocket/client/async/websocket_client_async.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,34 +31,31 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp_fixture::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; +@@ -48,39 +63,22 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc) +- : resolver_(net::make_strand(ioc)) +- , ws_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) ++ : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set the timeout for the operation +@@ -88,16 +86,12 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ void on_connect(beast::error_code ec, ++ webcpp_fixture::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Turn off the timeout on the tcp_stream, because +@@ -105,18 +99,13 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); ++ })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. +@@ -125,64 +114,41 @@ + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); +- ++ + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_close, shared_from_this())); + } + +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -194,15 +160,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async \n" << +- "Example:\n" << +- " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async \n" ++ << "Example:\n" ++ << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -210,14 +173,14 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/async-local/websocket_client_async_local.cpp ++++ wasip3/websocket/client/async-local/websocket_client_async_local.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -16,8 +34,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -26,24 +44,21 @@ + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; +@@ -51,20 +66,10 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc) +- : ws_(net::make_strand(ioc)) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation +- void +- run( +- char const* path, +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; +@@ -72,91 +77,59 @@ + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + +- void +- on_connect(beast::error_code ec) +- { +- if(ec) ++ void on_connect(beast::error_code ec) { ++ if (ec) + return fail(ec, "connect"); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-local"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); ++ })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); +- ++ + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); + } + +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); +- ++ + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_close, shared_from_this())); + } + +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -168,15 +141,13 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 5) +- { +- std::cerr << +- "Usage: websocket-client-async-local \n" << +- "Example:\n" << +- " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; ++ if (argc != 5) { ++ std::cerr ++ << "Usage: websocket-client-async-local \n" ++ << "Example:\n" ++ << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; +@@ -185,26 +156,23 @@ + auto const text = argv[4]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ +-std::cerr << +- "Local sockets not available on this platform" << std::endl; +-return EXIT_FAILURE; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; ++ return EXIT_FAILURE; + } + + #endif +--- upstream/websocket/client/async-ssl/websocket_client_async_ssl.cpp ++++ wasip3/websocket/client/async-ssl/websocket_client_async_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,38 +32,35 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include ++#include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp_fixture::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; +@@ -52,26 +68,15 @@ + + public: + // Resolver and socket require an io_context +- explicit +- session(net::io_context& ioc, ssl::context& ctx) +- : resolver_(net::make_strand(ioc)) +- , ws_(net::make_strand(ioc), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -85,19 +90,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -105,38 +102,30 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp_fixture::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); +- ++ + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); +- ++ + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_ssl_handshake, +- shared_from_this())); +- } +- +- void +- on_ssl_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); ++ } ++ ++ void on_ssl_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -144,79 +133,51 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); ++ })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -228,15 +189,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async-ssl \n" << +- "Example:\n" << +- " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async-ssl \n" ++ << "Example:\n" ++ << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -244,7 +202,7 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -260,7 +218,7 @@ + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp ++++ wasip3/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,39 +32,36 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" +- +-#include +-#include +-#include ++#include "common/root_certificates.hpp" ++ + #include + #include + #include ++#include + #include + #include + #include + #include +- +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++#include ++#include ++ ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-class session : public std::enable_shared_from_this +-{ +- tcp::resolver resolver_; ++class session : public std::enable_shared_from_this { ++ webcpp_fixture::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; +@@ -53,33 +69,21 @@ + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. +- session(net::strand ex, ssl::context& ctx) +- : resolver_(ex) +- , ws_(ex, ctx) +- { +- } ++ session(net::strand ex, ssl::context& ctx) ++ : resolver_(ex), ws_(ex, ctx) {} ++ + public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. +- explicit +- session(ssl::context& ctx) +- : session(net::make_strand(net::system_executor{}), ctx) +- { +- } ++ explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) ++ : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation +- void +- run( +- char const* host, +- char const* port, +- char const* text) +- { ++ void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) +- { +- beast::error_code ec{ +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()}; ++ if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { ++ beast::error_code ec{static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } +@@ -93,19 +97,11 @@ + + // Look up the domain name + resolver_.async_resolve( +- host, +- port, +- beast::bind_front_handler( +- &session::on_resolve, +- shared_from_this())); +- } +- +- void +- on_resolve( +- beast::error_code ec, +- tcp::resolver::results_type results) +- { +- if(ec) ++ host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); ++ } ++ ++ void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -113,16 +109,12 @@ + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( +- results, +- beast::bind_front_handler( +- &session::on_connect, +- shared_from_this())); +- } +- +- void +- on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) +- { +- if(ec) ++ results, beast::bind_front_handler(&session::on_connect, shared_from_this())); ++ } ++ ++ void on_connect(beast::error_code ec, ++ webcpp_fixture::resolver::results_type::endpoint_type ep) { ++ if (ec) + return fail(ec, "connect"); + + // Set a timeout on the operation +@@ -136,15 +128,11 @@ + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, +- beast::bind_front_handler( +- &session::on_ssl_handshake, +- shared_from_this())); +- } +- +- void +- on_ssl_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); ++ } ++ ++ void on_ssl_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -152,79 +140,51 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-async-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); ++ })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Send the message +- ws_.async_write( +- net::buffer(text_), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(net::buffer(text_), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, +- beast::bind_front_handler( +- &session::on_close, +- shared_from_this())); +- } +- +- void +- on_close(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_close, shared_from_this())); ++ } ++ ++ void on_close(beast::error_code ec) { ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -236,22 +196,19 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-async-ssl \n" << +- "Example:\n" << +- " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-async-ssl \n" ++ << "Example:\n" ++ << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + +- ++ webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + +@@ -262,12 +219,12 @@ + load_root_certificates(ctx); + + // Launch the asynchronous operation +- std::make_shared(ctx)->run(host, port, text); ++ std::make_shared(ioc, ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. +- net::query(net::system_executor(), net::execution::context).join(); ++ ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/awaitable/websocket_client_awaitable.cpp ++++ wasip3/websocket/client/awaitable/websocket_client_awaitable.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -16,8 +34,8 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +@@ -25,18 +43,16 @@ + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; ++namespace net = boost::asio; + + // Sends a WebSocket message and prints the response +-net::awaitable +-do_session(std::string host, std::string port, std::string text) +-{ ++net::awaitable do_session(std::string host, std::string port, std::string text) { + auto executor = co_await net::this_coro::executor; +- auto resolver = net::ip::tcp::resolver{ executor }; +- auto stream = websocket::stream{ executor }; ++ auto resolver = webcpp_fixture::resolver{executor}; ++ auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); +@@ -57,18 +73,13 @@ + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket +- stream.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::client)); ++ stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- stream.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set( +- http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); +@@ -93,18 +104,13 @@ + + //------------------------------------------------------------------------------ + +-int +-main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr +- << "Usage: websocket-client-awaitable \n" +- << "Example:\n" +- << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-awaitable \n" ++ << "Example:\n" ++ << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -112,24 +118,18 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- net::co_spawn( +- ioc, +- do_session(host, port, text), +- [](std::exception_ptr e) +- { +- if(e) +- std::rethrow_exception(e); +- }); ++ net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { ++ if (e) ++ std::rethrow_exception(e); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); +- } +- catch(std::exception const& e) +- { ++ ioc.run(); // lint-run: drives the application's network operations ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -138,9 +138,7 @@ + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/websocket/client/coro/websocket_client_coro.cpp ++++ wasip3/websocket/client/coro/websocket_client_coro.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,47 +31,39 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-void +-do_session( +- std::string host, +- std::string const& port, +- std::string const& text, +- net::io_context& ioc, +- net::yield_context yield) +-{ ++void do_session(std::string host, std::string const& port, std::string const& text, ++ webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -61,7 +71,7 @@ + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Update the host_ string. This will provide the value of the +@@ -74,27 +84,22 @@ + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message +@@ -102,12 +107,12 @@ + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -118,15 +123,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-coro \n" << +- "Example:\n" << +- " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-coro \n" ++ << "Example:\n" ++ << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -134,31 +136,27 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(text), +- std::ref(ioc), +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn(ioc, ++ std::bind(&do_session, std::string(host), std::string(port), ++ std::string(text), std::ref(ioc), std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp ++++ wasip3/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,53 +32,44 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Sends a WebSocket message and prints the response +-void +-do_session( +- std::string host, +- std::string const& port, +- std::string const& text, +- net::io_context& ioc, +- ssl::context& ctx, +- net::yield_context yield) +-{ ++void do_session(std::string host, std::string const& port, std::string const& text, ++ webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O +- tcp::resolver resolver(ioc); ++ webcpp_fixture::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation +@@ -67,12 +77,11 @@ + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "connect"); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) +- { ++ if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + return fail(ec, "connect"); + } +@@ -89,17 +98,14 @@ + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -107,18 +113,16 @@ + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::client)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message +@@ -126,12 +130,12 @@ + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully +@@ -142,15 +146,12 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char** argv) +-{ ++int main(int argc, char** argv) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-coro-ssl \n" << +- "Example:\n" << +- " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-coro-ssl \n" ++ << "Example:\n" ++ << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; +@@ -158,7 +159,7 @@ + auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -170,29 +171,25 @@ + load_root_certificates(ctx); + + // Launch the asynchronous operation +- boost::asio::spawn(ioc, std::bind( +- &do_session, +- std::string(host), +- std::string(port), +- std::string(text), +- std::ref(ioc), +- std::ref(ctx), +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_session, std::string(host), std::string(port), std::string(text), ++ std::ref(ioc), std::ref(ctx), std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service. The call will return when + // the socket is closed. +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/client/sync/websocket_client_sync.cpp ++++ wasip3/websocket/client/sync/websocket_client_sync.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -15,43 +33,39 @@ + + //[example_websocket_client + +-#include +-#include + #include + #include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-sync \n" << +- "Example:\n" << +- " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-sync \n" ++ << "Example:\n" ++ << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const port = argv[2]; ++ auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // These objects perform our I/O +- tcp::resolver resolver{ioc}; ++ webcpp_fixture::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name +@@ -66,13 +80,10 @@ + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + ws.handshake(host, "/"); +@@ -93,9 +104,7 @@ + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp ++++ wasip3/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,45 +32,41 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/root_certificates.hpp" ++#include "common/root_certificates.hpp" + +-#include +-#include +-#include + #include + #include + #include ++#include + #include + #include + #include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + // Sends a WebSocket message and prints the response +-int main(int argc, char** argv) +-{ +- try +- { ++int main(int argc, char** argv) { ++ try { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr << +- "Usage: websocket-client-sync-ssl \n" << +- "Example:\n" << +- " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-client-sync-ssl \n" ++ << "Example:\n" ++ << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; +- auto const port = argv[2]; +- auto const text = argv[3]; ++ auto const port = argv[2]; ++ auto const text = argv[3]; + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; +@@ -63,7 +78,7 @@ + load_root_certificates(ctx); + + // These objects perform our I/O +- tcp::resolver resolver{ioc}; ++ webcpp_fixture::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name +@@ -73,11 +88,9 @@ + auto ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) +- if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) +- { +- throw beast::system_error( +- static_cast(::ERR_get_error()), +- net::error::get_ssl_category()); ++ if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { ++ throw beast::system_error(static_cast(::ERR_get_error()), ++ net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification +@@ -92,13 +105,10 @@ + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::request_type& req) +- { +- req.set(http::field::user_agent, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-client-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { ++ req.set(http::field::user_agent, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); ++ })); + + // Perform the websocket handshake + ws.handshake(host, "/"); +@@ -119,9 +129,7 @@ + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/server/async/websocket_server_async.cpp ++++ wasip3/websocket/server/async/websocket_server_async.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,138 +31,98 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include + #include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- session(tcp::socket&& socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation +- void +- on_run() +- { ++ void on_run() { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-async"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); ++ })); + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) +- return; +- +- if(ec) ++ if (ec == websocket::error::closed) ++ return; ++ ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -158,82 +136,57 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(ioc) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } +@@ -245,37 +198,26 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-async
\n" << +- "Example:\n" << +- " websocket-server-async 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-async
\n" ++ << "Example:\n" ++ << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/async-local/websocket_server_async_local.cpp ++++ wasip3/websocket/server/async-local/websocket_server_async_local.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // Copyright (c) 2025 Mohammad Nejati +@@ -17,138 +35,98 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include + #include + #include + #include +-#include ++ + #include + + #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using stream_protocol = net::local::stream_protocol; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using stream_protocol = net::local::stream_protocol; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- session(stream_protocol::socket&& socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation +- void +- on_run() +- { ++ void on_run() { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-async-local"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); ++ })); + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + return; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -162,49 +140,29 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + + public: +- listener( +- net::io_context& ioc, +- stream_protocol::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(ioc, std::move(endpoint)) +- { +- } ++ listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) ++ : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, stream_protocol::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, stream_protocol::socket socket) { ++ if (ec) { + fail(ec, "accept"); + return; +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } +@@ -216,24 +174,20 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 3) +- { +- std::cerr << +- "Usage: websocket-server-async-local \n" << +- "Example:\n" << +- " websocket-server-async-local /tmp/ws.sock 1\n"; ++ if (argc != 3) { ++ std::cerr << "Usage: websocket-server-async-local \n" ++ << "Example:\n" ++ << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; +- auto const threads = std::max(1, std::atoi(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[2])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + std::remove(path); +@@ -242,20 +196,10 @@ + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; + } +@@ -263,11 +207,8 @@ + + #else + +-int +-main(int, char*[]) +-{ +- std::cerr << +- "Local sockets not available on this platform" << std::endl; ++int main(int, char*[]) { ++ std::cerr << "Local sockets not available on this platform" << std::endl; + return EXIT_FAILURE; + } + +--- upstream/websocket/server/async-ssl/websocket_server_async_ssl.cpp ++++ wasip3/websocket/server/async-ssl/websocket_server_async_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,84 +32,68 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session : public std::enable_shared_from_this +-{ ++class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- session(tcp::socket&& socket, ssl::context& ctx) +- : ws_(std::move(socket), ctx) +- { +- } ++ session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), +- beast::bind_front_handler( +- &session::on_run, +- shared_from_this())); ++ beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation +- void +- on_run() +- { ++ void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + +- // Perform the SSL handshake ++ // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, +- beast::bind_front_handler( +- &session::on_handshake, +- shared_from_this())); +- } +- +- void +- on_handshake(beast::error_code ec) +- { +- if(ec) ++ beast::bind_front_handler(&session::on_handshake, shared_from_this())); ++ } ++ ++ void on_handshake(beast::error_code ec) { ++ if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -98,78 +101,51 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-async-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); ++ })); + + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) +- return; +- +- if(ec) ++ if (ec == websocket::error::closed) ++ return; ++ ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -183,85 +159,59 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(net::make_strand(ioc)) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) ++ : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } +@@ -273,23 +223,20 @@ + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-async-ssl
\n" << +- "Example:\n" << +- " websocket-server-async-ssl 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-async-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -301,15 +248,7 @@ + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/awaitable/websocket_server_awaitable.cpp ++++ wasip3/websocket/server/awaitable/websocket_server_awaitable.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) + // +@@ -17,57 +35,49 @@ + #include + #include + #include +-#include +-#include ++#include ++#include + + #include + #include + #include + #include +-#include ++ + #include + + #if defined(BOOST_ASIO_HAS_CO_AWAIT) + +-namespace beast = boost::beast; +-namespace http = beast::http; ++namespace beast = webcpp::beast; ++namespace http = beast::http; + namespace websocket = beast::websocket; +-namespace net = boost::asio; ++namespace net = boost::asio; + + // Echoes back all received WebSocket messages +-net::awaitable +-do_session(websocket::stream stream) +-{ ++net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket +- stream.set_option( +- websocket::stream_base::timeout::suggested(beast::role_type::server)); ++ stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- stream.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set( +- http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-coro"); +- })); ++ stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); ++ })); + + // Accept the websocket handshake + co_await stream.async_accept(); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + co_return; + +- if(ec) +- throw boost::system::system_error{ ec }; ++ if (ec) ++ throw boost::system::system_error{ec}; + + // Echo the message back + stream.text(stream.got_text()); +@@ -76,28 +86,19 @@ + } + + // Accepts incoming connections and launches the sessions +-net::awaitable +-do_listen(net::ip::tcp::endpoint endpoint) +-{ ++net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { + auto executor = co_await net::this_coro::executor; +- auto acceptor = net::ip::tcp::acceptor{ executor, endpoint }; ++ auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + +- for(;;) +- { ++ for (;;) { + net::co_spawn( + executor, +- do_session(websocket::stream{ +- co_await acceptor.async_accept() }), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { ++ do_session(websocket::stream{co_await acceptor.async_accept()}), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { + std::rethrow_exception(e); +- } +- catch(std::exception& e) +- { ++ } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } +@@ -105,59 +106,42 @@ + } + } + +-int +-main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if(argc != 4) +- { +- std::cerr +- << "Usage: websocket-server-awaitable
\n" +- << "Example:\n" +- << " websocket-server-awaitable 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-awaitable
\n" ++ << "Example:\n" ++ << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); +- auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ auto const port = static_cast(std::atoi(argv[2])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc(threads); ++ webcpp::asio::io_context ioc(threads); + + // Spawn a listening port +- net::co_spawn( +- ioc, +- do_listen(net::ip::tcp::endpoint{ address, port }), +- [](std::exception_ptr e) +- { +- if(e) +- { +- try +- { +- std::rethrow_exception(e); +- } +- catch(std::exception const& e) +- { +- std::cerr << "Error: " << e.what() << std::endl; +- } +- } +- }); ++ net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), ++ [](std::exception_ptr e) { ++ if (e) { ++ try { ++ std::rethrow_exception(e); ++ } catch (std::exception const& e) { ++ std::cerr << "Error: " << e.what() << std::endl; ++ } ++ } ++ }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back([&ioc] { ioc.run(); }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } + + #else + +-int +-main(int, char*[]) +-{ ++int main(int, char*[]) { + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; + } +--- upstream/websocket/server/chat-multi/beast.hpp ++++ wasip3/websocket/server/chat-multi/beast.hpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,10 +28,10 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +-#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from + + #endif +--- upstream/websocket/server/chat-multi/http_session.cpp ++++ wasip3/websocket/server/chat-multi/http_session.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,70 +25,84 @@ + // Official repository: https://github.com/vinniefalco/CppCon2018 + // + ++#include ++#include + #include "http_session.hpp" + #include "websocket_session.hpp" +-#include +-#include + + //------------------------------------------------------------------------------ + + // Return a reasonable mime type based on the extension of a file. +-beast::string_view +-mime_type(beast::string_view path) +-{ ++beast::string_view mime_type(beast::string_view path) { + using beast::iequals; +- auto const ext = [&path] +- { ++ auto const ext = [&path] { + auto const pos = path.rfind("."); +- if(pos == beast::string_view::npos) ++ if (pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); +- if(iequals(ext, ".htm")) return "text/html"; +- if(iequals(ext, ".html")) return "text/html"; +- if(iequals(ext, ".php")) return "text/html"; +- if(iequals(ext, ".css")) return "text/css"; +- if(iequals(ext, ".txt")) return "text/plain"; +- if(iequals(ext, ".js")) return "application/javascript"; +- if(iequals(ext, ".json")) return "application/json"; +- if(iequals(ext, ".xml")) return "application/xml"; +- if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; +- if(iequals(ext, ".flv")) return "video/x-flv"; +- if(iequals(ext, ".png")) return "image/png"; +- if(iequals(ext, ".jpe")) return "image/jpeg"; +- if(iequals(ext, ".jpeg")) return "image/jpeg"; +- if(iequals(ext, ".jpg")) return "image/jpeg"; +- if(iequals(ext, ".gif")) return "image/gif"; +- if(iequals(ext, ".bmp")) return "image/bmp"; +- if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; +- if(iequals(ext, ".tiff")) return "image/tiff"; +- if(iequals(ext, ".tif")) return "image/tiff"; +- if(iequals(ext, ".svg")) return "image/svg+xml"; +- if(iequals(ext, ".svgz")) return "image/svg+xml"; ++ if (iequals(ext, ".htm")) ++ return "text/html"; ++ if (iequals(ext, ".html")) ++ return "text/html"; ++ if (iequals(ext, ".php")) ++ return "text/html"; ++ if (iequals(ext, ".css")) ++ return "text/css"; ++ if (iequals(ext, ".txt")) ++ return "text/plain"; ++ if (iequals(ext, ".js")) ++ return "application/javascript"; ++ if (iequals(ext, ".json")) ++ return "application/json"; ++ if (iequals(ext, ".xml")) ++ return "application/xml"; ++ if (iequals(ext, ".swf")) ++ return "application/x-shockwave-flash"; ++ if (iequals(ext, ".flv")) ++ return "video/x-flv"; ++ if (iequals(ext, ".png")) ++ return "image/png"; ++ if (iequals(ext, ".jpe")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpeg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".jpg")) ++ return "image/jpeg"; ++ if (iequals(ext, ".gif")) ++ return "image/gif"; ++ if (iequals(ext, ".bmp")) ++ return "image/bmp"; ++ if (iequals(ext, ".ico")) ++ return "image/vnd.microsoft.icon"; ++ if (iequals(ext, ".tiff")) ++ return "image/tiff"; ++ if (iequals(ext, ".tif")) ++ return "image/tiff"; ++ if (iequals(ext, ".svg")) ++ return "image/svg+xml"; ++ if (iequals(ext, ".svgz")) ++ return "image/svg+xml"; + return "application/text"; + } + + // Append an HTTP rel-path to a local filesystem path. + // The returned path is normalized for the platform. +-std::string +-path_cat( +- beast::string_view base, +- beast::string_view path) +-{ +- if(base.empty()) ++std::string path_cat(beast::string_view base, beast::string_view path) { ++ if (base.empty()) + return std::string(path); + std::string result(base); + #ifdef BOOST_MSVC + char constexpr path_separator = '\\'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +- for(auto& c : result) +- if(c == '/') ++ for (auto& c : result) ++ if (c == '/') + c = path_separator; + #else + char constexpr path_separator = '/'; +- if(result.back() == path_separator) ++ if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + #endif +@@ -82,15 +114,10 @@ + // The concrete type of the response message (which depends on the + // request), is type-erased in message_generator. + template +-http::message_generator +-handle_request( +- beast::string_view doc_root, +- http::request>&& req) +-{ ++http::message_generator handle_request(beast::string_view doc_root, ++ http::request>&& req) { + // Returns a bad request response +- auto const bad_request = +- [&req](beast::string_view why) +- { ++ auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -101,9 +128,7 @@ + }; + + // Returns a not found response +- auto const not_found = +- [&req](beast::string_view target) +- { ++ auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -114,9 +139,7 @@ + }; + + // Returns a server error response +- auto const server_error = +- [&req](beast::string_view what) +- { ++ auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); +@@ -127,19 +150,17 @@ + }; + + // Make sure we can handle the method +- if( req.method() != http::verb::get && +- req.method() != http::verb::head) ++ if (req.method() != http::verb::get && req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". +- if( req.target().empty() || +- req.target()[0] != '/' || ++ if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); +- if(req.target().back() == '/') ++ if (req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file +@@ -148,19 +169,18 @@ + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist +- if(ec == boost::system::errc::no_such_file_or_directory) ++ if (ec == boost::system::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error +- if(ec) ++ if (ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request +- if(req.method() == http::verb::head) +- { ++ if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); +@@ -170,10 +190,8 @@ + } + + // Respond to GET request +- http::response res{ +- std::piecewise_construct, +- std::make_tuple(std::move(body)), +- std::make_tuple(http::status::ok, req.version())}; ++ http::response res{std::piecewise_construct, std::make_tuple(std::move(body)), ++ std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); +@@ -183,38 +201,23 @@ + + //------------------------------------------------------------------------------ + +-http_session:: +-http_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state) +- : stream_(std::move(socket)) +- , state_(state) +-{ +-} +- +-void +-http_session:: +-run() +-{ ++http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) ++ : stream_(std::move(socket)), state_(state) {} ++ ++void http_session::run() { + do_read(); + } + + // Report a failure +-void +-http_session:: +-fail(beast::error_code ec, char const* what) +-{ ++void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if(ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + +-void +-http_session:: +-do_read() +-{ ++void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + +@@ -226,44 +229,32 @@ + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request +- http::async_read( +- stream_, +- buffer_, +- parser_->get(), +- beast::bind_front_handler( +- &http_session::on_read, +- shared_from_this())); +-} +- +-void +-http_session:: +-on_read(beast::error_code ec, std::size_t) +-{ ++ http::async_read(stream_, buffer_, parser_->get(), ++ beast::bind_front_handler(&http_session::on_read, shared_from_this())); ++} ++ ++void http_session::on_read(beast::error_code ec, std::size_t) { + // This means they closed the connection +- if(ec == http::error::end_of_stream) +- { ++ if (ec == http::error::end_of_stream) { + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + return; + } + + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade +- if(websocket::is_upgrade(parser_->get())) +- { ++ if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. +- boost::make_shared( +- stream_.release_socket(), +- state_)->run(parser_->release()); ++ boost::make_shared(stream_.release_socket(), state_) ++ ->run(parser_->release()); + return; + } + + // Handle request +- http::message_generator msg = +- handle_request(state_->doc_root(), parser_->release()); ++ http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); +@@ -271,24 +262,18 @@ + auto self = shared_from_this(); + + // Send the response +- beast::async_write( +- stream_, std::move(msg), +- [self, keep_alive](beast::error_code ec, std::size_t bytes) +- { +- self->on_write(ec, bytes, keep_alive); +- }); +-} +- +-void +-http_session:: +-on_write(beast::error_code ec, std::size_t, bool keep_alive) +-{ ++ beast::async_write(stream_, std::move(msg), ++ [self, keep_alive](beast::error_code ec, std::size_t bytes) { ++ self->on_write(ec, bytes, keep_alive); ++ }); ++} ++ ++void http_session::on_write(beast::error_code ec, std::size_t, bool keep_alive) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "write"); + +- if(! keep_alive) +- { ++ if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); +--- upstream/websocket/server/chat-multi/http_session.hpp ++++ wasip3/websocket/server/chat-multi/http_session.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,18 +27,17 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +-#include "net.hpp" +-#include "beast.hpp" +-#include "shared_state.hpp" + #include + #include + #include + #include ++#include "beast.hpp" ++#include "net.hpp" ++#include "shared_state.hpp" + + /** Represents an established HTTP connection +-*/ +-class http_session : public boost::enable_shared_from_this +-{ ++ */ ++class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; +@@ -38,9 +54,7 @@ + void on_write(beast::error_code ec, std::size_t, bool close); + + public: +- http_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state); ++ http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); + }; +--- upstream/websocket/server/chat-multi/listener.cpp ++++ wasip3/websocket/server/chat-multi/listener.cpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,95 +24,67 @@ + // Official repository: https://github.com/vinniefalco/CppCon2018 + // + ++#include ++#include "http_session.hpp" + #include "listener.hpp" +-#include "http_session.hpp" +-#include + +-listener:: +-listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- boost::shared_ptr const& state) +- : ioc_(ioc) +- , acceptor_(ioc) +- , state_(state) +-{ ++listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ boost::shared_ptr const& state) ++ : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + +-void +-listener:: +-run() +-{ ++void listener::run() { + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + // Report a failure +-void +-listener:: +-fail(beast::error_code ec, char const* what) +-{ ++void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations +- if(ec == net::error::operation_aborted) ++ if (ec == net::error::operation_aborted) + return; + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Handle a connection +-void +-listener:: +-on_accept(beast::error_code ec, tcp::socket socket) +-{ +- if(ec) ++void listener::on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) + return fail(ec, "accept"); + else + // Launch a new session for this connection +- boost::make_shared( +- std::move(socket), +- state_)->run(); ++ boost::make_shared(std::move(socket), state_)->run(); + + // The new connection gets its own strand +- acceptor_.async_accept( +- net::make_strand(ioc_), +- beast::bind_front_handler( +- &listener::on_accept, +- shared_from_this())); ++ acceptor_.async_accept(net::make_strand(ioc_), ++ beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } +--- upstream/websocket/server/chat-multi/listener.hpp ++++ wasip3/websocket/server/chat-multi/listener.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,19 +27,18 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +-#include "beast.hpp" +-#include "net.hpp" + #include + #include + #include ++#include "beast.hpp" ++#include "net.hpp" + + // Forward declaration + class shared_state; + + // Accepts incoming connections and launches the sessions +-class listener : public boost::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + +@@ -30,10 +46,8 @@ + void on_accept(beast::error_code ec, tcp::socket socket); + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- boost::shared_ptr const& state); ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +--- upstream/websocket/server/chat-multi/main.cpp ++++ wasip3/websocket/server/chat-multi/main.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -21,64 +39,39 @@ + #include "listener.hpp" + #include "shared_state.hpp" + +-#include + #include + #include + #include + +-int +-main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 5) +- { +- std::cerr << +- "Usage: websocket-chat-multi
\n" << +- "Example:\n" << +- " websocket-chat-server 0.0.0.0 8080 . 5\n"; ++ if (argc != 5) { ++ std::cerr << "Usage: websocket-chat-multi
\n" ++ << "Example:\n" ++ << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto address = net::ip::make_address(argv[1]); + auto port = static_cast(std::atoi(argv[2])); + auto doc_root = argv[3]; +- auto const threads = std::max(1, std::atoi(argv[4])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O +- net::io_context ioc; ++ webcpp::asio::io_context ioc; + + // Create and launch a listening port +- boost::make_shared( +- ioc, +- tcp::endpoint{address, port}, +- boost::make_shared(doc_root))->run(); ++ boost::make_shared(ioc, tcp::endpoint{address, port}, ++ boost::make_shared(doc_root)) ++ ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown +- net::signal_set signals(ioc, SIGINT, SIGTERM); +- signals.async_wait( +- [&ioc](boost::system::error_code const&, int) +- { +- // Stop the io_context. This will cause run() +- // to return immediately, eventually destroying the +- // io_context and any remaining handlers in it. +- ioc.stop(); +- }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit +- for(auto& t : v) +- t.join(); + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/chat-multi/net.hpp ++++ wasip3/websocket/server/chat-multi/net.hpp +@@ -1,3 +1,20 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,9 +27,20 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + #endif +--- upstream/websocket/server/chat-multi/shared_state.cpp ++++ wasip3/websocket/server/chat-multi/shared_state.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,33 +28,20 @@ + #include "shared_state.hpp" + #include "websocket_session.hpp" + +-shared_state:: +-shared_state(std::string doc_root) +- : doc_root_(std::move(doc_root)) +-{ +-} ++shared_state::shared_state(std::string doc_root) : doc_root_(std::move(doc_root)) {} + +-void +-shared_state:: +-join(websocket_session* session) +-{ ++void shared_state::join(websocket_session* session) { + std::lock_guard lock(mutex_); + sessions_.insert(session); + } + +-void +-shared_state:: +-leave(websocket_session* session) +-{ ++void shared_state::leave(websocket_session* session) { + std::lock_guard lock(mutex_); + sessions_.erase(session); + } + + // Broadcast a message to all websocket client sessions +-void +-shared_state:: +-send(std::string message) +-{ ++void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + +@@ -47,13 +52,13 @@ + { + std::lock_guard lock(mutex_); + v.reserve(sessions_.size()); +- for(auto p : sessions_) ++ for (auto p : sessions_) + v.emplace_back(p->weak_from_this()); + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. +- for(auto const& wp : v) +- if(auto sp = wp.lock()) ++ for (auto const& wp : v) ++ if (auto sp = wp.lock()) + sp->send(ss); + } +--- upstream/websocket/server/chat-multi/shared_state.hpp ++++ wasip3/websocket/server/chat-multi/shared_state.hpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -20,8 +38,7 @@ + class websocket_session; + + // Represents the shared server state +-class shared_state +-{ ++class shared_state { + std::string const doc_root_; + + // This mutex synchronizes all access to sessions_ +@@ -31,18 +48,13 @@ + std::unordered_set sessions_; + + public: +- explicit +- shared_state(std::string doc_root); ++ explicit shared_state(std::string doc_root); + +- std::string const& +- doc_root() const noexcept +- { +- return doc_root_; +- } ++ std::string const& doc_root() const noexcept { return doc_root_; } + +- void join (websocket_session* session); +- void leave (websocket_session* session); +- void send (std::string message); ++ void join(websocket_session* session); ++ void leave(websocket_session* session); ++ void send(std::string message); + }; + + #endif +--- upstream/websocket/server/chat-multi/websocket_session.cpp ++++ wasip3/websocket/server/chat-multi/websocket_session.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -7,62 +25,42 @@ + // Official repository: https://github.com/vinniefalco/CppCon2018 + // + ++#include + #include "websocket_session.hpp" +-#include + +-websocket_session:: +-websocket_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state) +- : ws_(std::move(socket)) +- , state_(state) +-{ +-} ++websocket_session::websocket_session(tcp::socket&& socket, ++ boost::shared_ptr const& state) ++ : ws_(std::move(socket)), state_(state) {} + +-websocket_session:: +-~websocket_session() +-{ ++websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); + } + +-void +-websocket_session:: +-fail(beast::error_code ec, char const* what) +-{ ++void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these +- if( ec == net::error::operation_aborted || +- ec == websocket::error::closed) ++ if (ec == net::error::operation_aborted || ec == websocket::error::closed) + return; + + std::cerr << what << ": " << ec.message() << "\n"; + } + +-void +-websocket_session:: +-on_accept(beast::error_code ec) +-{ ++void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "accept"); + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void +-websocket_session:: +-on_read(beast::error_code ec, std::size_t) +-{ ++void websocket_session::on_read(beast::error_code ec, std::size_t) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Send to all connections +@@ -72,64 +70,43 @@ + buffer_.consume(buffer_.size()); + + // Read another message +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &websocket_session::on_read, +- shared_from_this())); ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + +-void +-websocket_session:: +-send(boost::shared_ptr const& ss) +-{ ++void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + +- net::post( +- ws_.get_executor(), +- beast::bind_front_handler( +- &websocket_session::on_send, +- shared_from_this(), +- ss)); ++ net::post(ws_.get_executor(), ++ beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); + } + +-void +-websocket_session:: +-on_send(boost::shared_ptr const& ss) +-{ ++void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? +- if(queue_.size() > 1) ++ if (queue_.size() > 1) + return; + + // We are not currently writing, so send this immediately +- ws_.async_write( +- net::buffer(*queue_.front()), +- beast::bind_front_handler( +- &websocket_session::on_write, +- shared_from_this())); ++ ws_.async_write(net::buffer(*queue_.front()), ++ beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } + +-void +-websocket_session:: +-on_write(beast::error_code ec, std::size_t) +-{ ++void websocket_session::on_write(beast::error_code ec, std::size_t) { + // Handle the error, if any +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any +- if(! queue_.empty()) ++ if (!queue_.empty()) + ws_.async_write( + net::buffer(*queue_.front()), +- beast::bind_front_handler( +- &websocket_session::on_write, +- shared_from_this())); ++ beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +--- upstream/websocket/server/chat-multi/websocket_session.hpp ++++ wasip3/websocket/server/chat-multi/websocket_session.hpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -10,8 +28,8 @@ + #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + ++#include "beast.hpp" + #include "net.hpp" +-#include "beast.hpp" + #include "shared_state.hpp" + + #include +@@ -23,9 +41,8 @@ + class shared_state; + + /** Represents an active WebSocket connection to the server +-*/ +-class websocket_session : public boost::enable_shared_from_this +-{ ++ */ ++class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; +@@ -37,50 +54,34 @@ + void on_write(beast::error_code ec, std::size_t bytes_transferred); + + public: +- websocket_session( +- tcp::socket&& socket, +- boost::shared_ptr const& state); ++ websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + +- template +- void +- run(http::request> req); ++ template ++ void run(http::request> req); + + // Send a message +- void +- send(boost::shared_ptr const& ss); ++ void send(boost::shared_ptr const& ss); + + private: +- void +- on_send(boost::shared_ptr const& ss); ++ void on_send(boost::shared_ptr const& ss); + }; + +-template +-void +-websocket_session:: +-run(http::request> req) +-{ ++template ++void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-chat-multi"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); ++ })); + + // Accept the websocket handshake +- ws_.async_accept( +- req, +- beast::bind_front_handler( +- &websocket_session::on_accept, +- shared_from_this())); ++ ws_.async_accept(req, ++ beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + + #endif +--- upstream/websocket/server/coro/websocket_server_coro.cpp ++++ wasip3/websocket/server/coro/websocket_server_coro.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,63 +31,51 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include + #include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-void +-do_session( +- websocket::stream& ws, +- net::yield_context yield) +-{ ++void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-coro"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); ++ })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -77,16 +83,16 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } +@@ -94,102 +100,79 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_session, +- websocket::stream< +- beast::tcp_stream>(std::move(socket)), +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ std::bind(&do_session, websocket::stream(std::move(socket)), ++ std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-coro
\n" << +- "Example:\n" << +- " websocket-server-coro 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-coro
\n" ++ << "Example:\n" ++ << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc(threads); ++ webcpp::asio::io_context ioc(threads); + + // Spawn a listening port +- boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- tcp::endpoint{address, port}, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ boost::asio::spawn( ++ ioc, ++ std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the application's network ++ // operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp ++++ wasip3/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,44 +32,38 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-void +-do_session( +- websocket::stream>& ws, +- net::yield_context yield) +-{ ++void do_session(websocket::stream>& ws, net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. +@@ -58,7 +71,7 @@ + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -66,26 +79,20 @@ + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-coro-ssl"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); ++ })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -93,16 +100,16 @@ + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; + +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } +@@ -110,73 +117,62 @@ + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-void +-do_listen( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint, +- net::yield_context yield) +-{ ++void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, ++ net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); +- if(ec) ++ if (ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_session, +- websocket::stream>(std::move(socket), ctx), +- std::placeholders::_1), +- // we ignore the result of the session, +- // most errors are handled with error_code +- boost::asio::detached); ++ std::bind(&do_session, ++ websocket::stream>(std::move(socket), ctx), ++ std::placeholders::_1), ++ // we ignore the result of the session, ++ // most errors are handled with error_code ++ boost::asio::detached); + } + } + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-coro-ssl
\n" << +- "Example:\n" << +- " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-coro-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -186,34 +182,22 @@ + + // Spawn a listening port + boost::asio::spawn(ioc, +- std::bind( +- &do_listen, +- std::ref(ioc), +- std::ref(ctx), +- tcp::endpoint{address, port}, +- std::placeholders::_1), +- // on completion, spawn will call this function +- [](std::exception_ptr ex) +- { +- // if an exception occurred in the coroutine, +- // it's something critical, e.g. out of memory +- // we capture normal errors in the ec +- // so we just rethrow the exception here, +- // which will cause `ioc.run()` to throw +- if (ex) +- std::rethrow_exception(ex); +- }); ++ std::bind(&do_listen, std::ref(ioc), std::ref(ctx), ++ tcp::endpoint{address, port}, std::placeholders::_1), ++ // on completion, spawn will call this function ++ [](std::exception_ptr ex) { ++ // if an exception occurred in the coroutine, ++ // it's something critical, e.g. out of memory ++ // we capture normal errors in the ec ++ // so we just rethrow the exception here, ++ // which will cause `ioc.run()` to throw // lint-run: drives the ++ // application's network operations ++ if (ex) ++ std::rethrow_exception(ex); ++ }); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/fast/websocket_server_fast.cpp ++++ wasip3/websocket/server/fast/websocket_server_fast.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -26,42 +44,38 @@ + https://github.com/crossbario/autobahn-testsuite + */ + +-#include +-#include +-#include +-#include ++#include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); + } + + // Adjust settings on the stream +-template +-void +-setup_stream(websocket::stream& ws) +-{ ++template ++void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + +@@ -79,156 +93,63 @@ + + //------------------------------------------------------------------------------ + +-void +-do_sync_session(websocket::stream& ws) +-{ +- beast::error_code ec; +- +- setup_stream(ws); +- +- // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, std::string( +- BOOST_BEAST_VERSION_STRING) + "-Sync"); +- })); +- +- ws.accept(ec); +- if(ec) +- return fail(ec, "accept"); +- +- for(;;) +- { +- beast::flat_buffer buffer; +- +- ws.read(buffer, ec); +- if(ec == websocket::error::closed) +- break; +- if(ec) +- return fail(ec, "read"); +- ws.text(ws.got_text()); +- ws.write(buffer.data(), ec); +- if(ec) +- return fail(ec, "write"); +- } +-} +- +-void +-do_sync_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint) +-{ +- beast::error_code ec; +- tcp::acceptor acceptor{ioc, endpoint}; +- for(;;) +- { +- tcp::socket socket{ioc}; +- +- acceptor.accept(socket, ec); +- if(ec) +- return fail(ec, "accept"); +- +- std::thread(std::bind( +- &do_sync_session, +- websocket::stream( +- std::move(socket)))).detach(); +- } +-} +- +-//------------------------------------------------------------------------------ +- + // Echoes back all received WebSocket messages +-class async_session : public std::enable_shared_from_this +-{ ++class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- async_session(tcp::socket&& socket) +- : ws_(std::move(socket)) +- { +- setup_stream(ws_); +- } ++ explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, std::string( +- BOOST_BEAST_VERSION_STRING) + "-Async"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); ++ })); + + // Accept the websocket handshake +- ws_.async_accept( +- beast::bind_front_handler( +- &async_session::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec) +- { +- if(ec) ++ ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec) { ++ if (ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + +- void +- do_read() +- { ++ void do_read() { + // Read a message into our buffer +- ws_.async_read( +- buffer_, +- beast::bind_front_handler( +- &async_session::on_read, +- shared_from_this())); +- } +- +- void +- on_read( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_read(buffer_, ++ beast::bind_front_handler(&async_session::on_read, shared_from_this())); ++ } ++ ++ void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed +- if(ec == websocket::error::closed) +- return; +- +- if(ec) ++ if (ec == websocket::error::closed) ++ return; ++ ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- ws_.async_write( +- buffer_.data(), +- beast::bind_front_handler( +- &async_session::on_write, +- shared_from_this())); +- } +- +- void +- on_write( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ ws_.async_write(buffer_.data(), ++ beast::bind_front_handler(&async_session::on_write, shared_from_this())); ++ } ++ ++ void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- if(ec) ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -240,82 +161,59 @@ + }; + + // Accepts incoming connections and launches the sessions +-class async_listener : public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class async_listener : public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + + public: +- async_listener( +- net::io_context& ioc, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- { ++ async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- do_accept(); +- } ++ void run() { do_accept(); } + + private: +- void +- do_accept() +- { ++ void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), +- beast::bind_front_handler( +- &async_listener::on_accept, +- shared_from_this())); +- } +- +- void +- on_accept(beast::error_code ec, tcp::socket socket) +- { +- if(ec) +- { ++ beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); ++ } ++ ++ void on_accept(beast::error_code ec, tcp::socket socket) { ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } +@@ -327,155 +225,115 @@ + + //------------------------------------------------------------------------------ + +-void +-do_coro_session( +- websocket::stream& ws, +- net::yield_context yield) +-{ ++void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket +- ws.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, std::string( +- BOOST_BEAST_VERSION_STRING) + "-Fiber"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); ++ })); + + ws.async_accept(yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); +- if(ec == websocket::error::closed) ++ if (ec == websocket::error::closed) + break; +- if(ec) ++ if (ec) + return fail(ec, "read"); + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); +- if(ec) ++ if (ec) + return fail(ec, "write"); + } + } + +-void +-do_coro_listen( +- net::io_context& ioc, +- tcp::endpoint endpoint, +- net::yield_context yield) +-{ ++void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, ++ net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); +- if(ec) ++ if (ec) + return fail(ec, "open"); + + acceptor.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) ++ if (ec) + return fail(ec, "set_option"); + + acceptor.bind(endpoint, ec); +- if(ec) ++ if (ec) + return fail(ec, "bind"); + + acceptor.listen(net::socket_base::max_listen_connections, ec); +- if(ec) ++ if (ec) + return fail(ec, "listen"); + +- for(;;) +- { ++ for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); +- if(ec) +- { ++ if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), +- std::bind( +- &do_coro_session, +- websocket::stream< +- beast::tcp_stream>(std::move(socket)), +- std::placeholders::_1), boost::asio::detached); +- } +-} +- +-//------------------------------------------------------------------------------ +- +-int main(int argc, char* argv[]) +-{ ++ std::bind(&do_coro_session, websocket::stream(std::move(socket)), ++ std::placeholders::_1), ++ boost::asio::detached); ++ } ++} ++ ++//------------------------------------------------------------------------------ ++ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-fast
\n" << +- "Example:\n" +- " websocket-server-fast 0.0.0.0 8080 1\n" +- " Connect to:\n" +- " starting-port+0 for synchronous,\n" +- " starting-port+1 for asynchronous,\n" +- " starting-port+2 for coroutine.\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-fast
\n" ++ << "Example:\n" ++ " websocket-server-fast 0.0.0.0 8080 1\n" ++ " Connect to:\n" ++ " starting-port+0 for synchronous,\n" ++ " starting-port+1 for asynchronous,\n" ++ " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create sync port +- std::thread(beast::bind_front_handler( +- &do_sync_listen, +- std::ref(ioc), +- tcp::endpoint{ +- address, +- static_cast(port + 0u)} +- )).detach(); ++ std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Create async port +- std::make_shared( +- ioc, +- tcp::endpoint{ +- address, +- static_cast(port + 1u)})->run(); ++ std::make_shared(ioc, ++ tcp::endpoint{address, static_cast(port + 1u)}) ++ ->run(); + + // Create coro port + boost::asio::spawn(ioc, +- std::bind( +- &do_coro_listen, +- std::ref(ioc), +- tcp::endpoint{ +- address, +- static_cast(port + 2u)}, +- std::placeholders::_1), boost::asio::detached); ++ std::bind(&do_coro_listen, std::ref(ioc), ++ tcp::endpoint{address, static_cast(port + 2u)}, ++ std::placeholders::_1), ++ boost::asio::detached); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/stackless/websocket_server_stackless.cpp ++++ wasip3/websocket/server/stackless/websocket_server_stackless.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,128 +31,91 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include ++#include + #include ++#include + #include +-#include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- explicit +- session(tcp::socket socket) +- : ws_(std::move(socket)) +- { +- } ++ explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(ws_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ net::dispatch( ++ ws_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); +- reenter(*this) +- { ++ reenter(*this) { + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-stackless"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); ++ })); + + // Accept the websocket handshake + yield ws_.async_accept( +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // Read a message into our buffer + yield ws_.async_read( +- buffer_, +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec == websocket::error::closed) +- { ++ buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write( +- buffer_.data(), +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec) ++ yield ws_.async_write(buffer_.data(), ++ std::bind(&session::loop, shared_from_this(), ++ std::placeholders::_1, std::placeholders::_2)); ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -143,94 +124,65 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: +- listener( +- net::io_context& ioc, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , acceptor_(net::make_strand(ioc)) +- , socket_(net::make_strand(ioc)) +- { ++ listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) ++ : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- std::bind( +- &listener::loop, +- shared_from_this(), +- std::placeholders::_1)); +- if(ec) +- { ++ socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } +@@ -241,42 +193,31 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-stackless
\n" << +- "Example:\n" << +- " websocket-server-stackless 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-stackless
\n" ++ << "Example:\n" ++ << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp ++++ wasip3/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,93 +32,72 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" +- +-#include +-#include +-#include ++#include "common/server_certificate.hpp" ++ ++#include + #include + #include + #include + #include +-#include ++#include + #include + #include + #include + #include + #include +-#include ++#include ++#include ++ + #include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Report a failure +-void +-fail(beast::error_code ec, char const* what) +-{ ++void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; + } + + // Echoes back all received WebSocket messages +-class session +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ ++class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + + public: + // Take ownership of the socket +- session(tcp::socket&& socket, ssl::context& ctx) +- : ws_(std::move(socket), ctx) +- { +- } ++ session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation +- void +- run() +- { ++ void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. +- net::dispatch(ws_.get_executor(), +- beast::bind_front_handler(&session::loop, +- shared_from_this(), +- beast::error_code{}, +- 0)); +- } +- +- #include +- +- void +- loop( +- beast::error_code ec, +- std::size_t bytes_transferred) +- { ++ net::dispatch( ++ ws_.get_executor(), ++ beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); ++ } ++ ++#include ++ ++ void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + +- reenter(*this) +- { ++ reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because +@@ -107,57 +105,38 @@ + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket +- ws_.set_option( +- websocket::stream_base::timeout::suggested( +- beast::role_type::server)); ++ ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake +- ws_.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-stackless-ssl"); +- })); ++ ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + ++ " websocket-server-stackless-ssl"); ++ })); + + // Accept the websocket handshake + yield ws_.async_accept( +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- 0)); +- if(ec) ++ std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); ++ if (ec) + return fail(ec, "accept"); + +- for(;;) +- { ++ for (;;) { + // Read a message into our buffer + yield ws_.async_read( +- buffer_, +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec == websocket::error::closed) +- { ++ buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, ++ std::placeholders::_2)); ++ if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } +- if(ec) ++ if (ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); +- yield ws_.async_write( +- buffer_.data(), +- std::bind( +- &session::loop, +- shared_from_this(), +- std::placeholders::_1, +- std::placeholders::_2)); +- if(ec) ++ yield ws_.async_write(buffer_.data(), ++ std::bind(&session::loop, shared_from_this(), ++ std::placeholders::_1, std::placeholders::_2)); ++ if (ec) + return fail(ec, "write"); + + // Clear the buffer +@@ -166,97 +145,66 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + + // Accepts incoming connections and launches the sessions +-class listener +- : public boost::asio::coroutine +- , public std::enable_shared_from_this +-{ +- net::io_context& ioc_; ++class listener : public boost::asio::coroutine, public std::enable_shared_from_this { ++ webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + + public: +- listener( +- net::io_context& ioc, +- ssl::context& ctx, +- tcp::endpoint endpoint) +- : ioc_(ioc) +- , ctx_(ctx) +- , acceptor_(ioc) +- , socket_(ioc) +- { ++ listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) ++ : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); +- if(ec) +- { ++ if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections +- acceptor_.listen( +- net::socket_base::max_listen_connections, ec); +- if(ec) +- { ++ acceptor_.listen(net::socket_base::max_listen_connections, ec); ++ if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections +- void +- run() +- { +- loop(); +- } ++ void run() { loop(); } + + private: +- +- #include +- +- void +- loop(beast::error_code ec = {}) +- { +- reenter(*this) +- { +- for(;;) +- { ++#include ++ ++ void loop(beast::error_code ec = {}) { ++ reenter(*this) { ++ for (;;) { + yield acceptor_.async_accept( +- socket_, +- std::bind( +- &listener::loop, +- shared_from_this(), +- std::placeholders::_1)); +- if(ec) +- { ++ socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); ++ if (ec) { + fail(ec, "accept"); +- } +- else +- { ++ } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } +@@ -267,28 +215,25 @@ + } + } + +- #include ++#include + }; + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ ++int main(int argc, char* argv[]) { + // Check command line arguments. +- if (argc != 4) +- { +- std::cerr << +- "Usage: websocket-server-async-ssl
\n" << +- "Example:\n" << +- " websocket-server-async-ssl 0.0.0.0 8080 1\n"; ++ if (argc != 4) { ++ std::cerr << "Usage: websocket-server-async-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); +- auto const threads = std::max(1, std::atoi(argv[3])); ++ [[maybe_unused]] auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O +- net::io_context ioc{threads}; ++ webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -300,15 +245,7 @@ + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads +- std::vector v; +- v.reserve(threads - 1); +- for(auto i = threads - 1; i > 0; --i) +- v.emplace_back( +- [&ioc] +- { +- ioc.run(); +- }); +- ioc.run(); ++ ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } +--- upstream/websocket/server/sync/websocket_server_sync.cpp ++++ wasip3/websocket/server/sync/websocket_server_sync.cpp +@@ -1,3 +1,21 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,46 +31,38 @@ + // + //------------------------------------------------------------------------------ + +-#include +-#include + #include + #include + #include + #include + #include +-#include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages +-void +-do_session(tcp::socket socket) +-{ +- try +- { ++void do_session(tcp::socket socket) { ++ try { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-sync"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); ++ })); + + // Accept the websocket handshake + ws.accept(); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -63,44 +73,35 @@ + ws.text(ws.got_text()); + ws.write(buffer.data()); + } +- } +- catch(beast::system_error const& se) +- { ++ } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if(se.code() != websocket::error::closed) ++ if (se.code() != websocket::error::closed) + std::cerr << "Error: " << se.code().message() << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 3) +- { +- std::cerr << +- "Usage: websocket-server-sync
\n" << +- "Example:\n" << +- " websocket-server-sync 0.0.0.0 8080\n"; ++ if (argc != 3) { ++ std::cerr << "Usage: websocket-server-sync
\n" ++ << "Example:\n" ++ << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -108,13 +109,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread( +- &do_session, +- std::move(socket)).detach(); ++ do_session(std::move(socket)); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +--- upstream/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp ++++ wasip3/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +@@ -1,3 +1,22 @@ ++// Copyright (c) 2026 WebCpp.org ++// ++// Distributed under the Boost Software License, Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// https://www.boost.org/LICENSE_1_0.txt) ++// ++// Generated by example/applications/tools/prepare.py. Edit the generator. ++// Upstream authors and their original notice follow. ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "fixture.hpp" ++#include "fixture_resolver.hpp" + // + // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) + // +@@ -13,34 +32,30 @@ + // + //------------------------------------------------------------------------------ + +-#include "example/common/server_certificate.hpp" ++#include "common/server_certificate.hpp" + +-#include +-#include +-#include + #include + #include ++#include + #include + #include + #include + #include +-#include ++#include ++#include + +-namespace beast = boost::beast; // from +-namespace http = beast::http; // from +-namespace websocket = beast::websocket; // from +-namespace net = boost::asio; // from +-namespace ssl = boost::asio::ssl; // from +-using tcp = boost::asio::ip::tcp; // from ++namespace beast = webcpp::beast; // from ++namespace http = beast::http; // from ++namespace websocket = beast::websocket; // from ++namespace net = boost::asio; // from ++namespace ssl = boost::asio::ssl; // from ++using tcp = webcpp::asio::ip::tcp; // from + + //------------------------------------------------------------------------------ + + // Echoes back all received WebSocket messages +-void +-do_session(tcp::socket socket, ssl::context& ctx) +-{ +- try +- { ++void do_session(tcp::socket socket, ssl::context& ctx) { ++ try { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + +@@ -48,19 +63,15 @@ + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake +- ws.set_option(websocket::stream_base::decorator( +- [](websocket::response_type& res) +- { +- res.set(http::field::server, +- std::string(BOOST_BEAST_VERSION_STRING) + +- " websocket-server-sync-ssl"); +- })); ++ ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { ++ res.set(http::field::server, ++ std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); ++ })); + + // Accept the websocket handshake + ws.accept(); + +- for(;;) +- { ++ for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + +@@ -71,39 +82,31 @@ + ws.text(ws.got_text()); + ws.write(buffer.data()); + } +- } +- catch(beast::system_error const& se) +- { ++ } catch (beast::system_error const& se) { + // This indicates that the session was closed +- if(se.code() != websocket::error::closed) ++ if (se.code() != websocket::error::closed) + std::cerr << "Error: " << se.code().message() << std::endl; +- } +- catch(std::exception const& e) +- { ++ } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << std::endl; + } + } + + //------------------------------------------------------------------------------ + +-int main(int argc, char* argv[]) +-{ +- try +- { ++int main(int argc, char* argv[]) { ++ try { + // Check command line arguments. +- if (argc != 3) +- { +- std::cerr << +- "Usage: websocket-server-sync-ssl
\n" << +- "Example:\n" << +- " websocket-server-sync-ssl 0.0.0.0 8080\n"; ++ if (argc != 3) { ++ std::cerr << "Usage: websocket-server-sync-ssl
\n" ++ << "Example:\n" ++ << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + // The io_context is required for all I/O +- net::io_context ioc{1}; ++ webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; +@@ -113,8 +116,7 @@ + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; +- for(;;) +- { ++ for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + +@@ -122,14 +124,9 @@ + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket +- std::thread( +- &do_session, +- std::move(socket), +- std::ref(ctx)).detach(); ++ do_session(std::move(socket), ctx); + } +- } +- catch (const std::exception& e) +- { ++ } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp new file mode 100644 index 0000000..b7053f9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp @@ -0,0 +1,666 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +using executor_type = net::strand; +using stream_type = beast::tcp_stream::rebind_executor::other; +using acceptor_type = webcpp::asio::ip::tcp::acceptor::rebind_executor::other; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +/** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. +*/ +class task_group { + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + explicit task_group(net::any_io_executor exec) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : cv_{std::move(exec), net::steady_timer::time_point::max()} {} + + task_group(task_group const&) = delete; + task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + + @note `completion_token` must have an associated executor that matches + the one the child task runs on (e.g. via `net::bind_executor`). This is + because `emit`() can run on a different thread than the task, and + `co_spawn` dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template + auto adapt(CompletionToken&& completion_token) { + auto const lg = std::scoped_lock{mtx_}; + auto const cs = css_.emplace(css_.end()); + + class remover { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: + remover(task_group* tg, decltype(css_)::iterator cs) : tg_{tg}, cs_{cs} {} + + remover(remover&& other) noexcept + : tg_{std::exchange(other.tg_, nullptr)}, cs_{other.cs_} {} + + // A mutex or timer failure during this upstream task teardown is fatal by design. + // NOLINTNEXTLINE(bugprone-exception-escape) + ~remover() { + if (tg_) { + auto const lg = std::scoped_lock{tg_->mtx_}; + if (tg_->css_.erase(cs_) == tg_->css_.end()) { + tg_->cv_.cancel(); + } + } + } + }; + + return net::bind_cancellation_slot( + cs->slot(), + net::consign(std::forward(completion_token), remover{this, cs})); + } + + /** Emits the signal to all child tasks and invokes the slot's + handler, if any. + + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + void emit(net::cancellation_type type) { + auto const lg = std::scoped_lock{mtx_}; + for (auto& cs : css_) { + cs.emit(type); + } + } + + /** Starts an asynchronous wait on the task_group. + + The completion handler will be called when: + + - All the child tasks completed. + - The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion + handler must be: + @code + void handler( + boost::system::error_code const& error // result of operation + ); + @endcode + + @par Thread Safety + `Distinct` `objects:` Safe. + `Shared` `objects:` Safe. + */ + template > + auto async_wait(CompletionToken&& completion_token = + net::default_completion_token_t{}) { + return net::async_compose( + // The apparent recursion crosses an asynchronous completion boundary. + // NOLINTNEXTLINE(misc-no-recursion) + [this, scheduled = false](auto&& self, boost::system::error_code ec = {}) mutable { + if (!scheduled) { + self.reset_cancellation_state(net::enable_total_cancellation()); + } + + if (!self.cancelled() && ec == net::error::operation_aborted) { + ec = {}; + } + + { + auto const lg = std::scoped_lock{mtx_}; + + if (!css_.empty() && !ec) { + scheduled = true; + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return cv_.async_wait(std::move(self)); + } + } + + if (!std::exchange(scheduled, true)) { + // Asio composed operations transfer their own state to the next completion. + // NOLINTNEXTLINE(bugprone-move-forwarding-reference) + return net::post(net::append(std::move(self), ec)); + } + + self.complete(ec); + }, + completion_token, cv_); + } +}; + +template +net::awaitable run_websocket_session(Stream& stream, + beast::flat_buffer& buffer, + http::request req) { + auto const cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{stream}; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + + while (!cs.cancelled()) { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed || ec == ssl::error::stream_truncated) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + // Echo the message back + ws.text(ws.got_text()); + co_await ws.async_write(buffer.data()); + + // Clear the buffer + buffer.consume(buffer.size()); + } + + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close(websocket::close_code::service_restart, net::as_tuple); + + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; + } +} + +template +net::awaitable run_session(Stream& stream, beast::flat_buffer& buffer, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + + while (!cs.cancelled()) { + http::request_parser parser; + parser.body_limit(10000); + + auto [ec, _] = co_await http::async_read(stream, buffer, parser, net::as_tuple); + + if (ec == http::error::end_of_stream) { + co_return; + } + + if (websocket::is_upgrade(parser.get())) { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + + co_await run_websocket_session(stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); + if (!res.keep_alive()) { + co_await beast::async_write(stream, std::move(res)); + co_return; + } + + co_await beast::async_write(stream, std::move(res)); + } +} + +net::awaitable detect_session(stream_type stream, ssl::context& ctx, + beast::string_view doc_root) { + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation(), + net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be + // inherited by all child coroutines. + co_await net::this_coro::throw_if_cancelled(false); + + stream.expires_after(std::chrono::seconds(30)); + + if (co_await beast::async_detect_ssl(stream, buffer)) { + ssl::stream ssl_stream{std::move(stream), ctx}; + + auto const bytes_transferred = + co_await ssl_stream.async_handshake(ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + + if (!ssl_stream.lowest_layer().is_open()) { + co_return; + } + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error{ec}; + } + } else { + co_await run_session(stream, buffer, doc_root); + + if (!stream.socket().is_open()) { + co_return; + } + + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + } +} + +net::awaitable listen(task_group& task_group, ssl::context& ctx, + webcpp::asio::ip::tcp::endpoint endpoint, + beast::string_view doc_root) { + auto const cs = co_await net::this_coro::cancellation_state; + auto const executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{executor, endpoint}; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state(net::enable_total_cancellation()); + + while (!cs.cancelled()) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = co_await acceptor.async_accept(socket_executor, net::as_tuple); + + if (ec == net::error::operation_aborted) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + net::co_spawn( + socket_executor, detect_session(stream_type{std::move(socket)}, ctx, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(socket_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }))); + } +} + +net::awaitable handle_signals(task_group& task_group) { + auto const executor = co_await net::this_coro::executor; + auto deadline = net::steady_timer{executor}; + deadline.expires_after(std::chrono::seconds(4)); + + co_await deadline.async_wait(); + + { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( + net::as_tuple(net::cancel_after(std::chrono::seconds{10}))); + + if (ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); + co_await task_group.async_wait(); + } + + std::cout << "Child tasks completed.\n"; + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const endpoint = webcpp::asio::ip::tcp::endpoint{address, port}; + auto const doc_root = beast::string_view{argv[3]}; + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines + task_group task_group{ioc.get_executor()}; + + // Create and launch a listening coroutine + auto const listener_executor = net::make_strand(ioc); + net::co_spawn(listener_executor, listen(task_group, ctx, endpoint, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::bind_executor(listener_executor, task_group.adapt([](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in listener: " << e.what() << "\n"; + } + } + }))); + + // Create and launch a signal handler coroutine + net::co_spawn(net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // Block until all the threads exit + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server-flex/advanced_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server-flex/advanced_server_flex.cpp new file mode 100644 index 0000000..2646c5d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server-flex/advanced_server_flex.cpp @@ -0,0 +1,858 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class websocket_session { + websocket_session() = default; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + derived().ws().set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( + websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server-flex"); + })); + + // Accept the websocket handshake + derived().ws().async_accept(req, beast::bind_front_handler(&websocket_session::on_accept, + derived().shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + derived().ws().async_read(buffer_, beast::bind_front_handler(&websocket_session::on_read, + derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), + beast::bind_front_handler(&websocket_session::on_write, derived().shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } + +public: + // Start the asynchronous operation + template + void run(http::request> req) { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream ws_; + +public: + // Create the session + explicit plain_websocket_session(beast::tcp_stream&& stream) : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL WebSocket connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_websocket_session : public websocket_session, + public std::enable_shared_from_this { + websocket::stream> ws_; + +public: + // Create the ssl_websocket_session + explicit ssl_websocket_session(ssl::stream&& stream) + : ws_(std::move(stream)) {} + + // Called by the base class + websocket::stream>& ws() { return ws_; } +}; + +//------------------------------------------------------------------------------ + +template +void make_websocket_session(beast::tcp_stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +template +void make_websocket_session(ssl::stream stream, + http::request> req) { + std::make_shared(std::move(stream))->run(std::move(req)); +} + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class http_session { + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +protected: + beast::flat_buffer buffer; + +public: + // Construct the session +private: + http_session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + derived().stream(), buffer, *parser_, + beast::bind_front_handler(&http_session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + return make_websocket_session(derived().release_stream(), parser_->release()); + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write(derived().stream(), std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, + derived().shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + friend Derived; +}; + +//------------------------------------------------------------------------------ + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_http_session : public http_session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_http_session(beast::tcp_stream&& stream, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream)) {} + + // Start the session + void run() { this->do_read(); } + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Called by the base class + beast::tcp_stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_http_session : public http_session, + public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the http_session + ssl_http_session(beast::tcp_stream&& stream, ssl::context& ctx, beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session(std::move(buffer), doc_root), + stream_(std::move(stream), ctx) {} + + // Start the session + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( + ssl::stream_base::server, buffer.data(), + beast::bind_front_handler(&ssl_http_session::on_handshake, shared_from_this())); + } + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Called by the base class + ssl::stream release_stream() { return std::move(stream_); } + + // Called by the base class + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_http_session::on_shutdown, shared_from_this())); + } + +private: + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + explicit detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&detect_session::on_run, this->shared_from_this())); + } + + void on_run() { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( + stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, this->shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(std::move(stream_), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(std::move(stream_), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector http_session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server-flex
\n" + << "Example:\n" + << " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server/advanced_server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server/advanced_server.cpp new file mode 100644 index 0000000..38ada15 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/advanced/server/advanced_server.cpp @@ -0,0 +1,613 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server +// +//------------------------------------------------------------------------------ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class websocket_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit websocket_session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Start the asynchronous accept operation + template + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void do_accept(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); + } + +private: + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), beast::bind_front_handler(&websocket_session::on_write, + shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection +class http_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +public: + // Take ownership of the socket + http_session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) { + static_assert(queue_limit > 0, "queue limit must be positive"); + } + + // Start the session + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&http_session::do_read, this->shared_from_this())); + } + +private: + void do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read(stream_, buffer_, *parser_, + beast::bind_front_handler(&http_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + std::make_shared(stream_.release_socket()) + ->do_accept(parser_->release()); + return; + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) { + do_read(); + } + } + + void queue_write(http::message_generator response) { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) { + do_write(); + } + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void do_write() { + if (!response_queue_.empty()) { + bool const keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, std::move(response_queue_.front()), + beast::bind_front_handler(&http_session::on_write, shared_from_this(), keep_alive)); + } + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Resume the read if it has been paused + if (response_queue_.size() == queue_limit) { + do_read(); + } + + response_queue_.pop(); + + do_write(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(acceptor_.get_executor(), + beast::bind_front_handler(&listener::do_accept, this->shared_from_this())); + } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the http session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: advanced-server
\n" + << "Example:\n" + << " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/common/root_certificates.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/common/root_certificates.hpp new file mode 100644 index 0000000..56a857b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/common/root_certificates.hpp @@ -0,0 +1,3983 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP + +#include +#include + +/* + PLEASE READ + + These root certificates here are included just to make the + SSL client examples work. They are NOT intended to be + illustrative of best-practices for performing TLS certificate + verification. + + A REAL program which needs to verify the authenticity of a + server IP address resolved from a given DNS name needs to + consult the operating system specific certificate store + to validate the chain of signatures, compare the domain name + properly against the domain name in the certificate, check + the certificate revocation list, and probably do some other + things. + + ALL of these operations are entirely outside the scope of + both Boost.Beast and Boost.Asio. + + See (work in progress): + https://github.com/djarek/certify + + tl;dr: root_certificates.hpp should not be used in production code +*/ + +namespace ssl = boost::asio::ssl; // from + +namespace detail { + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CA")) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(ctx.load_verify_file(path, ec)); + return; + } + + std::string cert = + "# ACCVRAIZ1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" + "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" + "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ\n" + "BgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwHUEtJQUNDVjENMAsGA1UECgwEQUND\n" + "VjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCb\n" + "qau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gMjmoY\n" + "HtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWo\n" + "G2ioPej0RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpA\n" + "lHPrzg5XPAOBOp0KoVdDaaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhr\n" + "IA8wKFSVf+DuzgpmndFALW4ir50awQUZ0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/\n" + "0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDGWuzndN9wrqODJerWx5eH\n" + "k6fGioozl2A3ED6XPm4pFdahD9GIL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\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Commercial\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" + "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" + "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL\n" + "MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1\n" + "yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr\n" + "VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/\n" + "nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG\n" + "XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj\n" + "vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt\n" + "Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g\n" + "N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" + "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Networking\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBOZXR3b3JraW5nMB4XDTEwMDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SEHi3y\n" + "YJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbua\n" + "kCNrmreIdIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRL\n" + "QESxG9fhwoXA3hA/Pe24/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp\n" + "6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG\n" + "yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i\n" + "QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfO\n" + "tDIuUFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzu\n" + "QY0x2+c06lkh1QF612S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZ\n" + "Lgo/bNjR9eUJtGxUAArgFU2HdW23WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4u\n" + "olu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9/ZFvgrG+CJPbFEfxojfHRZ48\n" + "x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVz\n" + "dCBQcmVtaXVtMB4XDTEwMDEyOTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkG\n" + "A1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1U\n" + "cnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxBLf\n" + "qV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtnBKAQ\n" + "JG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ\n" + "+jjeRFcV5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9m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3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF\n" + "u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH\n" + "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" + "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" + "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" + "KeC2uAloGRwYQw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" + "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" + "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" + "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" + "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" + "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" + "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" + "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" + "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" + "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK\n" + "gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ\n" + "W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg\n" + "1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K\n" + "8nu+NQWpEjTj82R0Yiw9AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r\n" + "2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvdfLC6HM783k81ds8P+HgfajZRRidhW+me\n" + "z/CiV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MdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Atos TrustedRoot 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE\n" + "AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG\n" + "EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM\n" + "FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC\n" + "REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp\n" + "Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM\n" + "VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+\n" + "SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ\n" + "4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L\n" + "cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi\n" + "eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV\n" + "HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG\n" + "A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j\n" + "vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP\n" + "DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc\n" + "maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D\n" + "lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv\n" + "KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Autoridad de Certificacion Firmaprofesional CIF A62634068\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UE\n" + "BhM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2WFbm5PEn4KPJ2V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Baltimore CyberTrust Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" + "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" + "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" + "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" + "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" + "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" + "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" + "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" + "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" + "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" + "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" + "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" + "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" + "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" + "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" + "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" + "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" + "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" + "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" + "BQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1g1Lr\n" + "6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPV\n" + "L4O2fuPn9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC91\n" + "1K2GScuVr1QGbNgGE41b/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHx\n" + "MlAQTn/0hpPshNOOvEu/XAFOBz3cFIqUCqTqc/sLUegTBxj6DvEr0VQVfTzh97QZ\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KdewlNWudLSDBaGOYKbeaP4NK7\n" + "5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" + "3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" + "Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 3 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" + "BQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRHsJ8Y\n" + "ZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3E\n" + "N3coTRiR5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9\n" + "tznDDgFHmV0ST9tD+leh7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX\n" + "0DJq1l1sDPGzbjniazEuOQAnFN44wOwZZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c\n" + "/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH2xc519woe2v1n/MuwU8X\n" + "KhDzzMro6/1rqy6any2CbgTUU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lLvD\n" + "u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq\n" + "4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CA Disig Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV\n" + "BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu\n" + "MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy\n" + "MDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sxEzARBgNVBAcTCkJyYXRpc2xhdmEx\n" + "EzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERpc2lnIFJvb3QgUjIw\n" + "ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbCw3Oe\n" + "NcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNH\n" + "PWSb6WiaxswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3I\n" + "x2ymrdMxp7zo5eFm1tL7A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbe\n" + "QTg06ov80egEFGEtQX6sx3dOy1FU+16SGBsEWmjGycT6txOgmLcRK7fWV8x8nhfR\n" + "yyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqVg8NTEQxzHQuyRpDRQjrO\n" + "QG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa5Beny912\n" + "H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbn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sH8tZ/3zbBt1RqPlShfppNcL\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CFCA EV ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD\n" + "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx\n" + "MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j\n" + "aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJP\n" + "T1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnVBU03\n" + "sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpL\n" + "TIpTUnrD7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5\n" + "/ZOkVIBMUtRSqy5J35DNuF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp\n" + "7hZZLDRJGqgG16iI0gNyejLi6mhNbiyWZXvKWfry4t3uMCz7zEasxGPrb382KzRz\n" + "EpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7xzbh72fROdOXW3NiGUgt\n" + "hxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9fpy25IGvP\n" + "a931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqot\n" + "aK8KgWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNg\n" + "TnYGmE69g60dW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dc0Hz+Ys63su\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB\n" + "gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV\n" + "BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw\n" + "MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl\n" + "YXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01P\n" + "RE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3\n" + "UcEbVASY06m/weaKXTuH+7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI\n" + "2GqGd0S7WWaXUF601CxwRM/aN5VCaTwwxHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8\n" + "Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV4EajcNxo2f8ESIl33rXp\n" + "+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA1KGzqSX+\n" + "DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5O\n" + "nKVIrLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW\n" + "/zAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6g\n" + "PKA6hjhodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9u\n" + "QXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAPpiem/Yb6dc5t3iuHXIY\n" + "SdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CPOGEIqB6BCsAv\n" + "IC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/\n" + "RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4\n" + "zJVSk/BwJVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd\n" + "BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB\n" + "ZQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" + "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" + "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" + "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" + "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" + "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" + "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" + "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB\n" + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" + "EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" + "Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2Vyd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dEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV\n" + "2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna\n" + "FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ\n" + "CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK\n" + "boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke\n" + "jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL\n" + "S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb\n" + "QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl\n" + "0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB\n" + "NVOFBkpdn627G190\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNV\n" + "BAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4X\n" + "DTA3MDYyOTE1MTMwNVoXDTI3MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQ\n" + "BgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwIQ2VydGlnbmEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7qXOEm7RFHYeGifBZ4\n" + "QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7l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najkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh\n" + "jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw\n" + "3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM\n" + "MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D\n" + "ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBU\n" + "cnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIyMTIwNzM3WhcNMjkxMjMxMTIwNzM3\n" + "WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMg\n" + "Uy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSIw\n" + "IAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0B\n" + "AQEFAAOCAQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rH\n" + "UV+rpDKmYYe2bg+G0jACl/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LM\n" + "TXPb865Px1bVWqeWifrzq2jUI4ZZJ88JJ7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVU\n" + "BBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4fOQtf/WsX+sWn7Et0brM\n" + "kUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0cvW0QM8x\n" + "AcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNV\n" + "HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15y\n" + "sHhE49wcrwn9I0j6vSrEuVUEtRCjjSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfL\n" + "I9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1mS1FhIrlQgnXdAIv94nYmem8\n" + "J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5ajZt3hrvJBW8qY\n" + "VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI\n" + "03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCB\n" + "gDELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMu\n" + "QS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIG\n" + "A1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29yayBDQSAyMCIYDzIwMTExMDA2MDgz\n" + "OTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQTDEiMCAGA1UEChMZ\n" + "VW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRp\n" + "Zm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RNcgRRtDoGCERuKTsZPpd1iHkTf\n" + "CVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuAL55MYIR4PSFk1vtBHxgP58l1cb29\n" + "XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMoclm2q8KMZiYcdywm\n" + "djWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tMpkT/\n" + "WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jb\n" + "AoJnwTnbw3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksq\n" + "P/ujmv5zMnHCnsZy4YpoJ/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Ko\n" + "b7a6bINDd82Kkhehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnj\n" + "XALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P\n" + "5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbi\n" + "DrW5viSP\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Chambers of Commerce Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xKTAnBgNVBAMTIENoYW1iZXJz\n" + "IG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEyMjk1MFo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0zcKzBIKinmwPQN/aUv0NCB9szTq\n" + "jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De\n" + "fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg\n" + "OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ\n" + "d0jQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Comodo AAA Services root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb\n" + "MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow\n" + "GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj\n" + "YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM\n" + "GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" + "ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua\n" + "BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe\n" + "3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4\n" + "YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR\n" + "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GiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW\n" + "WL1WMRJOEcgh4LMRkWXbtKaIOM5V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\n" + "ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM\n" + "HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03\n" + "UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42\n" + "tSHKXzlABF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9R\n" + "ySPocq60vFYJfxLLHLGvKZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsM\n" + "lFqVlNpQmvH/pStmMaTJOKDfHR+4CS7zp+hnUquVH+BGPtikw8paxTGA6Eian5Rp\n" + "/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUCAwEAAaOCARowggEWMA8G\n" + "A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ4PGEMA4G\n" + "A1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVj\n" + "dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUy\n" + "MENBJTIwMiUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRl\n" + "cmV2b2NhdGlvbmxpc3QwQ6BBoD+GPWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3Js\n" + "L2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAwOS5jcmwwDQYJKoZIhvcNAQEL\n" + "BQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm2H6NMLVwMeni\n" + "acfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0\n" + "o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K\n" + "zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8\n" + "PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y\n" + "Johw1+qRzT65ysCQblrGXnRl11z+o+I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 EV 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw\n" + "NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV\n" + "BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw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dXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na\n" + "xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX\n" + "KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DST Root CA X3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" + "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" + "DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" + "PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" + "Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + "AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" + "rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" + "OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" + "xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" + "7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" + "aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" + "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" + "SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" + "ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" + "AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" + "R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" + "JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" + "Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c\n" + "JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP\n" + "mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+\n" + "wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4\n" + "VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/\n" + "AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB\n" + "AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW\n" + "BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun\n" + "pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC\n" + "dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf\n" + "fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm\n" + "NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx\n" + "H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe\n" + "+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b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6uwE9W3jfMw3+qBCe703e4YtsXfJwo\n" + "IhNzbM8m9Yop5w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg\n" + "RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq\n" + "hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf\n" + "Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q\n" + "RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD\n" + "AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY\n" + "JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv\n" + "6pZjamVFkpUBtA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApeg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kXDiqw8cvpOp/2PV5Adg\n" + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n" + "MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI\n" + "2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx\n" + "1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ\n" + "q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz\n" + "tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ\n" + "vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP\n" + "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV\n" + "5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY\n" + "1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4\n" + "NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG\n" + "Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91\n" + "8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe\n" + "pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl\n" + "MrY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe\n" + "Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw\n" + "EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x\n" + "IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF\n" + "K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG\n" + "fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO\n" + "Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd\n" + "BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx\n" + "AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/\n" + "oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8\n" + "sycX\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert High Assurance EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n" + "ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n" + "LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug\n" + "RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm\n" + "+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW\n" + "PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM\n" + "xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB\n" + "Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3\n" + "hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg\n" + "EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA\n" + "FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec\n" + "nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z\n" + "eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF\n" + "hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2\n" + "Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe\n" + "vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep\n" + "+OkuE6N36B9K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Trusted Root G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5j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DAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB\n" + "hjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD\n" + "ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2\n" + "SV1EY+CtnJYYZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd\n" + "+SeuMIW59mdNOj6PWTkiU0TryF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWc\n" + "fFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy7zBZLq7gcfJW5GqXb5JQbZaNaHqa\n" + "sjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iahixTXTBmyUEFxPT9N\n" + "cCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN5r5N\n" + "0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie\n" + "4u1Ki7wb/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI\n" + "r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1\n" + "/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm\n" + "gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# E-Tugra Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNV\n" + "BAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+BgNVB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IbvPuW/mIPX64b24D5EI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EE Certification Centre Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1\n" + "MQswCQYDVQQGEwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1\n" + "czEoMCYGA1UEAwwfRUUgQ2VydGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYG\n" + "CSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIwMTAxMDMwMTAxMDMwWhgPMjAzMDEy\n" + "MTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlBUyBTZXJ0aWZpdHNl\n" + "ZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRyZSBS\n" + "b290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEB\n" + "AQUAA4IBDwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUy\n" + "euuOF0+W2Ap7kaJjbMeMTC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvO\n" + "bntl8jixwKIy72KyaOBhU8E2lf/slLo2rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIw\n" + "WFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw93X2PaRka9ZP585ArQ/d\n" + "MtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtNP2MbRMNE\n" + "1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYD\n" + "VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/\n" + "zQas8fElyalL1BSZMEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYB\n" + "BQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEF\n" + "BQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+RjxY6hUFaTlrg4wCQiZrxTFGGV\n" + "v9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqMlIpPnTX/dqQG\n" + "E5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u\n" + "uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIW\n" + "iAYLtqZLICjU3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/v\n" + "GVCJYMzpJJUPwssd8m92kMfMdcGWxZ0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust.net Premium 2048 Secure Server CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML\n" + "RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp\n" + "bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5\n" + "IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0yOTA3\n" + "MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3\n" + "LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnk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gzURZVE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\n" + "Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\n" + "KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\n" + "cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw\n" + "NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw\n" + "NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy\n" + "ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV\n" + "BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ\n" + "KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo\n" + "Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4\n" + "4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9\n" + "KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI\n" + "rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi\n" + "94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB\n" + "sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi\n" + "gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo\n" + "kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE\n" + "vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t\n" + "O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua\n" + "AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP\n" + "9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/\n" + "eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\n" + "0vdXcDazv/wor3ElhVsT/h5/WrQ8\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - EC1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG\n" + "A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3\n" + "d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu\n" + "dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq\n" + "RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy\n" + "MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD\n" + "VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0\n" + "L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g\n" + "Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD\n" + "ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi\n" + "A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt\n" + "ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH\n" + "Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O\n" + "BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC\n" + "R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX\n" + "hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50\n" + "cnVzdC5uZXQvbGV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5ZiXMRrEPR9RP/\n" + "jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ\n" + "Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v\n" + "1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R\n" + "nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH\n" + "VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAw\n" + "gb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL\n" + "Ex9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykg\n" + "MjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMjAw\n" + "BgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEc0\n" + "MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1\n" + "c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJ\n" + "bmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3Qg\n" + "Um9vdCBDZXJ0a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ZDIBf9PD3Vht7LGr\n" + "hFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/\n" + "B7NTeLUKYvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uI\n" + "AeV8KEsD+UmDfLJ/fOPtjqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbw\n" + "H5Lk6rWS02FREAutp9lfx1/cH6NcjKF+m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+\n" + "b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKWRGhXxNUzzxkvFMSUHHuk\n" + "2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjAJOgc47Ol\n" + "IQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk\n" + "5F6G+TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuY\n" + "n/PIjhs4ViFqUZPTkcpG2om3PVODLAgfi49T3f+sHw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GDCA TrustAUTH R5 ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UE\n" + "BhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ\n" + "IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0\n" + "MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVowYjELMAkGA1UEBhMCQ04xMjAwBgNV\n" + "BAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8w\n" + "HQYDVQQDDBZHRENB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hXOYV0GkLH6VsTX4/5\n" + "COmSdI31R9KrO9b7eGZONn356ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ry\n" + "L3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd+PwyvzeG5LuOmCd+uh8W4XAR8gPf\n" + "JWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQHtZa37dG/OaG+svg\n" + "IHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBDF8Io\n" + "2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV\n" + "09tL7ECQ8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQ\n" + "XR4EzzffHqhmsYzmIGrv/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrq\n" + "T8p+ck0LcIymSLumoRT2+1hEmRSuqguTaaApJUqlyyvdimYHFngVV3Eb7PVHhPOe\n" + "MTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+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7pwoHyXa/6xmld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3\n" + "d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9bgsiG1eGZbYwE8na6SfZu6W0eX6Dv\n" + "J4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq4BjFbkerQUIpm/Zg\n" + "DdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWErtXvM\n" + "+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyy\n" + "F62ARPBopY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9\n" + "SQ98POyDGCBDTtWTurQ0sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdws\n" + "E3PYJ/HQcu51OyLemGhmW/HGY0dVHLqlCFF1pkgl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTukk3Lv\n" + "CvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3Kg\n" + "GjSY6D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0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFuk\n" + "fCPAlaUs3L6JbyO5o91lAFJekazInXJ0glMLfalAvWhgxeG4VDvBNhcl2MG9AjEA\n" + "njWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOaKaqW04MjyaR7YbPMAuhd\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu\n" + "hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/l\n" + "xKvRHYqjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBSATNbrdP9JNqPV2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0\n" + "CMRw3J5QdCHojXohw0+WbhXRIjVhLfoIN+4Zba3bssx9BzT1YBkstTTZbyACMANx\n" + "sbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11xzPKwTdb+mciUqXWi4w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Global CA\n" + "-----BEGIN CERTIFICATE-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njaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n" + "hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n" + "5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY\n" + "MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo\n" + "R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx\n" + "MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK\n" + "Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9\n" + "AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA\n" + "ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0\n" + "7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W\n" + "kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI\n" + "mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1\n" + "6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl\n" + "4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K\n" + "oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj\n" + "UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU\n" + "AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL\n" + "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj\n" + "KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2\n" + "MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV\n" + "BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw\n" + "NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV\n" + "BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH\n" + "MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL\n" + "So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal\n" + "tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG\n" + "CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT\n" + "qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz\n" + "rD6ogRLQy7rQkgu2npaqBA+K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB\n" + "mDELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsT\n" + "MChjKSAyMDA4IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s\n" + "eTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhv\n" + "cml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIzNTk1OVowgZgxCzAJ\n" + "BgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg\n" + "MjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0\n" + "BgNVBAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg\n" + "LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz\n" + "+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5jK/BGvESyiaHAKAxJcCGVn2TAppMSAmUm\n" + "hsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdEc5IiaacDiGydY8hS2pgn\n" + "5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3CIShwiP/W\n" + "JmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exAL\n" + "DmKudlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZC\n" + "huOl1UcCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw\n" + "HQYDVR0OBBYEFMR5yo6hTgMdHNxr2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IB\n" + "AQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9cr5HqQ6XErhK8WTTOd8lNNTB\n" + "zU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbEAp7aDHdlDkQN\n" + "kv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD\n" + "AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUH\n" + "SJsMC8tJP33st/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2G\n" + "spki4cErx5z481+oghLrGREt\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBF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MBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY\n" + "MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG\n" + "9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc\n" + "aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX\n" + "IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn\n" + "ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z\n" + "uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN\n" + "Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja\n" + "QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW\n" + "koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9\n" + "ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt\n" + "DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm\n" + "bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxM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n" + "HSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8EBAMCAYYwDQYJ\n" + "KoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z\n" + "dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQ\n" + "L1EuxBRa3ugZ4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgr\n" + "Fg5fNuH8KrUwJM/gYwx7WBr+mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSo\n" + "ag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpqA1Ihn0CoZ1Dy81of398j9tx4TuaY\n" + "T1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz\n" + "GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m\n" + "1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV\n" + "OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH\n" + "6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX\n" + "QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ\n" + "FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F\n" + "uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX\n" + "kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs\n" + "ewv4n4Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc\n" + "8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke\n" + "hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI\n" + "KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg\n" + "515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO\n" + "xwy8p2Fp8fc74SrL+SvzZpA3\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\n" + "A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\n" + "b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw\n" + "MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\n" + "YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT\n" + "aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ\n" + "jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp\n" + "xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp\n" + "1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG\n" + "snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ\n" + "U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8\n" + "9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E\n" + "BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B\n" + "AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz\n" + "yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE\n" + "38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP\n" + "AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\n" + "DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\n" + "HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1\n" + "MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL\n" + "v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8\n" + "eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq\n" + "tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd\n" + "C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa\n" + "zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB\n" + "mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH\n" + "V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n\n" + "bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG\n" + "3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs\n" + "J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO\n" + "291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS\n" + "ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd\n" + "AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7\n" + "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R3\n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dRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\n" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\n" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\n" + "WD9f\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R6\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg\n" + "MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh\n" + "bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQx\n" + "MjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjET\n" + "MBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCAiIwDQYJ\n" + "KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQssgrRI\n" + "xutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1k\n" + "ZguSgMpE3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxD\n" + "aNc9PIrFsmbVkJq3MQbFvuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJw\n" + "LnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqMPKq0pPbzlUoSB239jLKJz9CgYXfIWHSw\n" + "1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+azayOeSsJDa38O+2HBNX\n" + "k7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO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ffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R\n" + "8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4\n" + "5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Global Chambersign Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD\n" + "aGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMxNDBaFw0zODA3MzEx\n" + "MjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3Vy\n" + "cmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAG\n" + "A1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAl\n" + "BgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZI\n" + "hvcNAQEBBQADggIPADCCAgoCggIBAMDfVtPkOpt2RbQT2//BthmLN0EYlVJH6xed\n" + "KYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXfXjaOcNFccUMd2drvXNL7\n" + "G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0ZJJ0YPP2\n" + "zxhPYLIj0Mc7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pY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZI\n" + "hvcNAQEFBQADggIBAICIf3DekijZBZRG/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZ\n" + "UohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6ReAJ3spED8IXDneRRXoz\n" + "X1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/sdZ7LoR/x\n" + "fxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVz\n" + "a2Mg9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yyd\n" + "Yhz2rXzdpjEetrHHfoUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMd\n" + "SqlapskD7+3056huirRXhOukP9DuqqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9O\n" + "AP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETrP3iZ8ntxPjzxmKfFGBI/5rso\n" + "M0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVqc5iJWzouE4ge\n" + "v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z\n" + "09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh\n" + "MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE\n" + "YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3\n" + "MDYyMFoXDTM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IZ0KbIIOqPjCDPoQ\n" + "HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER\n" + "dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf\n" + "ReYNnyicsbkqWletNw+vHX/bvZ8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" + "EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp\n" + "ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz\n" + "NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH\n" + "EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE\n" + "AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw\n" + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD\n" + "E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH\n" + "/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy\n" + "DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh\n" + "GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR\n" + "tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA\n" + "AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE\n" + "FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX\n" + "WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu\n" + "9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr\n" + "gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo\n" + "2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n" + "LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n" + "4uJEvlz36hz1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions ECC RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN\n" + "BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl\n" + "bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv\n" + "b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ\n" + "BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj\n" + "YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5\n" + "MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0\n" + "dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg\n" + "QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa\n" + "jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC\n" + "MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi\n" + "C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep\n" + "lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof\n" + "TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1Ix\n" + "RDBCBgNVBAoTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1p\n" + "YyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIFJvb3RDQSAyMDExMB4XDTExMTIw\n" + "NjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYTAkdSMUQwQgYDVQQK\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Wftjj++n08C9bMJL/NMh98qy5V8Acys\n" + "Nnq/onN694/BtZqhFLKPM58N7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXI\n" + "l7WdmplNsDz4SgCbZN2fOUvRJ9e4\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix\n" + "DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k\n" + "IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT\n" + "N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9v\n" + "dENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAxMTIxWjCBpjELMAkG\n" + "A1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNh\n" + "ZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkx\n" + "QDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgUm9vdENBIDIwMTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" + "AQDC+Kk/G4n8PDwEXT2QNrCROnk8ZlrvbTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA\n" + "4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+ehiGsxr/CL0BgzuNtFajT0\n" + "AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+6PAQZe10\n" + "4S+nfK8nNLspfZu2z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vo2FXDtKK4F5D7Rpn0lQ\n" + "l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf\n" + "bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4\n" + "pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK\n" + "e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0\n" + "vm9qp/UsQu0yrbYhnr68\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsx\n" + "FjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3Qg\n" + "Um9vdCBDQSAxMB4XDTAzMDUxNTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkG\n" + "A1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdr\n" + "b25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1ApzQ\n" + "jVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEn\n" + "PzlTCeqrauh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjh\n" + "ZY4bXSNmO7ilMlHIhqqhqZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9\n" + "nnV0ttgCXjqQesBCNnLsak3c78QA3xMYV18meMjWCnl3v/evt3a5pQuEF10Q6m/h\n" + "q5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNVHRMBAf8ECDAGAQH/AgED\n" + "MA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7ih9legYsC\n" + "mEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI3\n" + "7piol7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clB\n" + "oiMBdDhViw+5LmeiIAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJs\n" + "EhTkYY2sEJCehFC78JZvRZ+K88psT/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpO\n" + "fMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilTc4afU9hDDl3WY4JxHYB0yvbi\n" + "AmvZWg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL\n" + "BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ\n" + "SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n\n" + "a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5\n" + "NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtvbmcxEjAQBgNVBAcT\n" + "CUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMXSG9u\n" + "Z2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK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RTnU+kLBEUx3XZL7av9YROXr\n" + "gZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov+BS5gLNdTaqX4fnk\n" + "GMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDceqFS\n" + "3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJm\n" + "Ozj/2ZQw9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+\n" + "l6mc1X5VTMbeRRAc6uk7nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6c\n" + "JfTzPV4e0hz5sy229zdcxsshTrD3mUcYhcErulWuBurQB7Lcq9CClnXO0lD+mefP\n" + "L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa\n" + "LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG\n" + "mpv0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ISRG Root X1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" + "WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n" + "ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n" + "MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n" + "h77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6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5\n" + "ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n" + "TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n" + "jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n" + "oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n" + "4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n" + "mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" + "emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Commercial Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu\n" + "VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw\n" + "MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw\n" + "JQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ldhNlT\n" + "3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9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mrlR94gjmmmVYjzlVYA211QC//G5Xc7UI2/YRYRK\n" + "W2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUXfeu+h1sXIFRRk0pT\n" + "AwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/rokTLq\n" + "l1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG\n" + "4iZZRHUe2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZ\n" + "mUlO+KWA2yUPHGNiiskzZ2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A\n" + "7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7RcGzM7vRX+Bi6hG6H\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Public Sector Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu\n" + "VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN\n" + "MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0\n" + "MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTyP4o7\n" + "ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGy\n" + "RBb06tD6Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlS\n"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IHWchezxQMxNRF4eKLg6TCMf4Df\n" + "WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5\n" + "+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ\n" + "tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA\n" + "GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv\n" + "8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Izenpe.com\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4\n" + "MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6\n" + "ZW5wZS5jb20wHhcNMDcxMjEzMTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYD\n" + "VQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5j\n" + "b20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ03rKDx6sp4boFmVq\n" + "scIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAKClaO\n" + "xdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6H\n" + "LmYRY2xU+zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFX\n" + "uaOKmMPsOzTFlUFpfnXCPCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQD\n" + "yCV8wXDbO/QJLVQnSK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5hzkQiCeR7Csg1lw\n" + "LDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCT\n" + "VyvehQP5aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGk\n" + "LhObNA5me0mrZJfQRsN5nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJb\n" + "UjWumDqtujWTI6cfSN01RpiyEGjkpTHCClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/\n" + "QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZoQ0iy2+tzJOeRf1SktoA+\n" + "naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1ZWrOZyGls\n" + "QyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# LuxTrust Global Root 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL\n" + "BQAwRjELMAkGA1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNV\n" + "BAMMFkx1eFRydXN0IEdsb2JhbCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUw\n" + "MzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEWMBQGA1UECgwNTHV4VHJ1c3QgUy5B\n" + "LjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBANeFl78RmOnwYoNMPIf5U2o3C/IPPIfOb9wmKb3F\n" + "ibrJgz337spbxm1Jc7TJRqMbNBM/wYlFV/TZsfs2ZUv7COJIcRHIbjuend+JZTem\n" + "hfY7RBi2xjcwYkSSl2l9QjA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GvI1+ut7MV3CwRI9\n" + "loGIlonBWVx65n9wNOeD4rHh4bhY79SV5GCc8JaXcozrhAIuZY+kt9J/Z93I055c\n" + "qqmkoCUUBpvsT34tC38ddfEz2O3OuHVtPlu5mB0xDVbYQw8wkbIEa91WvpWAVWe+\n" + "2M2D2RjuLg+GLZKecBPs3lHJQ3gCpU3I+V/EkVhGFndadKpAvAefMLmx9xIX3eP/\n" + "JEAdemrRTxgKqpAd60Ae36EeRJIQmvKN4dFLRp7oRUKX6kWZ8+xm1QL68qZKJKre\n" + "zrnK+T+Tb/mjuuqlPpmt/f97mfVl7vBZKGfXkJWkE4SphMHozs51k2MavDzq1WQf\n" + "LSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc7kGUnF4ZLvhFSZl0kbAEb+MEWrGrKqv+\n" + "x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6\n" + "oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Microsec e-Szigno Root CA 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\n" + "VQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0\n" + "ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0G\n" + "CSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTAeFw0wOTA2MTYxMTMwMThaFw0y\n" + "OTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3Qx\n" + "FjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3pp\n" + "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DDfSJlgnCW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# NetLock Arany (Class Gold) Főtanúsítvány\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG\n" + "EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3\n" + "MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl\n" + "cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR\n" + "dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgxMjA2MTUwODIxWjCB\n" + "pzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxOZXRM\n" + "b2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlm\n" + "aWNhdGlvbiBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNz\n" + "IEdvbGQpIEbFkXRhbsO6c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAxCRec75LbRTDofTjl5Bu0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrT\n" + "lF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw/HpYzY6b7cNGbIRwXdrz\n" + "AZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAkH3B5r9s5\n" + "VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRG\n" + "ILdwfzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2\n" + "BJtr+UBdADTHLpl1neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAG\n" + "AQH/AgEEMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2M\n" + "U9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwWqZw8UQCgwBEIBaeZ5m8BiFRh\n" + "bvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTtaYtOUZcTh5m2C\n" + "+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC\n" + "bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2F\n" + "uLjbvrW5KfnaNwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2\n" + "XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Network Solutions Certificate Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBi\n" + "MQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu\n" + "MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3Jp\n" + "dHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJV\n" + "UzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydO\n" + "ZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqG\n" + "SIb3DQEBAQUAA4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JKwYBBAGCNxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOx\n" + "SPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vImMMkQyh2I+3QZH4VFvbBsUfk2\n" + "ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4+vg1YFkCExh8\n" + "vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa\n" + "hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZi\n" + "Fj4A4xylNoEYokxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ\n" + "/L7fCg0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GB CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBt\n" + "MQswCQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUg\n" + "Rm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9i\n" + "YWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAwMzJaFw0zOTEyMDExNTEwMzFaMG0x\n" + "CzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBG\n" + "b3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh\n" + "bCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3\n" + "HEokKtaXscriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGx\n" + "WuR51jIjK+FTzJlFXHtPrby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX\n" + "1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNk\n" + "u7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4oQnc/nSMbsrY9gBQHTC5P\n" + "99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvgGUpuuy9r\n" + "M2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw\n" + "AwEB/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUB\n" + "BAMCAQAwDQYJKoZIhvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrgh\n" + "cViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5\n" + "gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3ZwLWoo4rO\n" + "ZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" + "aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic\n" + "Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GC CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw\n" + "CQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91\n" + "bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtle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ljYXRlIFBvbGljeS4wIgYI\n" + "KwYBBQUHAgEWFmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3T\n" + "KbkGGew5Oanwl4Rqy+/fMIGuBgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rq\n" + "y+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1p\n" + "dGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD\n" + "VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL\n" + "MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk\n" + "fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8\n" + "7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R\n" + "cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y\n" + "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n" + "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n" + "SnQ2+Q==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 1 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3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HX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC\n" + "MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2\n" + "cDMT/uFPpiN3GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUN\n" + "qXsCHKnQO18LwIE6PWThv6ctTr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5\n" + "YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP+V04ikkwj+3x6xn0dxoxGE1nVGwv\n" + "b2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh3jRJjehZrJ3ydlo2\n" + "8hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fawx/k\n" + "NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj\n" + "ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp\n" + "q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt\n" + "nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9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wDQYJKoZIhvcNAQEFBQADggIBAD4KFk2f\n" + "BluornFdLwUvZ+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzn\n" + "g/iN/Ae42l9NLmeyhP3ZRPx3UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2Bl\n" + "fF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodmVjB3pjd4M1IQWK4/YY7yarHvGH5K\n" + "WWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK+JDSV6IZUaUtl0Ha\n" + "B0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrWIozc\n" + "hLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPR\n" + "TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD\n" + "mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z\n" + "ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y\n" + "4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza\n" + "8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00\n" + "MjAxMTIxODU5Mz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Qr36LLTn91nMX66\n" + "AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RC\n" + "roijQ1h5fq7KpVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0Ga\n" + "W/ZZGYjeVYg3UQt4XAoeo0L9x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4n\n" + "lv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgzdWqTHBLmYF5vHX/JHyPLhGGfHoJE\n" + "+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6XU/IyAgkwo1jwDQHV\n" + "csaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+NwmNtd\n" + "dbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg\n" + "KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM\n" + "HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4\n" + "WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDMwggI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\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00\n" + "MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286IxSR\n" + "/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNu\n" + "FoM7pmRLMon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXR\n" + "U7Ox7sWTaYI+FrUoRqHe6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+c\n" + "ra1AdHkrAj80//ogaX3T7mH1urPnMNA3I4ZyYUUpSFlob3emLoG+B01vr87ERROR\n" + "FHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3UVDmrJqMz6nWB2i3ND0/k\n" + "A9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f75li59wzw\n" + "eyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634Ryl\n" + "sSqiMd5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBp\n" + "VzgeAVuNVejH38DMdyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0Q\n" + "A4XN8f+MFrXBsj6IbGB/kE+V9/YtrQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+\n" + "ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB\n" + "BjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZIhvcNAQELBQAD\n" + "ggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px\n" + "KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnI\n" + "FUBhynLWcKzSt/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5Wvv\n" + "oxXqA/4Ti2Tk08HS6IT7SdEQTXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFg\n" + "u/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9DuDcpmvJRPpq3t/O5jrFc/ZSXPsoaP\n" + "0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGibIh6BJpsQBJFxwAYf\n" + "3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmDhPbl\n" + "8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+\n" + "DhcI00iX0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HN\n" + "PlopNLk9hM6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/\n" + "ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx\n" + "NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv\n" + "bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49\n" + "AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA\n" + "VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku\n" + "WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP\n" + "MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX\n" + "5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ\n" + "ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg\n" + "h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority RSA R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF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mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0\n" + "aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz\n" + "WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0\n" + "b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS\n" + "b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB\n" + "BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI\n" + "7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg\n" + "CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD\n" + "VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T\n" + "kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+\n" + "gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority RSA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz\n" + "OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv\n" + "bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2R\n" + "xFdHaxh3a3by/ZPkPQ/CFp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aX\n" + "qhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcC\n" + "C52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/geoeOy3ZExqysdBP+lSgQ3\n" + "6YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkpk8zruFvh\n" + "/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrF\n" + "YD3ZfBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93E\n" + "JN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FqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsF\n" + "AAOCAQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw\n" + "8PRBEew/R40/cof5O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOG\n" + "nXkZ7/e7DDWQw4rtTw/1zBLZpD67oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCP\n" + "oky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul4+vJhaAlIDf7js4MNIThPIGy\n" + "d05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6+/NNIxuZMzSg\n" + "LvWpCz/UXeHPhJ/iGcJfitYgHuNztw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureSign RootCA11\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDEr\n" + "MCkGA1UEChMiSmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoG\n" + "A1UEAxMTU2VjdXJlU2lnbiBSb290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0\n" + "MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSswKQYDVQQKEyJKYXBhbiBDZXJ0aWZp\n" + "Y2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1cmVTaWduIFJvb3RD\n" + "QTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvLTJsz\n" + "i1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8\n" + "h9uuywGOwvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOV\n" + "MdrAG/LuYpmGYz+/3ZMqg6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9\n" + "UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rPO7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni\n" + "8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitAbpSACW22s293bzUIUPsC\n" + "h8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZXt94wDgYD\n" + "VR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB\n" + "AKChOBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xm\n" + "KbabfSVSSUOrTC4rbnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQ\n" + "X5Ucv+2rIrVls4W6ng+4reV6G4pQOh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWr\n" + "QbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01y8hSyn+B/tlr0/cR7SXf+Of5\n" + "pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061lgeLKBObjBmN\n" + "QSdJQO7e5iNEOdyhIta6A/I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureTrust CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI\n" + "MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x\n" + "FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz\n" + "MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv\n" + "cnBvcmF0aW9uMRcwFQYDVQ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" + "AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L\n" + "URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO\n" + "H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm\n" + "I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY\n" + "iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc\n" + "f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication RootCA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl\n" + "MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe\n" + "U2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoX\n" + "DTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRy\n" + "dXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3VyaXR5IENvbW11bmlj\n" + "YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV\n" + "OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr\n" + "zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM\n" + "VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ\n" + "hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO\n" + "ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw\n" + "awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs\n" + "OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3\n" + "DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF\n" + "coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc\n" + "okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8\n" + "t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy\n" + "1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/\n" + "SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY\n" + "MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t\n" + "dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5\n" + "WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD\n" + "VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8\n" + "9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ\n" + "DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9\n" + "Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N\n" + "QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ\n" + "xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G\n" + "A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T\n" + "AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG\n" + "kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr\n" + "Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5\n" + "Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU\n" + "JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot\n" + "RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Sonera Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP\n"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HllpwrN9M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gRVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0y\n" + "MjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIg\n" + "TmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRlcmxhbmRlbiBFViBS\n" + "b290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkkSzrS\n" + "M4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nC\n" + "UiY4iKTWO0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3d\n" + "Z//BYY1jTw+bbRcwJu+r0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46p\n" + "rfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13l\n" + "pJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gVXJrm0w912fxBmJc+qiXb\n" + "j5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr08C+eKxC\n" + "KFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS\n" + "/ZbV0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0X\n" + "cgOPvZuM5l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cert += + "# Staat der Nederlanden Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloX\n" + "DTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMCTkwxHjAcBgNVBAoMFVN0YWF0IGRl\n" + "ciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5lZGVybGFuZGVuIFJv\n" + "b3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4yolQP\n" + "cPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WW\n" + "IkYFsO2tx1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqX\n" + "xz8ecAgwoNzFs21v0IJyEavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFy\n" + "KJLZWyNtZrVtB0LrpjPOktvA9mxjeM3KTj215VKb8b475lRgsGYeCasH/lSJEULR\n" + "9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUurmkVLoR9BvUhTFXFkC4az\n" + "5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU51nus6+N8\n" + "6U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7\n" + "Ngzp07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHP\n" + "bMk7ccHViLVlvMDoFxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXt\n" + "BznaqB16nzaeErAMZRKQFWDZJkBE41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTt\n" + "XUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMBAAGjQjBAMA8GA1UdEwEB/wQF\n" + "MAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleuyjWcLhL75Lpd\n" + "INyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD\n" + "U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwp\n" + "LiniyMMB8jPqKqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8\n" + "Ipf3YF3qKS9Ysr1YvY2WTxB1v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixp\n" + "gZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA8KCWAg8zxXHzniN9lLf9OtMJgwYh\n" + "/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b8KKaa8MFSu1BYBQw\n" + "0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0rmj1A\n" + "fsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq\n" + "4BZ+Extq1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR\n" + "1VmiiXTTn74eS9fGbbeIJG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/\n" + "QFH1T/U67cjF68IeHRaVesd+QnGTbksVtzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM\n" + "94B7IWcnMFk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" +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AwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Services Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZW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LTyxQGjhdByPq1z\n" + "qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n" + "iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n" + "0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n" + "sSi6\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Gold CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n" + "BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln\n" + "biBHb2xkIENBIC0gRzIwHhcNMDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBF\n" + "MQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMR8wHQYDVQQDExZT\n" + "d2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC\n" + "CgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUqt2/8\n" + "76LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+\n" + "bbqBHH5CjCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c\n" + "6bM8K8vzARO/Ws/BtQpgvd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqE\n" + "emA8atufK+ze3gE/bk3lUIbLtK/tREDFylqM2tIrfKjuvqblCqoOpd8FUrdVxyJd\n" + "MmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvRAiTysybUa9oEVeXBCsdt\n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a1ShNqR88uC1aVVMvOmttqtKay20EIhid3\n" + "92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp\n" + "Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w\n" + "ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt\n" + "Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Silver CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE\n" + "BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWdu\n" + "IFNpbHZlciBDQSAtIEcyMB4XDTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0Nlow\n" + "RzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMY\n" + "U3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A\n" + "MIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644N0Mv\n" + "Fz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7br\n" + "YT7QbNHm+/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieF\n" + "nbAVlDLaYQ1HTWBCrpJH6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH\n" + "6ATK72oxh9TAtvmUcXtnZLi2kUpCe2UuMGoM9ZDulebyzYLs2aFK7PayS+VFheZt\n" + "eJMELpyCbTapxD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11bHkFlt4dR2X\n" + "em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR\n" + "dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/\n" + "OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+\n" + "hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy\n" + "tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgxMDAxMTA0MDE0WhcNMzMxMDAxMjM1\n" + "OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy\n" + "aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50\n" + "ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0G\n" + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUd\n" + "AqSzm1nzHoqvNK38DcLZSBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiC\n" + "FoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/FvudocP05l03Sx5iRUKrERLMjfTlH6VJi\n" + "1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx9702cu+fjOlbpSD8DT6Iavq\n" + "jnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGVWOHAD3bZ\n" + "wI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGj\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/\n" + "WSA2AHmgoCJrjNXyYdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhy\n" + "NsZt+U2e+iKo4YFWz827n+qrkRk4r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPAC\n" + "uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw\n" + "IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6\n" + "g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN\n" + "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" + "BSeOE6Fuwg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx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ml\n" + "e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p\n" + "TpPDpFQUWw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx\n" + "GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp\n" + "bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w\n" + "KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0\n" + "BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRpZmlrYXNpIC0gU3Vy\n" + "dW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYDVQQG\n" + "EwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXll\n" + "IEJpbGltc2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklU\n" + "QUsxLTArBgNVBAsTJEthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBT\n" + "TTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11IFNNIFNTTCBLb2sgU2VydGlmaWthc2kg\n" + "LSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr3UwM6q7\n" + "a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y86Ij5iySr\n" + "LqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INr\n" + "N3wcwv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2X\n" + "YacQuFWQfw4tJzh03+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/\n" + "iSIzL+aFCr2lqBs23tPcLG07xxO9WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4f\n" + "AJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQUZT/HiobGPN08VFw1+DrtUgxH\n" + "V8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh\n" + "AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPf\n" + "IPP54+M638yclNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4\n" + "lzwDGrpDxpa5RXI4s6ehlj2Re37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c\n" + "8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0jq5Rm+K37DwhuJi1/FwcJsoz7UMCf\n" + "lo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcx\n" + "EjAQBgNVBAoTCVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMT\n" + "VFdDQSBHbG9iYWwgUm9vdCBDQTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5\n" + "NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQKEwlUQUlXQU4tQ0ExED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1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WF\n" + "H6vPNOw/KP4M8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNo\n" + "RI2T9GRwoD2dKAXDOXC4Ynsg/eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+\n" + "nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlglPx4mI88k1HtQJAH32RjJMtOcQWh\n" + "15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryPA9gK8kxkRr05YuWW\n" + "6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3mi4TW\n" + "nsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5j\n" + "wa19hAM8EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWz\n" + "aGHQRiapIVJpLesux+t3zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmy\n" + "KwbQBM0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TWCA Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES\n" + "MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU\n" + "V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz\n" + "WhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJVEFJV0FO\n" + "LUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + "AQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFE\n" + "AcK0HMMxQhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HH\n" + "K3XLfJ+utdGdIzdjp9xCoi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeX\n" + "RfwZVzsrb+RH9JlF/h3x+JejiB03HFyP4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/z\n" + "rX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1ry+UPizgN7gr8/g+YnzAx\n" + "3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkq\n" + "hkiG9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeC\n" + "MErJk/9q56YAf4lCmtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdls\n" + "XebQ79NqZp4VKIV66IIArB6nCWlWQtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62D\n" + "lhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVYT0bf+215WfKEIlKuD8z7fDvn\n" + "aspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocnyYh0igzyXxfkZ\n" + "YiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Taiwan GRCA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/\n" + "MQswCQYDVQQGEwJUVzEwMC4GA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E\n" + "MTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg209yewDL7MTqK\n" + "UWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ\n" + "TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyf\n" + "qzvS/3WXy6TjZwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaK\n" + "ZEk9GhiHkASfQlK3T8v+R0F2Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFE\n" + "JPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlUD7gsL0u8qV1bYH+Mh6XgUmMqvtg7\n" + "hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6QzDxARvBMB1uUO07+1\n" + "EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+HbkZ6Mm\n" + "nD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WX\n" + "udpVBrkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz\n" + "ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe\n" + "LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl\n" + "pYYsfPQS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TeliaSonera Root CA v1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAw\n" + "NzEUMBIGA1UECgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJv\n" + "b3QgQ0Eg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wI//DTDGjkk0kiP0Qnb7tt3oNmzqjMDfz1mgbl\n" + "dxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx\n" + "0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1Tj\n" + "TQpgcmLNkQfWpb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBed\n" + "Y2gea+zDTYa4EzAvXUYNR0PVG6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7\n" + "Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpcc41teyWRyu5FrgZLAMzTsVlQ2jqI\n" + "OylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOTJsjrDNYmiLbAJM+7\n" + "vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2qReW\n" + "t88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcn\n" + "HL/EVlP6Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVx\n" + "SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor ECA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U\n" + "cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxFzAVBgNVBAMMDlRydXN0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fGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50\n" + "soIipX1TH0XsJ5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BI\n" + "WJZpTdwHjFGTot+fDz2LYLSCjaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1Wi\n" + "tJ/X5g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U\n" + "cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29y\n" + "IFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkxMjMxMTcyMzE2WjCB\n" + "pDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFuYW1h\n" + "IENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUG\n" + "A1UECwweVHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZU\n" + "cnVzdENvciBSb290Q2VydCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + "CgKCAQEAv463leLCJhJrMxnHQFgKq1mqjQCj/IDHUHuO1CAmujIS2CNUSSUQIpid\n" + "RtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4pQa81QBeCQryJ3pS/C3V\n" + "seq0iWEk8xoT26nPUu0MJLq5nux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Q7DsdwyhEQsb8tGD+pmQQ9P8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZE\n" + "f1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHVl/9D7S3B2l0pKoU/rGXuhg8F\n" + "jZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYliB6XzCGcKQEN\n" + "ZetX2fNXlrtIzYE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Extended Validation Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBF\n" + "eHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMx\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNV\n" + "BAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrsiWog\n" + "D4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvS\n" + "sPGP2KxFRv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aop\n" + "O2z6+I9tTcg1367r3CTueUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dk\n" + "sHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR59mzLC52LqGj3n5qiAno8geK+LLNEOfi\n" + "c0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH0mK1lTnj8/FtDw5lhIpj\n" + "VMW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TajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx\n" + "cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM\n" + "fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Global G2 Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH\n" + "bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0x\n" + "CzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlUcnVzdDEbMBkGA1UEAwwSVUNBIEds\n" + "b2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxeYr\n" + "b3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmToni9\n" + "kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzm\n" + "VHqUwCoV8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/R\n" + "VogvGjqNO7uCEeBHANBSh6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDc\n" + "C/Vkw85DvG1xudLeJ1uK6NjGruFZfc8oLTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIj\n" + "tm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/R+zvWr9LesGtOxdQXGLY\n" + "D0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBeKW4bHAyv\n" + "j5OJrdu9o54hyokZ7N+1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SN4p1bX\n" + "UB+K+wb1whnw0A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + "VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo\n" + "I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng\n" + "o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G\n" + "A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB\n" + "zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW\n" + "RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB\n" + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw\n" + "MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV\n" + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU\n" + "aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B\n" + "3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY\n" + "tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/\n" + "Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2\n" + "VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT\n" + "79uq/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6\n" + "c0Plfg6lZrEpfDKEY1WJxA3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AvgnEzDHNb842m1R0aB\n" + "L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n" + "jjxDah2nGN59PRbxYvnKkKj9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjELMAkG\n" + "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJp\n" + "U2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwg\n" + "SW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2ln\n" + "biBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5\n" + "IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8Utpkmw4tXNherJI9/gHm\n" + "GUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGzrl0Bp3ve\n" + "fLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUw\n" + "AwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJ\n" + "aW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYj\n" + "aHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMW\n" + "kf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMDA2gAMGUCMGYhDBgmYFo4e1ZC\n" + "4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIxAJw9SDkjOVga\n" + "FRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\n" + "ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQ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lK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Universal Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB\n" + "vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MTgwNgYDVQQDEy9W\n" + "ZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJVUzEX\n" + "MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0\n" + "IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9y\n" + "IGF1dGhvcml6ZWQgdXNlIG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNh\n" + "bCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF\n" + "AAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj1mCOkdeQmIN65lgZOIzF\n" + "9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGPMiJhgsWH\n" + "H26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+H\n" + "LL729fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN\n" + "/BMReYTtXlT2NJ8IAfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPT\n" + "rJ9VAMf2CGqUuV/c4DPxhGD5WycRtPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0GCCsGAQUFBwEMBGEwX6FdoFsw\n" + "WTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2Oa8PPgGrUSBgs\n" + "exkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud\n" + "DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4\n" + "sAPmLGd75JR3Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+\n" + "seQxIcaBlVZaDrHC1LGmWazxY8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz\n" + "4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTxP/jgdFcrGJ2BtMQo2pSXpXDrrB2+\n" + "BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+PwGZsY6rp2aQW9IHR\n" + "lRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3\n" + "7M2CYfE45k+XmCpajQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Verisign Class 3 Public Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n"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5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu\n" + "imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te\n" + "2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe\n" + "DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC\n" + "/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p\n" + "F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt\n" + "TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# XRamp Global CA Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB\n" + "gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk\n" + "MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY\n" + "UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx\n" + "NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3\n" + "dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2Vy\n" + "dmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB\n" + "dXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCY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q5L6I\n" + "Jd1hJyMctTEHBDa0GpC9oHRxUIltvBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNw\n" + "i/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7NzTogVZ96edhBiIL5VaZVDADlN\n" + "9u6wWk5JRFRYX0KD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ePKI Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe\n" + "MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0\n" + "ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMxMjdaMF4xCzAJBgNVBAYTAlRXMSMw\n" + "IQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEqMCgGA1UECwwhZVBL\n" + "SSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEF\n" + "AAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAH\n" + "SyZbCUNsIZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAh\n" + "ijHyl3SJCRImHJ7K2RKilTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3X\n" + "DZoTM1PRYfl61dd4s5oz9wCGzh1NlDivqOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1\n" + "TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX12ruOzjjK9SXDrkb5wdJ\n" + "fzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0OWQqraff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h0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z\n" + "Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE\n" + "W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D\n" + "hNQ+IIX3Sj0rnP0qCglN6oH4EZw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - C3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG\n" + "EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx\n" + "IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND\n" + "IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci\n" + "MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti\n" + "sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O\n" + "BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\n" + "Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c\n" + "3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J\n" + "0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n" + "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n" + "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n" + "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n" + "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n" + "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n" + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n" + "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n" + "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n" + "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n" + "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n" + "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n" + "+JbNR6iC8hZVdyR+EhCVBCyj\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - C1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELB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um6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT\n" + "+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo\n" + "WXzhriKi4gp6D/piq1JM4fHfyr6DDUI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - G1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD\n" + "VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU\n" + "ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH\n" + "MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO\n" + "MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv\n" + "Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN\n" + "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz\n" + "f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO\n" + "8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq\n" + "d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM\n" + "tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt\n" + "Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB\n" + "o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD\n" + "AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x\n" + "PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM\n" + "wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d\n" + "GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH\n" + "6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby\n" + "RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx\n" + "iN66zB+Afko=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB\n" + "qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV\n" + "BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw\n" + "NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j\n" + "LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG\n" + "A1UECxMvKGMp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thawte Primary Root CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp\n" + "IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi\n" + "BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw\n" + "MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh\n" + "d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig\n" + "YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v\n" + "dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/\n" + "BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6\n" + "papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K\n" + "DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3\n" + "KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox\n" + "XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjC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VHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" + "HQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJKoZIhvcNAQELBQADggEBABpA\n" + "2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweKA3rD6z8KLFIW\n" + "oCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu\n" + "t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7c\n" + "KUGRIjxpp7sC8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fM\n" + "m7v/OeZWYdMKp8RcTGB7BXcmer/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZu\n" + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + + static_cast( + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + ctx.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec)); + if (ec) { + return; + } +} + +} // namespace detail + +// Load the root certificates into an ssl::context + +inline void load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) { + detail::load_root_certificates(ctx, ec); +} + +inline void load_root_certificates(ssl::context& ctx) { + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); + if (ec) { + throw boost::system::system_error{ec}; + } +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/common/server_certificate.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/common/server_certificate.hpp new file mode 100644 index 0000000..43902a3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/common/server_certificate.hpp @@ -0,0 +1,139 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP + +#include +#include +#include +#include + +/* Load a signed certificate into the ssl context, and configure + the context for use with a server. + + For this to work with the browser or operating system, it is + necessary to import the "Beast Test CA" certificate into + the local certificate store, browser, or operating system + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. +*/ +inline void load_server_certificate(boost::asio::ssl::context& ctx) { + if (auto const* path = std::getenv("WEBCPP_BEAST_FIXTURE_CERT")) { + ctx.use_certificate_chain_file(path); + ctx.use_private_key_file(std::getenv("WEBCPP_BEAST_FIXTURE_KEY"), + boost::asio::ssl::context::pem); + return; + } + + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 + openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj + "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = + "-----BEGIN CERTIFICATE-----\n" + "MIIDlTCCAn2gAwIBAgIUOLxr3q7Wd/pto1+2MsW4fdRheCIwDQYJKoZIhvcNAQEL\n" + "BQAwWjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRQwEgYDVQQHDAtMb3MgQW5n\n" + "ZWxlczEOMAwGA1UECgwFQmVhc3QxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTAe\n" + "Fw0yMTA3MDYwMTQ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z1wnADzjpbJrpegCA3pmvhT\n" + "7356drqnCGY9\n" + "-----END CERTIFICATE-----\n"; + + std::string const key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz0GwgnxSBhygx\n" + "BdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOTLppr5MKxqQHEpYdyDYGD1noBoz4T\n" + "iIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05P41c2F9pBEnUwUxIUG1Cb6AN0cZW\n" + "F/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATmWm9SJc2lsjWptbyIN6hFXLYPXTwn\n" + "YzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7rV+AiGTxUU35V0AzpJlmvct5aJV/\n" + "5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4lIzJ8yxzOzSStBPxvdrOobSSNlRZ\n" + "IlE7gnyNAgMBAAECggEAY0RorQmldGx9D7M+XYOPjsWLs1px0cXFwGA20kCgVEp1\n" + "kleBeHt93JqJsTKwOzN2tswl9/ZrnIPWPUpcbBlB40ggjzQk5k4jBY50Nk2jsxuV\n" + "9A9qzrP7AoqhAYTQjZe42SMtbkPZhEeOyvCqxBAi6csLhcv4eB4+In0kQo7dfvLs\n" + "Xu/3WhSsuAWqdD9EGnhD3n+hVTtgiasRe9318/3R9DzP+IokoQGOtXm+1dsfP0mV\n" + "8XGzQHBpUtJNn0yi6SC4kGEQuKkX33zORlSnZgT5VBLofNgra0THd7x3atOx1lbr\n" + "V0QizvCdBa6j6FwhOQwW8UwgOCnUbWXl/Xn4OaofMQKBgQDdRXSMyys7qUMe4SYM\n" + "Mdawj+rjv0Hg98/xORuXKEISh2snJGKEwV7L0vCn468n+sM19z62Axz+lvOUH8Qr\n" + "hLkBNqJvtIP+b0ljRjem78K4a4qIqUlpejpRLw6a/+44L76pMJXrYg3zdBfwzfwu\n" + "b9NXdwHzWoNuj4v36teGP6xOUwKBgQDQCT52XX96NseNC6HeK5BgWYYjjxmhksHi\n" + "stjzPJKySWXZqJpHfXI8qpOd0Sd1FHB+q1s3hand9c+Rxs762OXlqA9Q4i+4qEYZ\n" + "qhyRkTsl+2BhgzxmoqGd5gsVT7KV8XqtuHWLmetNEi+7+mGSFf2iNFnonKlvT1JX\n" + "4OQZC7ntnwKBgH/ORFmmaFxXkfteFLnqd5UYK5ZMvGKTALrWP4d5q2BEc7HyJC2F\n" + "+5lDR9nRezRedS7QlppPBgpPanXeO1LfoHSA+CYJYEwwP3Vl83Mq/Y/EHgp9rXeN\n" + "L+4AfjEtLo2pljjnZVDGHETIg6OFdunjkXDtvmSvnUbZBwG11bMnSAEdAoGBAKFw\n" + "qwJb6FNFM3JnNoQctnuuvYPWxwM1yjRMqkOIHCczAlD4oFEeLoqZrNhpuP8Ij4wd\n" + "GjpqBbpzyVLNP043B6FC3C/edz4Lh+resjDczVPaUZ8aosLbLiREoxE0udfWf2dU\n" + "oBNnrMwwcs6jrRga7Kr1iVgUSwBQRAxiP2CYUv7tAoGBAKdPdekPNP/rCnHkKIkj\n" + "o13pr+LJ8t+15vVzZNHwPHUWiYXFhG8Ivx7rqLQSPGcuPhNss3bg1RJiZAUvF6fd\n" + "e6QS4EZM9dhhlO2FmPQCJMrRVDXaV+9TcJZXCbclQnzzBus9pwZZyw4Anxo0vmir\n" + "nOMOU6XI4lO9Xge/QDEN4Y2R\n" + "-----END PRIVATE KEY-----\n"; + + std::string const dh = + "-----BEGIN DH PARAMETERS-----\n" + "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" + "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" + "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" + "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; + + ctx.set_password_callback( + [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; }); + + ctx.set_options(boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); + + ctx.use_certificate_chain(boost::asio::buffer(cert.data(), cert.size())); + + ctx.use_private_key(boost::asio::buffer(key.data(), key.size()), + boost::asio::ssl::context::file_format::pem); + + ctx.use_tmp_dh(boost::asio::buffer(dh.data(), dh.size())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/http_examples.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/http_examples.hpp new file mode 100644 index 0000000..beceabc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/http_examples.hpp @@ -0,0 +1,939 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include + +/* This file contains the functions and classes found in the documentation + + They are compiled and run as part of the unit tests, so you can copy + the code and use it in your own projects as a starting point for + building a network application. +*/ + +// The documentation assumes the webcpp::beast::http namespace +namespace boost { +namespace beast { +namespace http { + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_http_send_expect_100_continue + +/** Send a request with Expect: 100-continue + + This function will send a request with the Expect: 100-continue + field by first sending the header, then waiting for a successful + response from the server before continuing to send the body. If + a non-successful server response is received, the function + returns immediately. + + @param stream The remote HTTP server stream. + + @param buffer The buffer used for reading. + + @param req The request to send. This function modifies the object: + the Expect header field is inserted into the message if it does + not already exist, and set to "100-continue". + + @param ec Set to the error, if any occurred. +*/ +template +void send_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, + request>& req, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); + + // Create the serializer + request_serializer> sr{req}; + + // Send just the header + write_header(stream, sr, ec); + if (ec) + return; + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); + if (ec) + return; + if (res.result() != status::continue_) { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; + } + } + + // Server is OK with the request, send the body + write(stream, sr, ec); +} + +//] + +//[example_http_receive_expect_100_continue + +/** Receive a request, handling Expect: 100-continue if present. + + This function will read a request from the specified stream. + If the request contains the Expect: 100-continue field, a + status response will be delivered. + + @param stream The remote HTTP client stream. + + @param buffer The buffer used for reading. + + @param ec Set to the error, if any occurred. +*/ +template +void receive_expect_100_continue(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); + if (ec) + return; + + // Check for the Expect field value + if (beast::iequals(parser.get()[field::expect], "100-continue")) { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); + if (ec) + return; + } + + // Read the rest of the message. + // + read(stream, buffer, parser, ec); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Send Child Process Output +// +//------------------------------------------------------------------------------ + +//[example_http_send_cgi_response + +/** Send the output of a child process as an HTTP response. + + The output of the child process comes from a `SyncReadStream`. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. + + @param input A stream to read the child process output from. + + @param output A stream to write the HTTP response to. + + @param ec Set to the error, if any occurred. +*/ +template +void send_cgi_response(SyncReadStream& input, SyncWriteStream& output, error_code& ec) { + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. + response res; + + res.result(status::ok); + res.version(11); + res.set(field::server, "Beast"); + res.set(field::transfer_encoding, "chunked"); + + // No data yet, but we set more = true to indicate + // that it might be coming later. Otherwise the + // serializer::is_done would return true right after + // sending the header. + res.body().data = nullptr; + res.body().more = true; + + // Create the serializer. + response_serializer sr{res}; + + // Send the header immediately. + write_header(output, sr, ec); + if (ec) + return; + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do { + // Read a buffer from the child process + char buffer[2048]; + auto bytes_transferred = input.read_some(boost::asio::buffer(buffer, sizeof(buffer)), ec); + if (ec == boost::asio::error::eof) { + ec = {}; + + // `nullptr` indicates there is no buffer + res.body().data = nullptr; + + // `false` means no more data is coming + res.body().more = false; + } else { + if (ec) + return; + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming + res.body().data = buffer; + res.body().size = bytes_transferred; + res.body().more = true; + } + + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. + if (ec == error::need_buffer) { + ec = {}; + continue; + } + if (ec) + return; + } while (!sr.is_done()); +} + +//] + +//-------------------------------------------------------------------------- +// +// Example: HEAD Request +// +//-------------------------------------------------------------------------- + +//[example_http_do_head_response + +/** Handle a HEAD request for a resource. + */ +template +void do_server_head(SyncStream& stream, DynamicBuffer& buffer, error_code& ec) { + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; + + // Read the request + request req; + read(stream, buffer, req, ec); + if (ec) + return; + + // Set up the response, starting with the common fields + response res; + res.version(11); + res.set(field::server, "test"); + + // Now handle request-specific fields + switch (req.method()) { + case verb::head: + case verb::get: { + // A HEAD request is handled by delivering the same + // set of headers that would be sent for a GET request, + // including the Content-Length, except for the body. + res.result(status::ok); + res.content_length(payload.size()); + + // For GET requests, we include the body + if (req.method() == verb::get) { + // We deliver the same payload for GET requests + // regardless of the target. A real server might + // deliver a file based on the target. + res.body() = payload; + } + break; + } + + default: { + // We return responses indicating an error if + // we do not recognize the request method. + res.result(status::bad_request); + res.set(field::content_type, "text/plain"); + res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; + res.prepare_payload(); + break; + } + } + + // Send the response + write(stream, res, ec); + if (ec) + return; +} + +//] + +//[example_http_do_head_request + +/** Send a HEAD request for a resource. + + This function submits a HEAD request for the specified resource + and returns the response. + + @param res The response. This is an output parameter. + + @param stream The synchronous stream to use. + + @param buffer The buffer to use. + + @param target The request target. + + @param ec Set to the error, if any occurred. + + @throws std::invalid_argument if target is empty. +*/ +template +response do_head_request(SyncStream& stream, DynamicBuffer& buffer, string_view target, + error_code& ec) { + // Do some type checking to be a good citizen + static_assert(is_sync_stream::value, "SyncStream requirements not met"); + static_assert(boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. + if (target.empty()) + throw std::invalid_argument("target may not be empty"); + + // Build the HEAD request for the target + request req; + req.version(11); + req.method(verb::head); + req.target(target); + req.set(field::user_agent, "test"); + + // A client MUST send a Host header field in all HTTP/1.1 request messages. + // https://tools.ietf.org/html/rfc7230#section-5.4 + req.set(field::host, "localhost"); + + // Now send it + write(stream, req, ec); + if (ec) + return {}; + + // Create a parser to read the response. + // We use the `empty_body` type since + // a response to a HEAD request MUST NOT + // include a body. + response_parser p; + + // Inform the parser that there will be no body. + p.skip(true); + + // Read the message. Even though fields like + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); + if (ec) + return {}; + + // Transfer ownership of the response to the caller. + return p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: HTTP Relay +// +//------------------------------------------------------------------------------ + +//[example_http_relay + +/** Relay an HTTP message. + + This function efficiently relays an HTTP message from a downstream + client to an upstream server, or from an upstream server to a + downstream client. After the message header is read from the input, + a user provided transformation function is invoked which may change + the contents of the header before forwarding to the output. This may + be used to adjust fields such as Server, or proxy fields. + + @param output The stream to write to. + + @param input The stream to read from. + + @param buffer The buffer to use for the input. + + @param transform The header transformation to apply. The function will + be called with this signature: + @code + template + void transform(message< + isRequest, Body, Fields>&, // The message to transform + error_code&); // Set to the error, if any + @endcode + + @param ec Set to the error if any occurred. + + @tparam isRequest `true` to relay a request. + + @tparam Fields The type of fields to use for the message. +*/ +template +void relay(SyncWriteStream& output, SyncReadStream& input, DynamicBuffer& buffer, error_code& ec, + Transform&& transform) { + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + char buf[2048]; + + // Create a parser with a buffer body to read from the input. + parser p; + + // Create a serializer from the message contained in the parser. + serializer sr{p.get()}; + + // Read just the header from the input + read_header(input, buffer, p, ec); + if (ec) + return; + + // Apply the caller's header transformation + transform(p.get(), ec); + if (ec) + return; + + // Send the transformed message to the output + write_header(output, sr, ec); + if (ec) + return; + + // Loop over the input and transfer it to the output + do { + if (!p.is_done()) { + // Set up the body for writing into our small buffer + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = sizeof(buf) - p.get().body().size; + p.get().body().data = buf; + p.get().body().more = !p.is_done(); + } else { + p.get().body().data = nullptr; + p.get().body().size = 0; + } + + // Write everything in the buffer (which might be empty) + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + } while (!p.is_done() && !sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Serialize to std::ostream +// +//------------------------------------------------------------------------------ + +//[example_http_write_ostream + +// The detail namespace means "not public" +namespace detail { + +// This helper is needed for C++11. +// When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +template +class write_ostream_helper { + Serializer& sr_; + std::ostream& os_; + +public: + write_ostream_helper(Serializer& sr, std::ostream& os) : sr_(sr), os_(os) {} + + // This function is called by the serializer + template + void operator()(error_code& ec, ConstBufferSequence const& buffers) const { + // Error codes must be cleared on success + ec = {}; + + // Keep a running total of how much we wrote + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence + for (auto it = boost::asio::buffer_sequence_begin(buffers); + it != boost::asio::buffer_sequence_end(buffers); ++it) { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream + os_.write(reinterpret_cast(buffer.data()), buffer.size()); + + // If the std::ostream fails, convert it to an error code + if (os_.fail()) { + ec = make_error_code(errc::io_error); + return; + } + + // Adjust our running total + bytes_transferred += buffer_size(buffer); + } + + // Inform the serializer of the amount we consumed + sr_.consume(bytes_transferred); + } +}; + +} // namespace detail + +/** Write a message to a `std::ostream`. + + This function writes the serialized representation of the + HTTP/1 message to the sream. + + @param os The `std::ostream` to write to. + + @param msg The message to serialize. + + @param ec Set to the error, if any occurred. +*/ +template +void write_ostream(std::ostream& os, message& msg, error_code& ec) { + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; + do { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); + if (ec) + return; + } while (!sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Parse from std::istream +// +//------------------------------------------------------------------------------ + +//[example_http_read_istream + +/** Read a message from a `std::istream`. + + This function attempts to parse a complete HTTP/1 message from the stream. + + @param is The `std::istream` to read from. + + @param buffer The buffer to use. + + @param msg The message to store the result. + + @param ec Set to the error, if any occurred. +*/ +template +void read_istream(std::istream& is, basic_flat_buffer& buffer, + message& msg, error_code& ec) { + // Create the message parser + // + // Arguments passed to the parser's constructor are + // forwarded to the message constructor. Here, we use + // a move construction in case the caller has constructed + // their message in a non-default way. + // + parser p{std::move(msg)}; + + do { + // Extract whatever characters are presently available in the istream + if (is.rdbuf()->in_avail() > 0) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream + buffer.commit( + static_cast(is.readsome(reinterpret_cast(b.data()), b.size()))); + } else if (buffer.size() == 0) { + // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream + if (!is.eof()) { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + + // Try to get more from the istream. This might block. + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. + if (is.fail() && !is.eof()) { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; + } + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); + } else { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); + if (ec) + return; + break; + } + } + + // Write the data to the parser + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. + if (ec == error::need_more) + ec = {}; + if (ec) + return; + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); + } while (!p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Deferred Body Type +// +//------------------------------------------------------------------------------ + +//[example_http_defer_body + +/** Handle a form POST request, choosing a body type depending on the Content-Type. + + This reads a request from the input stream. If the method is POST, and + the Content-Type is "application/x-www-form-urlencoded " or + "multipart/form-data", a `string_body` is used to receive and store + the message body. Otherwise, a `dynamic_body` is used to store the message + body. After the request is received, the handler will be invoked with the + request. + + @param stream The stream to read from. + + @param buffer The buffer to use for reading. + + @param handler The handler to invoke when the request is complete. + The handler must be invokable with this signature: + @code + template + void handler(request&& req); + @endcode + + @throws system_error Thrown on failure. +*/ +template +void do_form_request(SyncReadStream& stream, DynamicBuffer& buffer, Handler&& handler) { + // Start with an empty_body parser + request_parser req0; + + // Read just the header. Otherwise, the empty_body + // would generate an error if body octets were received. + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb + switch (req0.get().method()) { + case verb::post: { + // If this is not a form upload then use a string_body + if (req0.get()[field::content_type] != "application/x-www-form-urlencoded" && + req0.get()[field::content_type] != "multipart/form-data") + goto do_dynamic_body; + + // Commit to string_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + + do_dynamic_body: + default: { + // Commit to dynamic_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Incremental Read +// +//------------------------------------------------------------------------------ + +//[example_incremental_read + +/* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. +*/ +template +void read_and_print_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + parser p; + read_header(stream, buffer, p, ec); + if (ec) + return; + while (!p.is_done()) { + char buf[512]; + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + read(stream, buffer, p, ec); + if (ec == error::need_buffer) + ec = {}; + if (ec) + return; + os.write(buf, sizeof(buf) - p.get().body().size); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Read large response body +// +//------------------------------------------------------------------------------ + +//[example_read_large_response_body + +/* This function uses custom size limit of the resposne body. + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. +*/ +template +std::size_t read_large_response_body(SyncReadStream& stream, DynamicBuffer& buffer, + message>& msg, + std::size_t body_limit, error_code& ec) { + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = http::read(stream, buffer, p, ec); + if (ec) + return bytes_transferred; + msg = p.release(); + return bytes_transferred; +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_chunk_parsing + +/** Read a message with a chunked body and print the chunks and extensions + */ +template +void print_chunked_body(std::ostream& os, SyncReadStream& stream, DynamicBuffer& buffer, + error_code& ec) { + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); + if (ec) + return; + + // This container will hold the extensions for each chunk + chunk_extensions ce; + + // This string will hold the body of each chunk + std::string chunk; + + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = + [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk + string_view extensions, // The raw chunk-extensions string. Already validated. + error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); + if (ev) + return; + + // See if the chunk is too big + if (size > (std::numeric_limits::max)()) { + ev = error::body_limit; + return; + } + + // Make sure we have enough storage, and + // reset the container for the upcoming chunk + chunk.reserve(static_cast(size)); + chunk.clear(); + }; + + // Set the callback. The function requires a non-const reference so we + // use a local variable, since temporaries can only bind to const refs. + p.on_chunk_header(header_cb); + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. + auto body_cb = [&](std::uint64_t remain, // The number of bytes left in this chunk + string_view body, // A buffer holding chunk body data + error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. + if (remain == body.size()) + ec = error::end_of_chunk; + + // Append this piece to our container + chunk.append(body.data(), body.size()); + + // The return value informs the parser of how much of the body we + // consumed. We will indicate that we consumed everything passed in. + return body.size(); + }; + p.on_chunk_body(body_cb); + + while (!p.is_done()) { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); + if (!ec) + continue; + else if (ec != error::end_of_chunk) + return; + else + ec = {}; + + // We got a whole chunk, print the extensions: + for (auto const& extension : ce) { + os << "Extension: " << extension.first; + if (!extension.second.empty()) + os << " = " << extension.second << std::endl; + else + os << std::endl; + } + + // Now print the chunk body + os << "Chunk Body: " << chunk << std::endl; + } + + // Get a reference to the parsed message, this is for convenience + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it + for (auto const& name : token_list{msg[field::trailer]}) { + // Find the trailer field + auto it = msg.find(name); + if (it == msg.end()) { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << std::endl; + continue; + } + os << it->name() << ": " << it->value() << std::endl; + } +} + +//] + +} // namespace http +} // namespace beast +} // namespace boost diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/ssl/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/ssl/client.cpp new file mode 100644 index 0000000..39991ec --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/ssl/client.cpp @@ -0,0 +1,149 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } + } +} + +net::awaitable request(ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + ssl::stream stream{executor, ctx}; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) + if (!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set a callback to verify that the hostname in the server + // certificate matches the expected value + stream.set_verify_callback(ssl::host_name_verification("localhost")); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request + http::request req{http::verb::get, "/", 11}; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); + + // Read the response + beast::flat_buffer buf; + http::response res; + co_await http::async_read(stream, buf, res); + + // Print the response body + std::cout << res.body(); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); + } +} + +} // namespace + +int main() { + try { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful + ctx.set_verify_mode(ssl::verify_peer); + + // The servers's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Client certificate and private key (if server request for). + ctx.use_certificate_chain_file("client.crt"); + ctx.use_private_key_file("client.key", ssl::context::pem); + + net::co_spawn(ioc, request(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/ssl/server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/ssl/server.cpp new file mode 100644 index 0000000..24d3245 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/doc/ssl/server.cpp @@ -0,0 +1,143 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +namespace { +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void print_exception(std::exception_ptr eptr) { + if (eptr) { + try { + std::rethrow_exception(eptr); + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } + } +} + +net::awaitable handle_session(ssl::stream stream) { + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + + // Read and discard a request + beast::flat_buffer buf; + http::request req; + co_await http::async_read(stream, buf, req); + + // Write the response + http::response res; + res.body() = "Hello!"; + co_await http::async_write(stream, res); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if (ec && ec != ssl::error::stream_truncated) { + throw boost::system::system_error(ec); + } +} + +net::awaitable acceptor(ssl::context& ctx) { + auto const executor = co_await net::this_coro::executor; + webcpp::asio::ip::tcp::endpoint const endpoint{net::ip::make_address("127.0.0.1"), + webcpp_fixture::port_number()}; + webcpp::asio::ip::tcp::acceptor acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, handle_session({co_await acceptor.async_accept(), ctx}), + print_exception); + } +} + +} // namespace + +int main() { + try { + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ssl::context::sslv23}; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options(ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. + // Asio exposes the OpenSSL verification bitmask as signed integer constants. + // NOLINTNEXTLINE(bugprone-signed-bitwise) + ctx.set_verify_mode(ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Server certificate and private key. + ctx.use_certificate_chain_file("server.crt"); + ctx.use_private_key_file("server.key", ssl::context::pem); + + // DH parameters for DHE-based cipher suites + ctx.use_tmp_dh_file("dh4096.pem"); + + net::co_spawn(ioc, acceptor(ctx), print_exception); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception& e) { + std::cerr << e.what() << '\n'; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/echo-op/echo_op.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/echo-op/echo_op.cpp new file mode 100644 index 0000000..51fb14d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/echo-op/echo_op.cpp @@ -0,0 +1,392 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; +namespace beast = webcpp::beast; + +namespace { + +//[example_core_echo_op_1 + +template +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + + //] + -> net::async_result, void(beast::error_code)>::return_type; + +//------------------------------------------------------------------------------ + +//[example_core_echo_op_2 + +/** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending + in a newline (`"\\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + + - A line was read in and written back on the stream + + - An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` + and `async_write_some` function. The program must ensure that no + other reads or writes are performed until this operation completes. + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the + first line. These characters are stored in the dynamic buffer_state. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the + requirements of AsyncReadStream and `AsyncWriteStream` + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is + responsible for ensuring that the lifetime of this object is + extended least until the completion handler is invoked. + + @param token The handler to be called when the operation completes. + The implementation takes ownership of the handler by performing a decay-copy. + The handler must be invocable with this signature: + @code + void handler( + beast::error_code error // Result of operation. + ); + @endcode + + Regardless of whether the asynchronous operation completes immediately or + not, the handler will not be invoked from within this function. Invocation + of the handler will be performed in a manner equivalent to using + `net::post`. +*/ +template +// Each documentation snippet presents the complete public declaration. +// NOLINTNEXTLINE(readability-redundant-declaration) +auto async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ + CompletionToken&& token) + -> net::async_result*/ + std::decay_t, + void(beast::error_code) /*< The completion handler signature goes here >*/ + >::return_type; +//] + +//[example_core_echo_op_3 + +template +class echo_op; + +// This example uses the Asio's stackless "fauxroutines", implemented +// using a macro-based solution. It makes the code easier to write and +// easier to read. This include file defines the necessary macros and types. +#include + +// Read a line and echo it back +// +template +// Stackless coroutine macros generate the branches in this operation. +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +auto async_echo(AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + -> net::async_result, + void(beast::error_code)>::return_type /*< The completion handler + signature goes here >*/ +{ + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. + static_assert(beast::is_async_stream::value, + "AsyncStream type requirements not met"); + static_assert(net::is_dynamic_buffer::value, + "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, + // and creates the `async_result` object which becomes the + // return value of this initiating function. + + net::async_completion init(token); + + // The helper macro BOOST_ASIO_HANDLER_TYPE converts the completion + // token type into a concrete handler type of the correct signature. + + using handler_type = BOOST_ASIO_HANDLER_TYPE(CompletionToken, void(beast::error_code)); + + // The class template `async_base` holds the caller's completion + // handler for us, and provides all of the boilerplate for forwarding + // the associated allocator and associated executor from the caller's + // handler to our operation. It also maintains a `net::executor_work_guard` + // for the executor associated with the stream. This work guard is + // inexpensive, and prevents the execution context from running out + // of work. It is usually necessary although rarely it can be skipped + // depending on the operation (this echo example needs it because it + // performs more than one asynchronous operation in a row). + // We declare this type alias to make the code easier to read. + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ + beast::executor_type /*< The type of executor used by the stream to dispatch + asynchronous operations >*/ + >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + + // Asio operation state combines completion ownership with coroutine resume state. + // NOLINTNEXTLINE(misc-multiple-inheritance) + struct echo_op : base_type, boost::asio::coroutine { + AsyncStream& stream_state; + DynamicBuffer& buffer_state; + + echo_op(AsyncStream& stream, DynamicBuffer& buffer, handler_type&& handler) + : base_type( + std::move( + handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , + stream_state(stream), + buffer_state(buffer) { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our + // asynchronous control flow. + (*this)({}, 0, false); + } + + // If a newline is present in the buffer sequence, this function returns + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + + static std::size_t find_newline(DynamicBuffer::const_buffers_type const& buffers) { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + + const auto begin = + net::buffers_iterator::begin(buffers); + const auto end = + net::buffers_iterator::end(buffers); + const auto result = std::find(begin, end, '\n'); + + if (result == end) { + return 0; // not found + } + + return result + 1 - begin; + } + + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + + // Resume labels generated by the stackless coroutine form one state machine. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void operator()( + beast::error_code ec, std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + + reenter(*this) { + for (;;) { + // Resume labels cannot cross an initialized local; it is assigned before use. + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer_state.data()); + + // If we don't have the newline, then read more + if (pos == 0) { + // Resume labels cannot cross an initialized local; it is assigned before + // use. NOLINTNEXTLINE(cppcoreguidelines-init-variables) + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, + buffer_state.capacity() - buffer_state.size()), + std::min(65536, // and over 65536 is too much. + buffer_state.max_size() - buffer_state.size())); + + // Read some data into our dynamic buffer_state. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + + yield stream_state.async_read_some(buffer_state.prepare(bytes_to_read), + std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. + + // Move the bytes read from the writable area to the + // readable area. + + buffer_state.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. + if (ec) { + break; + } + + // Keep looping until we get the newline + continue; + } + + // We have our newline, so send the first `pos` bytes of the + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + + yield net::async_write(stream_state, + beast::buffers_prefix(pos, buffer_state.data()), + std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, + // and the `reenter` statement above will cause control to jump + // to the following line. The variable `pos` is no longer valid + // (remember that we returned from the function using `yield` above) + // but we can use `bytes_transferred` to know how much of the buffer + // to consume. With "real" coroutines this will be easier and more + // natural. + + buffer_state.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. + + break; + } + + // When a composed operation completes immediately, it must not + // directly invoke the completion handler otherwise it could + // lead to unfairness, starvation, or stack overflow. Therefore, + // if cont == false (meaning, that the call stack still includes + // the frame of the initiating function) then we need to use + // `net::post` to cause us to be called again after the initiating + // function. The function `async_base::invoke` takes care of + // calling the final completion handler, using post if the + // first argument is false, otherwise invoking it directly. + + this->complete(cont, ec); + } + } + }; + + // Create the composed operation and launch it. This is a constructor + // call followed by invocation of operator(). We use BOOST_ASIO_HANDLER_TYPE + // to convert the completion token into the correct handler type, + // allowing user-defined specializations of the async_result template + // to be used. + + echo_op(stream, buffer, std::move(init.completion_handler)); + + // This hook lets the caller see a return value when appropriate. + // For example this might return std::future if + // CompletionToken is net::use_future, or this might + // return an error code if CompletionToken specifies a coroutine. + + return init.result.get(); +} + +// Including this file undefines the macros used by the stackless fauxroutines. +#include + +//] + +struct move_only_handler { + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) { + if (ec) { + std::cerr << ": " << ec.message() << '\n'; + } + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + if (argc != 3) { + std::cerr << "Usage: echo-op
\n" + << "Example:\n" + << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. + webcpp::asio::io_context ioc; + webcpp::asio::ip::tcp::acceptor acceptor{ioc}; + const endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); + acceptor.listen(); + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); + ioc.run(); // lint-run: drives the application's network operations + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-local/http_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-local/http_client_async_local.cpp new file mode 100644 index 0000000..ec0b467 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-local/http_client_async_local.cpp @@ -0,0 +1,184 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) : stream_(ioc) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* target, + int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, std::string{host} + ":" + port); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5 && argc != 6) { + std::cerr << "Usage: http-client-async-local []\n" + << "Example:\n" + << " http-client-async-local /tmp/http.sock localhost 80 /\n" + << " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + const auto* const host = argv[2]; + const auto* const port = argv[3]; + const auto* const target = argv[4]; + int const version = argc == 6 && (std::strcmp("1.0", argv[5]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..7b92a52 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,260 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) + : resolver_(strand), stream_(strand, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl-system-executor []\n" + << "Example:\n" + << " http-client-async-ssl-system-executor www.example.com 443 /\n" + << " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, target, version); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..93ad560 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,255 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + explicit session(net::any_io_executor ex, ssl::context& ctx) + : resolver_(ex), stream_(ex, ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream_.native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async-ssl []\n" + << "Example:\n" + << " http-client-async-ssl www.example.com 443 /\n" + << " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared(net::make_strand(ioc), ctx)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..04365ef --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/async/http_client_async.cpp @@ -0,0 +1,198 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), stream_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* target, int version) { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res_ << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-async []\n" + << "Example:\n" + << " http-client-async www.example.com 80 /\n" + << " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..6a8dedf --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,199 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include "common/root_certificates.hpp" + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, int version, + ssl::context& ctx) { + auto executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = ssl::stream{executor, ctx}; + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec && ec != net::ssl::error::stream_truncated) { + throw boost::system::system_error(ec, "shutdown"); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..bc69458 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,155 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string target, + int version) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = beast::tcp_stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw boost::system::system_error(ec, "shutdown"); + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + auto const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn(ioc, do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/body/json_body.hpp new file mode 100644 index 0000000..2711011 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/body/json_body.hpp @@ -0,0 +1,120 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body { + using value_type = json::value; + + struct writer { + using const_buffers_type = boost::asio::const_buffer; + + template + writer(webcpp::beast::http::header const& /*unused*/, + value_type const& body) { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer_.reset(&body); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void init(boost::system::error_code& ec) { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> get(boost::system::error_code& ec) { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer_.read(buffer_.data(), buffer_.size()); + return std::make_pair(boost::asio::const_buffer(len.data(), len.size()), + !serializer_.done()); + } + + private: + json::serializer serializer_; + // half of the probable networking buffer, let's leave some space for headers + std::array buffer_{}; + }; + + struct reader { + template + reader(webcpp::beast::http::header& /*unused*/, value_type& body) + : body_(body) {} + + void init(boost::optional const& content_length, + boost::system::error_code& ec) { + // If we know the content-length, we can allocate a monotonic resource to increase the + // parsing speed. We're using it rather then a static_resource, so a consumer can modify + // the resulting value. It is also only assumption that the parsed json will be smaller + // than the serialize one, it might not always be the case. + if (content_length) { + parser_.reset( + json::make_shared_resource(*content_length)); + } + ec = {}; + } + + template + std::size_t put(ConstBufferSequence const& buffers, boost::system::error_code& ec) { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser_.write_some(static_cast(buffers.data()), buffers.size(), ec); + } + + void finish(boost::system::error_code& ec) { + ec = {}; + // We check manually if the json is complete. + if (parser_.done()) { + body_ = parser_.release(); + } else { + ec = boost::json::error::incomplete; + } + } + + private: + json::stream_parser parser_; + value_type& body_; + }; +}; + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/body/json_client.cpp new file mode 100644 index 0000000..3780af1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/body/json_client.cpp @@ -0,0 +1,80 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +#include "json_body.hpp" + +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +int main(int /*unused*/, char** /*unused*/) { + // Our test endpoint for testing the json + const auto* const host = webcpp_fixture::host(); + const auto* const target = "/post"; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/coro-ssl/http_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/coro-ssl/http_client_coro_ssl.cpp new file mode 100644 index 0000000..f0dd8e3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -0,0 +1,239 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + int version, webcpp::asio::io_context& ioc, ssl::context& ctx, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res << '\n'; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream.async_shutdown(yield[ec]); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + { + fail(ec, "shutdown"); + return; + } + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro-ssl []\n" + << "Example:\n" + << " http-client-coro-ssl www.example.com 443 /\n" + << " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/coro/http_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/coro/http_client_coro.cpp new file mode 100644 index 0000000..514c962 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/coro/http_client_coro.cpp @@ -0,0 +1,189 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void do_session(std::string const& host, std::string const& port, std::string const& target, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + int version, webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + { + fail(ec, "shutdown"); + return; + } + } + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-coro []\n" + << "Example:\n" + << " http-client-coro www.example.com 80 /\n" + << " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(target), version, + std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..c322d17 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/http_crawl.cpp @@ -0,0 +1,313 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +namespace { +class crawl_report { + net::strand strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + explicit crawl_report(webcpp::asio::io_context& ioc) + : strand_(ioc.get_executor()), index_(0), hosts_(urls_large_data()) {} + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void aggregate(F const& f) { + net::post(strand_, [&, f] { + f(*this); + if (count_ % 100 == 0) { + std::cerr << "Progress: " << count_ << " of " << hosts_.size() << "\n"; + // std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* get_host() { + auto const n = index_++; + if (n >= hosts_.size()) { + return nullptr; + } + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& operator<<(std::ostream& os, crawl_report const& report) { + // Print the report + os << "Crawl report\n" + << " Failure counts\n" + << " Timer : " << report.timer_failures << "\n" + << " Resolve : " << report.resolve_failures << "\n" + << " Connect : " << report.connect_failures << "\n" + << " Write : " << report.write_failures << "\n" + << " Read : " << report.read_failures << "\n" + << " Success : " << report.success << "\n" + << " Status codes\n"; + for (auto const& result : report.status_codes) { + os << " " << std::setw(3) << result.first << ": " << result.second << " (" + << http::obsolete_reason(static_cast(result.first)) << ")\n"; + } + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this { + enum { + // Use a small timeout to keep things lively + timeout = 5, + }; + + crawl_report& report_; + net::strand ex_; + webcpp_fixture::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker(crawl_report& report, webcpp::asio::io_context& ioc) + : report_(report), ex_(net::make_strand(ioc.get_executor())), resolver_(ex_), stream_(ex_) { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation + void run() { do_get_host(); } + + void do_get_host() { + // Grab another host + const auto* const host = report_.get_host(); + + // nullptr means no more work + if (host == nullptr) { + return; + } + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve(host, webcpp_fixture::port(), + beast::bind_front_handler(&worker::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.resolve_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect(results, + beast::bind_front_handler(&worker::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + // Value type is required by the original asynchronous callback contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type /*unused*/) { + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.connect_failures; }); + do_get_host(); + return; + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler(&worker::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.write_failures; }); + do_get_host(); + return; + } + + // Receive the HTTP response + res_ = {}; + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler(&worker::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + report_.aggregate([](crawl_report& rep) { ++rep.read_failures; }); + do_get_host(); + return; + } + + auto const code = res_.result_int(); + report_.aggregate([code](crawl_report& rep) { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_both, ec)); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer { + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() : when_(clock_type::now()) {} + + [[nodiscard]] duration elapsed() const { return clock_type::now() - when_; } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-crawl \n" << "Example:\n" << " http-crawl 100\n"; + return EXIT_FAILURE; + } + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[1])); + + // The io_context is used to aggregate the statistics + webcpp::asio::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + timer t; + + // Each worker preserves the original crawl state machine on one explicit executor. + for (int index = 0; index < threads; ++index) { + std::make_shared(report, ioc)->run(); + } + ioc.run(); // lint-run: advances every crawl worker and its aggregate report + + std::cout << "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() + << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..7f35263 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include "urls_large_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" + +std::vector const& urls_large_data() { + static const std::vector hosts{"localhost", "127.0.0.1", "localhost"}; + return hosts; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..f7fbba8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..b418dff --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/methods/http_client_methods.cpp @@ -0,0 +1,218 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// perform a get request +namespace { +void do_get(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + +// perform a patch request +void do_patch(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a put request +void do_put(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a delete request +void do_delete(beast::tcp_stream& stream, http::request& req, + beast::flat_buffer buffer, http::response& res) { + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 2) { + std::cerr << "Usage: http-client-method \n" + << "Example:\n" + << " http-client-method get\n" + << " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char* c = argv[1]; *c != '\0'; c++) { + *c = static_cast(std::tolower(*c)); + } + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(webcpp_fixture::host(), webcpp_fixture::port()); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, webcpp_fixture::host()); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") { + do_get(stream, req, buffer, res); + } else if (method == "head") { + do_head(stream, req, buffer, res); + } else if (method == "patch") { + do_patch(stream, req, buffer, res); + } else if (method == "put") { + do_put(stream, req, buffer, res); + } else if (method == "post") { + do_post(stream, req, buffer, res); + } else if (method == "delete") { + do_delete(stream, req, buffer, res); + } else { + std::cerr << "Unknown method: " << method << '\n'; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" << req << '\n'; + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..0954fb9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,157 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync-ssl []\n" + << "Example:\n" + << " http-client-sync-ssl www.example.com 443 /\n" + << " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(stream.native_handle(), host)) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the stream + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec != net::ssl::error::stream_truncated) { + throw beast::system_error{ec}; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..11f1d5b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/client/sync/http_client_sync.cpp @@ -0,0 +1,124 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +// from +using tcp = webcpp::asio::ip::tcp; // from + +// Performs an HTTP GET and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4 && argc != 5) { + std::cerr << "Usage: http-client-sync []\n" + << "Example:\n" + << " http-client-sync www.example.com 80 /\n" + << " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const* const host = argv[1]; + auto const* const port = argv[2]; + auto const* const target = argv[3]; + int const version = argc == 5 && (std::strcmp("1.0", argv[4]) == 0) ? 10 : 11; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << '\n'; + + // Gracefully close the socket + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_both, ec)); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if (ec && ec != beast::errc::not_connected) { + throw beast::system_error{ec}; + } + + // If we get here then the connection is closed gracefully + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async-local/http_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async-local/http_server_async_local.cpp new file mode 100644 index 0000000..bd34fe0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async-local/http_server_async_local.cpp @@ -0,0 +1,442 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::basic_stream + stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(stream_protocol::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(net::make_strand(ioc), std::move(endpoint)), doc_root_(doc_root) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-async-local \n" + << "Example:\n" + << " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { + std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async-ssl/http_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async-ssl/http_server_async_ssl.cpp new file mode 100644 index 0000000..44ecd22 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async-ssl/http_server_async_ssl.cpp @@ -0,0 +1,527 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + void on_run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + do_read(); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, this->shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async-ssl
\n" + << "Example:\n" + << " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async/http_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async/http_server_async.cpp new file mode 100644 index 0000000..0e73a5e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/async/http_server_async.cpp @@ -0,0 +1,461 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + { + do_close(); + return; + } + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::on_write, shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + do_close(); + return; + } + + // Read another request + do_read(); + } + + void do_close() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + return; // To avoid infinite loop + } + // Create the session and run it + std::make_shared(std::move(socket), doc_root_)->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-async
\n" + << "Example:\n" + << " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/awaitable/http_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/awaitable/http_server_awaitable.cpp new file mode 100644 index 0000000..9afc382 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/awaitable/http_server_awaitable.cpp @@ -0,0 +1,358 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +// Handles an HTTP server connection +net::awaitable do_session(beast::tcp_stream stream, + std::shared_ptr doc_root) { + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + co_await http::async_read(stream, buffer, req); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(webcpp::asio::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have + // dropped the connection already. +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint, + std::shared_ptr doc_root) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn(executor, + do_session(beast::tcp_stream{co_await acceptor.async_accept()}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-awaitable
\n" + << "Example:\n" + << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}, doc_root), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/coro-ssl/http_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/coro-ssl/http_server_coro_ssl.cpp new file mode 100644 index 0000000..8e293ee --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -0,0 +1,486 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(ssl::stream& stream, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::shared_ptr const& doc_root, net::yield_context yield) { + bool keep_alive = true; + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle the request + http::message_generator res = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, ssl::stream(std::move(socket), ctx), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro-ssl
\n" + << "Example:\n" + << " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, doc_root, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/coro/http_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/coro/http_server_coro.cpp new file mode 100644 index 0000000..9a85bd5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/coro/http_server_coro.cpp @@ -0,0 +1,436 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(beast::tcp_stream& stream, std::shared_ptr const& doc_root, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + for (;;) { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + std::shared_ptr const& doc_root, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn(acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio + // spawn/completion overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, beast::tcp_stream(std::move(socket)), + doc_root, std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-coro
\n" + << "Example:\n" + << " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/fast/fields_alloc.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/fast/fields_alloc.hpp new file mode 100644 index 0000000..39e3bd3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/fast/fields_alloc.hpp @@ -0,0 +1,168 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP +#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP + +#include +#include +#include +#include + +namespace detail { + +class static_pool { + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + + char* end() { return reinterpret_cast(this + 1) + size_; } + + explicit static_pool(std::size_t size) : size_(size), p_(reinterpret_cast(this + 1)) {} + +public: + static static_pool& construct(std::size_t size) { + auto* p = new char[sizeof(static_pool) + size]; + return *(::new (p) static_pool{size}); + } + + static static_pool& share(static_pool& pool) { + ++pool.refs_; + return pool; + } + + void destroy() { + if ((--refs_) != 0u) { + return; + } + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* alloc(std::size_t n) { + auto* last = p_ + n; + if (last >= end()) { + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + } + ++count_; + auto* p = p_; + p_ = last; + return p; + } + + void dealloc() { + if ((--count_) != 0u) { + return; + } + p_ = reinterpret_cast(this + 1); + } +}; + +} // namespace detail + +/** A non-thread-safe allocator optimized for @ref basic_fields. + + This allocator obtains memory from a pre-allocated memory block + of a given size. It does nothing in deallocate until all + previously allocated blocks are deallocated, upon which it + resets the internal memory block for re-use. + + To use this allocator declare an instance persistent to the + connection or session, and construct with the block size. + A good rule of thumb is 20% more than the maximum allowed + header size. For example if the application only allows up + to an 8,000 byte header, the block size could be 9,600. + + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. +*/ +template +struct fields_alloc { + detail::static_pool* pool; + +public: + using value_type = T; + using is_always_equal = std::false_type; + using pointer = T*; + using reference = T&; + using const_pointer = T const*; + using const_reference = T const&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template + struct rebind { + using other = fields_alloc; + }; + +#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) + // Workaround for g++ + // basic_string assumes that allocators are default-constructible + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 + fields_alloc() = default; +#endif + + explicit fields_alloc(std::size_t size) : pool(&detail::static_pool::construct(size)) {} + + fields_alloc(fields_alloc const& other) : pool(&detail::static_pool::share(*other.pool)) {} + + template + explicit fields_alloc(fields_alloc const& other) + : pool(&detail::static_pool::share(*other.pool)) {} + + ~fields_alloc() { pool->destroy(); } + + value_type* allocate(size_type n) { + return static_cast(pool->alloc(n * sizeof(T))); + } + + void deallocate(value_type* /*unused*/, size_type /*unused*/) { pool->dealloc(); } + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template + void construct(U* ptr, Args&&... args) { + ::new (static_cast(ptr)) U(std::forward(args)...); + } + + template + void destroy(U* ptr) { + ptr->~U(); + } +#endif + + template + friend bool operator==(fields_alloc const& lhs, fields_alloc const& rhs) { + return &lhs.pool == &rhs.pool_; + } + + template + friend bool operator!=(fields_alloc const& lhs, fields_alloc const& rhs) { + return !(lhs == rhs); + } +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/fast/http_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/fast/http_server_fast.cpp new file mode 100644 index 0000000..10b0f6b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/fast/http_server_fast.cpp @@ -0,0 +1,371 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include "fields_alloc.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +class http_worker { +public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + + // Retain the upstream borrowing constructor contract in this reference counterpart. + // NOLINTNEXTLINE(modernize-pass-by-value) + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) + : acceptor_(acceptor), doc_root_(doc_root) {} + + void start() { + accept(); + check_deadline(); + } + +private: + using alloc_t = fields_alloc; + // using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. + tcp::acceptor& acceptor_; + + // The path to the root of the document directory. + std::string doc_root_; + + // The socket for the currently connected client. + tcp::socket socket_{acceptor_.get_executor()}; + + // The buffer for performing reads + beast::flat_static_buffer<8192> buffer_; + + // The allocator used for the fields in the request and reply. + alloc_t alloc_{8192}; + + // The parser for reading the requests + boost::optional> parser_; + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{acceptor_.get_executor(), + std::chrono::steady_clock::time_point::max()}; + + // The string-based response message. + boost::optional>> + string_response_; + + // The string-based response serializer. + boost::optional>> + string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. + boost::optional>> + file_serializer_; + + void accept() { + // Clean up any previous connection. + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.close(ec)); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept(socket_, [this](beast::error_code ec) { + if (ec) { + accept(); + } else { + // Request must be fully processed within 60 seconds. + request_deadline_.expires_after(std::chrono::seconds(60)); + + read_request(); + } + }); + } + + void read_request() { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. + // + // Arguments passed to the parser constructor are + // forwarded to the message object. A single argument + // is forwarded to the body constructor. + // + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // + parser_.emplace(std::piecewise_construct, std::make_tuple(), std::make_tuple(alloc_)); + + http::async_read(socket_, buffer_, *parser_, [this](beast::error_code ec, std::size_t) { + if (ec) { + accept(); + } else { + process_request(parser_->get()); + } + }); + } + + void process_request(http::request> const& req) { + if (req.method() == http::verb::get) { + send_file(req.target()); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + } + } + + void send_bad_response(http::status status, std::string const& error) { + string_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + + string_serializer_.emplace(*string_response_); + + http::async_write(socket_, *string_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + string_serializer_.reset(); + string_response_.reset(); + accept(); + }); + } + + void send_file(beast::string_view target) { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.contains("..")) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append(target.data(), target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open(full_path.c_str(), beast::file_mode::read, ec); + if (ec) { + send_bad_response(http::status::not_found, "File not found\r\n"); + return; + } + + file_response_.emplace(std::piecewise_construct, std::make_tuple(), + std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + + file_serializer_.emplace(*file_response_); + + http::async_write(socket_, *file_serializer_, [this](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket_.shutdown(tcp::socket::shutdown_send, ec)); + file_serializer_.reset(); + file_response_.reset(); + accept(); + }); + } + + void check_deadline() { + // The deadline may have moved, so check it has really passed. + if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. + request_deadline_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + request_deadline_.async_wait([this](beast::error_code) { check_deadline(); }); + } +}; + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 6) { + std::cerr << "Usage: http_server_fast
" + "{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " http_server_fast 0::0 80 . 100 block\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + std::string const doc_root = argv[3]; + int const num_workers = webcpp_fixture::integer(argv[4]); + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + bool spin = (std::strcmp(argv[5], "spin") == 0); + + webcpp::asio::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; + for (int i = 0; i < num_workers; ++i) { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) { + for (;;) { + ioc.poll(); + } + } else { + ioc.run(); // lint-run: drives the application's network operations + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/flex/http_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/flex/http_server_flex.cpp new file mode 100644 index 0000000..736a1ed --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/flex/http_server_flex.cpp @@ -0,0 +1,628 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP flex server (plain and SSL), asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class session { + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& derived() { return static_cast(*this); } + + std::shared_ptr doc_root_; + http::request req_; + +protected: + beast::flat_buffer buffer; + +public: + // Take ownership of the buffer +private: + session(beast::flat_buffer buffer, std::shared_ptr const& doc_root) + : doc_root_(doc_root), buffer(std::move(buffer)) {} + +public: + void do_read() { + // Set the timeout. + beast::get_lowest_layer(derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + derived().stream(), buffer, req_, + beast::bind_front_handler(&session::on_read, derived().shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if (ec == http::error::end_of_stream) { + return derived().do_eof(); + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send the response + send_response(handle_request(*doc_root_, std::move(req_))); + } + + void send_response(http::message_generator&& msg) { + bool const keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write(derived().stream(), std::move(msg), + beast::bind_front_handler(&session::on_write, + derived().shared_from_this(), keep_alive)); + } + + void on_write(bool keep_alive, beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Read another request + do_read(); + } + + friend Derived; +}; + +// Handles a plain HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class plain_session : public session, + public std::enable_shared_from_this { + beast::tcp_stream stream_; + +public: + // Create the session + plain_session(tcp::socket&& socket, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket)) {} + + // Called by the base class + beast::tcp_stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::do_read, shared_from_this())); + } + + void do_eof() { + // Send a TCP shutdown + beast::error_code ec; + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } +}; + +// Handles an SSL HTTP connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class ssl_session : public session, public std::enable_shared_from_this { + ssl::stream stream_; + +public: + // Create the session + ssl_session(tcp::socket&& socket, ssl::context& ctx, beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session(std::move(buffer), doc_root), stream_(std::move(socket), ctx) {} + + // Called by the base class + ssl::stream& stream() { return stream_; } + + // Start the asynchronous operation + void run() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self] { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( + ssl::stream_base::server, self->buffer.data(), + beast::bind_front_handler(&ssl_session::on_handshake, self)); + }); + } + + void on_handshake(beast::error_code ec, std::size_t bytes_used) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Consume the portion of the buffer used by the handshake + buffer.consume(bytes_used); + + do_read(); + } + + void do_eof() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler(&ssl_session::on_shutdown, shared_from_this())); + } + + // Member shape is part of the upstream Body or bound-callback interface. + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) + void on_shutdown(beast::error_code ec) { + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this { + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + detect_session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)), ctx_(ctx), doc_root_(doc_root) {} + + // Launch the detector + void run() { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake + async_detect_ssl(stream_, buffer_, + beast::bind_front_handler(&detect_session::on_detect, shared_from_this())); + } + + void on_detect(beast::error_code ec, bool result) { + if (ec) { + { + fail(ec, "detect"); + return; + } + } + + if (result) { + // Launch SSL session + std::make_shared(stream_.release_socket(), ctx_, std::move(buffer_), + doc_root_) + ->run(); + return; + } + + // Launch plain session + std::make_shared(stream_.release_socket(), std::move(buffer_), doc_root_) + ->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)), doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the detector session and run it + std::make_shared(std::move(socket), ctx_, doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-flex
\n" + << "Example:\n" + << " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/small/http_server_small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/small/http_server_small.cpp new file mode 100644 index 0000000..044ca94 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/small/http_server_small.cpp @@ -0,0 +1,234 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +namespace { +namespace my_program_state { +std::size_t request_count() { + static std::size_t count = 0; + return ++count; +} + +std::time_t now() { + return std::time(nullptr); +} +} // namespace my_program_state + +class http_connection : public std::enable_shared_from_this { +public: + explicit http_connection(tcp::socket socket) : socket_(std::move(socket)) {} + + // Initiate the asynchronous operations associated with the connection. + void start() { + read_request(); + check_deadline(); + } + +private: + // The socket for the currently connected client. + tcp::socket socket_; + + // The buffer for performing reads. + beast::flat_buffer buffer_{8192}; + + // The request message. + http::request request_; + + // The response message. + http::response response_; + + // The timer for putting a deadline on connection processing. + net::steady_timer deadline_{socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. + void read_request() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + http::async_read(socket_, buffer_, request_, + [self](beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + if (!ec) { + self->process_request(); + } + }); + } + + // Determine what needs to be done with the request message. + void process_request() { + response_.version(request_.version()); + response_.keep_alive(false); + + if (request_.method() == http::verb::get) { + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + } else { + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" << std::string(request_.method_string()) << "'"; + } + + write_response(); + } + + // Construct a response message based on the program state. + void create_response() { + if (request_.target() == "/count") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } else if (request_.target() == "/time") { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } else { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + // Asynchronously transmit the response message. + void write_response() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write(socket_, response_, [self](beast::error_code ec, std::size_t) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.shutdown(tcp::socket::shutdown_send, ec)); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void check_deadline() { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + deadline_.async_wait([self](beast::error_code ec) { + if (!ec) { + // Close socket to cancel any outstanding operation. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(self->socket_.close(ec)); + } + }); + } +}; + +// "Loop" forever accepting new connections. +void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { + acceptor.async_accept(socket, [&](beast::error_code ec) { + if (!ec) { + std::make_shared(std::move(socket))->start(); + } + http_server(acceptor, socket); + }); +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + webcpp::asio::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/stackless-ssl/http_server_stackless_ssl.cpp new file mode 100644 index 0000000..b66f69f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -0,0 +1,538 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if (ec == net::ssl::error::stream_truncated) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + for (;;) { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + yield stream_.async_shutdown( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + ctx_(ctx), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_, doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless-ssl
\n" + << "Example:\n" + << " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/stackless/http_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/stackless/http_server_stackless.cpp new file mode 100644 index 0000000..63877a9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/stackless/http_server_stackless.cpp @@ -0,0 +1,475 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket, std::shared_ptr const& doc_root) + : stream_(std::move(socket)), doc_root_(doc_root) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + for (;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler(&session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + yield { + // Handle request + http::message_generator msg = handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler(&session::loop, shared_from_this())); + } + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive_) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc), + acceptor_(net::make_strand(ioc)), + socket_(net::make_strand(ioc)), + doc_root_(doc_root) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + socket_, beast::bind_front_handler(&listener::loop, shared_from_this())); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http-server-stackless
\n" + << "Example:\n" + << " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port}, doc_root)->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/sync-ssl/http_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/sync-ssl/http_server_sync_ssl.cpp new file mode 100644 index 0000000..54339d3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -0,0 +1,376 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, ssl::context& ctx, + std::shared_ptr const& doc_root) { + beast::error_code ec; + + // Construct the stream around the socket + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.handshake(ssl::stream_base::server, ec)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Perform the SSL shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream.shutdown(ec)); + if (ec) { + { + fail(ec, "shutdown"); + return; + } + } + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync-ssl
\n" + << "Example:\n" + << " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(socket, ctx, doc_root); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/sync/http_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/sync/http_server_sync.cpp new file mode 100644 index 0000000..8f05db9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/http/server/sync/http_server_sync.cpp @@ -0,0 +1,344 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void do_session(tcp::socket& socket, std::shared_ptr const& doc_root) { + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if (ec == http::error::end_of_stream) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Handle request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(socket.shutdown(tcp::socket::shutdown_send, ec)); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync
\n" + << "Example:\n" + << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(socket, doc_root); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/mapping.json b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/mapping.json new file mode 100644 index 0000000..9597742 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/mapping.json @@ -0,0 +1,50 @@ +{ + "applications": [ + "advanced-server", + "advanced-server-flex", + "advanced-server-flex-awaitable", + "doc-ssl-client", + "doc-ssl-server", + "echo-op", + "http-client-async", + "http-client-async-ssl", + "http-client-async-ssl-system-executor", + "http-client-awaitable", + "http-client-awaitable-ssl", + "json_client", + "http-crawl", + "http-client-methods", + "http-client-sync", + "http-client-sync-ssl", + "http-server-async", + "http-server-async-ssl", + "http-server-awaitable", + "http-server-fast", + "http-server-flex", + "http-server-small", + "http-server-stackless", + "http-server-stackless-ssl", + "http-server-sync", + "http-server-sync-ssl", + "websocket-client-async", + "websocket-client-async-ssl", + "websocket-client-async-ssl-system-executor", + "websocket-client-awaitable", + "websocket-client-sync", + "websocket-client-sync-ssl", + "websocket-server-async", + "websocket-server-async-ssl", + "websocket-server-awaitable", + "websocket-chat-multi", + "websocket-server-stackless", + "websocket-server-stackless-ssl", + "websocket-server-sync", + "websocket-server-sync-ssl" + ], + "adaptations": [ + "Fixture resolver posts localhost; original asynchronous DNS remains blocked.", + "Worker pools, system_executor and detached sessions share an explicit io_context.", + "OS signal cancellation becomes an awaitable deadline or driver-controlled shutdown.", + "Sync server accepts one complete connection; driver bounds asynchronous listeners." + ] +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-local/websocket_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-local/websocket_client_async_local.cpp new file mode 100644 index 0000000..ae07c32 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-local/websocket_client_async_local.cpp @@ -0,0 +1,198 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include + +#include +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) : ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* path, char const* host, char const* port, char const* text) { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; + + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-local"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr + << "Usage: websocket-client-async-local \n" + << "Example:\n" + << " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + const auto* const host = argv[2]; + const auto* const port = argv[3]; + const auto* const text = argv[4]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..3188974 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,266 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) + : resolver_(ex), ws_(ex, ctx) {} + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : session(net::make_strand(boost::asio::any_io_executor(ioc.get_executor())), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + webcpp::asio::io_context ioc; + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + ioc.run(); // lint-run: explicit single-thread application executor + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..35a7ec1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,260 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc), ctx) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) { + beast::error_code ec{static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler(&session::on_ssl_handshake, shared_from_this())); + } + + void on_ssl_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async-ssl \n" + << "Example:\n" + << " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..b3d949b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,218 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this { + webcpp_fixture::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit session(webcpp::asio::io_context& ioc) + : resolver_(net::make_strand(ioc)), ws_(net::make_strand(ioc)) {} + + // Start the asynchronous operation + void run(char const* host, char const* port, char const* text) { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, port, beast::bind_front_handler(&session::on_resolve, shared_from_this())); + } + + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + void on_resolve(beast::error_code ec, webcpp_fixture::resolver::results_type results) { + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, beast::bind_front_handler(&session::on_connect, shared_from_this())); + } + + void on_connect(beast::error_code ec, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp_fixture::resolver::results_type::endpoint_type ep) { + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-async"); + })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws_.async_write(net::buffer(text_), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler(&session::on_close, shared_from_this())); + } + + void on_close(beast::error_code ec) { + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << '\n'; + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-async \n" + << "Example:\n" + << " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..19b5e34 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,149 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +namespace { +net::awaitable do_session(std::string host, std::string port, std::string text) { + auto const executor = co_await net::this_coro::executor; + auto resolver = webcpp_fixture::resolver{executor}; + auto stream = websocket::stream{executor}; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); + + // Send the message + co_await stream.async_write(net::buffer(text)); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::co_spawn(ioc, do_session(host, port, text), [](std::exception_ptr e) { + if (e) { + std::rethrow_exception(e); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp new file mode 100644 index 0000000..f08778a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -0,0 +1,235 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, ssl::context& ctx, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + fail(ec, "connect"); + return; + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); + if (ec) { + { + fail(ec, "ssl_handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro-ssl \n" + << "Example:\n" + << " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), std::string(text), + std::ref(ioc), std::ref(ctx), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/coro/websocket_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/coro/websocket_client_coro.cpp new file mode 100644 index 0000000..0a7d7b3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/coro/websocket_client_coro.cpp @@ -0,0 +1,197 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void do_session(std::string host, std::string const& port, std::string const& text, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + webcpp::asio::io_context& ioc, net::yield_context yield) { + beast::error_code ec; + + // These objects perform our I/O + webcpp_fixture::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if (ec) { + { + fail(ec, "resolve"); + return; + } + } + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto const ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if (ec) { + { + fail(ec, "connect"); + return; + } + } + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if (ec) { + { + fail(ec, "close"); + return; + } + } + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-coro \n" + << "Example:\n" + << " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + const auto* const host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, std::string(host), std::string(port), + std::string(text), std::ref(ioc), std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..bcca15b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,142 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync-ssl \n" + << "Example:\n" + << " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if (!SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) { + throw beast::system_error(static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..7745078 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,119 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +// The process entry point retains the standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-client-sync \n" + << "Example:\n" + << " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + const auto* const port = argv[2]; + const auto* const text = argv[3]; + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // These objects perform our I/O + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + webcpp_fixture::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + // Keep native-shaped resolver and execution-property call syntax across backends. + // NOLINTNEXTLINE(readability-static-accessed-through-instance) + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto const ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req) { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << '\n'; + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async-local/websocket_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async-local/websocket_server_async_local.cpp new file mode 100644 index 0000000..7ab7915 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async-local/websocket_server_async_local.cpp @@ -0,0 +1,231 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(stream_protocol::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-local"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + stream_protocol::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, stream_protocol::endpoint endpoint) + // The same completion handoff supports native owning and host borrowing overloads. + // NOLINTNEXTLINE(performance-move-const-arg) + : ioc_(ioc), acceptor_(ioc, std::move(endpoint)) {} + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, stream_protocol::socket socket) { + if (ec) { + fail(ec, "accept"); + return; + } + // Create the session and run it + std::make_shared(std::move(socket))->run(); + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-async-local \n" + << "Example:\n" + << " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + const auto* const path = argv[1]; + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Remove previous binding + static_cast(std::remove(path)); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; + } catch (std::exception const& e) { + std::cerr << e.what() << '\n'; + return EXIT_FAILURE; + } +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async-ssl/websocket_server_async_ssl.cpp new file mode 100644 index 0000000..a588f02 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -0,0 +1,285 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, + beast::bind_front_handler(&session::on_handshake, shared_from_this())); + } + + void on_handshake(beast::error_code ec) { + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async-ssl"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async/websocket_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async/websocket_server_async.cpp new file mode 100644 index 0000000..a068d69 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/async/websocket_server_async.cpp @@ -0,0 +1,250 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket&& socket) : ws_(std::move(socket)) {} + + // Get on the correct executor + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::on_run, shared_from_this())); + } + + // Start the asynchronous operation + void on_run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-async"); + })); + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, beast::bind_front_handler(&session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) : ioc_(ioc), acceptor_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async
\n" + << "Example:\n" + << " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/awaitable/websocket_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/awaitable/websocket_server_awaitable.cpp new file mode 100644 index 0000000..487bda0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/awaitable/websocket_server_awaitable.cpp @@ -0,0 +1,155 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT + +namespace beast = webcpp::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Echoes back all received WebSocket messages +namespace { +net::awaitable do_session(websocket::stream stream) { + // Set suggested timeout settings for the websocket + stream.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + co_await stream.async_accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + + if (ec == websocket::error::closed) { + co_return; + } + + if (ec) { + throw boost::system::system_error{ec}; + } + + // Echo the message back + stream.text(stream.got_text()); + co_await stream.async_write(buffer.data()); + } +} + +// Accepts incoming connections and launches the sessions +net::awaitable do_listen(webcpp::asio::ip::tcp::endpoint endpoint) { + auto const executor = co_await net::this_coro::executor; + auto acceptor = webcpp::asio::ip::tcp::acceptor{executor, endpoint}; + + for (;;) { + net::co_spawn( + executor, + do_session(websocket::stream{co_await acceptor.async_accept()}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception& e) { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-awaitable
\n" + << "Example:\n" + << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn(ioc, do_listen(webcpp::asio::ip::tcp::endpoint{address, port}), + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr e) { + if (e) { + try { + std::rethrow_exception(e); + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} + +#else +#error "This application requires its declared Asio backend" + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/beast.hpp new file mode 100644 index 0000000..62813fc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/beast.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/http_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/http_session.cpp new file mode 100644 index 0000000..8221545 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/http_session.cpp @@ -0,0 +1,337 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include +#include "http_session.hpp" +#include "websocket_session.hpp" + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +namespace { +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) { + return beast::string_view{}; + } + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) { + return "text/html"; + } + if (iequals(ext, ".html")) { + return "text/html"; + } + if (iequals(ext, ".php")) { + return "text/html"; + } + if (iequals(ext, ".css")) { + return "text/css"; + } + if (iequals(ext, ".txt")) { + return "text/plain"; + } + if (iequals(ext, ".js")) { + return "application/javascript"; + } + if (iequals(ext, ".json")) { + return "application/json"; + } + if (iequals(ext, ".xml")) { + return "application/xml"; + } + if (iequals(ext, ".swf")) { + return "application/x-shockwave-flash"; + } + if (iequals(ext, ".flv")) { + return "video/x-flv"; + } + if (iequals(ext, ".png")) { + return "image/png"; + } + if (iequals(ext, ".jpe")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpeg")) { + return "image/jpeg"; + } + if (iequals(ext, ".jpg")) { + return "image/jpeg"; + } + if (iequals(ext, ".gif")) { + return "image/gif"; + } + if (iequals(ext, ".bmp")) { + return "image/bmp"; + } + if (iequals(ext, ".ico")) { + return "image/vnd.microsoft.icon"; + } + if (iequals(ext, ".tiff")) { + return "image/tiff"; + } + if (iequals(ext, ".tif")) { + return "image/tiff"; + } + if (iequals(ext, ".svg")) { + return "image/svg+xml"; + } + if (iequals(ext, ".svgz")) { + return "image/svg+xml"; + } + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) { + return std::string(path); + } + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if (result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if (result.back() == path_separator) { + result.resize(result.size() - 1); + } + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator handle_request(beast::string_view doc_root, + http::request>&& req) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) { + return bad_request("Unknown HTTP-method"); + } + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) { + return bad_request("Illegal request-target"); + } + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') { + path.append("index.html"); + } + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == boost::system::errc::no_such_file_or_directory) { + return not_found(req.target()); + } + + // Handle an unknown error + if (ec) { + return server_error(ec.message()); + } + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version()), + }; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +} // namespace + +http_session::http_session(tcp::socket&& socket, boost::shared_ptr const& state) + : stream_(std::move(socket)), state_(state) {} + +void http_session::run() { + do_read(); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void http_session::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void http_session::do_read() { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, parser_->get(), + beast::bind_front_handler(&http_session::on_read, shared_from_this())); +} + +void http_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // This means they closed the connection + if (ec == http::error::end_of_stream) { + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // See if it is a WebSocket Upgrade + if (websocket::is_upgrade(parser_->get())) { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + boost::make_shared(stream_.release_socket(), state_) + ->run(parser_->release()); + return; + } + + // Handle request + http::message_generator msg = handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool const keep_alive = msg.keep_alive(); + + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + auto self = shared_from_this(); + + // Send the response + beast::async_write(stream_, std::move(msg), + [self, keep_alive](beast::error_code ec, std::size_t bytes) { + self->on_write(ec, bytes, keep_alive); + }); +} + +void http_session::on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + if (!keep_alive) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(stream_.socket().shutdown(tcp::socket::shutdown_send, ec)); + return; + } + + // Read another request + do_read(); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/http_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/http_session.hpp new file mode 100644 index 0000000..71bc175 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/http_session.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +#include +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +/** Represents an established HTTP connection + */ +class http_session : public boost::enable_shared_from_this { + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + + struct send_lambda; + + void fail(beast::error_code ec, char const* what); + void do_read(); + void on_read(beast::error_code ec, std::size_t /*unused*/); + void on_write(beast::error_code ec, std::size_t /*unused*/, bool keep_alive); + +public: + http_session(tcp::socket&& socket, boost::shared_ptr const& state); + + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/listener.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/listener.cpp new file mode 100644 index 0000000..a470005 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/listener.cpp @@ -0,0 +1,108 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "http_session.hpp" +#include "listener.hpp" + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +listener::listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc), acceptor_(ioc), state_(state) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } +} + +void listener::run() { + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} + +// Report a failure +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void listener::fail(beast::error_code ec, char const* what) { + // Don't report on canceled operations + if (ec == net::error::operation_aborted) { + return; + } + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handle a connection +void listener::on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + { + // Launch a new session for this connection + boost::make_shared(std::move(socket), state_)->run(); + } + + // The new connection gets its own strand + acceptor_.async_accept(net::make_strand(ioc_), + beast::bind_front_handler(&listener::on_accept, shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/listener.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/listener.hpp new file mode 100644 index 0000000..cc0fec3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/listener.hpp @@ -0,0 +1,56 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +#include +#include +#include +#include "beast.hpp" +#include "net.hpp" + +// Forward declaration +class shared_state; + +// Accepts incoming connections and launches the sessions +class listener : public boost::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec, tcp::socket socket); + +public: + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/main.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/main.cpp new file mode 100644 index 0000000..44cbcf2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/main.cpp @@ -0,0 +1,79 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +//------------------------------------------------------------------------------ +/* + WebSocket chat server, multi-threaded + + This implements a multi-user chat room using WebSocket. The + `io_context` runs on any number of threads, specified at + the command line. + +*/ +//------------------------------------------------------------------------------ + +#include "listener.hpp" +#include "shared_state.hpp" + +#include +#include +#include + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: websocket-chat-multi
\n" + << "Example:\n" + << " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + auto* doc_root = argv[3]; + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[4])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc; + + // Create and launch a listening port + boost::make_shared(ioc, tcp::endpoint{address, port}, + boost::make_shared(doc_root)) + ->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/net.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/net.hpp new file mode 100644 index 0000000..07f416f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/net.hpp @@ -0,0 +1,46 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/shared_state.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/shared_state.cpp new file mode 100644 index 0000000..59b69c5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/shared_state.cpp @@ -0,0 +1,69 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "shared_state.hpp" +#include "websocket_session.hpp" + +shared_state::shared_state(std::string doc_root) : document_root(std::move(doc_root)) {} + +void shared_state::join(websocket_session* session) { + std::scoped_lock const lock(mutex_); + sessions_.insert(session); +} + +void shared_state::leave(websocket_session* session) { + std::scoped_lock const lock(mutex_); + sessions_.erase(session); +} + +// Broadcast a message to all websocket client sessions +void shared_state::send(std::string message) { + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + + // Make a local list of all the weak pointers representing + // the sessions, so we can do the actual sending without + // holding the mutex: + std::vector> v; + { + std::scoped_lock const lock(mutex_); + v.reserve(sessions_.size()); + for (auto* p : sessions_) { + v.emplace_back(p->weak_from_this()); + } + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. + for (auto const& wp : v) { + // This mutable object is passed through the upstream asynchronous or stream interface. + // NOLINTNEXTLINE(misc-const-correctness) + if (const auto sp = wp.lock()) { + sp->send(ss); + } + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/shared_state.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/shared_state.hpp new file mode 100644 index 0000000..e52d632 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/shared_state.hpp @@ -0,0 +1,60 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP + +#include +#include +#include +#include +#include + +// Forward declaration +class websocket_session; + +// Represents the shared server state +class shared_state { + std::string const document_root; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; + + // Keep a list of all the connected clients + std::unordered_set sessions_; + +public: + explicit shared_state(std::string doc_root); + + [[nodiscard]] std::string const& doc_root() const noexcept { return document_root; } + + void join(websocket_session* session); + void leave(websocket_session* session); + void send(std::string message); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/websocket_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/websocket_session.cpp new file mode 100644 index 0000000..2e36915 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/websocket_session.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include +#include "websocket_session.hpp" + +websocket_session::websocket_session(tcp::socket&& socket, + boost::shared_ptr const& state) + : ws_(std::move(socket)), state_(state) {} + +websocket_session::~websocket_session() { + // Remove this session from the list of active sessions + state_->leave(this); +} + +// Member shape is part of the upstream Body or bound-callback interface. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +void websocket_session::fail(beast::error_code ec, char const* what) { + // Don't report these + if (ec == net::error::operation_aborted || ec == websocket::error::closed) { + return; + } + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void websocket_session::on_accept(beast::error_code ec) { + // Handle the error, if any + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::on_read(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Read another message + ws_.async_read(buffer_, + beast::bind_front_handler(&websocket_session::on_read, shared_from_this())); +} + +void websocket_session::send(boost::shared_ptr const& ss) { + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + + net::post(ws_.get_executor(), + beast::bind_front_handler(&websocket_session::on_send, shared_from_this(), ss)); +} + +void websocket_session::on_send(boost::shared_ptr const& ss) { + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? + if (queue_.size() > 1) { + return; + } + + // We are not currently writing, so send this immediately + ws_.async_write(net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); +} + +void websocket_session::on_write(beast::error_code ec, std::size_t /*unused*/) { + // Handle the error, if any + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any + if (!queue_.empty()) { + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler(&websocket_session::on_write, shared_from_this())); + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/websocket_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/websocket_session.hpp new file mode 100644 index 0000000..0d66c49 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/chat-multi/websocket_session.hpp @@ -0,0 +1,89 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + +#include "beast.hpp" +#include "net.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// Forward declaration +class shared_state; + +/** Represents an active WebSocket connection to the server + */ +class websocket_session : public boost::enable_shared_from_this { + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; + std::vector> queue_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); + +public: + websocket_session(tcp::socket&& socket, boost::shared_ptr const& state); + + ~websocket_session(); + + template + void run(http::request> req); + + // Send a message + void send(boost::shared_ptr const& ss); + +private: + void on_send(boost::shared_ptr const& ss); +}; + +template +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void websocket_session::run(http::request> req) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-chat-multi"); + })); + + // Accept the websocket handshake + ws_.async_accept(req, + beast::bind_front_handler(&websocket_session::on_accept, shared_from_this())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp new file mode 100644 index 0000000..88f8792 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -0,0 +1,262 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_session(websocket::stream>& ws, net::yield_context yield) { + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro-ssl"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + break; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro-ssl
\n" + << "Example:\n" + << " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), std::ref(ctx), + tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the + // application's network operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/coro/websocket_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/coro/websocket_server_coro.cpp new file mode 100644 index 0000000..566b73f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/coro/websocket_server_coro.cpp @@ -0,0 +1,231 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-coro"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if (ec == websocket::error::closed) { + break; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, net::yield_context yield) { + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + } else { + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } + } +} + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-coro
\n" + << "Example:\n" + << " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc(threads); + + // Spawn a listening port + boost::asio::spawn( + ioc, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_listen, std::ref(ioc), tcp::endpoint{address, port}, std::placeholders::_1), + // on completion, spawn will call this function + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [](std::exception_ptr ex) { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw // lint-run: drives the application's network + // operations + if (ex) { + std::rethrow_exception(ex); + } + }); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/fast/websocket_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/fast/websocket_server_fast.cpp new file mode 100644 index 0000000..b64a2e9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/fast/websocket_server_fast.cpp @@ -0,0 +1,411 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, fast +// +//------------------------------------------------------------------------------ + +/* This server contains the following ports: + + Synchronous + Asynchronous + Coroutine + + This program is optimized for the Autobahn|Testsuite + benchmarking and WebSocket compliants testing program. + + See: + https://github.com/crossbario/autobahn-testsuite +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); +} + +// Adjust settings on the stream +template +void setup_stream(websocket::stream& ws) { + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + + websocket::permessage_deflate pmd; + pmd.client_enable = true; + pmd.server_enable = true; + pmd.compLevel = 3; + ws.set_option(pmd); + + ws.auto_fragment(false); + + // Autobahn|Testsuite needs this + ws.read_message_max(64 * 1024 * 1024); +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +class async_session : public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit async_session(tcp::socket&& socket) : ws_(std::move(socket)) { setup_stream(ws_); } + + // Start the asynchronous operation + void run() { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Async"); + })); + + // Accept the websocket handshake + ws_.async_accept(beast::bind_front_handler(&async_session::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec) { + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + // Read a message + do_read(); + } + + void do_read() { + // Read a message into our buffer + ws_.async_read(buffer_, + beast::bind_front_handler(&async_session::on_read, shared_from_this())); + } + + void on_read(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed + if (ec == websocket::error::closed) { + return; + } + + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write(buffer_.data(), + beast::bind_front_handler(&async_session::on_write, shared_from_this())); + } + + void on_write(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +// Accepts incoming connections and launches the sessions +class async_listener : public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + async_listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { do_accept(); } + +private: + void do_accept() { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler(&async_listener::on_accept, shared_from_this())); + } + + void on_accept(beast::error_code ec, tcp::socket socket) { + if (ec) { + fail(ec, "accept"); + } else { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_coro_session(websocket::stream& ws, net::yield_context yield) { + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket + ws.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + "-Fiber"); + })); + + ws.async_accept(yield[ec]); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); + if (ec == websocket::error::closed) { + break; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if (ec) { + { + fail(ec, "write"); + return; + } + } + } +} + +// Value parameters retain the upstream callback and coroutine ownership contract. +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void do_coro_listen(webcpp::asio::io_context& ioc, tcp::endpoint endpoint, + // Value parameters retain the upstream callback and coroutine ownership + // contract. NOLINTNEXTLINE(performance-unnecessary-value-param) + net::yield_context yield) { + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.open(endpoint.protocol(), ec)); + if (ec) { + { + fail(ec, "open"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + { + fail(ec, "set_option"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.bind(endpoint, ec)); + if (ec) { + { + fail(ec, "bind"); + return; + } + } + + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + { + fail(ec, "listen"); + return; + } + } + + for (;;) { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); + if (ec) { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_session, websocket::stream(std::move(socket)), + std::placeholders::_1), + boost::asio::detached); + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-fast
\n" + << "Example:\n" + " websocket-server-fast 0.0.0.0 8080 1\n" + " Connect to:\n" + " starting-port+0 for synchronous,\n" + " starting-port+1 for asynchronous,\n" + " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create sync port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Create async port + std::make_shared(ioc, + tcp::endpoint{address, static_cast(port + 1u)}) + ->run(); + + // Create coro port + boost::asio::spawn(ioc, + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&do_coro_listen, std::ref(ioc), + tcp::endpoint{address, static_cast(port + 2u)}, + std::placeholders::_1), + boost::asio::detached); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp new file mode 100644 index 0000000..3a8a9f6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -0,0 +1,304 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) : ws_(std::move(socket), ctx) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + + reenter(*this) { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "handshake"); + return; + } + } + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless-ssl"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) + : ioc_(ioc), ctx_(ctx), acceptor_(ioc), socket_(ioc) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-async-ssl
\n" + << "Example:\n" + << " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/stackless/websocket_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/stackless/websocket_server_stackless.cpp new file mode 100644 index 0000000..e224bda --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/stackless/websocket_server_stackless.cpp @@ -0,0 +1,270 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +namespace { +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class session : public boost::asio::coroutine, public std::enable_shared_from_this { + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit session(tcp::socket socket) : ws_(std::move(socket)) {} + + // Start the asynchronous operation + void run() { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + ws_.get_executor(), + beast::bind_front_handler(&session::loop, shared_from_this(), beast::error_code{}, 0)); + } + +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec, std::size_t bytes_transferred) { + boost::ignore_unused(bytes_transferred); + reenter(*this) { + // Set suggested timeout settings for the websocket + ws_.set_option(websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-stackless"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion overload. + // NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, 0)); + if (ec) { + { + fail(ec, "accept"); + return; + } + } + + for (;;) { + // Read a message into our buffer + yield ws_.async_read( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + buffer_, std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec == websocket::error::closed) { + // This indicates that the session was closed + return; + } + if (ec) { + { + fail(ec, "read"); + return; + } + } + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + std::bind(&session::loop, shared_from_this(), std::placeholders::_1, + std::placeholders::_2)); + if (ec) { + { + fail(ec, "write"); + return; + } + } + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + +#include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +// Upstream combines coroutine state and shared lifetime as independent mixins. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class listener : public boost::asio::coroutine, public std::enable_shared_from_this { + webcpp::asio::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + // Value parameters retain the upstream callback and coroutine ownership contract. + // NOLINTNEXTLINE(performance-unnecessary-value-param) + listener(webcpp::asio::io_context& ioc, tcp::endpoint endpoint) + : ioc_(ioc), acceptor_(net::make_strand(ioc)), socket_(net::make_strand(ioc)) { + beast::error_code ec; + + // Open the acceptor + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.open(endpoint.protocol(), ec)); + if (ec) { + fail(ec, "open"); + return; + } + + // Allow address reuse + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.set_option(net::socket_base::reuse_address(true), ec)); + if (ec) { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.bind(endpoint, ec)); + if (ec) { + fail(ec, "bind"); + return; + } + + // Start listening for connections + // The ec output and the returned reference carry the same operation status. + // NOLINTNEXTLINE(bugprone-unused-return-value) + static_cast(acceptor_.listen(net::socket_base::max_listen_connections, ec)); + if (ec) { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void run() { loop(); } + +private: +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include + + // The retained stackless coroutine expands each yield into nested resume branches. + // NOLINTNEXTLINE(readability-function-cognitive-complexity) + void loop(beast::error_code ec = {}) { + reenter(*this) { + for (;;) { + yield acceptor_.async_accept( + // The concrete bound signature selects the upstream Asio spawn/completion + // overload. NOLINTNEXTLINE(modernize-avoid-bind) + socket_, std::bind(&listener::loop, shared_from_this(), std::placeholders::_1)); + if (ec) { + fail(ec, "accept"); + } else { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + +// Asio yield/unyield headers intentionally toggle macros and have no include guards. +// NOLINTNEXTLINE(readability-duplicate-include) +#include +}; + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: websocket-server-stackless
\n" + << "Example:\n" + << " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + [[maybe_unused]] auto const threads = std::max(1, webcpp_fixture::integer(argv[3])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + ioc.run(); // lint-run: drives the application's network operations + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp new file mode 100644 index 0000000..6824509 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -0,0 +1,138 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket, ssl::context& ctx) { + try { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync-ssl"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed + if (se.code() != websocket::error::closed) { + std::cerr << "Error: " << se.code().message() << '\n'; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync-ssl
\n" + << "Example:\n" + << " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(std::move(socket), ctx); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/sync/websocket_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/sync/websocket_server_sync.cpp new file mode 100644 index 0000000..ec2e0bc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/applications/wasip3/websocket/server/sync/websocket_server_sync.cpp @@ -0,0 +1,123 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +// +// Generated by example/applications/tools/prepare.py. Edit the generator. +// Upstream authors and their original notice follow. + +#include +#include +#include +#include +#include +#include +#include +#include "fixture.hpp" +#include "fixture_resolver.hpp" +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +namespace beast = webcpp::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = webcpp::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +namespace { +void do_session(tcp::socket socket) { + try { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator([](websocket::response_type& res) { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + " websocket-server-sync"); + })); + + // Accept the websocket handshake + ws.accept(); + + for (;;) { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } catch (beast::system_error const& se) { + // This indicates that the session was closed + if (se.code() != websocket::error::closed) { + std::cerr << "Error: " << se.code().message() << '\n'; + } + } catch (std::exception const& e) { + std::cerr << "Error: " << e.what() << '\n'; + } +} + +//------------------------------------------------------------------------------ + +} // namespace + +// The process entry point retains its standard char** argv signature. +// NOLINTNEXTLINE(misc-const-correctness) +int main(int argc, char** argv) { + try { + // Check command line arguments. + if (argc != 3) { + std::cerr << "Usage: websocket-server-sync
\n" + << "Example:\n" + << " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(webcpp_fixture::integer(argv[2])); + + // The io_context is required for all I/O + webcpp::asio::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (unsigned accepted = 0; accepted < 1; ++accepted) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + do_session(std::move(socket)); + } + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << '\n'; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/browser/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/browser/Jamfile new file mode 100644 index 0000000..99a03c8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/browser/Jamfile @@ -0,0 +1,15 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project : requirements -/webcpp/beast//beast ; +import webcpp ; +webcpp.targets emscripten ; +webcpp.original node : ../../test/browser ; +webcpp.variants client : client.cpp : /webcpp/beast//browser ; +webcpp.drive browser_tutorial : .//client + : client.variants.json 120 + : ../../test/browser/run.mjs : --program client --expected "browser tutorial: ok" ; +webcpp.lane browser : browser_tutorial : emscripten ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/browser/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/browser/client.cpp new file mode 100644 index 0000000..b51e2ed --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/browser/client.cpp @@ -0,0 +1,90 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The browser contract driver serves this page beside its controlled peers. +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +int main() { + namespace beast = webcpp::beast; + namespace net = webcpp::asio; + net::io_context io; + net::ip::tcp::resolver resolver(io); + boost::system::error_code ec; + const auto port = (emscripten::val::global("beastPeerPort").isUndefined() + ? emscripten::val::global("location")["port"] + : emscripten::val::global("beastPeerPort")) + .as(); + const std::string host = "127.0.0.1:" + port; + const auto addresses = resolver.resolve("127.0.0.1", port, ec); + if (ec) { + return 1; + } + + // tag::browser-websocket-client[] + beast::websocket::stream socket(io); + beast::get_lowest_layer(socket).connect(addresses, ec); + if (ec) { + return 1; + } + // These synchronous operations suspend into the browser event loop. + socket.handshake(host, "/echo", ec); + if (ec) { + return 1; + } + socket.text(true); + socket.write(boost::asio::buffer("hello", 5), ec); + if (ec) { + return 1; + } + beast::flat_buffer incoming; + socket.read(incoming, ec); + if (ec || beast::buffers_to_string(incoming.data()) != "hello") { + return 1; + } + socket.close(beast::websocket::close_code::normal, ec); + if (ec) { + return 1; + } + // end::browser-websocket-client[] + + // tag::browser-fetch-client[] + beast::tcp_stream stream(io); + stream.connect(addresses, ec); + if (ec) { + return 1; + } + beast::http::request request{beast::http::verb::post, "/http", 11}; + request.set(beast::http::field::host, host); + request.body() = "hello"; + request.prepare_payload(); + beast::http::write(stream, request, ec); + if (ec) { + return 1; + } + beast::http::response response; + incoming.consume(incoming.size()); + beast::http::read(stream, incoming, response, ec); + if (ec || response.result_int() != 200 || response.body() != "hello") { + return 1; + } + stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec); + if (ec) { + return 1; + } + // end::browser-fetch-client[] + std::puts("browser tutorial: ok"); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/http_message.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/http_message.cpp new file mode 100644 index 0000000..3cb5962 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/http_message.cpp @@ -0,0 +1,39 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifdef WEBCPP_TEST_UPSTREAM_BEAST +#include +namespace http = boost::beast::http; +#else +#include +namespace http = webcpp::beast::http; +#endif + +#include + +namespace { +// tag::handler[] +http::response handle_request(const http::request& request) { + http::response response{http::status::ok, request.version()}; + response.set(http::field::content_type, "text/plain"); + response.body() = "Hello from WebCPP\n"; + response.prepare_payload(); + return response; +} + +// end::handler[] +} // namespace + +// tag::program[] +int main() { + const http::request request{http::verb::get, "/hello", 11}; + const auto response = handle_request(request); + std::cout << response.result_int() << ' ' << response.reason() << '\n'; + std::cout << response[http::field::content_type] << '\n'; + std::cout << response.body(); +} + +// end::program[] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/http_message.expected b/libraries/beast/openspec/changes/genesis/reference/source/example/http_message.expected new file mode 100644 index 0000000..0654939 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/http_message.expected @@ -0,0 +1,3 @@ +200 OK +text/plain +Hello from WebCPP diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/CMakeLists.txt new file mode 100644 index 0000000..1c11d90 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +find_package(OpenSSL) + +add_subdirectory(advanced) +add_subdirectory(http) +add_subdirectory(websocket) + +add_subdirectory(doc) + +add_subdirectory(echo-op) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/Jamfile new file mode 100644 index 0000000..bf7c532 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/Jamfile @@ -0,0 +1,36 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import testing ; +import-search /boost/config/checks ; +import config : requires ; + +project /boost/beast/example + : requirements + [ requires + cxx11_constexpr + cxx11_decltype + cxx11_hdr_tuple + #cxx11_sfinae_expr # Every MSVC fails this + cxx11_template_aliases + cxx11_variadic_templates + ] + /boost/beast/test//lib-asio/static + on:/boost/beast/test//lib-beast/static + .. + ; + +build-project advanced ; +build-project http ; +build-project websocket ; + +build-project doc ; + +# legacy +build-project echo-op ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/LICENSE_1_0.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/CMakeLists.txt new file mode 100644 index 0000000..3b6e54c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(server) + +if (OPENSSL_FOUND) + add_subdirectory(server-flex) + add_subdirectory(server-flex-awaitable) +endif () diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/Jamfile new file mode 100644 index 0000000..644246c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project server ; + +# SSL +build-project server-flex ; + +# C++20 +build-project server-flex-awaitable ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/CMakeLists.txt new file mode 100644 index 0000000..3e557b1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(advanced-server-flex-awaitable + Jamfile + advanced_server_flex_awaitable.cpp) + +source_group("" FILES + Jamfile + advanced_server_flex_awaitable.cpp) + +target_include_directories(advanced-server-flex-awaitable + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(advanced-server-flex-awaitable + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(advanced-server-flex-awaitable + PROPERTIES FOLDER "example-advanced-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/Jamfile new file mode 100644 index 0000000..bf60ef0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe advanced-server-flex-awaitable : + advanced_server_flex_awaitable.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp new file mode 100644 index 0000000..fabdee2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp @@ -0,0 +1,677 @@ +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +using executor_type = net::strand; +using stream_type = typename beast::tcp_stream::rebind_executor::other; +using acceptor_type = typename net::ip::tcp::acceptor::rebind_executor::other; + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +/** A thread-safe task group that tracks child tasks, allows emitting + cancellation signals to them, and waiting for their completion. +*/ +class task_group +{ + std::mutex mtx_; + net::steady_timer cv_; + std::list css_; + +public: + task_group(net::any_io_executor exec) + : cv_{ std::move(exec), net::steady_timer::time_point::max() } + { + } + + task_group(task_group const&) = delete; + task_group(task_group&&) = delete; + + /** Adds a cancellation slot and a wrapper object that will remove the child + task from the list when it completes. + + @param completion_token The completion token that will be adapted. + + @note @p completion_token must have an associated executor that matches + the one the child task runs on (e.g. via @c net::bind_executor). This is + because @c emit() can run on a different thread than the task, and + @c co_spawn dispatches the cancellation to the handler's associated + executor; without one, the signal is emitted inline on the calling + thread, racing with the task. + + @par Thread Safety + @e Distinct @e objects: Safe.@n + @e Shared @e objects: Safe. + */ + template + auto + adapt(CompletionToken&& completion_token) + { + auto lg = std::lock_guard{ mtx_ }; + auto cs = css_.emplace(css_.end()); + + class remover + { + task_group* tg_; + decltype(css_)::iterator cs_; + + public: + remover( + task_group* tg, + decltype(css_)::iterator cs) + : tg_{ tg } + , cs_{ cs } + { + } + + remover(remover&& other) noexcept + : tg_{ std::exchange(other.tg_, nullptr) } + , cs_{ other.cs_ } + { + } + + ~remover() + { + if(tg_) + { + auto lg = std::lock_guard{ tg_->mtx_ }; + if(tg_->css_.erase(cs_) == tg_->css_.end()) + tg_->cv_.cancel(); + } + } + }; + + return net::bind_cancellation_slot( + cs->slot(), + net::consign( + std::forward(completion_token), + remover{ this, cs })); + } + + /** Emits the signal to all child tasks and invokes the slot's + handler, if any. + + @param type The completion type that will be emitted to child tasks. + + @par Thread Safety + @e Distinct @e objects: Safe.@n + @e Shared @e objects: Safe. + */ + void + emit(net::cancellation_type type) + { + auto lg = std::lock_guard{ mtx_ }; + for(auto& cs : css_) + cs.emit(type); + } + + /** Starts an asynchronous wait on the task_group. + + The completion handler will be called when: + + @li All the child tasks completed. + @li The operation was cancelled. + + @param completion_token The completion token that will be used to + produce a completion handler. The function signature of the completion + handler must be: + @code + void handler( + boost::system::error_code const& error // result of operation + ); + @endcode + + @par Thread Safety + @e Distinct @e objects: Safe.@n + @e Shared @e objects: Safe. + */ + template< + typename CompletionToken = + net::default_completion_token_t> + auto + async_wait( + CompletionToken&& completion_token = + net::default_completion_token_t{}) + { + return net:: + async_compose( + [this, scheduled = false]( + auto&& self, boost::system::error_code ec = {}) mutable + { + if(!scheduled) + self.reset_cancellation_state( + net::enable_total_cancellation()); + + if(!self.cancelled() && ec == net::error::operation_aborted) + ec = {}; + + { + auto lg = std::lock_guard{ mtx_ }; + + if(!css_.empty() && !ec) + { + scheduled = true; + return cv_.async_wait(std::move(self)); + } + } + + if(!std::exchange(scheduled, true)) + return net::post(net::append(std::move(self), ec)); + + self.complete(ec); + }, + completion_token, + cv_); + } +}; + +template +net::awaitable +run_websocket_session( + Stream& stream, + beast::flat_buffer& buffer, + http::request req) +{ + auto cs = co_await net::this_coro::cancellation_state; + auto ws = websocket::stream{ stream }; + + // Set suggested timeout settings for the websocket + ws.set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set( + http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " advanced-server-flex"); + })); + + // Accept the websocket handshake + co_await ws.async_accept(req); + + while(!cs.cancelled()) + { + // Read a message + auto [ec, _] = co_await ws.async_read(buffer, net::as_tuple); + + if(ec == websocket::error::closed || ec == ssl::error::stream_truncated) + co_return; + + if(ec) + throw boost::system::system_error{ ec }; + + // Echo the message back + ws.text(ws.got_text()); + co_await ws.async_write(buffer.data()); + + // Clear the buffer + buffer.consume(buffer.size()); + } + + // A cancellation has been requested, gracefully close the session. + auto [ec] = co_await ws.async_close( + websocket::close_code::service_restart, net::as_tuple); + + if(ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error{ ec }; +} + +template +net::awaitable +run_session( + Stream& stream, + beast::flat_buffer& buffer, + beast::string_view doc_root) +{ + auto cs = co_await net::this_coro::cancellation_state; + + while(!cs.cancelled()) + { + http::request_parser parser; + parser.body_limit(10000); + + auto [ec, _] = + co_await http::async_read(stream, buffer, parser, net::as_tuple); + + if(ec == http::error::end_of_stream) + co_return; + + if(websocket::is_upgrade(parser.get())) + { + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(stream).expires_never(); + + co_await run_websocket_session( + stream, buffer, parser.release()); + + co_return; + } + + auto res = handle_request(doc_root, parser.release()); + if(!res.keep_alive()) + { + co_await beast::async_write(stream, std::move(res)); + co_return; + } + + co_await beast::async_write(stream, std::move(res)); + } +} + +net::awaitable +detect_session( + stream_type stream, + ssl::context& ctx, + beast::string_view doc_root) +{ + beast::flat_buffer buffer; + + // Allow total cancellation to change the cancellation state of this + // coroutine, but only allow terminal cancellation to propagate to async + // operations. This setting will be inherited by all child coroutines. + co_await net::this_coro::reset_cancellation_state( + net::enable_total_cancellation(), net::enable_terminal_cancellation()); + + // We want to be able to continue performing new async operations, such as + // cleanups, even after the coroutine is cancelled. This setting will be + // inherited by all child coroutines. + co_await net::this_coro::throw_if_cancelled(false); + + stream.expires_after(std::chrono::seconds(30)); + + if(co_await beast::async_detect_ssl(stream, buffer)) + { + ssl::stream ssl_stream{ std::move(stream), ctx }; + + auto bytes_transferred = co_await ssl_stream.async_handshake( + ssl::stream_base::server, buffer.data()); + + buffer.consume(bytes_transferred); + + co_await run_session(ssl_stream, buffer, doc_root); + + if(!ssl_stream.lowest_layer().is_open()) + co_return; + + // Gracefully close the stream + auto [ec] = co_await ssl_stream.async_shutdown(net::as_tuple); + if(ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error{ ec }; + } + else + { + co_await run_session(stream, buffer, doc_root); + + if(!stream.socket().is_open()) + co_return; + + stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); + } +} + +net::awaitable +listen( + task_group& task_group, + ssl::context& ctx, + net::ip::tcp::endpoint endpoint, + beast::string_view doc_root) +{ + auto cs = co_await net::this_coro::cancellation_state; + auto executor = co_await net::this_coro::executor; + auto acceptor = acceptor_type{ executor, endpoint }; + + // Allow total cancellation to propagate to async operations. + co_await net::this_coro::reset_cancellation_state( + net::enable_total_cancellation()); + + while(!cs.cancelled()) + { + auto socket_executor = net::make_strand(executor.get_inner_executor()); + auto [ec, socket] = + co_await acceptor.async_accept(socket_executor, net::as_tuple); + + if(ec == net::error::operation_aborted) + co_return; + + if(ec) + throw boost::system::system_error{ ec }; + + net::co_spawn( + socket_executor, + detect_session(stream_type{ std::move(socket) }, ctx, doc_root), + net::bind_executor( + socket_executor, + task_group.adapt( + [](std::exception_ptr e) + { + if(e) + { + try + { + std::rethrow_exception(e); + } + catch(std::exception& e) + { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }))); + } +} + +net::awaitable +handle_signals(task_group& task_group) +{ + auto executor = co_await net::this_coro::executor; + auto signal_set = net::signal_set{ executor, SIGINT, SIGTERM }; + + auto sig = co_await signal_set.async_wait(); + + if(sig == SIGINT) + { + std::cout << "Gracefully cancelling child tasks...\n"; + task_group.emit(net::cancellation_type::total); + + // Wait a limited time for child tasks to gracefully cancell + auto [ec] = co_await task_group.async_wait( + net::as_tuple(net::cancel_after(std::chrono::seconds{ 10 }))); + + if(ec == net::error::operation_aborted) // Timeout occurred + { + std::cout << "Sending a terminal cancellation signal...\n"; + task_group.emit(net::cancellation_type::terminal); + co_await task_group.async_wait(); + } + + std::cout << "Child tasks completed.\n"; + } + else // SIGTERM + { + net::query( + executor.get_inner_executor(), + net::execution::context).stop(); + } +} + +int +main(int argc, char* argv[]) +{ + // Check command line arguments. + if(argc != 5) + { + std::cerr << "Usage: advanced-server-flex-awaitable
\n" + << "Example:\n" + << " advanced-server-flex-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const endpoint = net::ip::tcp::endpoint{ address, port }; + auto const doc_root = beast::string_view{ argv[3] }; + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{ threads }; + + // The SSL context is required, and holds certificates + ssl::context ctx{ ssl::context::tlsv12 }; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Track coroutines + task_group task_group{ ioc.get_executor() }; + + // Create and launch a listening coroutine + auto listener_executor = net::make_strand(ioc); + net::co_spawn( + listener_executor, + listen(task_group, ctx, endpoint, doc_root), + net::bind_executor( + listener_executor, + task_group.adapt( + [](std::exception_ptr e) + { + if(e) + { + try + { + std::rethrow_exception(e); + } + catch(std::exception& e) + { + std::cerr << "Error in listener: " << e.what() << "\n"; + } + } + }))); + + // Create and launch a signal handler coroutine + net::co_spawn( + net::make_strand(ioc), handle_signals(task_group), net::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { ioc.run(); }); + ioc.run(); + + // Block until all the threads exit + for(auto& t : v) + t.join(); + + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/CMakeLists.txt new file mode 100644 index 0000000..9bd2363 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(advanced-server-flex + Jamfile + advanced_server_flex.cpp) + +source_group("" FILES + Jamfile + advanced_server_flex.cpp) + +target_include_directories(advanced-server-flex + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(advanced-server-flex + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(advanced-server-flex + PROPERTIES FOLDER "example-advanced-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/Jamfile new file mode 100644 index 0000000..163a489 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe advanced-server-flex : + advanced_server_flex.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/advanced_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/advanced_server_flex.cpp new file mode 100644 index 0000000..c04c91d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server-flex/advanced_server_flex.cpp @@ -0,0 +1,970 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server, flex (plain + SSL) +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class websocket_session +{ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& + derived() + { + return static_cast(*this); + } + + beast::flat_buffer buffer_; + + // Start the asynchronous operation + template + void + do_accept(http::request> req) + { + // Set suggested timeout settings for the websocket + derived().ws().set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + derived().ws().set_option( + websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " advanced-server-flex"); + })); + + // Accept the websocket handshake + derived().ws().async_accept( + req, + beast::bind_front_handler( + &websocket_session::on_accept, + derived().shared_from_this())); + } + +private: + void + on_accept(beast::error_code ec) + { + if(ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void + do_read() + { + // Read a message into our buffer + derived().ws().async_read( + buffer_, + beast::bind_front_handler( + &websocket_session::on_read, + derived().shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if(ec == websocket::error::closed) + return; + + if(ec) + return fail(ec, "read"); + + // Echo the message + derived().ws().text(derived().ws().got_text()); + derived().ws().async_write( + buffer_.data(), + beast::bind_front_handler( + &websocket_session::on_write, + derived().shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } + +public: + // Start the asynchronous operation + template + void + run(http::request> req) + { + // Accept the WebSocket upgrade request + do_accept(std::move(req)); + } +}; + +//------------------------------------------------------------------------------ + +// Handles a plain WebSocket connection +class plain_websocket_session + : public websocket_session + , public std::enable_shared_from_this +{ + websocket::stream ws_; + +public: + // Create the session + explicit + plain_websocket_session( + beast::tcp_stream&& stream) + : ws_(std::move(stream)) + { + } + + // Called by the base class + websocket::stream& + ws() + { + return ws_; + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL WebSocket connection +class ssl_websocket_session + : public websocket_session + , public std::enable_shared_from_this +{ + websocket::stream> ws_; + +public: + // Create the ssl_websocket_session + explicit + ssl_websocket_session(ssl::stream&& stream) + : ws_(std::move(stream)) + { + } + + // Called by the base class + websocket::stream>& + ws() + { + return ws_; + } +}; + +//------------------------------------------------------------------------------ + +template +void +make_websocket_session( + beast::tcp_stream stream, + http::request> req) +{ + std::make_shared( + std::move(stream))->run(std::move(req)); +} + +template +void +make_websocket_session( + ssl::stream stream, + http::request> req) +{ + std::make_shared( + std::move(stream))->run(std::move(req)); +} + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class http_session +{ + std::shared_ptr doc_root_; + + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& + derived() + { + return static_cast(*this); + } + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +protected: + beast::flat_buffer buffer_; + +public: + // Construct the session + http_session( + beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : doc_root_(doc_root) + , buffer_(std::move(buffer)) + { + } + + void + do_read() + { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + beast::get_lowest_layer( + derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + derived().stream(), + buffer_, + *parser_, + beast::bind_front_handler( + &http_session::on_read, + derived().shared_from_this())); + } + + void + on_read(beast::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if(ec == http::error::end_of_stream) + return derived().do_eof(); + + if(ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade + if(websocket::is_upgrade(parser_->get())) + { + // Disable the timeout. + // The websocket::stream uses its own timeout settings. + beast::get_lowest_layer(derived().stream()).expires_never(); + + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + return make_websocket_session( + derived().release_stream(), + parser_->release()); + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) + do_read(); + } + + void + queue_write(http::message_generator response) + { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) + do_write(); + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void + do_write() + { + if(! response_queue_.empty()) + { + bool keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + derived().stream(), + std::move(response_queue_.front()), + beast::bind_front_handler( + &http_session::on_write, + derived().shared_from_this(), + keep_alive)); + } + } + + void + on_write( + bool keep_alive, + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Resume the read if it has been paused + if(response_queue_.size() == queue_limit) + do_read(); + + response_queue_.pop(); + + do_write(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles a plain HTTP connection +class plain_http_session + : public http_session + , public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + +public: + // Create the session + plain_http_session( + beast::tcp_stream&& stream, + beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session( + std::move(buffer), + doc_root) + , stream_(std::move(stream)) + { + } + + // Start the session + void + run() + { + this->do_read(); + } + + // Called by the base class + beast::tcp_stream& + stream() + { + return stream_; + } + + // Called by the base class + beast::tcp_stream + release_stream() + { + return std::move(stream_); + } + + // Called by the base class + void + do_eof() + { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Handles an SSL HTTP connection +class ssl_http_session + : public http_session + , public std::enable_shared_from_this +{ + ssl::stream stream_; + +public: + // Create the http_session + ssl_http_session( + beast::tcp_stream&& stream, + ssl::context& ctx, + beast::flat_buffer&& buffer, + std::shared_ptr const& doc_root) + : http_session( + std::move(buffer), + doc_root) + , stream_(std::move(stream), ctx) + { + } + + // Start the session + void + run() + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + stream_.async_handshake( + ssl::stream_base::server, + buffer_.data(), + beast::bind_front_handler( + &ssl_http_session::on_handshake, + shared_from_this())); + } + + // Called by the base class + ssl::stream& + stream() + { + return stream_; + } + + // Called by the base class + ssl::stream + release_stream() + { + return std::move(stream_); + } + + // Called by the base class + void + do_eof() + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler( + &ssl_http_session::on_shutdown, + shared_from_this())); + } + +private: + void + on_handshake( + beast::error_code ec, + std::size_t bytes_used) + { + if(ec) + return fail(ec, "handshake"); + + // Consume the portion of the buffer used by the handshake + buffer_.consume(bytes_used); + + do_read(); + } + + void + on_shutdown(beast::error_code ec) + { + if(ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + explicit + detect_session( + tcp::socket&& socket, + ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)) + , ctx_(ctx) + , doc_root_(doc_root) + { + } + + // Launch the detector + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler( + &detect_session::on_run, + this->shared_from_this())); + } + + void + on_run() + { + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + beast::async_detect_ssl( + stream_, + buffer_, + beast::bind_front_handler( + &detect_session::on_detect, + this->shared_from_this())); + } + + void + on_detect(beast::error_code ec, bool result) + { + if(ec) + return fail(ec, "detect"); + + if(result) + { + // Launch SSL session + std::make_shared( + std::move(stream_), + ctx_, + std::move(buffer_), + doc_root_)->run(); + return; + } + + // Launch plain session + std::make_shared( + std::move(stream_), + std::move(buffer_), + doc_root_)->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , ctx_(ctx) + , acceptor_(net::make_strand(ioc)) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the detector http_session and run it + std::make_shared( + std::move(socket), + ctx_, + doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: advanced-server-flex
\n" << + "Example:\n" << + " advanced-server-flex 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared( + ioc, + ctx, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait( + [&](beast::error_code const&, int) + { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for(auto& t : v) + t.join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/CMakeLists.txt new file mode 100644 index 0000000..715b483 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(advanced-server + Jamfile + advanced_server.cpp) + +source_group("" FILES + Jamfile + advanced_server.cpp) + +target_link_libraries(advanced-server PRIVATE Boost::beast) + +set_target_properties(advanced-server PROPERTIES FOLDER "example-advanced-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/Jamfile new file mode 100644 index 0000000..5f9ceec --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe advanced-server : + advanced_server.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/advanced_server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/advanced_server.cpp new file mode 100644 index 0000000..e854b2a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/advanced/server/advanced_server.cpp @@ -0,0 +1,644 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: Advanced server +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class websocket_session : public std::enable_shared_from_this +{ + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit + websocket_session(tcp::socket&& socket) + : ws_(std::move(socket)) + { + } + + // Start the asynchronous accept operation + template + void + do_accept(http::request> req) + { + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " advanced-server"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, + beast::bind_front_handler( + &websocket_session::on_accept, + shared_from_this())); + } + +private: + void + on_accept(beast::error_code ec) + { + if(ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void + do_read() + { + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &websocket_session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This indicates that the websocket_session was closed + if(ec == websocket::error::closed) + return; + + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write( + buffer_.data(), + beast::bind_front_handler( + &websocket_session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Handles an HTTP server connection +class http_session : public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + + static constexpr std::size_t queue_limit = 8; // max responses + std::queue response_queue_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + +public: + // Take ownership of the socket + http_session( + tcp::socket&& socket, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)) + , doc_root_(doc_root) + { + static_assert(queue_limit > 0, + "queue limit must be positive"); + } + + // Start the session + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler( + &http_session::do_read, + this->shared_from_this())); + } + +private: + void + do_read() + { + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request using the parser-oriented interface + http::async_read( + stream_, + buffer_, + *parser_, + beast::bind_front_handler( + &http_session::on_read, + shared_from_this())); + } + + void + on_read(beast::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if(ec == http::error::end_of_stream) + return do_close(); + + if(ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade + if(websocket::is_upgrade(parser_->get())) + { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + std::make_shared( + stream_.release_socket())->do_accept(parser_->release()); + return; + } + + // Send the response + queue_write(handle_request(*doc_root_, parser_->release())); + + // If we aren't at the queue limit, try to pipeline another request + if (response_queue_.size() < queue_limit) + do_read(); + } + + void + queue_write(http::message_generator response) + { + // Allocate and store the work + response_queue_.push(std::move(response)); + + // If there was no previous work, start the write loop + if (response_queue_.size() == 1) + do_write(); + } + + // Called to start/continue the write-loop. Should not be called when + // write_loop is already active. + void + do_write() + { + if(! response_queue_.empty()) + { + bool keep_alive = response_queue_.front().keep_alive(); + + beast::async_write( + stream_, + std::move(response_queue_.front()), + beast::bind_front_handler( + &http_session::on_write, + shared_from_this(), + keep_alive)); + } + } + + void + on_write( + bool keep_alive, + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); + } + + // Resume the read if it has been paused + if(response_queue_.size() == queue_limit) + do_read(); + + response_queue_.pop(); + + do_write(); + } + + void + do_close() + { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , acceptor_(net::make_strand(ioc)) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + acceptor_.get_executor(), + beast::bind_front_handler( + &listener::do_accept, + this->shared_from_this())); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the http session and run it + std::make_shared( + std::move(socket), + doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: advanced-server
\n" << + "Example:\n" << + " advanced-server 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared( + ioc, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait( + [&](beast::error_code const&, int) + { + // Stop the `io_context`. This will cause `run()` + // to return immediately, eventually destroying the + // `io_context` and all of the sockets in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for(auto& t : v) + t.join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/common/root_certificates.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/common/root_certificates.hpp new file mode 100644 index 0000000..6a7396c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/common/root_certificates.hpp @@ -0,0 +1,3963 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP + +#include +#include + +/* + PLEASE READ + + These root certificates here are included just to make the + SSL client examples work. They are NOT intended to be + illustrative of best-practices for performing TLS certificate + verification. + + A REAL program which needs to verify the authenticity of a + server IP address resolved from a given DNS name needs to + consult the operating system specific certificate store + to validate the chain of signatures, compare the domain name + properly against the domain name in the certificate, check + the certificate revocation list, and probably do some other + things. + + ALL of these operations are entirely outside the scope of + both Boost.Beast and Boost.Asio. + + See (work in progress): + https://github.com/djarek/certify + + tl;dr: root_certificates.hpp should not be used in production code +*/ + +namespace ssl = boost::asio::ssl; // from + +namespace detail { + +inline +void +load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) +{ + std::string cert = + "# ACCVRAIZ1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE\n" + "AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw\n" + "CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ\n" + "BgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwHUEtJQUNDVjENMAsGA1UECgwEQUND\n" + "VjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCb\n" + "qau/YU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oABd15jm\n" + "fZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7Ixjp\n" + "6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp\n" + "1txyM/1d8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B\n" + "9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok\n" + "RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv\n" + "uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Actalis Authentication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + "IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC\n" + "SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1\n" + "ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv\n" + "UTufClrJwkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX\n" + "4ay8IMKx4INRimlNAJZaby/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL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7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX\n" + "X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok\n" + "fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R\n" + "K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU\n" + "ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU\n" + "LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT\n" + "LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Commercial\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP\n" + "Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr\n" + "ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL\n" + "MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1\n" + "yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr\n" + "VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/\n" + "nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG\n" + "XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj\n" + "vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt\n" + "Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g\n" + "N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC\n" + "nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Networking\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz\n" + "dCBOZXR3b3JraW5nMB4XDTEwMDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDEL\n" + "MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp\n" + "cm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SEHi3y\n" + "YJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbua\n" + "kCNrmreIdIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRL\n" + "QESxG9fhwoXA3hA/Pe24/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp\n" + "6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG\n" + "yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i\n" + "QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfO\n" + "tDIuUFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzu\n" + "QY0x2+c06lkh1QF612S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZ\n" + "Lgo/bNjR9eUJtGxUAArgFU2HdW23WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4u\n" + "olu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9/ZFvgrG+CJPbFEfxojfHRZ48\n" + "x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE\n" + "BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRww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YDVR0PAQH/\n" + "BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByvMiPIs0laUZx2\n" + "KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg\n" + "Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B\n" + "8OWycvpEgjNC6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQ\n" + "MKSOyARiqcTtNd56l+0OOF6SL5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc\n" + "0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK+4w1IX2COPKpVJEZNZOUbWo6xbLQ\n" + "u4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF\n" + "u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH\n" + "YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8\n" + "GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO\n" + "RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e\n" + "KeC2uAloGRwYQw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# AffirmTrust Premium ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC\n" + "VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ\n" + "cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ\n" + "BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt\n" + "VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D\n" + "0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9\n" + "ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G\n" + "A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs\n" + "aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I\n" + "flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1h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dYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS\n" + "k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl\n" + "7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm\n" + "btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl\n" + "urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+\n" + "fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n" + "n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Amazon Root CA 4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----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GmuhWawyfc2E8PzBhj/5kP\n" + "DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc\n" + "maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D\n" + "lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv\n" + "KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Autoridad de Certificacion Firmaprofesional CIF A62634068\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UE\n" + "BhMCRVMxQjBABgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1h\n" + "cHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEy\n" + "MzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIwQAYDVQQDDDlBdXRvcmlkYWQgZGUg\n" + "Q2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBBNjI2MzQwNjgwggIi\n" + "MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDDUtd9\n" + "thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQM\n" + "cas9UX4PB99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefG\n" + "L9ItWY16Ck6WaVICqjaY7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15i\n" + "NA9wBj4gGFrO93IbJWyTdBSTo3OxDqqHECNZXyAFGUftaI6SEspd/NYrspI8IM/h\n" + "X68gvqB2f3bl7BqG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lClrD2VQS\n" + "3a/DTg4fJl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5k\n" + "SeTy36LssUzAKh3ntLFlosS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF\n" + "3dvd6qJ2gHN99ZwExEWN57kci57q13XRcrHedUTnQn3iV2t93Jm8PYMo6oCTjcVM\n" + "ZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoRsaS8I8nkvof/uZS2+F0g\n" + "StRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTDKCOM/icz\n" + "Q0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQB\n" + "jLMi6Et8Vcad+qMUu2WFbm5PEn4KPJ2V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Baltimore CyberTrust Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" + "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" + "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" + "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" + "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" + "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" + "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" + "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" + "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" + "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" + "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" + "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" + "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" + "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" + "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" + "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" + "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" + "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" + "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTg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ae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3t\n" + "OluwlN5E40EIosHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo\n" + "+fsicdl9sz1Gv7SEr5AcD48Saq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7\n" + "KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYdDnkM/crqJIByw5c/8nerQyIKx+u2\n" + "DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us\n" + "H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ\n" + "I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7\n" + "5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" + "3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" + "Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Buypass Class 3 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFow\n" + "TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" + "HgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n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HEy9BHcEGhyoMZCCxt8l13nIoUE9Q2\n" + "HJLw5QY33KbmkJs4j1xrG0aGQ0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsa\n" + "O5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8ZORK15FTAaggiG6cX0S5y2CBNOxv\n" + "033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2KSb12tjE8nVhz36u\n" + "dmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz6MkE\n" + "kbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41\n" + "3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD\n" + "u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq\n" + "4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CA Disig Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV\n" + "BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu\n" + "MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy\n" + "MDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sxEzARBgNVBAcTCkJyYXRpc2xhdmEx\n" + "EzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERpc2lnIFJvb3QgUjIw\n" + "ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbCw3Oe\n" + "NcJxVX6B+6tGUODBfEl45qt5WDza/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"+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W81k/BfDxujRNt+3vrMNDcTa/F1bal\n" + "TFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjxmHHEt38OFdAlab0i\n" + "nSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01utI3\n" + "gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18Dr\n" + "G5gPcFw0sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3Os\n" + "zMOl6W8KjptlwlCFtaOgUxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8x\n" + "L4ysEr3vQCj8KWefshNPZiTEUxnpHikV7+ZtsH8tZ/3zbBt1RqPlShfppNcL\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# CFCA EV ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD\n" + "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx\n" + "MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j\n" + "aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJP\n" + "T1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnVBU03\n" + "sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpL\n" + "TIpTUnrD7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz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TeGSGn+ZnzxEk8rUQElsgIfXBDrDMlI1Dlb4pd19\n" + "xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjnaH9d\n" + "Ci77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN\n" + "5mydLIhyPDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe\n" + "/v5WOaHIz16eGWRGENoXkbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+Z\n" + "AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ\n" + "5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCB\n" + "gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV\n" + "BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw\n" + "MDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3Jl\n" + "YXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01P\n" + "RE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3\n" + "UcEbVASY06m/weaKXTuH+7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI\n" + "2GqGd0S7WWaXUF601CxwRM/aN5VCaTwwxHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8\n" + "Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV4EajcNxo2f8ESIl33rXp\n" + "+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA1KGzqSX+\n" + "DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5O\n" + "nKVIrLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW\n" + "/zAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6g\n" + "PKA6hjhodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9u\n" + "QXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAPpiem/Yb6dc5t3iuHXIY\n" + "SdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CPOGEIqB6BCsAv\n" + "IC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/\n" + "RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4\n" + "zJVSk/BwJVmcIGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5dd\n" + "BA6+C4OmF4O5MBKgxTMVBbkN+8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IB\n" + "ZQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" + "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" + "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" + "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" + "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" + "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" + "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" + "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" + "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# COMODO RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgk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1NqV5ta+aDY9fm4fTIrv0Q8h\n" + "bV6lUmPOEvjvKtpv6zf+EwLHyzs+ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFnc\n" + "fca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1kluPBS1xp81HlDQwY9qcEQCYsuu\n" + "HWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY1gkIl2PlwS6w\n" + "t0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw\n" + "WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certigna Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw\n" + "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + "MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x\n" + "MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD\n" + "VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX\n" + "BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" + "ggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sO\n" + "ty3tRQgXstmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9M\n" + "CiBtnyN6tMbaLOQdLNyzKNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPu\n" + "I9Vwzm1RaRDuoXrC0SIxwo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+ "HVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH6\n" + "0BGM+RFq7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncB\n" + "lA2c5uk5jR+mUYyZDDl34bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdi\n" + "o2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1\n" + "gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS6Cvu5zHbugRqh5jnxV/v\n" + "faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63\n" + "Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh\n" + "jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw\n" + "3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM\n" + "MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D\n" + "ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBU\n" + "cnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIyMTIwNzM3WhcNMjkxMjMxMTIwNzM3\n" + "WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMg\n" + "Uy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSIw\n" + "IAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0B\n" + "AQEFAAOCAQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rH\n" + "UV+rpDKmYYe2bg+G0jACl/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LM\n" + "TXPb865Px1bVWqeWifrzq2jUI4ZZJ88JJ7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVU\n" + "BBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4fOQtf/WsX+sWn7Et0brM\n" + "kUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0cvW0QM8x\n" + "AcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNV\n" + "HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15y\n" + "sHhE49wcrwn9I0j6vSrEuVUEtRCjjSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfL\n" + "I9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1mS1FhIrlQgnXdAIv94nYmem8\n" + "J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5ajZt3hrvJBW8qY\n" + "VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI\n" + "03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Certum Trusted Network CA 2\n" + "-----BEGIN CER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zAYspsbi\n" + "DrW5viSP\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Chambers of Commerce Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xKTAnBgNVBAMTIENoYW1iZXJz\n" + "IG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEyMjk1MFoXDTM4MDcz\n" + "MTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBj\n" + "dXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIw\n" + "EAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEp\n" + "MCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0G\n" + "CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW9\n" + "28sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKAXuFixrYp4YFs8r/lfTJq\n" + "VKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorjh40G072Q\n" + "DuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR\n" + "5gN/ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfL\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2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH3qLPaYRgM+gQDROpI9CF\n" + "5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbURWpGqOt1\n" + "glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaH\n" + "FoI6M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2\n" + "pSB7+R5KBWIBpih1YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MD\n" + "xvbxrN8y8NmBGuScvfaAFPDRLLmF9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QG\n" + "tjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcKzBIKinmwPQN/aUv0NCB9szTq\n" + "jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De\n" + "fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg\n" + "OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ\n" + "d0jQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Comodo AAA Services root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb\n" + "MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow\n" + "GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj\n" + "YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL\n" + "MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY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gT2\n" + "G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi\n" + "l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3\n" + "smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Cybertrust Global Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYG\n" + "A1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2Jh\n" + "bCBSb290MB4XDTA2MTIxNTA4MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UE\n" + "ChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBS\n" + "b290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Mi8vRRQZhP/8NN5\n" + "7CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW0ozS\n" + "J8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2y\n" + "HLtgwEZLAfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iP\n" + "t3sMpTjr3kfb1V05/Iin89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNz\n" + "FtApD0mpSPCzqrdsxacwOUBdrsTiXSZT8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAY\n" + "XSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/\n" + "MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2MDSgMqAw\n" + "hi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3Js\n" + "MB8GA1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQBW7wojoFROlZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMj\n" + "Wqd8BfP9IjsO0QbE2zZMcwSO5bAi5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUx\n" + "XOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2hO0j9n0Hq0V+09+zv+mKts2o\n" + "omcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+TX3EJIrduPuoc\n" + "A06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW\n" + "WL1WMRJOEcgh4LMRkWXbtKaIOM5V\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\n" + "ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM\n" + "HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03\n" + "UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE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65ysCQblrGXnRl11z+o+I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# D-TRUST Root Class 3 CA 2 EV 2009\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw\n" + "NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV\n" + "BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAwOTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfSegpn\n" + "ljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM0\n" + "3TP1YtHhzRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6Z\n" + "qQTMFexgaDbtCHu39b+T7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lR\n" + "p75mpoo6Kr3HGrHhFPC+Oh25z1uxav60sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8\n" + "HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure3511H3a6UCAwEAAaOCASQw\n" + "ggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyvcop9Ntea\n" + "HNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFw\n" + "Oi8vZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xh\n" + "c3MlMjAzJTIwQ0ElMjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1E\n" + "RT9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0MEagRKBChkBodHRwOi8vd3d3LmQt\n" + "dHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xhc3NfM19jYV8yX2V2XzIwMDku\n" + "Y3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+PPoeUSbrh/Yp\n" + "3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05\n" + "nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNF\n" + "CSuGdXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na\n" + "xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX\n" + "KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DST Root CA X3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" + "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" + "DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" + "PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" + "Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + "AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" + "rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" + "OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" + "xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" + "7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" + "aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" + "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" + "SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" + "ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" + "AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" + "R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" + "JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" + "Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQu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t1i8b5QZ7dsvfPx\n" + "H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe\n" + "+o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv\n" + "b3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQG\n" + "EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl\n" + "cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwggEi\n" + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSA\n" + "n61UQbVH35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4Htecc\n" + "biJVMWWXvdMX0h5i89vqbFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9Hp\n" + "EgjAALAcKxHad3A2m67OeYfcgnDmCXRwVWmvo2ifv922ebPynXApVfSr/5Vh88lA\n" + "bx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OPYLfykqGxvYmJHzDNw6Yu\n" + "YjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+RnlTGNAgMB\n" + "AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQW\n" + "BBTOw0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPI\n" + "QW5pJ6d1Ee88hjZv0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I\n" + "0jJmwYrA8y8678Dj1JGG0VDjA9tzd29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4Gni\n" + "lmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAWhsI6yLETcDbYz+70CjTVW0z9\n" + "B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv\n" + "ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo\n" + "IhNzbM8m9Yop5w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Assured ID Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg\n" + "RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq\n" + "hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf\n" + "Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q\n" + "RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\n" + "BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD\n" + "AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY\n" + "JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv\n" + "6pZjamVFkpUBtA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" + "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" + "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" + "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" + "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" + "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" + "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" + "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" + "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" + "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Global Root G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n" + "MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwYD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+ cert += + "# DigiCert Global Root G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw\n" + "CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu\n" + "ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe\n" + "Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw\n" + "EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x\n" + "IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF\n" + "K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG\n" + "fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO\n" + "Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd\n" + "BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx\n" + "AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/\n" + "oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8\n" + "sycX\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert High Assurance EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs\n" + "MQswCQYDVQQGEwJVUzEVMBMG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D41VHMWEZ71jF\n" + "hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2\n" + "Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe\n" + "vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep\n" + "+OkuE6N36B9K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# DigiCert Trusted Root G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3Qg\n" + "RzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBiMQswCQYDVQQGEwJV\n" + "UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu\n" + "Y29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3y\n" + "ithZwuEppz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1If\n" + "xp4VpX6+n6lXFllVcq9ok3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDV\n" + "ySAdYyktzuxeTsiT+CFhmzTrBcZe7FsavOvJz82sNEBfsXpm7nfISKhmV1efVFiO\n" + "DCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGYQJB5w3jHtrHEtWoYOAMQ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9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI\n" + "r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1\n" + "/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm\n" + "gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# E-Tugra Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNV\n" + "BAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBC\n" + "aWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNV\n" + "BAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQDDB9FLVR1\n" + "Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMwNTEyMDk0OFoXDTIz\n" + "MDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExQDA+\n" + "BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhp\n" + "em1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN\n" + "ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4vU/kwVRHoViVF56C/UY\n" + "B4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vdhQd2h8y/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"ZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAwDQYJKoZIhvcN\n" + "AQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJlF7W2u++AVtd0x7Y\n" + "/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNaAl6k\n" + "SBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhy\n" + "Rp/7SNVel+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOS\n" + "Agu+TGbrIP65y7WZf+a2E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xl\n" + "nJ2lYJU6Un/10asIbvPuW/mIPX64b24D5EI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# EE Certification Centre Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1\n" + "MQswCQYDVQQGEwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1\n" + "czEoMCYGA1UEAwwfRUUgQ2VydGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYG\n" + "CSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIwMTAxMDMwMTAxMDMwWhgPMjAzMDEy\n" + "MTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlBUyBTZXJ0aWZpdHNl\n" + "ZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRyZSBS\n" + "b290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEB\n" + "AQUAA4IBDwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUy\n" + "euuOF0+W2Ap7kaJjbMeMTC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvO\n" + "bntl8jixwKIy72KyaOBhU8E2lf/slLo2rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIw\n" + "WFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw93X2PaRka9ZP585ArQ/d\n" + "MtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtNP2MbRMNE\n" + "1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYD\n" + "VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/\n" + "zQas8fElyalL1BSZMEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYB\n" + "BQUHAwMGCCsGAQUFBwMEBggrBgEFBQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEF\n" + "BQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+RjxY6hUFaTlrg4wCQiZrxTFGGV\n" + "v9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqMlIpPnTX/dqQG\n" + "E5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u\n" + "uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIW\n" + "iAYLtqZLICjU3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/v\n" + "GVCJYMzpJJUPwssd8m92kMfMdcGWxZ0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust.net Premium 2048 Secure Server CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIEOGPe+DANB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B/zAdBgNV\n" + "HQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJKoZIhvcNAQEFBQADggEBADub\n" + "j1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPyT/4xmf3IDExo\n" + "U8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf\n" + "zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5b\n" + "u/8j72gZyxKTJ1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+\n" + "bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er\n" + "fF6adulZkMV8gzURZVE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\n" + "Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\n" + "KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\n" + "cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw\n" + "NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw\n" + "NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy\n" + "ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV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dQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\n" + "0vdXcDazv/wor3ElhVsT/h5/WrQ8\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - EC1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG\n" + "A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3\n" + "d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu\n" + "dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq\n" + "RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy\n" + "MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD\n" + "VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0\n" + "L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g\n" + "Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD\n" + "ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi\n" + "A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt\n" + "ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH\n" + "Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O\n" + "BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC\n" + "R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX\n" + "hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMC\n" + "VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50\n" + "cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3Qs\n" + "IEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVz\n" + "dCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwHhcNMDkwNzA3MTcy\n" + "NTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVu\n" + "dHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwt\n" + "dGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0\n" + "aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5IC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + "AoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP/vaCeb9zYQYKpSfYs1/T\n" + "RU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXzHHfV1IWN\n" + "cCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hW\n" + "wcKUs/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1\n" + "U1+cPvQXLOZprE4yTGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0\n" + "jaWvYkxN4FisZDQSA/i2jZRjJKRxAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAP\n" + "BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN\n" + "BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/\n" + "jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ\n" + "Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v\n" + "1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R\n" + "nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH\n" + "VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Entrust Root Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAw\n" + "gb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL\n" + "Ex9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykg\n" + "MjAx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ERTIFICATE-----\n" + "\n"; + cert += + "# GDCA TrustAUTH R5 ROOT\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UE\n" + "BhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ\n" + "IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0\n" + "MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVowYjELMAkGA1UEBhMCQ04xMjAwBgNV\n" + "BAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8w\n" + "HQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0BAQEF\n" + "AAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJj\n" + "Dp6L3TQsAlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBj\n" + "TnnEt1u9ol2x8kECK62pOqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+u\n" + "KU49tm7srsHwJ5uu4/Ts765/94Y9cnrrpftZTqfrlYwiOXnhLQiPzLyRuEH3FMEj\n" + "qcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ9Cy5WmYqsBebnh52nUpm\n" + "MUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQxXABZG12\n" + "ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloP\n" + "zgsMR6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3Gk\n" + "L30SgLdTMEZeS1SZD2fJpcjyIMGC7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" + "\n"; + cert += + "# GTS Root R1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" + "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + "QzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIy\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNl\n" + "cnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEB\n" + "AQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaM\n" + "f/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vX\n" + "mX7wCl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7\n" + "zUjwTcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0P\n" + "fyblqAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtc\n" + "vfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4\n" + "Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zqkUsp\n" + "zBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOO\n" + "Rc92wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYW\n" + "k70paDPvOmbsB4om3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+\n" + "DVrNVjzRlwW5y0vtOUucxD/SVRNuJLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgF\n" + "lQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV\n" + "HQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQADggIBADiW\n" + "Cu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1\n" + "d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6Z\n" + "XPYfcX3v73svfuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZR\n" + "gyFmxhE+885H7pwoHyXa/6xmld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3\n" + "d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9bgsiG1eGZbYwE8na6SfZu6W0eX6Dv\n" + "J4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq4BjFbkerQUIpm/Zg\n" + "DdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWErtXvM\n" + "+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyy\n" + "F62ARPBopY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9\n" + "SQ98POyDGCBDTtWTurQ0sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdws\n" + "E3PYJ/HQcu51OyLemGhmW/HGY0dVHLqlCFF1pkgl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0B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A1UEAxMLR1RTIFJvb3QgUjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout\n" + "736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2A\n" + "DDL24CejQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBTB8Sa6oC2uhYHP0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFuk\n" + "fCPAlaUs3L6JbyO5o91lAFJekazInXJ0glMLfalAvWhgxeG4VDvBNhcl2MG9AjEA\n" + "njWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOaKaqW04MjyaR7YbPMAuhd\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GTS Root R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQsw\n" + "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + "MBIGA1UEAxMLR1RTIFJvb3QgUjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw\n" + "MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + "Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjOPQIBBgUrgQQA\n" + "IgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu\n" + "hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/l\n" + "xKvRHYqjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\n" + "DgQWBBSATNbrdP9JNqPV2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0\n" + "CMRw3J5QdCHojXohw0+WbhXRIjVhLfoIN+4Zba3bssx9BzT1YBkstTTZbyACMANx\n" + "sbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11xzPKwTdb+mciUqXWi4w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Global CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n" + "MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\n" + "YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG\n" + "EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg\n" + "R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9\n" + "9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq\n" + "fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\n" + "iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\n" + "1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\n" + "bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\n" + "MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\n" + "ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\n" + "uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\n" + "Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\n" + "tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\n" + "PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n" + "hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n" + "5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY\n" + "MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo\n" + "R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx\n" + "MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK\n" + "Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp\n" + "ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9\n" + "AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA\n" + "ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0\n" + "7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W\n" + "kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI\n" + "mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" + "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ\n" + "KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1\n" + "6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl\n" + "4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K\n" + "oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj\n" + "UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU\n" + "AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL\n" + "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj\n" + "KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2\n" + "MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV\n" + "BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw\n" + "NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV\n" + "BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH\n" + "MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL\n" + "So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal\n" + "tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG\n" + "CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT\n" + "qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz\n" + "rD6ogRLQy7rQkgu2npaqBA+K\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB\n" + "mDELMA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y9cr5HqQ6XErhK8WTTOd8lNNTB\n" + "zU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbEAp7aDHdlDkQN\n" + "kv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD\n" + "AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUH\n" + "SJsMC8tJP33st/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2G\n" + "spki4cErx5z481+oghLrGREt\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE\n" + "BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0\n" + "IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV\n" + "VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8\n" + "cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT\n" + "QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh\n" + "F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v\n" + "c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQah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TaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9\n" + "ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt\n" + "DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm\n" + "bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GeoTrust Universal CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW\n" + "MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVy\n" + "c2FsIENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYD\n" + "VQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1\n" + "c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" + "AQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0DE81\n" + "WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUG\n" + "FF+3Qs17j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdq\n" + "XbboW0W63MOhBW9Wjo8QJqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxL\n" + "se4YuU6W3Nx2/zu+z18DwPw76L5GG//aQMJS9/7jOvdqdzXQ2o3rXhhqMcceujwb\n" + "KNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2WP0+G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n" + "OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH\n" + "6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX\n" + "QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk\n" + "MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH\n" + "bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX\n" + "DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD\n" + "QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ\n" + "FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F\n" + "uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX\n" + "kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs\n" + "ewv4n4Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign ECC Root CA - R5\n" + "-----BEGIN CERTIFICATE-----\n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/EjJKSZp4A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1\n" + "MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL\n" + "v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8\n" + "eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq\n" + "tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd\n" + "C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa\n" + "zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB\n" + "mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH\n" + "V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n\n" + "bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG\n" + "3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs\n" + "J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO\n" + "291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS\n" + "ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd\n" + "AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7\n" + "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\n" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\n" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\n" + "MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\n" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\n" + "RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\n" + "gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\n" + "KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\n" + "QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\n" + "XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\n" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\n" + "LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\n" + "RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\n" + "jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n" + "6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\n" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\n" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\n" + "WD9f\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# GlobalSign Root CA - R6\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg\n" + "MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh\n" + "bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQx\n" + "MjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjET\n" + "MBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCAiIwDQYJ\n" + "KoZIhvcNA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\n" + "55wsTLxDKZmOMNOsIeDjHfrYBzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLj\n" + "vUYAGm0CuiVdjaExUd1URhxN25mW7xocBFymFe944Hn+Xds+qkxV/ZoVqW/hpvvf\n" + "cDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr3TsTjxKM4kEaSHpz\n" + "oHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB10jZp\n" + "nOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs\n" + "pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v\n" + "JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R\n" + "8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4\n" + "5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Global Chambersign Root - 2008\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD\n" + "VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0\n" + "IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3\n" + "MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD\n" + "aGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMxNDBaFw0zODA3MzEx\n" + "MjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg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Vqc5iJWzouE4ge\n" + "v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z\n" + "09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh\n" + "MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE\n" + "YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3\n" + "MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo\n" + "ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg\n" + "MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN\n" + "ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA\n" + "PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w\n" + "wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi\n" + "EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY\n" + "avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+\n" + "YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE\n" + "sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h\n" + "/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5\n" + "IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD\n" + "ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy\n" + "OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P\n" + "TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ\n" + "HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER\n" + "dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf\n" + "ReYNnyicsbkqWletNw+vHX/bvZ8=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Go Daddy Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" + "EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp\n" + "ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz\n" + "NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH\n" + "EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE\n" + "AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw\n" + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD\n" + "E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH\n" + "/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy\n" + "DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh\n" + "GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR\n" + "tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA\n" + "AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE\n" + "FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX\n" + "WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu\n" + "9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr\n" + "gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo\n" + "2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n" + "LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n" + "4uJEvlz36hz1\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions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KR\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2011\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1Ix\n" + "RDBCBgNVBAoTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1\n" + "dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1p\n" + "YyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIFJvb3RDQSAyMDExMB4XDTExMTIw\n" + "NjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYTAkdSMUQwQgYDVQQK\n" + "EztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIENl\n" + "cnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl\n" + "c2VhcmNoIEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEB\n" + "BQADggEPADCCAQoCggEBAKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPz\n" + "dYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJ\n" + "fel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa71HFK9+WXesyHgLacEns\n" + "bgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u8yBRQlqD\n" + "75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSP\n" + "FEDH3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNV\n" + "HRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp\n" + "5dgTBCPuQSUwRwYDVR0eBEAwPqA8MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQu\n" + "b3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQub3JnMA0GCSqGSIb3DQEBBQUA\n" + "A4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVtXdMiKahsog2p\n" + "6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8\n" + "TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7\n" + "dIsXRSZMFpGD/md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8Acys\n" + "Nnq/onN694/BtZqhFLKPM58N7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXI\n" + "l7WdmplNsDz4SgCbZN2fOUvRJ9e4\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hellenic Academic and Research Institutions RootCA 2015\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix\n" + "DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k\n" + "IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT\n" + "N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9v\n" + "dENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAxMTIxWjCBpjELMAkG\n" + "A1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNh\n" + "Z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hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0I\n" + "XtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+D1hYc2Ryx+hFjtyp8iY/xnmMsVMI\n" + "M4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrMd/K4kPFox/la/vot\n" + "9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+yd+2V\n" + "Z5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/ea\n" + "j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh\n" + "X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ\n" + "l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf\n" + "bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4\n" + "pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK\n" + "e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0\n" + "vm9qp/UsQu0yrbYhnr68\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsx\n" + "FjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3Qg\n" + "Um9vdCBDQSAxMB4XDTAzMDUxNTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkG\n" + "A1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdr\n" + "b25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" + "AQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1ApzQ\n" + "jVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEn\n" + "PzlTCeqrauh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjh\n" + "ZY4bXSNmO7ilMlHIhqqhqZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9\n" + "nnV0ttgCXjqQesBCNnLsak3c78QA3xMYV18meMjWCnl3v/evt3a5pQuEF10Q6m/h\n" + "q5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNVHRMBAf8ECDAGAQH/AgED\n" + "MA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7ih9legYsC\n" + "mEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI3\n" + "7piol7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clB\n" + "oiMBdDhViw+5LmeiIAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJs\n" + "EhTkYY2sEJCehFC78JZvRZ+K88psT/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpO\n" + "fMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilTc4afU9hDDl3WY4JxHYB0yvbi\n" + "AmvZWg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Hongkong Post Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQw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NEwA/RiTZxPRN+ZItIsGxVd7GYYKecsAyVKvQv83j+Gj\n" + "Hno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwIDAQABo2MwYTAP\n" + "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e\n" + "i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEw\n" + "DQYJKoZIhvcNAQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG\n" + "7BJ8dNVI0lkUmcDrudHr9EgwW62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCk\n" + "MpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWldy8joRTnU+kLBEUx3XZL7av9YROXr\n" + "gZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov+BS5gLNdTaqX4fnk\n" + "GMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDceqFS\n" + "3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJm\n" + "Ozj/2ZQw9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+\n" + "l6mc1X5VTMbeRRAc6uk7nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6c\n" + "JfTzPV4e0hz5sy229zdcxsshTrD3mUcYhcErulWuBurQB7Lcq9CClnXO0lD+mefP\n" + "L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa\n" + "LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG\n" + "mpv0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ISRG Root X1\n" + "-----BEGIN C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Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI\n" + "rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq\n" + "hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL\n" + "ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ\n" + "3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK\n" + "NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5\n" + "ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n" + "TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n" + "jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n" + "oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n" + "4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n" + "mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" + "emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Commercial Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES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O01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB\n" + "/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZIhvcNAQELBQAD\n" + "ggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH\n" + "6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwt\n" + "LRvM7Kqas6pgghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93\n" + "nAbowacYXVKV7cndJZ5t+qntozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3\n" + "+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmVYjzlVYA211QC//G5Xc7UI2/YRYRK\n" + "W2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUXfeu+h1sXIFRRk0pT\n" + "AwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/rokTLq\n" + "l1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG\n" + "4iZZRHUe2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZ\n" + "mUlO+KWA2yUPHGNiiskzZ2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A\n" + "7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7RcGzM7vRX+Bi6hG6H\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# IdenTrust Public Sector Root CA 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN\n" + "MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblR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HQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMwDQYJKoZIhvcN\n" + "AQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj\n" + "t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHV\n" + "DRDtfULAj+7AmgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9\n" + "TaDKQGXSc3z1i9kKlT/YPyNtGtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8G\n" + "lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW\n" + "mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df\n" + "WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5\n" + "+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ\n" + "tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA\n" + "GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv\n" + "8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Izenpe.com\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4\n" + "MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6\n" + "ZW5wZS5jb20wHhcNMDcxMjEzMTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYD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W5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx\n" + "MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AQYwHQYDVR0OBBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUA\n" + "A4ICAQB4pgwWSp9MiDrAyw6lFn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWb\n" + "laQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbgakEyrkgPH7UIBzg/YsfqikuFgba56\n" + "awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8qhT/AQKM6WfxZSzwo\n" + "JNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Csg1lw\n" + "LDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCT\n" + "VyvehQP5aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGk\n" + "LhObNA5me0mrZJfQRsN5nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJb\n" + "UjWumDqtujWTI6cfSN01RpiyEGjkpTHCClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/\n" + "QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZoQ0iy2+tzJOeRf1SktoA+\n" + "naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1ZWrOZyGls\n" + "QyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# LuxTrust Global Root 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL\n" + "BQAwR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AUwAwEB/zBCBgNVHSAEOzA5MDcGByuB\n" + "KwEBAQowLDAqBggrBgEFBQcCARYeaHR0cHM6Ly9yZXBvc2l0b3J5Lmx1eHRydXN0\n" + "Lmx1MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBT/GCh2+UgFLKGu8SsbK7JT\n" + "+Et8szAdBgNVHQ4EFgQU/xgodvlIBSyhrvErGyuyU/hLfLMwDQYJKoZIhvcNAQEL\n" + "BQADggIBAGoZFO1uecEsh9QNcH7X9njJCwROxLHOk3D+sFTAMs2ZMGQXvw/l4jP9\n" + "BzZAcg4atmpZ1gDlaCDdLnINH2pkMSCEfUmmWjfrRcmF9dTHF5kH5ptV5AzoqbTO\n" + "jFu1EVzPig4N1qx3gf4ynCSecs5U89BvolbW7MM3LGVYvlcAGvI1+ut7MV3CwRI9\n" + "loGIlonBWVx65n9wNOeD4rHh4bhY79SV5GCc8JaXcozrhAIuZY+kt9J/Z93I055c\n" + "qqmkoCUUBpvsT34tC38ddfEz2O3OuHVtPlu5mB0xDVbYQw8wkbIEa91WvpWAVWe+\n" + "2M2D2RjuLg+GLZKecBPs3lHJQ3gCpU3I+V/EkVhGFndadKpAvAefMLmx9xIX3eP/\n" + "JEAdemrRTxgKqpAd60Ae36EeRJIQmvKN4dFLRp7oRUKX6kWZ8+xm1QL68qZKJKre\n" + "zrnK+T+Tb/mjuuqlPpmt/f97mfVl7vBZKGfXkJWkE4SphMHozs51k2MavDzq1WQf\n" + "LSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc7kGUnF4ZLvhFSZl0kbAEb+MEWrGrKqv+\n" + "x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6\n" + "oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Microsec e-Szigno Root CA 2009\n" + "-----BEGIN CERTIFICATE-----\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1SCOhGnqmKrs0aDAbBgNVHREEFDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqG\n" + "SIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0olZMEyL/azXm4Q5DwpL7v8u8h\n" + "mLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfXI/OMn74dseGk\n" + "ddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775\n" + "tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c\n" + "2Pm2G2JwCz02yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5t\n" + "HMN1Rq41Bab2XD0h7lbwyYIiLXpUq3DDfSJlgnCW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# NetLock Arany (Class Gold) Főtanúsítvány\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG\n" + "EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3\n" + "MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl\n" + "cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR\n" + "dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgxMjA2MTUwODIxWjCB\n" + "pzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxOZXRM\n" + "b2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlm\n" + "aWNhdGlvbiBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNz\n" + "IEdvbGQpIEbFkXRhbsO6c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAxCRec75LbRTDofTjl5Bu0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrT\n" + "lF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw/HpYzY6b7cNGbIRwXdrz\n" + "AZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAkH3B5r9s5\n" + "VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRG\n" + "ILdwfzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2\n" + "BJtr+UBdADTHLpl1neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAG\n" + "AQH/AgEEMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2M\n" + "U9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwWqZw8UQCgwBEIBaeZ5m8BiFRh\n" + "bvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTtaYtOUZcTh5m2C\n" + "+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC\n" + "bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2F\n" + "uLjbvrW5KfnaNwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2\n" + "XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Network Solutions Certificate Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "M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SqGSIb3DQEBBQUAA4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc8\n" + "6fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q4LqILPxFzBiwmZVRDuwduIj/\n" + "h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/GGUsyfJj4akH\n" + "/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv\n" + "wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN\n" + "pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GA CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCB\n" + "ijELMAkGA1UEBhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHly\n" + "aWdodCAoYykgMjAwNTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl\n" + "ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQSBDQTAeFw0w\n" + "NTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYDVQQGEwJDSDEQMA4G\n" + "A1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIwIAYD\n" + "VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBX\n" + "SVNlS2V5IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + "MIIBCgKCAQEAy0+zAJs9Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxR\n" + "VVuuk+g3/ytr6dTqvirdqFEr12bDYVxgAsj1znJ7O7jyTmUIms2kahnBAbtzptf2\n" + "w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbDd50kc3vkDIzh2TbhmYsF\n" + "mQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ/yxViJGg\n" + "4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t9\n" + "4B3RLoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYw\n" + "DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQw\n" + "EAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOx\n" + "SPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vImMMkQyh2I+3QZH4VFvbBsUfk2\n" + "ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4+vg1YFkCExh8\n" + "vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa\n" + "hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZi\n" + "Fj4A4xylNoEYokxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ\n" + "/L7fCg0=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GB CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBt\n" + "MQswCQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUg\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B4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" + "aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic\n" + "Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# OISTE WISeKey Global Root GC CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw\n" + "CQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91\n" + "bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwg\n" + "Um9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRaFw00MjA1MDkwOTU4MzNaMG0xCzAJ\n" + "BgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBGb3Vu\n" + "ZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2JhbCBS\n" + "b290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4ni\n" + "eUqjFqdrVCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4W\n" + "p2OQ0jnUsYd4XxiWD1AbNTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8E\n" + "BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7T\n" + "rYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0EAwMDaAAwZQIwJsdpW9zV\n" + "57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtkAjEA2zQg\n" + "Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC\n" + "TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0\n" + "aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0\n" + "aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz\n" + "MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw\n" + "IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR\n" + "dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG\n" + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp\n" + "li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D\n" + "rOpm2RgbaIr1VxqYuvXtdj182d6UajtLF8HVj71lODqV0D1VNk7feVcxKh7YWWVJ\n" + "WCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeLYzcS19Dsw3sgQUSj7cug\n" + "F+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWenAScOospU\n" + "xbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCC\n" + "Ak4wPQYIKwYBBQUHAQEEMTAv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y\n" + "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n" + "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n" + "SnQ2+Q==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 1 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00\n" + "MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakEPBtV\n" + "wedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWe\n" + "rNrwU8lmPNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF341\n" + "68Xfuw6cwI2H44g4hWf6Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh\n" + "4Pw5qlPafX7PGglTvF0FBM+hSo+LdoINofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXp\n" + "UhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/lg6AnhF4EwfWQvTA9xO+o\n" + "abw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV7qJZjqlc\n" + "3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Wy58yljXrQs8C097Vpl4KlbQMJImYFt\n" + "nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCa\n" + "GMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6XJxg\n" + "Fyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55J\n" + "WpzmM+Yklvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bB\n" + "rrcCaoF6qUWD4gXmuVbBlDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp\n" + "+ARz8un+XJiM9XOva7R+zdRcAitMOeGylZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1\n" + "ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt66/3FsvbzSUr5R/7mp/i\n" + "Ucw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1JdxnwQ5hYIiz\n" + "PtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og\n" + "/zOhD7osFRXql7P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0KCl3GBUzGpn/Z9Yr9y\n" + "4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza\n" + "8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 2 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00\n" + "MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFhZiFf\n" + "qq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMW\n" + "n4rjyduYNM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ym\n" + "c5GQYaYDFCDy54ejiK2toIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+\n" + "O7q414AB+6XrW7PFXmAqMaCvN+ggOp+oMiwMzAkd056OXbxMmO7FGmh77FOm6RQ1\n" + "o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+lV0POKa2Mq1W/xPtbAd0j\n" + "IaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZoL1NesNKq\n" + "IcGY5jDjZ1XHm26sGahVpkUG0CM62+t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4\n" + "WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x\n" + "GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv\n" + "b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV\n" + "BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W\n" + "YWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM\n" + "V0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNggDhoB\n" + "4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUr\n" + "H556VOijKTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd\n" + "8lyyBTNvijbO0BNO/79KDDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9Cabwv\n" + "vWhDFlaJKjdhkf2mrk7AyxRllDdLkgbvBNDInIjbC3uBr7E9KsRlOni27tyAsdLT\n" + "mZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwpp5ijJUMv7/FfJuGITfhe\n" + "btfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8nT8KKdjc\n" + "T5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDt\n" + "WAEXMJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhW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AyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp8kokUvd0/bpO5qgdAm6x\n" + "DYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBCbjPsMZ57\n" + "k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6s\n" + "zHXug/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0j\n" + "Wy10QJLZYxkNc91pvGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeT\n" + "mJlglFwjz1onl14LBQaTNx47aTbrqZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK\n" + "4SVhM7JZG+Ju1zdXtg2pEto=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# QuoVadis Root CA 3 G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQEL\n" + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00\n" + "MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + "aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMgRzMwggIiMA0GCSqG\n" + "SIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286IxSR\n" + "/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNu\n" + "FoM7pmRLMon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXR\n" + "U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+YUbKh4yE8/nxoGibIh6BJpsQBJFxwAYf\n" + "3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmDhPbl\n" + "8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+\n" + "DhcI00iX0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HN\n" + "PlopNLk9hM6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/\n" + "ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx\n" + "NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv\n" + "bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49\n" + "AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA\n" + "VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku\n" + "WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP\n" + "MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX\n" + "5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ\n" + "ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg\n" + "h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com EV Root Certification Authority RSA R2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNV\n" + "BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UE\n" + "CgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMB4XDTE3MDUzMTE4MTQzN1oXDTQy\n" + "MDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4G\n" + "A1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQD\n" + "DC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy\n" + "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvq\n" + "M0fNTPl9fb69LT3w23jhhqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssuf\n" + "OePPxU7Gk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OLk7K4S9ksrPJ/psEDzOFSz\n" + "/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXt\n" + "ll9ldDz7CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEm\n" + "Kf7GUmG6sXP/wwyc5WxqlD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKK\n" + "QbNmC1r7fSOl8hqw/96bg5Qu0T/fkreRrwU7ZcegbLHNYhLDkBvjJc40vG93drEQ\n" + "w/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi\n" + "S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07\n" + "mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority ECC\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC\n" + "VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T\n" + "U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0\n" + "aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz\n" + "WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0\n" + "b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS\n" + "b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB\n" + "BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI\n" + "7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg\n" + "CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud\n" + "EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD\n" + "VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T\n" + "kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+\n" + "gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SSL.com Root Certification Authority RSA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz\n" + "OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv\n" + "bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcN\n" + "AQEBBQADggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6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FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAslu1OJD7OAUN5F7kR/\n" + "q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjqerQ0\n" + "cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jr\n" + "a6x+3uxjMxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90I\n" + "H37hVZkLId6Tngr75qNJvTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/Y\n" + "K9f1JmzJBjSWFupwWRoyeXkLtoh/D1JIPb9s2KJELtFOt3JY04kTlf5Eq/jXixtu\n" + "nLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406ywKBjYZC6VWg3dGq2ktuf\n" + "oYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NIWuuA8ShY\n" + "Ic2wBlX7Jz9TkHCpBB5XJ7k=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SZAFIR ROOT CA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQEL\n" + "BQAwUTELMAkGA1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6\n" + "ZW5pb3dhIFMuQS4xGDAWBgNVBAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkw\n" + "NzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJBgNVBAYTAlBMMSgwJgYDVQQKDB9L\n" + "cmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYDVQQDDA9TWkFGSVIg\n" + "Uk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5QqEvN\n" + "QLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT\n" + "3PSQ1hNKDJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw\n" + "3gAeqDRHu5rr/gsUvTaE2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr6\n" + "3fE9biCloBK0TXC5ztdyO4mTp4CEHCdJckm1/zuVnsHMyAHs6A6KCpbns6aH5db5\n" + "BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwiieDhZNRnvDF5YTy7ykHN\n" + "XGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD\n" + "AgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsF\n" + "AAOCAQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw\n" + "8PRBEew/R40/cof5O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOG\n" + "nXkZ7/e7DDWQw4rtTw/1zBLZpD67oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCP\n" + "oky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul4+vJhaAlIDf7js4MNIThPIGy\n" + "d05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6+/NNIxuZMzSg\n" + "LvWpCz/UXeHPhJ/iGcJfitYgHuNztw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureSign RootCA11\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDEr\n" + "MCkGA1UEChMiSmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoG\n" + "A1U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Dg8OFmP9Mni0N5HeDk061lgeLKBObjBmN\n" + "QSdJQO7e5iNEOdyhIta6A/I=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SecureTrust CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI\n" + "MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x\n" + "FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz\n" + "MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv\n" + "cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN\n" + "AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz\n" + "Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO\n" + "0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao\n" + "wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj\n" + "7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS\n" + "8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT\n" + "BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB\n" + "/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg\n" + "JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5j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Z/kG5VacJ\n" + "jnIFHovdRIWCQtBJwB1g8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnI\n" + "HmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYVHDGA76oYa8J719rO+TMg1fW9ajMtgQT7\n" + "sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi0XPnj3pDAgMBAAGjgZ0w\n" + "gZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQF\n" + "MAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCsw\n" + "KaAnoCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsG\n" + "AQQBgjcVAQQDAgEAMA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0L\n" + "URYD7xh8yOOvaliTFGCRsoTciE6+OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXO\n" + "H0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm\n" + "I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY\n" + "iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc\n" + "f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication RootCA2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl\n" + "MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe\n" + "U2VjdXJpdHkgQ29t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IwAHIRc/\n" + "SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Security Communication Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY\n" + "MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t\n" + "dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5\n" + "WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD\n" + "VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8\n" + "9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ\n" + "DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9\n" + "Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N\n" + "QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ\n" + "xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G\n" + "A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T\n" + "AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG\n" + "kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr\n" + "Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5\n" + "Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU\n" + "JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot\n" + "RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Sonera Class 2 Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP\n" + "MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx\n" + "MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV\n" + "BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o\n" + "Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt\n" + "5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s\n" + "3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej\n" + "vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu\n" + "8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw\n" + "DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG\n" + "MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil\n" + "zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/\n" + "3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD\n" + "FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6\n" + "Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2\n" + "ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden EV Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gRVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0y\n" + "MjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIg\n" + "TmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRlcmxhbmRlbiBFViBS\n" + "b290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkkSzrS\n" + "M4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nC\n" + "UiY4iKTWO0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmd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r8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tNf1zuacpzEPuKqf2e\n" + "vTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi5Dp6\n" + "Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIa\n" + "Gl6I6lD4WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeL\n" + "eG9QgkRQP2YGiqtDhFZKDyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8\n" + "FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGyeUN51q1veieQA6TqJIc/2b3Z6fJfUEkc\n" + "7uzXLg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Staat der Nederlanden Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJO\n" + "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFh\n" + "dCBkZXIgTmVkZXJsYW5kZW4gUm9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloX\n" + "DTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMCTkwxHjAcBgNVBAoMFVN0YWF0IGRl\n" + "ciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5lZGVybGFuZGVuIFJv\n" + "b3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4yolQP\n" + "cPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WW\n" + "IkYFsO2tx1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqX\n" + "xz8ecAgwoNzFs21v0IJyEavSgWhZghe3eJ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" + "0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0rmj1A\n" + "fsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq\n" + "4BZ+Extq1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR\n" + "1VmiiXTTn74eS9fGbbeIJG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/\n" + "QFH1T/U67cjF68IeHRaVesd+QnGTbksVtzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM\n" + "94B7IWcnMFk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Class 2 CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBU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5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Starfield Services Root Certificate Authority - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs\n" + "ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5\n" + "MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD\n" + "VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy\n" + "ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy\n" + "dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI\n" + "hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p\n" + "OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2\n" + "8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K\n" + "Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe\n" + "hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk\n" + "6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw\n" + "DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q\n" + "AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI\n" + "bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB\n" + "ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z\n" + "qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n" + "iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n" + "0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n" + "sSi6\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Gold CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n" + "BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln\n" + "biBHb2xkIENBIC0gRzIwHhcNMDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBF\n" + "MQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMR8wHQYDVQQDExZT\n" + "d2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9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5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczO\n" + "UYrHUDFu4Up+GC9pWbY9ZIEr44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5\n" + "O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOfMke6UiI0HTJ6CVanfCU2qT1L2sCC\n" + "bwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6mGu6uLftIdxf+u+yv\n" + "GPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxpmo/a\n" + "77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC\n" + "hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3\n" + "92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp\n" + "Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w\n" + "ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt\n" + "Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# SwissSign Silver CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE\n" + "BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWdu\n" + "IFNpbHZlciBDQSAtIEcyMB4XDTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0Nlow\n" + "RzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAx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aWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIB\n" + "AHPGgeAn0i0P4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShp\n" + "WJHckRE1qTodvBqlYJ7YH39FkWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9\n" + "xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L3XWgwF15kIwb4FDm3jH+mHtwX6WQ\n" + "2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx/uNncqCxv1yL5PqZ\n" + "IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8\n" + "aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X\n" + "em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR\n" + "dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/\n" + "OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+\n" + "hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy\n" + "tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "Y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jASBgMmTnrpMwatXlajRWc2BQN\n" + "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" + "BSeOE6Fuwg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# T-TeleSec GlobalRoot Class 3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" + "KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd\n" + "BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl\n" + "YyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgxMDAxMTAyOTU2WhcNMzMxMDAxMjM1\n" + "OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy\n" + "aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50\n" + "ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0G\n" + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN\n" + "8ELg63iIVl6bmlQdTQyK9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/\n" + "RLyTPWGrTs0NvvAgJ1gORH8EGoel15YUNpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4\n" + "hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZFiP0Zf3WHHx+xGwpzJFu5\n" + "ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W0eDrXltM\n" + "EnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGj\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1\n" + "A/d2O2GCahKqGFPrAyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOy\n" + "WL6ukK2YJ5f+AbGwUgC4TeQbIXQbfsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ\n" + "1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzTucpH9sry9uetuUg/vBa3wW30\n" + "6gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT\n" + "91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml\n" + "e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p\n" + "TpPDpFQUWw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx\n" + "GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp\n" + "bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w\n" + "KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0\n" + "BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRpZmlrYXNpIC0gU3Vy\n" + "dW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYDVQQG\n" + "EwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZ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\n" + "\n"; + cert += + "# TWCA Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES\n" + "MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU\n" + "V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz\n" + "WhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJVEFJV0FO\n" + "LUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + "AQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFE\n" + "AcK0HMMxQhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HH\n" + "K3XLfJ+utdGdIzdjp9xCoi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeX\n" + "RfwZVzsrb+RH9JlF/h3x+JejiB03HFyP4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/z\n" + "rX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1ry+UPizgN7gr8/g+YnzAx\n" + "3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n" + "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkq\n" + "hkiG9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeC\n" + "MErJk/9q56YAf4lCmtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdls\n" + "XebQ79NqZp4VKIV66IIArB6nCWlWQtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62D\n" + "lhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVYT0bf+215WfKEIlKuD8z7fDvn\n" + "aspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocnyYh0igzyXxfkZ\n" + "YiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Taiwan GRCA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/\n" + "MQswCQYDVQQGEwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmlj\n" + "YXRpb24gQXV0aG9yaXR5MB4XDTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1ow\n" + "PzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dvdmVybm1lbnQgUm9vdCBDZXJ0aWZp\n" + "Y2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\n" + "AJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qNw8XR\n" + "IePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1q\n" + "gQdW8or5BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKy\n" + "yhwOeYHWtXBiCAEuTk8O1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAts\n" + "F/tnyMKtsc2AtJfcdgEWFelq16TheEfOhtX7MfP6Mb40qij7cEwdScevLJ1tZqa2\n" + "jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wov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Brkk7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44Vbnz\n" + "ssQwmSNOXfJIoRIM3BKQCZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDe\n" + "LMDDav7v3Aun+kbfYNucpllQdSNpc5Oy+fwC00fmcc4QAu4njIT/rEUNE1yDMuAl\n" + "pYYsfPQS\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TeliaSonera Root CA v1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAw\n" + "NzEUMBIGA1UECgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJv\n" + "b3QgQ0EgdjEwHhcNMDcxMDE4MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYD\n" + "VQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwWVGVsaWFTb25lcmEgUm9vdCBDQSB2\n" + "MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+6yfwIaPzaSZVfp3F\n" + "VRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA3GV1\n" + "7CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+X\n" + "Z75Ljo1kB1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+\n" + "/jXh7VB7qTCNGdMJjmhnXb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs\n" + "81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxHoLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkm\n" + "dtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3F0fUTPHSiXk+TT2YqGHe\n" + "Oh7S+F4D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YkUD/GKvvZt5y11ubQ2egZixVx\n" + "SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor ECA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U\n" + "cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxFzAVBgNVBAMMDlRydXN0Q29y\n" + "IEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3MjgwN1owgZwxCzAJBgNV\n" + "BAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQw\n" + "IgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRy\n" + "dXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3Ig\n" + "RUNBLTEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb\n" + "3w9U73NjKYKtR8aja+3+XzP4Q1HpGjORMRegdMTUpwHmspI+ap3tDvl0mEDTPwOA\n" + "BoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23xFUfJ3zSCNV2HykVh0A5\n" + "3ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmcp0yJF4Ou\n" + "owReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/\n" + "wZ0+fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZF\n" + "ZtS6mFjBAgMBAAGjYzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAf\n" + "BgNVHSMEGDAWgBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/\n" + "MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAQEABT41XBVwm8nHc2Fv\n" + "civUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u/ukZMjgDfxT2\n" + "AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F\n" + "hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50\n" + "soIipX1TH0XsJ5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BI\n" + "WJZpTdwHjFGTot+fDz2LYLSCjaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1Wi\n" + "tJ/X5g==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYD\n" + "VQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEk\n" + "MCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U\n" + "cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29y\n" + "IFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkxMjMxMTcyMzE2WjCB\n" + "pDELMAk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ZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djts\n" + "L1Ac59v2Z3kf9YKVmgenFK+P3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdN\n" + "zl/HHk484IkzlQsPpTLWPFp5LBk=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# TrustCor RootCert CA-2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNV\n" + "BAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQw\n" + "IgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRy\n" + "dXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0eTEfMB0GA1UEAwwWVHJ1c3RDb3Ig\n" + "Um9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEyMzExNzI2MzlaMIGk\n" + "MQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEg\n" + "Q2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYD\n" + "VQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRy\n" + "dXN0Q29yIFJvb3RDZXJ0IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "AoICAQCnIG7CKqJiJJWQdsg4foDSq8GbZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+\n" + "QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9NkRvRUqdw6VC0xK5mC8tkq\n" + "1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1oYxOdqHp\n" + "2yql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Az+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW\n" + "2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dvDDqPys/cA8GiCcjl/YBeyGBCARsaU1q7\n" + "N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYURpFHmygk71dSTlxCnKr3\n" + "Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANExdqtvArB\n" + "As8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp\n" + "5KeXRKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu\n" + "1uwJ\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Trustis FPS Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBF\n" + "MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQL\n" + "ExNUcnVzdGlzIEZQUyBSb290IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTEx\n" + "MzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNVBAoTD1RydXN0aXMgTGltaXRlZDEc\n" + "MBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQAD\n" + "ggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQRUN+\n" + "AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihH\n" + "iTHcDnlkH5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjj\n" + "vSkCqPoc4Vu5g6hBSLwacY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA\n" + "0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zto3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlB\n" + "OrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEAAaNTMFEwDwYDVR0TAQH/\n" + "BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAdBgNVHQ4E\n" + "FgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01\n" + "GX2cGE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmW\n" + "zaD+vkAMXBJV+JOCyinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP4\n" + "1BIy+Q7DsdwyhEQsb8tGD+pmQQ9P8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZE\n" + "f1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHVl/9D7S3B2l0pKoU/rGXuhg8F\n" + "jZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYliB6XzCGcKQEN\n" + "ZetX2fNXlrtIzYE=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Extended Validation Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBF\n" + "eHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMx\n" + "MDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNV\n" + "BAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggI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MaVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5\n" + "c6sq1WnIeJEmMX3ixzDx/BR4dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp\n" + "4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb+7lsq+KePRXBOy5nAliRn+/4Qh8s\n" + "t2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOWF3sGPjLtx7dCvHaj\n" + "2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwiGpWO\n" + "vpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2C\n" + "xR9GUeOcGMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx\n" + "cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM\n" + "fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# UCA Global G2 Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9\n" + "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH\n" + "bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0x\n" + "CzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlUcnVzdDEbMBkGA1UEAwwSVUNBIEds\n" + "b2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxeYr\n" + "b3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmToni9\n" +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4BFFJqIRNow6rSn4+7vW4LV\n" + "PtateJLbXDzz2K36uGt/xDYotgIVilQsnLAXc47QN6MUPJiVAAwpBVueSUmxX8fj\n" + "y88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHojhJi6IjMtX9Gl8Cb\n" + "EGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZkbxqg\n" + "DMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI\n" + "+Vg7RE+xygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGy\n" + "YiGqhkCyLmTTX8jjfhFnRR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bX\n" + "UB+K+wb1whnw0A==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust ECC Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx\n" + "MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + "Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg\n" + "VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm\n" + "aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo\n" + "I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng\n" + "o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G\n" + "A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD\n" + "VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB\n" + "zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW\n" + "RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# USERTrust RSA Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB\n" + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw\n" + "MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV\n" + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU\n" + "aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy\n" + "dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + "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z8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs\n" + "8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR\n" + "iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze\n" + "Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ\n" + "XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/\n" + "qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB\n" + "VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB\n" + "L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n" + "jjxDah2nGN59PRbxYvnKkKj9\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G4\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjELMAkG\n" + "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJp\n" + "U2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwg\n" + "SW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2ln\n" + "biBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5\n" + "IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8Utpkmw4tXNherJI9/gHm\n" + "GUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGzrl0Bp3ve\n" + "fLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUw\n" + "AwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJ\n" + "aW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYj\n" + "aHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMW\n" + "kf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMDA2gAMGUCMGYhDBgmYFo4e1ZC\n" + "4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIxAJw9SDkjOVga\n" + "FRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Class 3 Public Primary Certification Authority - G5\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBg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/zAOBgNVHQ8BAf8E\n" + "BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH\n" + "BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy\n" + "aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv\n" + "MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE\n" + "p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y\n" + "5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# VeriSign Universal Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB\n" + "vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MTgwNgYDVQQDEy9W\n" + "ZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wODA0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uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+\n" + "seQxIcaBlVZaDrHC1LGmWazxY8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz\n" + "4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTxP/jgdFcrGJ2BtMQo2pSXpXDrrB2+\n" + "BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+PwGZsY6rp2aQW9IHR\n" + "lRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3\n" + "7M2CYfE45k+XmCpajQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# Verisign Class 3 Public Primary Certification Authority - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw\n" + "CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl\n" + "cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu\n" + "LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT\n" + "aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp\n" + "dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD\n" + "VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT\n" + "aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ\n" + "bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu\n" + "IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg\n" + "LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b\n" + "N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t\n" + "KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu\n" + "kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm\n" + "CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ\n" + "Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu\n" + "imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te\n" + "2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe\n" + "DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC\n" + "/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p\n" + "F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt\n" + "TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# XRamp Global CA Root\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB\n" + "gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFt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4yw4sLjmdjItuFhwv\n" + "JoIQ4uNllAoEwF73XVv4EOLQunpL+943AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08C\n" + "AwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAcYwHQYDVR0O\n" + "BBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IBAQA+0hyJ\n" + "LjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecY\n" + "MnQ8SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ\n" + "44gx+FkagQnIl6Z0x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6I\n" + "Jd1hJyMctTEHBDa0GpC9oHRxUIltvBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNw\n" + "i/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7NzTogVZ96edhBiIL5VaZVDADlN\n" + "9u6wWk5JRFRYX0KD\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# ePKI Root Certification Authority\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe\n" + "MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0\n" + "ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe\n" + "Fw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMxMjdaMF4xCzAJBgNVBAYTAlRXMSMw\n" + "IQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEqMCgGA1UECwwhZVBL\n" + "SSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjAN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ZpVnPDimZI+ymBV3QGypzqKOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkP\n" + "JXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdVxrsStZf0X4OFunHB2WyBEXYKCrC/\n" + "gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEPNXubrjlpC2JgQCA2\n" + "j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+rGNm6\n" + "5ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUB\n" + "o2M3IUxExJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS\n" + "/jQ6fbjpKdx2qcgw+BRxgMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z\n" + "Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE\n" + "W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D\n" + "hNQ+IIX3Sj0rnP0qCglN6oH4EZw=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - C3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG\n" + "EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx\n" + "IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND\n" + "IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci\n" + "MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti\n" + "sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O\n" + "BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\n" + "Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c\n" + "3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J\n" + "0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign ECC Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG\n" + "EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo\n" + "bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g\n" + "RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ\n" + "TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s\n" + "b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw\n" + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0\n" + "WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS\n" + "fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB\n" + "zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq\n" + "hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB\n" + "CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD\n" + "+JbNR6iC8hZVdyR+EhCVBCyj\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - C1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkG\n" + "A1UEBhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEg\n" + "SW5jMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAw\n" + "MFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln\n" + "biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNpZ24gUm9v\n" + "dCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+upufGZ\n" + "BczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZ\n" + "HdPIWoU/Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH\n" + "3DspVpNqs8FqOp099cGXOFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvH\n" + "GPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4VI5b2P/AgNBbeCsbEBEV5f6f9vtKppa+c\n" + "xSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleoomslMuoaJuvimUnzYnu3Yy1\n" + "aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+XJGFehiq\n" + "TbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + "BQADggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87\n" + "/kOXSTKZEhVb3xEp/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4\n" + "kqNPEjE2NuLe/gDEo2APJ62gsIq1NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrG\n" + "YQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT\n" + "+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo\n" + "WXzhriKi4gp6D/piq1JM4fHfyr6DDUI=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# emSign Root CA - G1\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD\n" + "VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU\n" + "ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH\n" + "MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO\n" + "MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv\n" + "Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN\n" + "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz\n" + "f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO\n" + "8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq\n" + "d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM\n" + "tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt\n" + "Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB\n" + "o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD\n" + "AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x\n" + "PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM\n" + "wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d\n" + "GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH\n" + "6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby\n" + "RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx\n" + "iN66zB+Afko=\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB\n" + "qTELMAkGA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ANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU\n" + "DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz\n" + "YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX\n" + "xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2\n" + "/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/\n" + "LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7\n" + "jVaMaA==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G2\n" + "-----BEGIN CERTIFICATE-----\n" + "MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL\n" + "MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp\n" + "IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi\n" + "BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw\n" + "MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh\n" + "d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig\n" + "YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v\n" + "dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/\n" + "BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6\n" + "papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E\n" + "BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K\n" + "DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3\n" + "KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox\n" + "XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==\n" + "-----END CERTIFICATE-----\n" + "\n"; + cert += + "# thawte Primary Root CA - G3\n" + "-----BEGIN CERTIFICATE-----\n" + "MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCB\n" + "rjELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf\n" + "Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw\n" + "MDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNV\n" + "BAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0wODA0MDIwMDAwMDBa\n" + "Fw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhhd3Rl\n" + "LCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9u\n" + "MTgwNgYDVQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXpl\n" + "ZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEcz\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr8nLPvb2FvdeHsbnndm\n" + "gcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2AtP0LMqmsywCPLLEHd5N/8\n" + "YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC+BsUa0Lf\n" + "b1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS9\n" + "9irY7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2S\n" + "zhkGcuYMXDhpxwTWvGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUk\n" + "OQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" + "HQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJKoZIhvcNAQELBQADggEBABpA\n" + "2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweKA3rD6z8KLFIW\n" + "oCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu\n" + "t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7c\n" + "KUGRIjxpp7sC8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fM\n" + "m7v/OeZWYdMKp8RcTGB7BXcmer/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZu\n" + "MdRAGmI0Nj81Aa6sY6A=\n" + "-----END CERTIFICATE-----"; + + ctx.add_certificate_authority( + boost::asio::buffer(cert.data(), cert.size()), ec); + if(ec) + return; +} + +} // detail + +// Load the root certificates into an ssl::context + +inline +void +load_root_certificates(ssl::context& ctx, boost::system::error_code& ec) +{ + detail::load_root_certificates(ctx, ec); +} + +inline +void +load_root_certificates(ssl::context& ctx) +{ + boost::system::error_code ec; + detail::load_root_certificates(ctx, ec); + if(ec) + throw boost::system::system_error{ec}; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/common/server_certificate.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/common/server_certificate.hpp new file mode 100644 index 0000000..bf47661 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/common/server_certificate.hpp @@ -0,0 +1,125 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP +#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP + +#include +#include +#include +#include + +/* Load a signed certificate into the ssl context, and configure + the context for use with a server. + + For this to work with the browser or operating system, it is + necessary to import the "Beast Test CA" certificate into + the local certificate store, browser, or operating system + depending on your environment Please see the documentation + accompanying the Beast certificate for more details. +*/ +inline +void +load_server_certificate(boost::asio::ssl::context& ctx) +{ + /* + The certificate was generated from bash on Ubuntu (OpenSSL 1.1.1f) using: + + openssl dhparam -out dh.pem 2048 + openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj "/C=US/ST=CA/L=Los Angeles/O=Beast/CN=www.example.com" + */ + + std::string const cert = + "-----BEGIN CERTIFICATE-----\n" + "MIIDlTCCAn2gAwIBAgIUOLxr3q7Wd/pto1+2MsW4fdRheCIwDQYJKoZIhvcNAQEL\n" + "BQAwWjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRQwEgYDVQQHDAtMb3MgQW5n\n" + "ZWxlczEOMAwGA1UECgwFQmVhc3QxGDAWBgNVBAMMD3d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" + "qhvwIOmAObCzcoKkz3sChbk4ToUTqbC0TmFAXI5Upz1wnADzjpbJrpegCA3pmvhT\n" + "7356drqnCGY9\n" + "-----END CERTIFICATE-----\n"; + + std::string const key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz0GwgnxSBhygx\n" + "BdhTHGx5LDLIJSuIDJ6nMwZFvAjdhLnB/vOTLppr5MKxqQHEpYdyDYGD1noBoz4T\n" + "iIRj5JapChMgx58NLq5QyXkHV/ONT7yi8x05P41c2F9pBEnUwUxIUG1Cb6AN0cZW\n" + "F/wSMOZ0w3DoBhnl1sdQfQiS25MTK6x4tATmWm9SJc2lsjWptbyIN6hFXLYPXTwn\n" + "YzCLvv1EK6Ft7tMPc/FcJpd/wYHgl8shDmY7rV+AiGTxUU35V0AzpJlmvct5aJV/\n" + "5vSRRLwT9qLZSddE9zy/0rovC5GML6S7BUC4lIzJ8yxzOzSStBPxvdrOobSSNlRZ\n" + "IlE7gnyNAgMBAAECggEAY0RorQmldGx9D7M+XYOPjsWLs1px0cXFwGA20kCgVEp1\n" + "kleBeHt93JqJsTKwOzN2tswl9/ZrnIPWPUpcbBlB40ggjzQk5k4jBY50Nk2jsxuV\n" + "9A9qzrP7AoqhAYTQjZe42SMtbkPZhEeOyvCqxBAi6csLhcv4eB4+In0kQo7dfvLs\n" + "Xu/3WhSsuAWqdD9EGnhD3n+hVTtgiasRe9318/3R9DzP+IokoQGOtXm+1dsfP0mV\n" + "8XGzQHBpUtJNn0yi6SC4kGEQuKkX33zORlSnZgT5VBLofNgra0THd7x3atOx1lbr\n" + "V0QizvCdBa6j6FwhOQwW8UwgOCnUbWXl/Xn4OaofMQKBgQDdRXSMyys7qUMe4SYM\n" + "Mdawj+rjv0Hg98/xORuXKEISh2snJGKEwV7L0vCn468n+sM19z62Axz+lvOUH8Qr\n" + "hLkBNqJvtIP+b0ljRjem78K4a4qIqUlpejpRLw6a/+44L76pMJXrYg3zdBfwzfwu\n" + "b9NXdwHzWoNuj4v36teGP6xOUwKBgQDQCT52XX96NseNC6HeK5BgWYYjjxmhksHi\n" + "stjzPJKySWXZqJpHfXI8qpOd0Sd1FHB+q1s3hand9c+Rxs762OXlqA9Q4i+4qEYZ\n" + "qhyRkTsl+2BhgzxmoqGd5gsVT7KV8XqtuHWLmetNEi+7+mGSFf2iNFnonKlvT1JX\n" + "4OQZC7ntnwKBgH/ORFmmaFxXkfteFLnqd5UYK5ZMvGKTALrWP4d5q2BEc7HyJC2F\n" + "+5lDR9nRezRedS7QlppPBgpPanXeO1LfoHSA+CYJYEwwP3Vl83Mq/Y/EHgp9rXeN\n" + "L+4AfjEtLo2pljjnZVDGHETIg6OFdunjkXDtvmSvnUbZBwG11bMnSAEdAoGBAKFw\n" + "qwJb6FNFM3JnNoQctnuuvYPWxwM1yjRMqkOIHCczAlD4oFEeLoqZrNhpuP8Ij4wd\n" + "GjpqBbpzyVLNP043B6FC3C/edz4Lh+resjDczVPaUZ8aosLbLiREoxE0udfWf2dU\n" + "oBNnrMwwcs6jrRga7Kr1iVgUSwBQRAxiP2CYUv7tAoGBAKdPdekPNP/rCnHkKIkj\n" + "o13pr+LJ8t+15vVzZNHwPHUWiYXFhG8Ivx7rqLQSPGcuPhNss3bg1RJiZAUvF6fd\n" + "e6QS4EZM9dhhlO2FmPQCJMrRVDXaV+9TcJZXCbclQnzzBus9pwZZyw4Anxo0vmir\n" + "nOMOU6XI4lO9Xge/QDEN4Y2R\n" + "-----END PRIVATE KEY-----\n"; + + std::string const dh = + "-----BEGIN DH PARAMETERS-----\n" + "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" + "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" + "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" + "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" + "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" + "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" + "-----END DH PARAMETERS-----\n"; + + ctx.set_password_callback( + [](std::size_t, + boost::asio::ssl::context_base::password_purpose) + { + return "test"; + }); + + ctx.set_options( + boost::asio::ssl::context::default_workarounds | + boost::asio::ssl::context::no_sslv2 | + boost::asio::ssl::context::single_dh_use); + + ctx.use_certificate_chain( + boost::asio::buffer(cert.data(), cert.size())); + + ctx.use_private_key( + boost::asio::buffer(key.data(), key.size()), + boost::asio::ssl::context::file_format::pem); + + ctx.use_tmp_dh( + boost::asio::buffer(dh.data(), dh.size())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/CMakeLists.txt new file mode 100644 index 0000000..9704d31 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +if (OPENSSL_FOUND) + add_subdirectory(ssl) +endif () diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/Jamfile new file mode 100644 index 0000000..0493a4e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/Jamfile @@ -0,0 +1,10 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project ssl ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/http_examples.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/http_examples.hpp new file mode 100644 index 0000000..dac3e24 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/http_examples.hpp @@ -0,0 +1,1077 @@ +// +// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include + +/* This file contains the functions and classes found in the documentation + + They are compiled and run as part of the unit tests, so you can copy + the code and use it in your own projects as a starting point for + building a network application. +*/ + +// The documentation assumes the boost::beast::http namespace +namespace boost { +namespace beast { +namespace http { + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_http_send_expect_100_continue + +/** Send a request with Expect: 100-continue + + This function will send a request with the Expect: 100-continue + field by first sending the header, then waiting for a successful + response from the server before continuing to send the body. If + a non-successful server response is received, the function + returns immediately. + + @param stream The remote HTTP server stream. + + @param buffer The buffer used for reading. + + @param req The request to send. This function modifies the object: + the Expect header field is inserted into the message if it does + not already exist, and set to "100-continue". + + @param ec Set to the error, if any occurred. +*/ +template< + class SyncStream, + class DynamicBuffer, + class Body, class Allocator> +void +send_expect_100_continue( + SyncStream& stream, + DynamicBuffer& buffer, + request>& req, + error_code& ec) +{ + static_assert(is_sync_stream::value, + "SyncStream requirements not met"); + + static_assert( + boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Insert or replace the Expect field + req.set(field::expect, "100-continue"); + + // Create the serializer + request_serializer> sr{req}; + + // Send just the header + write_header(stream, sr, ec); + if(ec) + return; + + // Read the response from the server. + // A robust client could set a timeout here. + { + response res; + read(stream, buffer, res, ec); + if(ec) + return; + if(res.result() != status::continue_) + { + // The server indicated that it will not + // accept the request, so skip sending the body. + return; + } + } + + // Server is OK with the request, send the body + write(stream, sr, ec); +} + +//] + +//[example_http_receive_expect_100_continue + +/** Receive a request, handling Expect: 100-continue if present. + + This function will read a request from the specified stream. + If the request contains the Expect: 100-continue field, a + status response will be delivered. + + @param stream The remote HTTP client stream. + + @param buffer The buffer used for reading. + + @param ec Set to the error, if any occurred. +*/ +template< + class SyncStream, + class DynamicBuffer> +void +receive_expect_100_continue( + SyncStream& stream, + DynamicBuffer& buffer, + error_code& ec) +{ + static_assert(is_sync_stream::value, + "SyncStream requirements not met"); + + static_assert( + boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // Declare a parser for a request with a string body + request_parser parser; + + // Read the header + read_header(stream, buffer, parser, ec); + if(ec) + return; + + // Check for the Expect field value + if(beast::iequals(parser.get()[field::expect], "100-continue")) + { + // send 100 response + response res; + res.version(11); + res.result(status::continue_); + res.set(field::server, "test"); + write(stream, res, ec); + if(ec) + return; + } + + // Read the rest of the message. + // + read(stream, buffer, parser, ec); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Send Child Process Output +// +//------------------------------------------------------------------------------ + +//[example_http_send_cgi_response + +/** Send the output of a child process as an HTTP response. + + The output of the child process comes from a @b SyncReadStream. Data + will be sent continuously as it is produced, without the requirement + that the entire process output is buffered before being sent. The + response will use the chunked transfer encoding. + + @param input A stream to read the child process output from. + + @param output A stream to write the HTTP response to. + + @param ec Set to the error, if any occurred. +*/ +template< + class SyncReadStream, + class SyncWriteStream> +void +send_cgi_response( + SyncReadStream& input, + SyncWriteStream& output, + error_code& ec) +{ + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + // Set up the response. We use the buffer_body type, + // allowing serialization to use manually provided buffers. + response res; + + res.result(status::ok); + res.version(11); + res.set(field::server, "Beast"); + res.set(field::transfer_encoding, "chunked"); + + // No data yet, but we set more = true to indicate + // that it might be coming later. Otherwise the + // serializer::is_done would return true right after + // sending the header. + res.body().data = nullptr; + res.body().more = true; + + // Create the serializer. + response_serializer sr{res}; + + // Send the header immediately. + write_header(output, sr, ec); + if(ec) + return; + + // Alternate between reading from the child process + // and sending all the process output until there + // is no more output. + do + { + // Read a buffer from the child process + char buffer[2048]; + auto bytes_transferred = input.read_some( + boost::asio::buffer(buffer, sizeof(buffer)), ec); + if(ec == boost::asio::error::eof) + { + ec = {}; + + // `nullptr` indicates there is no buffer + res.body().data = nullptr; + + // `false` means no more data is coming + res.body().more = false; + } + else + { + if(ec) + return; + + // Point to our buffer with the bytes that + // we received, and indicate that there may + // be some more data coming + res.body().data = buffer; + res.body().size = bytes_transferred; + res.body().more = true; + } + + // Write everything in the body buffer + write(output, sr, ec); + + // This error is returned by body_buffer during + // serialization when it is done sending the data + // provided and needs another buffer. + if(ec == error::need_buffer) + { + ec = {}; + continue; + } + if(ec) + return; + } + while(! sr.is_done()); +} + +//] + +//-------------------------------------------------------------------------- +// +// Example: HEAD Request +// +//-------------------------------------------------------------------------- + +//[example_http_do_head_response + +/** Handle a HEAD request for a resource. +*/ +template< + class SyncStream, + class DynamicBuffer +> +void do_server_head( + SyncStream& stream, + DynamicBuffer& buffer, + error_code& ec) +{ + static_assert(is_sync_stream::value, + "SyncStream requirements not met"); + static_assert( + boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // We deliver this payload for all GET requests + static std::string const payload = "Hello, world!"; + + // Read the request + request req; + read(stream, buffer, req, ec); + if(ec) + return; + + // Set up the response, starting with the common fields + response res; + res.version(11); + res.set(field::server, "test"); + + // Now handle request-specific fields + switch(req.method()) + { + case verb::head: + case verb::get: + { + // A HEAD request is handled by delivering the same + // set of headers that would be sent for a GET request, + // including the Content-Length, except for the body. + res.result(status::ok); + res.content_length(payload.size()); + + // For GET requests, we include the body + if(req.method() == verb::get) + { + // We deliver the same payload for GET requests + // regardless of the target. A real server might + // deliver a file based on the target. + res.body() = payload; + } + break; + } + + default: + { + // We return responses indicating an error if + // we do not recognize the request method. + res.result(status::bad_request); + res.set(field::content_type, "text/plain"); + res.body() = "Invalid request-method '" + std::string(req.method_string()) + "'"; + res.prepare_payload(); + break; + } + } + + // Send the response + write(stream, res, ec); + if(ec) + return; +} + +//] + +//[example_http_do_head_request + +/** Send a HEAD request for a resource. + + This function submits a HEAD request for the specified resource + and returns the response. + + @param res The response. This is an output parameter. + + @param stream The synchronous stream to use. + + @param buffer The buffer to use. + + @param target The request target. + + @param ec Set to the error, if any occurred. + + @throws std::invalid_argument if target is empty. +*/ +template< + class SyncStream, + class DynamicBuffer +> +response +do_head_request( + SyncStream& stream, + DynamicBuffer& buffer, + string_view target, + error_code& ec) +{ + // Do some type checking to be a good citizen + static_assert(is_sync_stream::value, + "SyncStream requirements not met"); + static_assert( + boost::asio::is_dynamic_buffer::value, + "DynamicBuffer requirements not met"); + + // The interfaces we are using are low level and do not + // perform any checking of arguments; so we do it here. + if(target.empty()) + throw std::invalid_argument("target may not be empty"); + + // Build the HEAD request for the target + request req; + req.version(11); + req.method(verb::head); + req.target(target); + req.set(field::user_agent, "test"); + + // A client MUST send a Host header field in all HTTP/1.1 request messages. + // https://tools.ietf.org/html/rfc7230#section-5.4 + req.set(field::host, "localhost"); + + // Now send it + write(stream, req, ec); + if(ec) + return {}; + + // Create a parser to read the response. + // We use the `empty_body` type since + // a response to a HEAD request MUST NOT + // include a body. + response_parser p; + + // Inform the parser that there will be no body. + p.skip(true); + + // Read the message. Even though fields like + // Content-Length or Transfer-Encoding may be + // set, the message will not contain a body. + read(stream, buffer, p, ec); + if(ec) + return {}; + + // Transfer ownership of the response to the caller. + return p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: HTTP Relay +// +//------------------------------------------------------------------------------ + +//[example_http_relay + +/** Relay an HTTP message. + + This function efficiently relays an HTTP message from a downstream + client to an upstream server, or from an upstream server to a + downstream client. After the message header is read from the input, + a user provided transformation function is invoked which may change + the contents of the header before forwarding to the output. This may + be used to adjust fields such as Server, or proxy fields. + + @param output The stream to write to. + + @param input The stream to read from. + + @param buffer The buffer to use for the input. + + @param transform The header transformation to apply. The function will + be called with this signature: + @code + template + void transform(message< + isRequest, Body, Fields>&, // The message to transform + error_code&); // Set to the error, if any + @endcode + + @param ec Set to the error if any occurred. + + @tparam isRequest `true` to relay a request. + + @tparam Fields The type of fields to use for the message. +*/ +template< + bool isRequest, + class SyncWriteStream, + class SyncReadStream, + class DynamicBuffer, + class Transform> +void +relay( + SyncWriteStream& output, + SyncReadStream& input, + DynamicBuffer& buffer, + error_code& ec, + Transform&& transform) +{ + static_assert(is_sync_write_stream::value, + "SyncWriteStream requirements not met"); + + static_assert(is_sync_read_stream::value, + "SyncReadStream requirements not met"); + + // A small buffer for relaying the body piece by piece + char buf[2048]; + + // Create a parser with a buffer body to read from the input. + parser p; + + // Create a serializer from the message contained in the parser. + serializer sr{p.get()}; + + // Read just the header from the input + read_header(input, buffer, p, ec); + if(ec) + return; + + // Apply the caller's header transformation + transform(p.get(), ec); + if(ec) + return; + + // Send the transformed message to the output + write_header(output, sr, ec); + if(ec) + return; + + // Loop over the input and transfer it to the output + do + { + if(! p.is_done()) + { + // Set up the body for writing into our small buffer + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + + // Read as much as we can + read(input, buffer, p, ec); + + // This error is returned when buffer_body uses up the buffer + if(ec == error::need_buffer) + ec = {}; + if(ec) + return; + + // Set up the body for reading. + // This is how much was parsed: + p.get().body().size = sizeof(buf) - p.get().body().size; + p.get().body().data = buf; + p.get().body().more = ! p.is_done(); + } + else + { + p.get().body().data = nullptr; + p.get().body().size = 0; + } + + // Write everything in the buffer (which might be empty) + write(output, sr, ec); + + // This error is returned when buffer_body uses up the buffer + if(ec == error::need_buffer) + ec = {}; + if(ec) + return; + } + while(! p.is_done() && ! sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Serialize to std::ostream +// +//------------------------------------------------------------------------------ + +//[example_http_write_ostream + +// The detail namespace means "not public" +namespace detail { + +// This helper is needed for C++11. +// When invoked with a buffer sequence, writes the buffers `to the std::ostream`. +template +class write_ostream_helper +{ + Serializer& sr_; + std::ostream& os_; + +public: + write_ostream_helper(Serializer& sr, std::ostream& os) + : sr_(sr) + , os_(os) + { + } + + // This function is called by the serializer + template + void + operator()(error_code& ec, ConstBufferSequence const& buffers) const + { + // Error codes must be cleared on success + ec = {}; + + // Keep a running total of how much we wrote + std::size_t bytes_transferred = 0; + + // Loop over the buffer sequence + for(auto it = boost::asio::buffer_sequence_begin(buffers); + it != boost::asio::buffer_sequence_end(buffers); ++it) + { + // This is the next buffer in the sequence + boost::asio::const_buffer const buffer = *it; + + // Write it to the std::ostream + os_.write( + reinterpret_cast(buffer.data()), + buffer.size()); + + // If the std::ostream fails, convert it to an error code + if(os_.fail()) + { + ec = make_error_code(errc::io_error); + return; + } + + // Adjust our running total + bytes_transferred += buffer_size(buffer); + } + + // Inform the serializer of the amount we consumed + sr_.consume(bytes_transferred); + } +}; + +} // detail + +/** Write a message to a `std::ostream`. + + This function writes the serialized representation of the + HTTP/1 message to the sream. + + @param os The `std::ostream` to write to. + + @param msg The message to serialize. + + @param ec Set to the error, if any occurred. +*/ +template< + bool isRequest, + class Body, + class Fields> +void +write_ostream( + std::ostream& os, + message& msg, + error_code& ec) +{ + // Create the serializer instance + serializer sr{msg}; + + // This lambda is used as the "visit" function + detail::write_ostream_helper lambda{sr, os}; + do + { + // In C++14 we could use a generic lambda but since we want + // to require only C++11, the lambda is written out by hand. + // This function call retrieves the next serialized buffers. + sr.next(ec, lambda); + if(ec) + return; + } + while(! sr.is_done()); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Parse from std::istream +// +//------------------------------------------------------------------------------ + +//[example_http_read_istream + +/** Read a message from a `std::istream`. + + This function attempts to parse a complete HTTP/1 message from the stream. + + @param is The `std::istream` to read from. + + @param buffer The buffer to use. + + @param msg The message to store the result. + + @param ec Set to the error, if any occurred. +*/ +template< + class Allocator, + bool isRequest, + class Body> +void +read_istream( + std::istream& is, + basic_flat_buffer& buffer, + message& msg, + error_code& ec) +{ + // Create the message parser + // + // Arguments passed to the parser's constructor are + // forwarded to the message constructor. Here, we use + // a move construction in case the caller has constructed + // their message in a non-default way. + // + parser p{std::move(msg)}; + + do + { + // Extract whatever characters are presently available in the istream + if(is.rdbuf()->in_avail() > 0) + { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare( + static_cast(is.rdbuf()->in_avail())); + + // Now get everything we can from the istream + buffer.commit(static_cast(is.readsome( + reinterpret_cast(b.data()), b.size()))); + } + else if(buffer.size() == 0) + { + // Our buffer is empty and we need more characters, + // see if we've reached the end of file on the istream + if(! is.eof()) + { + // Get a mutable buffer sequence for writing + auto const b = buffer.prepare(1024); + + // Try to get more from the istream. This might block. + is.read(reinterpret_cast(b.data()), b.size()); + + // If an error occurs on the istream then return it to the caller. + if(is.fail() && ! is.eof()) + { + // We'll just re-use io_error since std::istream has no error_code interface. + ec = make_error_code(errc::io_error); + return; + } + + // Commit the characters we got to the buffer. + buffer.commit(static_cast(is.gcount())); + } + else + { + // Inform the parser that we've reached the end of the istream. + p.put_eof(ec); + if(ec) + return; + break; + } + } + + // Write the data to the parser + auto const bytes_used = p.put(buffer.data(), ec); + + // This error means that the parser needs additional octets. + if(ec == error::need_more) + ec = {}; + if(ec) + return; + + // Consume the buffer octets that were actually parsed. + buffer.consume(bytes_used); + } + while(! p.is_done()); + + // Transfer ownership of the message container in the parser to the caller. + msg = p.release(); +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Deferred Body Type +// +//------------------------------------------------------------------------------ + +//[example_http_defer_body + +/** Handle a form POST request, choosing a body type depending on the Content-Type. + + This reads a request from the input stream. If the method is POST, and + the Content-Type is "application/x-www-form-urlencoded " or + "multipart/form-data", a `string_body` is used to receive and store + the message body. Otherwise, a `dynamic_body` is used to store the message + body. After the request is received, the handler will be invoked with the + request. + + @param stream The stream to read from. + + @param buffer The buffer to use for reading. + + @param handler The handler to invoke when the request is complete. + The handler must be invokable with this signature: + @code + template + void handler(request&& req); + @endcode + + @throws system_error Thrown on failure. +*/ +template< + class SyncReadStream, + class DynamicBuffer, + class Handler> +void +do_form_request( + SyncReadStream& stream, + DynamicBuffer& buffer, + Handler&& handler) +{ + // Start with an empty_body parser + request_parser req0; + + // Read just the header. Otherwise, the empty_body + // would generate an error if body octets were received. + read_header(stream, buffer, req0); + + // Choose a body depending on the method verb + switch(req0.get().method()) + { + case verb::post: + { + // If this is not a form upload then use a string_body + if( req0.get()[field::content_type] != "application/x-www-form-urlencoded" && + req0.get()[field::content_type] != "multipart/form-data") + goto do_dynamic_body; + + // Commit to string_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + + do_dynamic_body: + default: + { + // Commit to dynamic_body as the body type. + // As long as there are no body octets in the parser + // we are constructing from, no exception is thrown. + request_parser req{std::move(req0)}; + + // Finish reading the message + read(stream, buffer, req); + + // Call the handler. It can take ownership + // if desired, since we are calling release() + handler(req.release()); + break; + } + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Incremental Read +// +//------------------------------------------------------------------------------ + +//[example_incremental_read + +/* This function reads a message using a fixed size buffer to hold + portions of the body, and prints the body contents to a `std::ostream`. +*/ +template< + bool isRequest, + class SyncReadStream, + class DynamicBuffer> +void +read_and_print_body( + std::ostream& os, + SyncReadStream& stream, + DynamicBuffer& buffer, + error_code& ec) +{ + parser p; + read_header(stream, buffer, p, ec); + if(ec) + return; + while(! p.is_done()) + { + char buf[512]; + p.get().body().data = buf; + p.get().body().size = sizeof(buf); + read(stream, buffer, p, ec); + if(ec == error::need_buffer) + ec = {}; + if(ec) + return; + os.write(buf, sizeof(buf) - p.get().body().size); + } +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Read large response body +// +//------------------------------------------------------------------------------ + +//[example_read_large_response_body + +/* This function uses custom size limit of the resposne body. + The key method is 'body_limit' of the parser. + body_limit is expressed in bytes. +*/ +template< + class SyncReadStream, + class DynamicBuffer, + bool isRequest, class Body, class Allocator> +std::size_t +read_large_response_body( + SyncReadStream& stream, + DynamicBuffer& buffer, + message>& msg, + std::size_t body_limit, + error_code& ec) +{ + parser p(std::move(msg)); + p.eager(true); + p.body_limit(body_limit); + auto const bytes_transferred = + http::read(stream, buffer, p, ec); + if(ec) + return bytes_transferred; + msg = p.release(); + return bytes_transferred; +} + +//] + +//------------------------------------------------------------------------------ +// +// Example: Expect 100-continue +// +//------------------------------------------------------------------------------ + +//[example_chunk_parsing + +/** Read a message with a chunked body and print the chunks and extensions +*/ +template< + bool isRequest, + class SyncReadStream, + class DynamicBuffer> +void +print_chunked_body( + std::ostream& os, + SyncReadStream& stream, + DynamicBuffer& buffer, + error_code& ec) +{ + // Declare the parser with an empty body since + // we plan on capturing the chunks ourselves. + parser p; + + // First read the complete header + read_header(stream, buffer, p, ec); + if(ec) + return; + + // This container will hold the extensions for each chunk + chunk_extensions ce; + + // This string will hold the body of each chunk + std::string chunk; + + // Declare our chunk header callback This is invoked + // after each chunk header and also after the last chunk. + auto header_cb = + [&](std::uint64_t size, // Size of the chunk, or zero for the last chunk + string_view extensions, // The raw chunk-extensions string. Already validated. + error_code& ev) // We can set this to indicate an error + { + // Parse the chunk extensions so we can access them easily + ce.parse(extensions, ev); + if(ev) + return; + + // See if the chunk is too big + if(size > (std::numeric_limits::max)()) + { + ev = error::body_limit; + return; + } + + // Make sure we have enough storage, and + // reset the container for the upcoming chunk + chunk.reserve(static_cast(size)); + chunk.clear(); + }; + + // Set the callback. The function requires a non-const reference so we + // use a local variable, since temporaries can only bind to const refs. + p.on_chunk_header(header_cb); + + // Declare the chunk body callback. This is called one or + // more times for each piece of a chunk body. + auto body_cb = + [&](std::uint64_t remain, // The number of bytes left in this chunk + string_view body, // A buffer holding chunk body data + error_code& ec) // We can set this to indicate an error + { + // If this is the last piece of the chunk body, + // set the error so that the call to `read` returns + // and we can process the chunk. + if(remain == body.size()) + ec = error::end_of_chunk; + + // Append this piece to our container + chunk.append(body.data(), body.size()); + + // The return value informs the parser of how much of the body we + // consumed. We will indicate that we consumed everything passed in. + return body.size(); + }; + p.on_chunk_body(body_cb); + + while(! p.is_done()) + { + // Read as much as we can. When we reach the end of the chunk, the chunk + // body callback will make the read return with the end_of_chunk error. + read(stream, buffer, p, ec); + if(! ec) + continue; + else if(ec != error::end_of_chunk) + return; + else + ec = {}; + + // We got a whole chunk, print the extensions: + for(auto const& extension : ce) + { + os << "Extension: " << extension.first; + if(! extension.second.empty()) + os << " = " << extension.second << std::endl; + else + os << std::endl; + } + + // Now print the chunk body + os << "Chunk Body: " << chunk << std::endl; + } + + // Get a reference to the parsed message, this is for convenience + auto const& msg = p.get(); + + // Check each field promised in the "Trailer" header and output it + for(auto const& name : token_list{msg[field::trailer]}) + { + // Find the trailer field + auto it = msg.find(name); + if(it == msg.end()) + { + // Oops! They promised the field but failed to deliver it + os << "Missing Trailer: " << name << std::endl; + continue; + } + os << it->name() << ": " << it->value() << std::endl; + } +} + +//] + +} // http +} // beast +} // boost diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/CMakeLists.txt new file mode 100644 index 0000000..fb1a03f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/CMakeLists.txt @@ -0,0 +1,44 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +# Client +add_executable(doc-ssl-client + Jamfile + client.cpp) + +source_group("" FILES + Jamfile + client.cpp) + +target_include_directories(doc-ssl-client + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(doc-ssl-client + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(doc-ssl-client + PROPERTIES FOLDER "example-doc-ssl") + +# Server +add_executable(doc-ssl-server + Jamfile + server.cpp) + +source_group("" FILES + Jamfile + server.cpp) + +target_include_directories(doc-ssl-server + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(doc-ssl-server + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(doc-ssl-server + PROPERTIES FOLDER "example-doc-ssl") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/Jamfile new file mode 100644 index 0000000..426ad69 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/Jamfile @@ -0,0 +1,20 @@ +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe doc-ssl-client : + client.cpp + : + coverage:no + ubasan:no + ; + +exe doc-ssl-server : + server.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/client.cpp new file mode 100644 index 0000000..9580486 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/client.cpp @@ -0,0 +1,137 @@ +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include + +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +void +print_exception(std::exception_ptr eptr) +{ + if(eptr) + { + try + { + std::rethrow_exception(eptr); + } + catch(std::exception& e) + { + std::cerr << e.what() << std::endl; + } + } +} + +net::awaitable +request(ssl::context& ctx) +{ + auto executor = co_await net::this_coro::executor; + net::ip::tcp::endpoint endpoint{ {}, 8080 }; + ssl::stream stream{ executor, ctx }; + + // Connect TCP socket + co_await stream.lowest_layer().async_connect(endpoint); + + // Set Server Name Indication (SNI) + if(!SSL_set_tlsext_host_name(stream.native_handle(), "localhost")) + { + throw beast::system_error( + static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set a callback to verify that the hostname in the server + // certificate matches the expected value + stream.set_verify_callback(ssl::host_name_verification("localhost")); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Write an HTTP GET request + http::request req{ http::verb::get, "/", 11 }; + req.set(http::field::host, "localhost"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + co_await http::async_write(stream, req); + + // Read the response + beast::flat_buffer buf; + http::response res; + co_await http::async_read(stream, buf, res); + + // Print the response body + std::cout << res.body(); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if(ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error(ec); +} + +int +main() +{ + try + { + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ ssl::context::sslv23 }; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options( + ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // set up the peer verification mode so that the TLS/SSL handshake fails + // if the certificate verification is unsuccessful + ctx.set_verify_mode(ssl::verify_peer); + + // The servers's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Client certificate and private key (if server request for). + ctx.use_certificate_chain_file("client.crt"); + ctx.use_private_key_file("client.key", ssl::context::pem); + + net::co_spawn(ioc, request(ctx), print_exception); + + ioc.run(); + } + catch(std::exception& e) + { + std::cerr << e.what() << std::endl; + } +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/server.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/server.cpp new file mode 100644 index 0000000..d9e1195 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/doc/ssl/server.cpp @@ -0,0 +1,133 @@ +// +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include + +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = net::ssl; + +void +print_exception(std::exception_ptr eptr) +{ + if(eptr) + { + try + { + std::rethrow_exception(eptr); + } + catch(std::exception& e) + { + std::cerr << e.what() << std::endl; + } + } +} + +net::awaitable +handle_session(ssl::stream stream) +{ + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::server); + + // Read and discard a request + beast::flat_buffer buf; + http::request req; + co_await http::async_read(stream, buf, req); + + // Write the response + http::response res; + res.body() = "Hello!"; + co_await http::async_write(stream, res); + + // Gracefully shutdown the SSL stream + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + if(ec && ec != ssl::error::stream_truncated) + throw boost::system::system_error(ec); +} + +net::awaitable +acceptor(ssl::context& ctx) +{ + auto executor = co_await net::this_coro::executor; + net::ip::tcp::endpoint endpoint{ {}, 8080 }; + net::ip::tcp::acceptor acceptor{ executor, endpoint }; + + for(;;) + { + net::co_spawn( + executor, + handle_session({ co_await acceptor.async_accept(), ctx }), + print_exception); + } +} + +int +main() +{ + try + { + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates, + // configurations and session related data + ssl::context ctx{ ssl::context::sslv23 }; + + // https://docs.openssl.org/3.4/man3/SSL_CTX_set_options/ + ctx.set_options( + ssl::context::no_sslv2 | ssl::context::default_workarounds | + ssl::context::single_dh_use); + + // Comment this line to disable client certificate request. + ctx.set_verify_mode( + ssl::verify_peer | ssl::verify_fail_if_no_peer_cert); + + // The client's certificate will be verified against this + // certificate authority. + ctx.load_verify_file("ca.crt"); + + // In a real application, the passphrase would be read from + // a secure place, such as a key vault. + ctx.set_password_callback([](auto, auto) { return "123456"; }); + + // Server certificate and private key. + ctx.use_certificate_chain_file("server.crt"); + ctx.use_private_key_file("server.key", ssl::context::pem); + + // DH parameters for DHE-based cipher suites + ctx.use_tmp_dh_file("dh4096.pem"); + + net::co_spawn(ioc, acceptor(ctx), print_exception); + + ioc.run(); + } + catch(std::exception& e) + { + std::cerr << e.what() << std::endl; + } +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/CMakeLists.txt new file mode 100644 index 0000000..7bece94 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(echo-op + Jamfile + echo_op.cpp) + +source_group("" FILES + Jamfile + echo_op.cpp) + +target_link_libraries(echo-op PRIVATE Boost::beast) + +set_target_properties(echo-op + PROPERTIES FOLDER "example-echo-op") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/Jamfile new file mode 100644 index 0000000..caeb767 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe echo-op : + echo_op.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/echo_op.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/echo_op.cpp new file mode 100644 index 0000000..96be659 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/echo-op/echo_op.cpp @@ -0,0 +1,377 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include +#include +#include +#include +#include +#include + +namespace net = boost::asio; +namespace beast = boost::beast; + +//[example_core_echo_op_1 + +template< + class AsyncStream, + class DynamicBuffer, + class CompletionToken> +auto +async_echo (AsyncStream& stream, DynamicBuffer& buffer, CompletionToken&& token) + +//] + -> + typename net::async_result< + typename std::decay::type, + void(beast::error_code)>::return_type; + +//------------------------------------------------------------------------------ + +//[example_core_echo_op_2 + +/** Asynchronously read a line and echo it back. + + This function is used to asynchronously read a line ending + in a newline (`"\n"`) from the stream, and then write + it back. + + This call always returns immediately. The asynchronous operation + will continue until one of the following conditions is true: + + @li A line was read in and written back on the stream + + @li An error occurs. + + The algorithm, known as a composed asynchronous operation, + is implemented in terms of calls to the stream's `async_read_some` + and `async_write_some` function. The program must ensure that no + other reads or writes are performed until this operation completes. + + Since the length of the line is not known ahead of time, the + implementation may read additional characters that lie past the + first line. These characters are stored in the dynamic buffer_. + The same dynamic buffer must be presented again in each call, + to provide the implementation with any leftover bytes. + + @param stream The stream to operate on. The type must meet the + requirements of AsyncReadStream and @AsyncWriteStream + + @param buffer A dynamic buffer to hold implementation-defined + temporary data. Ownership is not transferred; the caller is + responsible for ensuring that the lifetime of this object is + extended least until the completion handler is invoked. + + @param token The handler to be called when the operation completes. + The implementation takes ownership of the handler by performing a decay-copy. + The handler must be invocable with this signature: + @code + void handler( + beast::error_code error // Result of operation. + ); + @endcode + + Regardless of whether the asynchronous operation completes immediately or + not, the handler will not be invoked from within this function. Invocation + of the handler will be performed in a manner equivalent to using + `net::post`. +*/ +template< + class AsyncStream, + class DynamicBuffer, + class CompletionToken> +auto +async_echo ( + AsyncStream& stream, + DynamicBuffer& buffer, /*< Unlike Asio, we pass by non-const reference instead of rvalue-ref >*/ + CompletionToken&& token) -> + typename net::async_result< /*< `async_result` deduces the return type from the completion handler >*/ + typename std::decay::type, + void(beast::error_code) /*< The completion handler signature goes here >*/ + >::return_type; +//] + +//[example_core_echo_op_3 + +template +class echo_op; + +// This example uses the Asio's stackless "fauxroutines", implemented +// using a macro-based solution. It makes the code easier to write and +// easier to read. This include file defines the necessary macros and types. +#include + +// Read a line and echo it back +// +template< + class AsyncStream, + class DynamicBuffer, + class CompletionToken> +auto +async_echo( + AsyncStream& stream, + DynamicBuffer& buffer, + CompletionToken&& token) -> + typename net::async_result< + typename std::decay::type, + void(beast::error_code)>::return_type /*< The completion handler signature goes here >*/ +{ + // Perform some type checks using static assert, this helps + // with more friendly error messages when passing the wrong types. + static_assert( + beast::is_async_stream::value, + "AsyncStream type requirements not met"); + static_assert( + net::is_dynamic_buffer::value, + "DynamicBuffer type requirements not met"); + + // This class template deduces the actual handler type from a + // CompletionToken, captures a local reference to the handler, + // and creates the `async_result` object which becomes the + // return value of this initiating function. + + net::async_completion init(token); + + // The helper macro BOOST_ASIO_HANDLER_TYPE converts the completion + // token type into a concrete handler type of the correct signature. + + using handler_type = BOOST_ASIO_HANDLER_TYPE(CompletionToken, void(beast::error_code)); + + // The class template `async_base` holds the caller's completion + // handler for us, and provides all of the boilerplate for forwarding + // the associated allocator and associated executor from the caller's + // handler to our operation. It also maintains a `net::executor_work_guard` + // for the executor associated with the stream. This work guard is + // inexpensive, and prevents the execution context from running out + // of work. It is usually necessary although rarely it can be skipped + // depending on the operation (this echo example needs it because it + // performs more than one asynchronous operation in a row). + // We declare this type alias to make the code easier to read. + + using base_type = beast::async_base< + handler_type, /*< The type of the completion handler obtained from the token >*/ + beast::executor_type /*< The type of executor used by the stream to dispatch asynchronous operations >*/ + >; + + // This nested class implements the echo composed operation as a + // stateful completion handler. We derive from `async_base` to + // take care of boilerplate and we derived from asio::coroutine to + // allow the reenter and yield keywords to work. + + struct echo_op : base_type, boost::asio::coroutine + { + AsyncStream& stream_; + DynamicBuffer& buffer_; + + echo_op( + AsyncStream& stream, + DynamicBuffer& buffer, + handler_type&& handler) + : base_type( + std::move(handler), /*< The `async_base` helper takes ownership of the handler, >*/ + stream.get_executor()) /*< and also needs to know which executor to use. >*/ + , stream_(stream) + , buffer_(buffer) + { + // Launch the operation directly from the constructor. We + // pass `false` for `cont` to indicate that the calling + // thread does not represent a continuation of our + // asynchronous control flow. + (*this)({}, 0, false); + } + + // If a newline is present in the buffer sequence, this function returns + // the number of characters from the beginning of the buffer up to the + // newline, including the newline character. Otherwise it returns zero. + + std::size_t + find_newline(typename DynamicBuffer::const_buffers_type const& buffers) + { + // The `buffers_iterator` class template provides random-access + // iterators into a buffer sequence. Use the standard algorithm + // to look for the new line if it exists. + + auto begin = net::buffers_iterator< + typename DynamicBuffer::const_buffers_type>::begin(buffers); + auto end = net::buffers_iterator< + typename DynamicBuffer::const_buffers_type>::end(buffers); + auto result = std::find(begin, end, '\n'); + + if(result == end) + return 0; // not found + + return result + 1 - begin; + } + + // This is the entry point of our completion handler. Every time an + // asynchronous operation completes, this function will be invoked. + + void + operator()( + beast::error_code ec, + std::size_t bytes_transferred = 0, + bool cont = true) /*< Second and subsequent invocations will seee `cont=true`. */ + { + // The `reenter` keyword transfers control to the last + // yield point, or to the beginning of the scope if + // this is the first time. + + reenter(*this) + { + for(;;) + { + std::size_t pos; + + // Search for a newline in the readable bytes of the buffer + pos = find_newline(buffer_.data()); + + // If we don't have the newline, then read more + if(pos == 0) + { + std::size_t bytes_to_read; + + // Determine the number of bytes to read, + // using available capacity in the buffer first. + + bytes_to_read = std::min( + std::max(512, // under 512 is too little, + buffer_.capacity() - buffer_.size()), + std::min(65536, // and over 65536 is too much. + buffer_.max_size() - buffer_.size())); + + // Read some data into our dynamic buffer_. We transfer + // ownership of the composed operation by using the + // `std::move(*this)` idiom. The `yield` keyword causes + // the function to return immediately after the initiating + // function returns. + + yield stream_.async_read_some( + buffer_.prepare(bytes_to_read), std::move(*this)); + + // After the `async_read_some` completes, control is + // transferred to this line by the `reenter` keyword. + + // Move the bytes read from the writable area to the + // readable area. + + buffer_.commit(bytes_transferred); + + // If an error occurs, deliver it to the caller's completion handler. + if(ec) + break; + + // Keep looping until we get the newline + continue; + } + + // We have our newline, so send the first `pos` bytes of the + // buffers. The function `buffers_prefix` returns the front part + // of the buffers we want. + + yield net::async_write(stream_, + beast::buffers_prefix(pos, buffer_.data()), std::move(*this)); + + // After the `async_write` completes, our completion handler will + // be invoked with the error and the number of bytes transferred, + // and the `reenter` statement above will cause control to jump + // to the following line. The variable `pos` is no longer valid + // (remember that we returned from the function using `yield` above) + // but we can use `bytes_transferred` to know how much of the buffer + // to consume. With "real" coroutines this will be easier and more + // natural. + + buffer_.consume(bytes_transferred); + + // The loop terminates here, and we will either deliver a + // successful result or an error to the caller's completion handler. + + break; + } + + // When a composed operation completes immediately, it must not + // directly invoke the completion handler otherwise it could + // lead to unfairness, starvation, or stack overflow. Therefore, + // if cont == false (meaning, that the call stack still includes + // the frame of the initiating function) then we need to use + // `net::post` to cause us to be called again after the initiating + // function. The function `async_base::invoke` takes care of + // calling the final completion handler, using post if the + // first argument is false, otherwise invoking it directly. + + this->complete(cont, ec); + } + } + }; + + // Create the composed operation and launch it. This is a constructor + // call followed by invocation of operator(). We use BOOST_ASIO_HANDLER_TYPE + // to convert the completion token into the correct handler type, + // allowing user-defined specializations of the async_result template + // to be used. + + echo_op(stream, buffer, std::move(init.completion_handler)); + + // This hook lets the caller see a return value when appropriate. + // For example this might return std::future if + // CompletionToken is net::use_future, or this might + // return an error code if CompletionToken specifies a coroutine. + + return init.result.get(); +} + +// Including this file undefines the macros used by the stackless fauxroutines. +#include + +//] + +struct move_only_handler +{ + move_only_handler() = default; + move_only_handler(move_only_handler&&) = default; + move_only_handler(move_only_handler const&) = delete; + + void operator()(beast::error_code ec) + { + if(ec) + std::cerr << ": " << ec.message() << std::endl; + } +}; + +int main(int argc, char** argv) +{ + if(argc != 3) + { + std::cerr + << "Usage: echo-op
\n" + << "Example:\n" + << " echo-op 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + + namespace net = boost::asio; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + using endpoint_type = net::ip::tcp::endpoint; + + // Create a listening socket, accept a connection, perform + // the echo, and then shut everything down and exit. + net::io_context ioc; + net::ip::tcp::acceptor acceptor{ioc}; + endpoint_type ep(address, port); + acceptor.open(ep.protocol()); + acceptor.set_option(net::socket_base::reuse_address(true)); + acceptor.bind(ep); + acceptor.listen(); + auto sock = acceptor.accept(); + beast::flat_buffer buffer; + async_echo(sock, buffer, move_only_handler{}); + ioc.run(); + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/CMakeLists.txt new file mode 100644 index 0000000..e057d48 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/CMakeLists.txt @@ -0,0 +1,11 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(client) +add_subdirectory(server) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/Jamfile new file mode 100644 index 0000000..32f2c51 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/Jamfile @@ -0,0 +1,11 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project client ; +build-project server ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/CMakeLists.txt new file mode 100644 index 0000000..e55b9a2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(async) +add_subdirectory(async-local) +add_subdirectory(awaitable) +add_subdirectory(body) +add_subdirectory(coro) +add_subdirectory(crawl) +add_subdirectory(methods) +add_subdirectory(sync) + +if (OPENSSL_FOUND) + add_subdirectory(async-ssl) + add_subdirectory(async-ssl-system-executor) + add_subdirectory(awaitable-ssl) + add_subdirectory(coro-ssl) + add_subdirectory(sync-ssl) +endif () diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/Jamfile new file mode 100644 index 0000000..a6aa359 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/Jamfile @@ -0,0 +1,25 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project async ; +build-project async-local ; +build-project coro ; +build-project crawl ; +build-project sync ; +build-project awaitable ; + +# SSL +build-project async-ssl ; +build-project awaitable-ssl ; +build-project coro-ssl ; +build-project sync-ssl ; + +build-project body ; + +build-project methods ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/CMakeLists.txt new file mode 100644 index 0000000..7f8758f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-async-local + Jamfile + http_client_async_local.cpp) + +source_group("" FILES + Jamfile + http_client_async_local.cpp) + +target_link_libraries(http-client-async-local PRIVATE Boost::beast) + +set_target_properties(http-client-async-local + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/Jamfile new file mode 100644 index 0000000..272d857 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-client-async-local : + http_client_async_local.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/http_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/http_client_async_local.cpp new file mode 100644 index 0000000..39e4027 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-local/http_client_async_local.cpp @@ -0,0 +1,187 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using stream_protocol = net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this +{ + beast::basic_stream< + stream_protocol, + net::any_io_executor, + beast::unlimited_rate_policy> stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit + session(net::io_context& ioc) + : stream_(ioc) + { + } + + // Start the asynchronous operation + void + run( + char const* path, + char const* host, + char const* port, + char const* target, + int version) + { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, std::string{host} + ":" + port); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec) + { + if(ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res_ << std::endl; + + // Gracefully close the socket + stream_.socket().shutdown(stream_protocol::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. + if(ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 5 && argc != 6) + { + std::cerr << + "Usage: http-client-async-local []\n" << + "Example:\n" << + " http-client-async-local /tmp/http.sock localhost 80 /\n" << + " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; + auto const host = argv[2]; + auto const port = argv[3]; + auto const target = argv[4]; + int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ +std::cerr << + "Local sockets not available on this platform" << std::endl; +return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/CMakeLists.txt new file mode 100644 index 0000000..ef193a7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-async-ssl-system-executor + Jamfile + http_client_async_ssl_system_executor.cpp) + +source_group("" FILES + Jamfile + http_client_async_ssl_system_executor.cpp) + +target_include_directories(http-client-async-ssl-system-executor + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-client-async-ssl-system-executor + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-client-async-ssl-system-executor + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/Jamfile new file mode 100644 index 0000000..e85767d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-client-async-ssl-system-executor : + http_client_async_ssl_system_executor.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..45e7a7d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp @@ -0,0 +1,258 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this +{ + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand strand, ssl::context& ctx) + : resolver_(strand) + , stream_(strand, ctx) + { + } + +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O object. + explicit + session(ssl::context& ctx) + : session(net::make_strand(net::system_executor()), ctx) + { + } + + // Start the asynchronous operation + void + run( + char const* host, + char const* port, + char const* target, + int version) + { + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) + { + beast::error_code ec{ + static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, + port, + beast::bind_front_handler( + &session::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) + { + if(ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res_ << std::endl; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler( + &session::on_shutdown, + shared_from_this())); + } + + void + on_shutdown(beast::error_code ec) + { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-async-ssl-system-executor []\n" << + "Example:\n" << + " http-client-async-ssl-system-executor www.example.com 443 /\n" << + " http-client-async-ssl-system-executor www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, target, version); + + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/CMakeLists.txt new file mode 100644 index 0000000..0f5cc2b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-async-ssl + Jamfile + http_client_async_ssl.cpp) + +source_group("" FILES + Jamfile + http_client_async_ssl.cpp) + +target_include_directories(http-client-async-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-client-async-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-client-async-ssl + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/Jamfile new file mode 100644 index 0000000..96e85a1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-client-async-ssl : + http_client_async_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/http_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/http_client_async_ssl.cpp new file mode 100644 index 0000000..58c8104 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async-ssl/http_client_async_ssl.cpp @@ -0,0 +1,256 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this +{ + tcp::resolver resolver_; + ssl::stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + explicit + session( + net::any_io_executor ex, + ssl::context& ctx) + : resolver_(ex) + , stream_(ex, ctx) + { + } + + // Start the asynchronous operation + void + run( + char const* host, + char const* port, + char const* target, + int version) + { + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) + { + beast::error_code ec{ + static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream_.set_verify_callback(ssl::host_name_verification(host)); + + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, + port, + beast::bind_front_handler( + &session::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream_).async_connect( + results, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) + { + if(ec) + return fail(ec, "connect"); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::client, + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res_ << std::endl; + + // Set a timeout on the operation + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream_.async_shutdown( + beast::bind_front_handler( + &session::on_shutdown, + shared_from_this())); + } + + void + on_shutdown(beast::error_code ec) + { + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-async-ssl []\n" << + "Example:\n" << + " http-client-async-ssl www.example.com 443 /\n" << + " http-client-async-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + // The session is constructed with a strand to + // ensure that handlers do not execute concurrently. + std::make_shared( + net::make_strand(ioc), + ctx + )->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/CMakeLists.txt new file mode 100644 index 0000000..96b9d3f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-async + Jamfile + http_client_async.cpp) + +source_group("" FILES + Jamfile + http_client_async.cpp) + +target_link_libraries(http-client-async PRIVATE Boost::beast) + +set_target_properties(http-client-async + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/Jamfile new file mode 100644 index 0000000..abc9d4d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-client-async : + http_client_async.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/http_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/http_client_async.cpp new file mode 100644 index 0000000..f451df5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/async/http_client_async.cpp @@ -0,0 +1,189 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +class session : public std::enable_shared_from_this +{ + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + explicit + session(net::io_context& ioc) + : resolver_(net::make_strand(ioc)) + , stream_(net::make_strand(ioc)) + { + } + + // Start the asynchronous operation + void + run( + char const* host, + char const* port, + char const* target, + int version) + { + // Set up an HTTP GET request message + req_.version(version); + req_.method(http::verb::get); + req_.target(target); + req_.set(http::field::host, host); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Look up the domain name + resolver_.async_resolve( + host, + port, + beast::bind_front_handler( + &session::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect( + results, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) + { + if(ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream_, req_, + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Receive the HTTP response + http::async_read(stream_, buffer_, res_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res_ << std::endl; + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes so don't bother reporting it. + if(ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-async []\n" << + "Example:\n" << + " http-client-async www.example.com 80 /\n" << + " http-client-async www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, target, version); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/CMakeLists.txt new file mode 100644 index 0000000..066cdf5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-awaitable-ssl + Jamfile + http_client_awaitable_ssl.cpp) + +source_group("" FILES + Jamfile + http_client_awaitable_ssl.cpp) + +target_include_directories(http-client-awaitable-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-client-awaitable-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-client-awaitable-ssl + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/Jamfile new file mode 100644 index 0000000..d1d9ced --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-client-awaitable-ssl : + http_client_awaitable_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp new file mode 100644 index 0000000..fc2fddb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp @@ -0,0 +1,198 @@ +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "example/common/root_certificates.hpp" + +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; +namespace ssl = boost::asio::ssl; + +//------------------------------------------------------------------------------ + +// Performs an HTTP GET and prints the response +net::awaitable +do_session( + std::string host, + std::string port, + std::string target, + int version, + ssl::context& ctx) +{ + auto executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{ executor }; + auto stream = ssl::stream{ executor, ctx }; + + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) + { + throw beast::system_error( + static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await beast::get_lowest_layer(stream).async_connect(results); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + co_await stream.async_handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{ http::verb::get, target, version }; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << std::endl; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream - do not threat every error as an exception! + auto [ec] = co_await stream.async_shutdown(net::as_tuple); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec && ec != net::ssl::error::stream_truncated) + throw boost::system::system_error(ec, "shutdown"); +} + +//------------------------------------------------------------------------------ + +int +main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr + << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 443 /\n" + << " http-client-awaitable www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + auto const version = + argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ ssl::context::tlsv12_client }; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + net::co_spawn( + ioc, + do_session(host, port, target, version, ctx), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + [](std::exception_ptr e) + { + if(e) + std::rethrow_exception(e); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/CMakeLists.txt new file mode 100644 index 0000000..a5a5a9a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-awaitable + Jamfile + http_client_awaitable.cpp) + +source_group("" FILES + Jamfile + http_client_awaitable.cpp) + +target_link_libraries(http-client-awaitable PRIVATE Boost::beast) + +set_target_properties(http-client-awaitable + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/Jamfile new file mode 100644 index 0000000..7bfc7c1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-client-awaitable : + http_client_awaitable.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/http_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/http_client_awaitable.cpp new file mode 100644 index 0000000..4f0c289 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/awaitable/http_client_awaitable.cpp @@ -0,0 +1,145 @@ +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Performs an HTTP GET and prints the response +net::awaitable +do_session(std::string host, std::string port, std::string target, int version) +{ + auto executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{ executor }; + auto stream = beast::tcp_stream{ executor }; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + co_await stream.async_connect(results); + + // Set up an HTTP GET request message + http::request req{ http::verb::get, target, version }; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + co_await http::async_write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + co_await http::async_read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if(ec && ec != beast::errc::not_connected) + throw boost::system::system_error(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +int +main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << "Usage: http-client-awaitable []\n" + << "Example:\n" + << " http-client-awaitable www.example.com 80 /\n" + << " http-client-awaitable www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + auto const version = + argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn( + ioc, + do_session(host, port, target, version), + // If the awaitable exists with an exception, it gets delivered here + // as `e`. This can happen for regular errors, such as connection + // drops. + [](std::exception_ptr e) + { + if(e) + std::rethrow_exception(e); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/CMakeLists.txt new file mode 100644 index 0000000..8481846 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-json + Jamfile + json_client.cpp) + +source_group("" FILES + Jamfile + json_client.cpp) + +target_link_libraries(http-client-json PRIVATE Boost::beast Boost::json) + +set_target_properties(http-client-json + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/Jamfile new file mode 100644 index 0000000..49af034 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe json_client : json_client.cpp + : + coverage:no + ubasan:no + /boost/json//boost_json/static + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/json_body.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/json_body.hpp new file mode 100644 index 0000000..90e6a58 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/json_body.hpp @@ -0,0 +1,118 @@ +// +// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: JSON body +// +//------------------------------------------------------------------------------ + +#ifndef BOOST_BEAST_EXAMPLE_JSON_BODY +#define BOOST_BEAST_EXAMPLE_JSON_BODY + +#include +#include +#include +#include +#include + +namespace json = boost::json; + +struct json_body +{ + using value_type = json::value; + + struct writer + { + using const_buffers_type = boost::asio::const_buffer; + template + writer( + boost::beast::http::header const&, + value_type const& body) + { + // The serializer holds a pointer to the value, so all we need to do is to reset it. + serializer.reset(&body); + } + + void + init(boost::system::error_code& ec) + { + // The serializer always works, so no error can occur here. + ec = {}; + } + + boost::optional> + get(boost::system::error_code& ec) + { + ec = {}; + // We serialize as much as we can with the buffer. Often that'll suffice + const auto len = serializer.read(buffer, sizeof(buffer)); + return std::make_pair( + boost::asio::const_buffer(len.data(), len.size()), + !serializer.done()); + } + private: + json::serializer serializer; + // half of the probable networking buffer, let's leave some space for headers + char buffer[32768]; + }; + + struct reader + { + template + reader( + boost::beast::http::header&, + value_type& body) + : body(body) + { + } + void + init( + boost::optional const& content_length, + boost::system::error_code& ec) + { + + // If we know the content-length, we can allocate a monotonic resource to increase the parsing speed. + // We're using it rather then a static_resource, so a consumer can modify the resulting value. + // It is also only assumption that the parsed json will be smaller than the serialize one, + // it might not always be the case. + if (content_length) + parser.reset(json::make_shared_resource(*content_length)); + ec = {}; + } + + template + std::size_t + put(ConstBufferSequence const& buffers, boost::system::error_code& ec) + { + ec = {}; + // The parser just uses the `ec` to indicate errors, so we don't need to do anything. + return parser.write_some( + static_cast(buffers.data()), buffers.size(), ec); + } + + void + finish(boost::system::error_code& ec) + { + ec = {}; + // We check manually if the json is complete. + if (parser.done()) + body = parser.release(); + else + ec = boost::json::error::incomplete; + } + + private: + json::stream_parser parser; + value_type& body; + }; +}; + + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/json_client.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/json_client.cpp new file mode 100644 index 0000000..c905e22 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/body/json_client.cpp @@ -0,0 +1,61 @@ +#include "json_body.hpp" +#include + +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = net::ip::tcp; // from + +int main(int, char **) +{ + // Our test endpoint for testing the json + const auto host = "postman-echo.com"; + const auto target = "/post"; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, "80"); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP POST request message + http::request req{http::verb::post, target, 11}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + req.set(http::field::content_type, "application/json"); + req.body() = {{"type", "test"}, {"content", "pure awesomeness"}}; + req.prepare_payload(); + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Get the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + + return 0; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/CMakeLists.txt new file mode 100644 index 0000000..5ccc4f7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-coro-ssl + Jamfile + http_client_coro_ssl.cpp) + +source_group("" FILES + Jamfile + http_client_coro_ssl.cpp) + +target_include_directories(http-client-coro-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-client-coro-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-client-coro-ssl + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/Jamfile new file mode 100644 index 0000000..1348085 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/Jamfile @@ -0,0 +1,23 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-client-coro-ssl : + http_client_coro_ssl.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/http_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/http_client_coro_ssl.cpp new file mode 100644 index 0000000..74f5c2a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -0,0 +1,204 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void +do_session( + std::string const& host, + std::string const& port, + std::string const& target, + int version, + net::io_context& ioc, + ssl::context& ctx, + net::yield_context yield) +{ + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) + { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if(ec) + return fail(ec, "resolve"); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + get_lowest_layer(stream).async_connect(results, yield[ec]); + if(ec) + return fail(ec, "connect"); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::client, yield[ec]); + if(ec) + return fail(ec, "handshake"); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if(ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if(ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res << std::endl; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Gracefully close the stream + stream.async_shutdown(yield[ec]); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec != net::ssl::error::stream_truncated) + return fail(ec, "shutdown"); +} + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-coro-ssl []\n" << + "Example:\n" << + " http-client-coro-ssl www.example.com 443 /\n" << + " http-client-coro-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // Launch the asynchronous operation + boost::asio::spawn(ioc, std::bind( + &do_session, + std::string(host), + std::string(port), + std::string(target), + version, + std::ref(ioc), + std::ref(ctx), + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/CMakeLists.txt new file mode 100644 index 0000000..05e30c3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-coro + Jamfile + http_client_coro.cpp) + +source_group("" FILES + Jamfile + http_client_coro.cpp) + +target_link_libraries(http-client-coro PRIVATE Boost::beast) + +set_target_properties(http-client-coro + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/Jamfile new file mode 100644 index 0000000..66ee67b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-client-coro : + http_client_coro.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/http_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/http_client_coro.cpp new file mode 100644 index 0000000..9f083f3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/coro/http_client_coro.cpp @@ -0,0 +1,155 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Performs an HTTP GET and prints the response +void +do_session( + std::string const& host, + std::string const& port, + std::string const& target, + int version, + net::io_context& ioc, + net::yield_context yield) +{ + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if(ec) + return fail(ec, "resolve"); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + stream.async_connect(results, yield[ec]); + if(ec) + return fail(ec, "connect"); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Send the HTTP request to the remote host + http::async_write(stream, req, yield[ec]); + if(ec) + return fail(ec, "write"); + + // This buffer is used for reading and must be persisted + beast::flat_buffer b; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::async_read(stream, b, res, yield[ec]); + if(ec) + return fail(ec, "read"); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if(ec && ec != beast::errc::not_connected) + return fail(ec, "shutdown"); + + // If we get here then the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-coro []\n" << + "Example:\n" << + " http-client-coro www.example.com 80 /\n" << + " http-client-coro www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, std::bind( + &do_session, + std::string(host), + std::string(port), + std::string(target), + version, + std::ref(ioc), + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service. The call will return when + // the get operation is complete. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/CMakeLists.txt new file mode 100644 index 0000000..ba342a1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-crawl + Jamfile + http_crawl.cpp + urls_large_data.cpp) + +source_group("" FILES + Jamfile + http_crawl.cpp + urls_large_data.cpp) + +target_link_libraries(http-crawl PRIVATE Boost::beast) + +set_target_properties(http-crawl + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/Jamfile new file mode 100644 index 0000000..8f94c96 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-crawl : + http_crawl.cpp + urls_large_data.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/http_crawl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/http_crawl.cpp new file mode 100644 index 0000000..da92520 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/http_crawl.cpp @@ -0,0 +1,405 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP crawl (asynchronous) +// +//------------------------------------------------------------------------------ + +#include "urls_large_data.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace chrono = std::chrono; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = net::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// This structure aggregates statistics on all the sites +class crawl_report +{ + net::strand< + net::io_context::executor_type> strand_; + std::atomic index_; + std::vector const& hosts_; + std::size_t count_ = 0; + +public: + crawl_report(net::io_context& ioc) + : strand_(ioc.get_executor()) + , index_(0) + , hosts_(urls_large_data()) + { + } + + // Run an aggregation function on the strand. + // This allows synchronization without a mutex. + template + void + aggregate(F const& f) + { + net::post( + strand_, + [&, f] + { + f(*this); + if(count_ % 100 == 0) + { + std::cerr << + "Progress: " << count_ << " of " << hosts_.size() << "\n"; + //std::cerr << *this; + } + ++count_; + }); + } + + // Returns the next host to check + char const* + get_host() + { + auto const n = index_++; + if(n >= hosts_.size()) + return nullptr; + return hosts_[n]; + } + + // Counts the number of timer failures + std::size_t timer_failures = 0; + + // Counts the number of name resolution failures + std::size_t resolve_failures = 0; + + // Counts the number of connection failures + std::size_t connect_failures = 0; + + // Counts the number of write failures + std::size_t write_failures = 0; + + // Counts the number of read failures + std::size_t read_failures = 0; + + // Counts the number of success reads + std::size_t success = 0; + + // Counts the number received of each status code + std::map status_codes; +}; + +std::ostream& +operator<<(std::ostream& os, crawl_report const& report) +{ + // Print the report + os << + "Crawl report\n" << + " Failure counts\n" << + " Timer : " << report.timer_failures << "\n" << + " Resolve : " << report.resolve_failures << "\n" << + " Connect : " << report.connect_failures << "\n" << + " Write : " << report.write_failures << "\n" << + " Read : " << report.read_failures << "\n" << + " Success : " << report.success << "\n" << + " Status codes\n" + ; + for(auto const& result : report.status_codes) + os << + " " << std::setw(3) << result.first << ": " << result.second << + " (" << http::obsolete_reason(static_cast(result.first)) << ")\n"; + os.flush(); + return os; +} + +//------------------------------------------------------------------------------ + +// Performs HTTP GET requests and aggregates the results into a report +class worker : public std::enable_shared_from_this +{ + enum + { + // Use a small timeout to keep things lively + timeout = 5 + }; + + crawl_report& report_; + net::strand ex_; + tcp::resolver resolver_; + beast::tcp_stream stream_; + beast::flat_buffer buffer_; // (Must persist between reads) + http::request req_; + http::response res_; + +public: + worker(worker&&) = default; + + // Resolver and socket require an io_context + worker( + crawl_report& report, + net::io_context& ioc) + : report_(report) + , ex_(net::make_strand(ioc.get_executor())) + , resolver_(ex_) + , stream_(ex_) + { + // Set up the common fields of the request + req_.version(11); + req_.method(http::verb::get); + req_.target("/"); + req_.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + } + + // Start the asynchronous operation + void + run() + { + do_get_host(); + } + + void + do_get_host() + { + // Grab another host + auto const host = report_.get_host(); + + // nullptr means no more work + if(! host) + return; + + // The Host HTTP field is required + req_.set(http::field::host, host); + + // Set up an HTTP GET request message + // Look up the domain name + resolver_.async_resolve( + host, + "http", + beast::bind_front_handler( + &worker::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + { + report_.aggregate( + [](crawl_report& rep) + { + ++rep.resolve_failures; + }); + return do_get_host(); + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Make the connection on the IP address we get from a lookup + stream_.async_connect( + results, + beast::bind_front_handler( + &worker::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) + { + if(ec) + { + report_.aggregate( + [](crawl_report& rep) + { + ++rep.connect_failures; + }); + return do_get_host(); + } + + // Set a timeout on the operation + stream_.expires_after(std::chrono::seconds(10)); + + // Send the HTTP request to the remote host + http::async_write( + stream_, + req_, + beast::bind_front_handler( + &worker::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + { + report_.aggregate( + [](crawl_report& rep) + { + ++rep.write_failures; + }); + return do_get_host(); + } + + // Receive the HTTP response + res_ = {}; + http::async_read( + stream_, + buffer_, + res_, + beast::bind_front_handler( + &worker::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + { + report_.aggregate( + [](crawl_report& rep) + { + ++rep.read_failures; + }); + return do_get_host(); + } + + auto const code = res_.result_int(); + report_.aggregate( + [code](crawl_report& rep) + { + ++rep.success; + ++rep.status_codes[code]; + }); + + // Gracefully close the socket + stream_.socket().shutdown(tcp::socket::shutdown_both, ec); + stream_.close(); + + // If we get here then the connection is closed gracefully + + do_get_host(); + } +}; + +class timer +{ + using clock_type = chrono::system_clock; + + clock_type::time_point when_; + +public: + using duration = clock_type::duration; + + timer() + : when_(clock_type::now()) + { + } + + duration + elapsed() const + { + return clock_type::now() - when_; + } +}; + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 2) + { + std::cerr << + "Usage: http-crawl \n" << + "Example:\n" << + " http-crawl 100\n"; + return EXIT_FAILURE; + } + auto const threads = std::max(1, std::atoi(argv[1])); + + // The io_context is used to aggregate the statistics + net::io_context ioc; + + // The report holds the aggregated statistics + crawl_report report{ioc}; + + timer t; + + // Create and launch the worker threads. + std::vector workers; + workers.reserve(threads + 1); + for(int i = 0; i < threads; ++i) + { + // Each worker will eventually add some data to the aggregated + // report. Outstanding work is tracked in each worker to + // represent the forthcoming delivery of this data by that + // worker. + auto reporting_work = net::require( + ioc.get_executor(), + net::execution::outstanding_work.tracked); + + workers.emplace_back( + [&report, reporting_work] { + // We use a separate io_context for each worker because + // the asio resolver simulates asynchronous operation using + // a dedicated worker thread per io_context, and we want to + // do a lot of name resolutions in parallel. + net::io_context ioc; + std::make_shared(report, ioc)->run(); + ioc.run(); + }); + } + + // Add another thread to run the main io_context which + // is used to aggregate the statistics + workers.emplace_back( + [&ioc] + { + ioc.run(); + }); + + // Now block until all threads exit + for(std::size_t i = 0; i < workers.size(); ++i) + workers[i].join(); + + std::cout << + "Elapsed time: " << chrono::duration_cast(t.elapsed()).count() << " seconds\n"; + std::cout << report; + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/urls_large_data.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/urls_large_data.cpp new file mode 100644 index 0000000..cee46ee --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/urls_large_data.cpp @@ -0,0 +1,10021 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#include "urls_large_data.hpp" + +// Data from Alexa top 1 million sites +// http://s3.amazonaws.com/alexa-static/top-1m.csv.zip +// +std::vector const& +urls_large_data() +{ + static std::vector const urls ({ + "google.com", + "facebook.com", + "youtube.com", + "yahoo.com", + "baidu.com", + "wikipedia.org", + "qq.com", + "linkedin.com", + "taobao.com", + "twitter.com", + "live.com", + "amazon.com", + "sina.com.cn", + "google.co.in", + "hao123.com", + "blogspot.com", + "weibo.com", + "wordpress.com", + "yandex.ru", + "yahoo.co.jp", + "tmall.com", + "bing.com", + "vk.com", + "ebay.com", + "360.cn", + "google.de", + "sohu.com", + "pinterest.com", + "google.co.uk", + "ask.com", + "google.fr", + "msn.com", + "163.com", + "soso.com", + "tumblr.com", + "google.co.jp", + "instagram.com", + "mail.ru", + "google.com.br", + "microsoft.com", + "paypal.com", + "google.ru", + "xvideos.com", + "google.es", + "imdb.com", + "apple.com", + "google.it", + "adcash.com", + "craigslist.org", + "stackoverflow.com", + "amazon.co.jp", + "neobux.com", + "google.com.hk", + "imgur.com", + "ifeng.com", + "cnn.com", + "google.com.mx", + "xhamster.com", + "xinhuanet.com", + "gmw.cn", + "reddit.com", + "bbc.co.uk", + "blogger.com", + "google.ca", + "fc2.com", + "vube.com", + "go.com", + "akamaihd.net", + "alipay.com", + "about.com", + "people.com.cn", + "t.co", + "googleusercontent.com", + "wordpress.org", + "odnoklassniki.ru", + "alibaba.com", + "google.com.tr", + "aliexpress.com", + "youku.com", + "conduit.com", + "huffingtonpost.com", + "godaddy.com", + "flickr.com", + "pornhub.com", + "google.com.au", + "amazon.de", + "blogspot.in", + "kickass.to", + "ebay.de", + "netflix.com", + "google.pl", + "thepiratebay.se", + "bp.blogspot.com", + "adobe.com", + "dailymotion.com", + "china.com", + "vimeo.com", + "dailymail.co.uk", + "cnet.com", + "rakuten.co.jp", + "espn.go.com", + "ku6.com", + "ebay.co.uk", + "themeforest.net", + "xnxx.com", + "livejasmin.com", + "indiatimes.com", + "aol.com", + "redtube.com", + "dropbox.com", + "amazonaws.com", + "uol.com.br", + "weather.com", + "m2newmedia.com", + "amazon.co.uk", + "google.com.ar", + "google.com.sa", + "pixnet.net", + "nytimes.com", + "slideshare.net", + "youporn.com", + "google.com.eg", + "buzzfeed.com", + "wikimedia.org", + "booking.com", + "livejournal.com", + "globo.com", + "fiverr.com", + "adf.ly", + "secureserver.net", + "mozilla.org", + "google.com.pk", + "google.com.tw", + "google.nl", + "yelp.com", + "sogou.com", + "ameblo.jp", + "directrev.com", + "clkmon.com", + "hootsuite.com", + "deviantart.com", + "blogfa.com", + "wikia.com", + "outbrain.com", + "flipkart.com", + "wikihow.com", + "etsy.com", + "google.co.th", + "soundcloud.com", + "google.co.za", + "avg.com", + "w3schools.com", + "theguardian.com", + "stumbleupon.com", + "espncricinfo.com", + "livedoor.com", + "forbes.com", + "archive.org", + "4shared.com", + "foxnews.com", + "files.wordpress.com", + "answers.com", + "bankofamerica.com", + "chase.com", + "google.co.ve", + "mediafire.com", + "torrentz.eu", + "badoo.com", + "salesforce.com", + "aweber.com", + "sourceforge.net", + "bbc.com", + "addthis.com", + "liveinternet.ru", + "china.com.cn", + "indeed.com", + "reference.com", + "github.com", + "skype.com", + "hostgator.com", + "google.gr", + "bet365.com", + "spiegel.de", + "ask.fm", + "so.com", + "statcounter.com", + "gameforge.com", + "onet.pl", + "naver.com", + "google.com.co", + "developunit.info", + "google.com.vn", + "google.co.id", + "nicovideo.jp", + "shutterstock.com", + "walmart.com", + "google.be", + "mailchimp.com", + "softonic.com", + "stackexchange.com", + "google.com.ng", + "google.com.ua", + "popads.net", + "allegro.pl", + "gamer.com.tw", + "wordreference.com", + "wellsfargo.com", + "loading-delivery1.com", + "zillow.com", + "tripadvisor.com", + "quikr.com", + "pandora.com", + "wsj.com", + "goo.ne.jp", + "bild.de", + "tube8.com", + "wix.com", + "google.se", + "coccoc.com", + "google.ro", + "suning.com", + "photobucket.com", + "weebly.com", + "tianya.cn", + "warriorforum.com", + "telegraph.co.uk", + "google.dz", + "naver.jp", + "php.net", + "ups.com", + "rambler.ru", + "zedo.com", + "reuters.com", + "google.at", + "media.tumblr.com", + "taringa.net", + "google.com.ph", + "chinaz.com", + "mashable.com", + "blogspot.com.es", + "hurriyet.com.tr", + "google.com.pe", + "bleacherreport.com", + "gmx.net", + "wp.pl", + "goodreads.com", + "leboncoin.fr", + "rutracker.org", + "lenta.ru", + "babylon.com", + "domaintools.com", + "sharelive.net", + "rediff.com", + "google.ch", + "comcast.net", + "twitch.tv", + "avito.ru", + "kaskus.co.id", + "nbcnews.com", + "onclickads.net", + "businessinsider.com", + "ikea.com", + "codecanyon.net", + "ndtv.com", + "usps.com", + "google.cl", + "doublepimp.com", + "moz.com", + "google.com.sg", + "usatoday.com", + "dmm.co.jp", + "amazon.fr", + "google.pt", + "ucoz.ru", + "rt.com", + "milliyet.com.tr", + "xuite.net", + "samsung.com", + "fedex.com", + "uploaded.net", + "pcpop.com", + "google.com.bd", + "bitly.com", + "goodgamestudios.com", + "ettoday.net", + "baomihua.com", + "39.net", + "web.de", + "rbc.ru", + "9gag.com", + "disqus.com", + "snapdeal.com", + "xcar.com.cn", + "washingtonpost.com", + "bloomberg.com", + "scribd.com", + "hp.com", + "constantcontact.com", + "4dsply.com", + "gsmarena.com", + "intuit.com", + "meetup.com", + "nih.gov", + "americanexpress.com", + "ehow.com", + "infusionsoft.com", + "google.cz", + "mercadolivre.com.br", + "myntra.com", + "varzesh3.com", + "mobile01.com", + "hardsextube.com", + "goal.com", + "thefreecamsecret.com", + "thefreedictionary.com", + "douban.com", + "iqiyi.com", + "it168.com", + "mama.cn", + "tmz.com", + "time.com", + "olx.in", + "microsoftonline.com", + "hulu.com", + "enet.com.cn", + "speedtest.net", + "orange.fr", + "free.fr", + "detik.com", + "bluehost.com", + "libero.it", + "histats.com", + "webmd.com", + "eazel.com", + "hudong.com", + "extratorrent.cc", + "google.co.kr", + "chaturbate.com", + "huanqiu.com", + "cnzz.com", + "daum.net", + "xing.com", + "force.com", + "jrj.com.cn", + "pchome.net", + "cj.com", + "youjizz.com", + "delta-search.com", + "techcrunch.com", + "motherless.com", + "tinyurl.com", + "beeg.com", + "kooora.com", + "google.cn", + "clickbank.com", + "yandex.ua", + "ad6media.fr", + "google.no", + "amazon.cn", + "zippyshare.com", + "acesse.com", + "google.co.hu", + "google.ae", + "hdfcbank.com", + "nba.com", + "zendesk.com", + "blogspot.co.uk", + "bestbuy.com", + "accuweather.com", + "getresponse.com", + "repubblica.it", + "xywy.com", + "ci123.com", + "ebay.in", + "in.com", + "ign.com", + "groupon.com", + "yesky.com", + "elpais.com", + "marca.com", + "kwejk.pl", + "caijing.com.cn", + "google.ie", + "cloudfront.net", + "intoday.in", + "wideinfo.org", + "pof.com", + "kakaku.com", + "bitauto.com", + "life.com.tw", + "xe.com", + "goo.gl", + "google.az", + "feedly.com", + "tagged.com", + "amazon.in", + "list-manage.com", + "w3.org", + "quora.com", + "ixxx.com", + "mysearchdial.com", + "dell.com", + "seznam.cz", + "t-online.de", + "plugrush.com", + "nydailynews.com", + "okcupid.com", + "istockphoto.com", + "snapdo.com", + "abcnews.go.com", + "target.com", + "latimes.com", + "mywebsearch.com", + "joomla.org", + "odesk.com", + "surveymonkey.com", + "elmundo.es", + "siteadvisor.com", + "aili.com", + "uimserv.net", + "ebay.com.au", + "doubleclick.com", + "zeobit.com", + "google.co.il", + "fbcdn.net", + "ero-advertising.com", + "issuu.com", + "naukri.com", + "gazeta.pl", + "ck101.com", + "udn.com", + "google.dk", + "ce.cn", + "capitalone.com", + "att.com", + "drudgereport.com", + "blackhatworld.com", + "adrotator.se", + "retailmenot.com", + "justdial.com", + "icicibank.com", + "likes.com", + "elance.com", + "cntv.cn", + "ameba.jp", + "java.com", + "lifehacker.com", + "jabong.com", + "gizmodo.com", + "ebay.it", + "lenovo.com", + "hypergames.net", + "google.fi", + "doorblog.jp", + "blogspot.de", + "jimdo.com", + "probux.com", + "blogspot.it", + "habrahabr.ru", + "webmoney.ru", + "irctc.co.in", + "sahibinden.com", + "github.io", + "informer.com", + "mysearchresults.com", + "upworthy.com", + "pch.com", + "eyny.com", + "canadaalltax.com", + "b5m.com", + "freelancer.com", + "match.com", + "searchfun.in", + "adnxs.com", + "sberbank.ru", + "ig.com.br", + "trulia.com", + "subscene.com", + "corriere.it", + "livescore.com", + "irs.gov", + "twoo.com", + "clixsense.com", + "4399.com", + "xda-developers.com", + "iminent.com", + "google.com.my", + "onlinesbi.com", + "empowernetwork.com", + "zing.vn", + "youdao.com", + "systweak.com", + "flipora.com", + "ning.com", + "engadget.com", + "abril.com.br", + "exoclick.com", + "semrush.com", + "commentcamarche.net", + "shareasale.com", + "vnexpress.net", + "battle.net", + "youm7.com", + "digg.com", + "rapidgator.net", + "expedia.com", + "twimg.com", + "newegg.com", + "lady8844.com", + "xgo.com.cn", + "pcgames.com.cn", + "fotolia.com", + "rednet.cn", + "inspsearch.com", + "lemonde.fr", + "adultfriendfinder.com", + "typepad.com", + "mercadolibre.com.ar", + "homedepot.com", + "chip.de", + "lefigaro.fr", + "swagbucks.com", + "taleo.net", + "kinopoisk.ru", + "oracle.com", + "who.is", + "2ch.net", + "qtrax.com", + "eonline.com", + "sochi2014.com", + "myfreecams.com", + "pcbaby.com.cn", + "gome.com.cn", + "amazon.it", + "timeanddate.com", + "bestusefuldownloads.com", + "foursquare.com", + "telexfree.com", + "gc.ca", + "58.com", + "hubspot.com", + "backpage.com", + "examiner.com", + "ria.ru", + "google.sk", + "opensiteexplorer.org", + "awesomehp.com", + "sexlog.com", + "gutefrage.net", + "steampowered.com", + "slate.com", + "marketwatch.com", + "beva.com", + "shaadi.com", + "v1.cn", + "teensdigest.com", + "blogspot.ru", + "taboola.com", + "citrixonline.com", + "hatena.ne.jp", + "seesaa.net", + "houzz.com", + "bodybuilding.com", + "webs.com", + "chexun.com", + "ya.ru", + "citibank.com", + "viralnova.com", + "2345.com", + "ashleyrnadison.com", + "verizonwireless.com", + "55bbs.com", + "theblaze.com", + "123rf.com", + "gotomeeting.com", + "kijiji.ca", + "linkbucks.com", + "haber7.com", + "pravda.com.ua", + "altervista.org", + "mihanblog.com", + "terra.com.br", + "soku.com", + "urbandictionary.com", + "mercadolibre.com.mx", + "pixiv.net", + "oneindia.in", + "yellowpages.com", + "hotels.com", + "drtuber.com", + "scoop.it", + "blogspot.jp", + "cbslocal.com", + "movie4k.to", + "cpmterra.com", + "hubpages.com", + "mobile.de", + "yaolan.com", + "etao.com", + "hidemyass.com", + "ca.gov", + "dreamstime.com", + "firedrive.com", + "searchengines.ru", + "m-w.com", + "ebay.fr", + "templatemonster.com", + "evernote.com", + "fastdailyfind.com", + "amazon.es", + "gateable.com", + "hupu.com", + "y8.com", + "blogspot.com.tr", + "tokobagus.com", + "azlyrics.com", + "website-unavailable.com", + "r10.net", + "wiktionary.org", + "bongacams.com", + "focus.de", + "linksynergy.com", + "steamcommunity.com", + "vk.me", + "sakura.ne.jp", + "foxsports.com", + "optmd.com", + "tabelog.com", + "narod.ru", + "glassdoor.com", + "outlook.com", + "europa.eu", + "viadeo.com", + "leadpages.net", + "ouedkniss.com", + "facenama.com", + "lpcloudsvr302.com", + "agoda.com", + "qvo6.com", + "majesticseo.com", + "mirror.co.uk", + "google.com.kw", + "filehippo.com", + "moneycontrol.com", + "duckduckgo.com", + "npr.org", + "coupons.com", + "mynet.com", + "allrecipes.com", + "priceline.com", + "liveleak.com", + "jqw.com", + "slickdeals.net", + "webcrawler.com", + "babytree.com", + "amung.us", + "tomshardware.com", + "openadserving.com", + "independent.co.uk", + "kompas.com", + "turbobit.net", + "google.kz", + "leo.org", + "yandex.com.tr", + "mp3skull.com", + "nordstrom.com", + "news.com.au", + "traidnt.net", + "wunderground.com", + "cnbc.com", + "jquery.com", + "dict.cc", + "persianblog.ir", + "clarin.com", + "all-free-download.com", + "fhserve.com", + "sape.ru", + "asos.com", + "addmefast.com", + "lequipe.fr", + "lapatilla.com", + "ancestry.com", + "stockstar.com", + "monster.com", + "people.com", + "gawker.com", + "howstuffworks.com", + "tradedoubler.com", + "over-blog.com", + "cbc.ca", + "fishcod.com", + "yoka.com", + "macys.com", + "gazeta.ru", + "free-tv-video-online.me", + "google.bg", + "google.lk", + "southwest.com", + "realtor.com", + "custhelp.com", + "bhaskar.com", + "softpedia.com", + "farsnews.com", + "cy-pr.com", + "theverge.com", + "tudou.com", + "youboy.com", + "porn.com", + "wetransfer.com", + "virgilio.it", + "mega.co.nz", + "sfgate.com", + "delta-homes.com", + "squarespace.com", + "watchseries.lt", + "overstock.com", + "nifty.com", + "jvzoo.com", + "lanacion.com.ar", + "prntscr.com", + "vesti.ru", + "zimbio.com", + "adscale.de", + "google.co.nz", + "yac.mx", + "tickld.com", + "kayak.com", + "youth.cn", + "jd.com", + "shopclues.com", + "allocine.fr", + "cracked.com", + "eventbrite.com", + "behance.net", + "youtube-mp3.org", + "bankmellat.ir", + "echo.msk.ru", + "autohome.com.cn", + "yandex.kz", + "sex.com", + "smh.com.au", + "digikala.com", + "mackolik.com", + "rottentomatoes.com", + "renren.com", + "wired.com", + "imageshack.us", + "interia.pl", + "zanox.com", + "eastday.com", + "fool.com", + "chinabyte.com", + "haberturk.com", + "hespress.com", + "wow.com", + "jobrapido.com", + "idnes.cz", + "qinbei.com", + "pr-cy.ru", + "klikbca.com", + "17ok.com", + "gamefaqs.com", + "immobilienscout24.de", + "biblegateway.com", + "espnfc.com", + "ehowenespanol.com", + "tabnak.ir", + "avazutracking.net", + "sapo.pt", + "welt.de", + "google.com.ec", + "sears.com", + "pcmag.com", + "nownews.com", + "kickstarter.com", + "pixlr.com", + "hongkiat.com", + "chinatimes.com", + "zoho.com", + "reverso.net", + "indianrail.gov.in", + "privatehomeclips.com", + "cbssports.com", + "entrepreneur.com", + "sporx.com", + "bhphotovideo.com", + "fatakat.com", + "xunlei.com", + "nikkei.com", + "chron.com", + "24h.com.vn", + "basecamp.com", + "airtel.in", + "dealshark.com", + "shopify.com", + "babycenter.com", + "letitbit.net", + "nuvid.com", + "yts.re", + "aparat.com", + "r2games.com", + "prestashop.com", + "alarabiya.net", + "india.com", + "magentocommerce.com", + "heise.de", + "sulekha.com", + "mpnrs.com", + "ibm.com", + "cbsnews.com", + "searchengineland.com", + "mapquest.com", + "ccb.com", + "zappos.com", + "rightmove.co.uk", + "sahadan.com", + "milanuncios.com", + "wenku.baidu.com/user/reg", + "ovh.net", + "screencast.com", + "ahrefs.com", + "6.cn", + "businessweek.com", + "linternaute.com", + "dafont.com", + "bestblackhatforum.com", + "streamcloud.eu", + "as.com", + "gtmetrix.com", + "wmmail.ru", + "spankwire.com", + "google.com.do", + "jeuxvideo.com", + "digitalpoint.com", + "amazon.ca", + "mlb.com", + "weheartit.com", + "list.ru", + "leagueoflegends.com", + "56.com", + "bloglovin.com", + "payoneer.com", + "nokia.com", + "aizhan.com", + "novinky.cz", + "ustream.tv", + "getbootstrap.com", + "seekingalpha.com", + "codwide.com", + "vice.com", + "usmagazine.com", + "primewire.ag", + "cam4.com", + "thehindu.com", + "deezer.com", + "graphicriver.net", + "dmm.com", + "biglobe.ne.jp", + "google.rs", + "z5x.net", + "tutsplus.com", + "icicibank.co.in", + "indiamart.com", + "gap.com", + "ensonhaber.com", + "sitepoint.com", + "rutor.org", + "chinanews.com", + "brainyquote.com", + "keepvid.com", + "censor.net.ua", + "subito.it", + "tablica.pl", + "onlylady.com", + "zulily.com", + "squidoo.com", + "change.org", + "sh.st", + "webhostingtalk.com", + "9gag.tv", + "nairaland.com", + "gulfup.com", + "staples.com", + "gamespot.com", + "woorank.com", + "box.com", + "infobae.com", + "elegantthemes.com", + "104.com.tw", + "aftonbladet.se", + "google.hr", + "myegy.com", + "noticias24.com", + "eastmoney.com", + "lowes.com", + "xtube.com", + "worldstarhiphop.com", + "glispa.com", + "verizon.com", + "united.com", + "linkwithin.com", + "google.com.ly", + "whitepages.com", + "games.la", + "dmoz.org", + "imagebam.com", + "careerbuilder.com", + "sky.com", + "instructables.com", + "mercadolibre.com.ve", + "makemytrip.com", + "pinimg.com", + "pingdom.com", + "foodnetwork.com", + "orf.at", + "android.com", + "wiocha.pl", + "csdn.net", + "appledaily.com.tw", + "nike.com", + "eluniversal.com.mx", + "delta.com", + "ezinearticles.com", + "sueddeutsche.de", + "woothemes.com", + "comcast.com", + "gismeteo.ru", + "lotour.com", + "nfl.com", + "xbox.com", + "almanar.com.lb", + "disney.go.com", + "ctrip.com", + "forexfactory.com", + "clicksvenue.com", + "nhl.com", + "ted.com", + "gstatic.com", + "forobeta.com", + "ovh.com", + "mystart.com", + "maktoob.com", + "nouvelobs.com", + "hindustantimes.com", + "billdesk.com", + "1und1.de", + "zhaopin.com", + "weather.gov", + "kioskea.net", + "myspace.com", + "firstpost.com", + "picmonkey.com", + "grooveshark.com", + "exblog.jp", + "pantip.com", + "earthlink.net", + "styletv.com.cn", + "icloud.com", + "manta.com", + "google.by", + "mediaset.it", + "searchenginewatch.com", + "japanpost.jp", + "postimg.org", + "mbc.net", + "cheezburger.com", + "workercn.cn", + "directadvert.ru", + "nationzoom.com", + "caixa.gov.br", + "gumtree.com", + "51job.com", + "viooz.co", + "usbank.com", + "wmtransfer.com", + "fidelity.com", + "gogetlinks.net", + "office365.com", + "pchome.com.tw", + "feedburner.com", + "mp3truck.net", + "sfr.fr", + "junglee.com", + "keezmovies.com", + "binarysystem4u.com", + "way2sms.com", + "oyunskor.com", + "peyvandha.ir", + "ticketmaster.com", + "lacaixa.es", + "video-one.com", + "yomiuri.co.jp", + "popcash.net", + "nypost.com", + "dubizzle.com", + "wpmudev.org", + "mgid.com", + "google.lt", + "zazzle.com", + "nbcolympics.com", + "battlefield.com", + "avast.com", + "jsfiddle.net", + "namecheap.com", + "css-tricks.com", + "friv.com", + "6park.com", + "xhamstercams.com", + "mysql.com", + "dx.com", + "thechive.com", + "vsuch.com", + "souq.com", + "anyoption.com", + "dantri.com.vn", + "ebay.es", + "abc.es", + "whatsapp.com", + "bitshare.com", + "savefrom.net", + "beytoote.com", + "xiaomi.com", + "prweb.com", + "prothom-alo.com", + "pagesjaunes.fr", + "bbb.org", + "eenadu.net", + "tinypic.com", + "whois.com", + "sourtimes.org", + "adk2.com", + "criteo.com", + "tistory.com", + "ilyke.net", + "ruten.com.tw", + "skysports.com", + "makeuseof.com", + "p5w.net", + "hh.ru", + "nationalgeographic.com", + "pornmd.com", + "rakuten.ne.jp", + "idealo.de", + "telegraaf.nl", + "barnesandnoble.com", + "mynavi.jp", + "4chan.org", + "media-fire.org", + "crunchbase.com", + "bravotube.net", + "myfitnesspal.com", + "today.com", + "mit.edu", + "cnmo.com", + "nu.nl", + "tripadvisor.co.uk", + "spotify.com", + "homeway.com.cn", + "dianping.com", + "costco.com", + "pastebin.com", + "dhgate.com", + "windowsphone.com", + "stagram.com", + "investopedia.com", + "ninemsn.com.au", + "excite.co.jp", + "22find.com", + "google.iq", + "hi5.com", + "ad4game.com", + "kohls.com", + "online.sh.cn", + "geocities.jp", + "investing.com", + "haberler.com", + "ft.com", + "weblio.jp", + "google.tn", + "list-manage1.com", + "hsbc.co.uk", + "ppstream.com", + "cloob.com", + "korrespondent.net", + "ucoz.com", + "1and1.com", + "mail.com", + "fotostrana.ru", + "accountonline.com", + "forgeofempires.com", + "dribbble.com", + "city-data.com", + "drupal.org", + "tunein.com", + "51fanli.com", + "ibtimes.com", + "intel.com", + "polyvore.com", + "cbs.com", + "bab.la", + "imobile.com.cn", + "bestadbid.com", + "eztv.it", + "smashingmagazine.com", + "skyrock.com", + "copyscape.com", + "cookpad.com", + "smallseotools.com", + "asus.com", + "anysex.com", + "nbcsports.com", + "kinox.to", + "mbank.com.pl", + "500px.com", + "sofanti.com", + "marktplaats.nl", + "cpanel.net", + "hm.com", + "chicagotribune.com", + "ultimate-guitar.com", + "infolinks.com", + "merdeka.com", + "yandex.by", + "tribalfusion.com", + "livedoor.biz", + "prezi.com", + "last.fm", + "sznews.com", + "junbi-tracker.com", + "so-net.ne.jp", + "cocolog-nifty.com", + "ocn.ne.jp", + "perezhilton.com", + "yaplakal.com", + "championat.com", + "ebay.ca", + "mangareader.net", + "donanimhaber.com", + "miniclip.com", + "vcommission.com", + "noaa.gov", + "imagefap.com", + "gumtree.com.au", + "liveperson.net", + "gfycat.com", + "hollywoodreporter.com", + "dropboxusercontent.com", + "akhbarak.net", + "sou300.com", + "kicker.de", + "livestream.com", + "tribunnews.com", + "kp.ru", + "techradar.com", + "315che.com", + "dw.de", + "codeproject.com", + "newsru.com", + "pconline.com.cn", + "aa.com", + "usaa.com", + "asahi.com", + "themetapicture.com", + "quicksprout.com", + "piriform.com", + "888poker.com", + "gittigidiyor.com", + "nhk.or.jp", + "statigr.am", + "ipage.com", + "gazzetta.it", + "letv.com", + "yourlust.com", + "freepik.com", + "trello.com", + "mixi.jp", + "livememe.com", + "ew.com", + "seosprint.net", + "doisongphapluat.com", + "autotrader.com", + "docstoc.com", + "viva.co.id", + "livestrong.com", + "inc.com", + "hunantv.com", + "bahn.de", + "depositphotos.com", + "rackspace.com", + "flippa.com", + "norton.com", + "lynda.com", + "teamviewer.com", + "vip.com", + "ksl.com", + "solarmovie.so", + "klout.com", + "pikabu.ru", + "vporn.com", + "apache.org", + "sportbox.ru", + "correios.com.br", + "toptenreviews.com", + "ea.com", + "thenextweb.com", + "superuser.com", + "delicious.com", + "zoosk.com", + "inbox.com", + "kongregate.com", + "starbaby.cn", + "888casino.com", + "brazzers.com", + "sockshare.com", + "megashare.info", + "vistaprint.com", + "porntube.com", + "seriesyonkis.com", + "20minutos.es", + "jagran.com", + "programme-tv.net", + "elcomercio.pe", + "blogspot.kr", + "t411.me", + "googleapis.com", + "blog.com", + "qingdaonews.com", + "sedo.com", + "itmedia.co.jp", + "mtv.com", + "ynet.co.il", + "playstation.com", + "pornhublive.com", + "thedailybeast.com", + "r7.com", + "sabah.com.tr", + "126.com", + "topix.com", + "liga.net", + "marriott.com", + "tvn24.pl", + "sitesell.com", + "netdna-cdn.com", + "startimes.com", + "hstpnetwork.com", + "blogspot.com.au", + "17u.cn", + "subscribe.ru", + "woot.com", + "rozblog.com", + "wimp.com", + "vg.no", + "t-mobile.com", + "bmi.ir", + "kankan.com", + "tsn.ua", + "gumtree.co.za", + "googleadservices.com", + "pnc.com", + "cars.com", + "soccerway.com", + "o2.pl", + "zeit.de", + "zopim.com", + "cloudflare.com", + "givemesport.com", + "statscrop.com", + "gravatar.com", + "flightradar24.com", + "ubuntu.com", + "salon.com", + "ytimg.com", + "trovigo.com", + "sunporno.com", + "libertagia.com", + "mihanwebads.com", + "shopathome.com", + "cdiscount.com", + "commbank.com.au", + "elwatannews.com", + "discovercard.com", + "infowars.com", + "blogimg.jp", + "portaldosites.com", + "fixya.com", + "drom.ru", + "fastpic.ru", + "pbs.org", + "kandao.com", + "okwave.jp", + "faz.net", + "sbnation.com", + "hilton.com", + "duba.com", + "homeshop18.com", + "ultimasnoticias.com.ve", + "bankrate.com", + "megasesso.com", + "studiopress.com", + "sports.ru", + "asriran.com", + "etoro.com", + "cafemom.com", + "dhl.de", + "indiegogo.com", + "tdcanadatrust.com", + "1tv.ru", + "gogvo.com", + "bt.com", + "blogspot.tw", + "zergnet.com", + "garanti.com.tr", + "privatbank.ua", + "sanook.com", + "travelocity.com", + "networksolutions.com", + "thqafawe3lom.com", + "trklnks.com", + "torchbrowser.com", + "logmein.com", + "williamhill.com", + "zhihu.com", + "auto.ru", + "craigslist.ca", + "olx.com.pk", + "smi2.ru", + "ukr.net", + "dpreview.com", + "boston.com", + "folha.uol.com.br", + "name.com", + "ashemaletube.com", + "slimspots.com", + "envato.com", + "6pm.com", + "fandango.com", + "sozcu.com.tr", + "nikkeibp.co.jp", + "aufeminin.com", + "baiducontent.com", + "buscape.com.br", + "funnyordie.com", + "337.com", + "sakshi.com", + "airasia.com", + "samanyoluhaber.com", + "picofile.com", + "blackberry.com", + "google.com.gt", + "io9.com", + "easyhits4u.com", + "qianyan001.com", + "flashx.tv", + "zap2it.com", + "dnsrsearch.com", + "patch.com", + "staticflickr.com", + "clicksor.com", + "mcafee.com", + "zerohedge.com", + "zara.com", + "freelotto.com", + "tutorialspoint.com", + "qone8.com", + "olx.com.br", + "axisbank.com", + "marketgid.com", + "your-server.de", + "game321.com", + "harvard.edu", + "indianexpress.com", + "fatwallet.com", + "nudevista.com", + "paper.li", + "opera.com", + "serving-sys.com", + "nowvideo.sx", + "theatlantic.com", + "cisco.com", + "bookmyshow.com", + "webmasterworld.com", + "metro.co.uk", + "leparisien.fr", + "orbitz.com", + "h2porn.com", + "4cdn.org", + "itar-tass.com", + "nasa.gov", + "macrumors.com", + "google.si", + "usnews.com", + "premierleague.com", + "largeporntube.com", + "blogsky.com", + "bufferapp.com", + "zeroredirect1.com", + "sendspace.com", + "stanford.edu", + "state.gov", + "yjc.ir", + "abc.net.au", + "pornsharing.com", + "4pda.ru", + "52pk.net", + "meituan.com", + "mmgp.ru", + "sponichi.co.jp", + "masrawy.com", + "whatismyipaddress.com", + "onlinewebfind.com", + "news24.com", + "zdnet.com", + "imagevenue.com", + "gameaholic.com", + "mediaplex.com", + "clip.vn", + "2mdn.net", + "nmisr.com", + "musica.com", + "networkedblogs.com", + "metrolyrics.com", + "chacha.com", + "internetdownloadmanager.com", + "legacy.com", + "wwe.com", + "icbc.com.cn", + "ny.gov", + "chomikuj.pl", + "alexa.com", + "pcworld.com", + "overthumbs.com", + "adp.com", + "ad2games.com", + "adme.ru", + "bidvertiser.com", + "rtl.de", + "sweetim.com", + "gaana.com", + "7k7k.com", + "livingsocial.com", + "netteller.com", + "rakuten.com", + "chess.com", + "blackboard.com", + "thekitchn.com", + "ilfattoquotidiano.it", + "20minutes.fr", + "soufun.com", + "nerdbux.com", + "breitbart.com", + "webtretho.com", + "tvguide.com", + "miralinks.ru", + "weather.com.cn", + "zalando.de", + "dangdang.com", + "bubblews.com", + "thoughtcatalog.com", + "114la.com", + "msn.ca", + "blogmura.com", + "americanas.com.br", + "elitedaily.com", + "lightinthebox.com", + "bizjournals.com", + "yixun.com", + "itau.com.br", + "51.la", + "doodle.com", + "arabyonline.com", + "opencart.com", + "bomnegocio.com", + "lego.com", + "pclady.com.cn", + "metacafe.com", + "kimiss.com", + "journaldunet.com", + "gnavi.co.jp", + "51auto.com", + "clickey.com", + "chekb.com", + "searchnu.com", + "diply.com", + "walgreens.com", + "descargar.es", + "mirrorcreator.com", + "pornerbros.com", + "askmen.com", + "shop.com", + "inmotionhosting.com", + "filmweb.pl", + "kbb.com", + "appround.biz", + "aljazeera.com", + "lumosity.com", + "sweet-page.com", + "pole-emploi.fr", + "fishki.net", + "rollingstone.com", + "kapanlagi.com", + "yandex.com", + "cnblogs.com", + "plaintube.com", + "intentmedia.net", + "about.me", + "torrentz.in", + "01net.com", + "gyazo.com", + "nic.ru", + "juicyads.com", + "trend.az", + "askubuntu.com", + "unam.mx", + "tradus.com", + "tigerdirect.com", + "letras.mus.br", + "imagetwist.com", + "perfectmoney.is", + "wpbeginner.com", + "thepiratetrader.com", + "victoriassecret.com", + "images-amazon.com", + "tusfiles.net", + "chefkoch.de", + "ojooo.com", + "alphaporno.com", + "betfair.com", + "tympanus.net", + "td.com", + "4tube.com", + "phonearena.com", + "bankmandiri.co.id", + "cox.net", + "ozon.ru", + "perfectgirls.net", + "asana.com", + "sprint.com", + "berniaga.com", + "vente-privee.com", + "ing.nl", + "finn.no", + "atwiki.jp", + "toysrus.com", + "petflow.com", + "reverbnation.com", + "freeones.com", + "abc.go.com", + "bradesco.com.br", + "yenisafak.com.tr", + "profit-partner.ru", + "redfin.com", + "mangafox.me", + "appnexus.com", + "sxc.hu", + "speedanalysis.net", + "n-tv.de", + "qidian.com", + "teespring.com", + "break.com", + "nailedhard.com", + "jalan.net", + "authorize.net", + "adultadworld.com", + "sootoo.com", + "roboform.com", + "kotaku.com", + "multitran.ru", + "food.com", + "twitpic.com", + "pogo.com", + "sabq.org", + "priceminister.com", + "lexpress.fr", + "livetv.sx", + "nikkansports.com", + "securepaynet.net", + "vodoumedia.com", + "airbnb.com", + "trafficholder.com", + "rr.com", + "expireddomains.net", + "bandcamp.com", + "wayfair.com", + "tut.by", + "maybank2u.com.my", + "similarweb.com", + "zol.com.cn", + "247realmedia.com", + "asp.net", + "lonelyplanet.com", + "seopult.ru", + "whois.net", + "academia.edu", + "univision.com", + "interfax.ru", + "amarillasinternet.com", + "miercn.com", + "barclays.co.uk", + "societe.com", + "khabaronline.ir", + "unity3d.com", + "nyaa.se", + "euronews.com", + "verizon.net", + "rutube.ru", + "wetter.com", + "imlive.com", + "ggpht.com", + "docin.com", + "yify-torrents.com", + "yhd.com", + "citibank.co.in", + "xdating.com", + "roblox.com", + "voyages-sncf.com", + "189.cn", + "identi.li", + "bayt.com", + "medicinenet.com", + "wmaraci.com", + "stern.de", + "eluniversal.com", + "zoopla.co.uk", + "easyjet.com", + "dhl.com", + "freakshare.com", + "rojadirecta.me", + "sp.gov.br", + "friendfeed.com", + "beamtele.com", + "searchenginejournal.com", + "nocookie.net", + "reliancenetconnect.co.in", + "google.co.ma", + "fanpop.com", + "adk2.co", + "tagesschau.de", + "nate.com", + "ole.com.ar", + "index.hu", + "aruba.it", + "eltiempo.com", + "resellerclub.com", + "qip.ru", + "xossip.com", + "siteground.com", + "royalbank.com", + "advfn.com", + "tebyan.net", + "iciba.com", + "bigcartel.com", + "sciencedirect.com", + "hepsiburada.com", + "cpasbien.me", + "alfabank.ru", + "microsoftstore.com", + "discogs.com", + "onliner.by", + "socialmediaexaminer.com", + "seasonvar.ru", + "tripadvisor.in", + "360doc.com", + "chinabroadcast.cn", + "realestate.com.au", + "avira.com", + "herokuapp.com", + "downloadsetup.net", + "torcache.net", + "uefa.com", + "rg.ru", + "qianlong.com", + "hugedomains.com", + "arstechnica.com", + "fifa.com", + "ryanair.com", + "i.ua", + "axisbank.co.in", + "alimama.com", + "wanggou.com", + "radikal.com.tr", + "echoroukonline.com", + "unian.net", + "slashdot.org", + "dmv.org", + "mayoclinic.org", + "newsmax.com", + "google.com.et", + "icontact.com", + "vanguardngr.com", + "infojobs.net", + "say-move.org", + "ileehoo.com", + "mirtesen.ru", + "yam.com", + "e-hentai.org", + "wikimapia.org", + "shop-pro.jp", + "bukalapak.com", + "jcpenney.com", + "ilmeteo.it", + "iltasanomat.fi", + "telecomitalia.it", + "kariyer.net", + "shutterfly.com", + "santabanta.com", + "softlayer.com", + "complex.com", + "mamba.ru", + "netshoes.com.br", + "theweathernetwork.com", + "politico.com", + "advego.ru", + "eroprofile.com", + "mainichi.jp", + "nta.go.jp", + "sfimg.com", + "ap.org", + "webex.com", + "hinet.net", + "skyscrapercity.com", + "affili.net", + "adplxmd.com", + "iltalehti.fi", + "impress.co.jp", + "jezebel.com", + "extremetube.com", + "digitaltrends.com", + "one.com", + "ranker.com", + "qiwi.com", + "collegehumor.com", + "nbc.com", + "boursorama.com", + "watch32.com", + "meetcheap.com", + "forums.wordpress.com", + "cvs.com", + "kenh14.vn", + "yallakora.com", + "plurk.com", + "xtool.ru", + "airtel.com", + "wp.com", + "sftimes.co", + "economist.com", + "rapidshare.com", + "redbox.com", + "audible.com", + "kissmetrics.com", + "atpanel.com", + "wargaming.net", + "1337x.org", + "shahrekhabar.com", + "bdnews24.com", + "tvrain.ru", + "wykop.pl", + "mts.ru", + "nnm-club.me", + "schwab.com", + "elconfidencial.com", + "modelmayhem.com", + "zhidao.baidu.com/user/admin", + "aastocks.com", + "tiscali.it", + "qadabra.com", + "autoscout24.de", + "vatanim.com.tr", + "gotowebinar.com", + "edmunds.com", + "ebaumsworld.com", + "megafilmeshd.net", + "poste.it", + "mcssl.com", + "aljazeera.net", + "netvibes.com", + "sme.sk", + "tesco.com", + "525j.com.cn", + "tf1.fr", + "ccidnet.com", + "ldblog.jp", + "blockchain.info", + "played.to", + "nthwall.com", + "justanswer.com", + "clickbank.net", + "fnac.com", + "gmarket.co.kr", + "clipconverter.cc", + "nextmedia.com", + "bb.com.br", + "learntotradethemarket.com", + "pornoid.com", + "downloadha.com", + "hellporno.com", + "ooo-sex.com", + "blocket.se", + "tubeplus.me", + "seek.com.au", + "filestube.to", + "ceneo.pl", + "walmart.com.br", + "sonymobile.com", + "dyndns.org", + "ulmart.ru", + "vrbo.com", + "sport.pl", + "ashleymadison.com", + "el-wlid.com", + "boredpanda.com", + "udemy.com", + "mobogenie.com", + "tubegalore.com", + "theglobeandmail.com", + "bancobrasil.com.br", + "888.com", + "adreactor.com", + "zomato.com", + "depositfiles.com", + "moneysavingexpert.com", + "dofus.com", + "oanda.com", + "sport1.de", + "justhost.com", + "longhoo.net", + "otomoto.pl", + "techrepublic.com", + "westpac.com.au", + "dreamhost.com", + "ilsole24ore.com", + "clubic.com", + "gamme.com.tw", + "doctissimo.fr", + "isna.ir", + "s2d6.com", + "tdbank.com", + "zwaar.net", + "slando.ua", + "segodnya.ua", + "appannie.com", + "bartarinha.ir", + "egotastic.com", + "ed.gov", + "lg.com", + "120ask.com", + "hostmonster.com", + "super.cz", + "mercola.com", + "bayproxy.me", + "day.az", + "dummies.com", + "azet.sk", + "huffingtonpost.co.uk", + "okezone.com", + "medu.ir", + "lavanguardia.com", + "espreso.tv", + "nymag.com", + "autotrader.co.uk", + "socialmediatoday.com", + "wn.com", + "rtbpop.com", + "99designs.com", + "sanspo.com", + "proboards.com", + "virginmedia.com", + "99acres.com", + "blic.rs", + "pingomatic.com", + "prnewswire.com", + "sony.com", + "seobuilding.ru", + "www.gov.uk", + "jugem.jp", + "watchtower.com", + "seoprofiler.com", + "centrum.cz", + "techbrowsing.com", + "almasryalyoum.com", + "lolking.net", + "nipic.com", + "fanfiction.net", + "bwin.com", + "anyporn.com", + "sulit.com.ph", + "quickmeme.com", + "carview.co.jp", + "haizhangs.com", + "airtelforum.com", + "flirt4free.com", + "billboard.com", + "trademe.co.nz", + "rapgenius.com", + "pchouse.com.cn", + "beforeitsnews.com", + "peopleperhour.com", + "basecamphq.com", + "onlinedown.net", + "bet365.es", + "fucked-tube.com", + "santander.co.uk", + "speedbit.com", + "gi-akademie.com", + "google.com.pr", + "winupdatevideos.com", + "bizrate.com", + "xxxbunker.com", + "coursera.org", + "zoominfo.com", + "rarbg.com", + "ahram.org.eg", + "howtogeek.com", + "focus.cn", + "duden.de", + "mufg.jp", + "ex.ua", + "titan24.com", + "greatandhra.com", + "qqbaobao.com", + "rtve.es", + "yandex.net", + "yle.fi", + "panoramio.com", + "google.com.af", + "scol.com.cn", + "gamestop.com", + "xiami.com", + "webpagetest.org", + "creativecommons.org", + "archive.is", + "timesjobs.com", + "centurylink.com", + "wowhead.com", + "wordstream.com", + "lloydsbank.co.uk", + "incredibar.com", + "vagalume.com.br", + "installerapplicationusa.com", + "shinobi.jp", + "ruvr.ru", + "natwest.com", + "roulettebotplus.com", + "wildberries.ru", + "huaban.com", + "buenosearch.com", + "reg.ru", + "tempo.co", + "qvc.com", + "mangahere.com", + "tv.com", + "boc.cn", + "fnb.co.za", + "made-in-china.com", + "eleconomista.es", + "ubuntuforums.org", + "derstandard.at", + "xml-sitemaps.com", + "jang.com.pk", + "jiayuan.com", + "credit-agricole.fr", + "androidcentral.com", + "urbanspoon.com", + "pornoxo.com", + "regnum.ru", + "bedbathandbeyond.com", + "skladchik.com", + "daily.co.jp", + "n-mobile.net", + "suntrust.com", + "justjared.com", + "vid2c.com", + "gettyimages.com", + "tubecup.com", + "kinogo.net", + "similarsites.com", + "fling.com", + "vine.co", + "banglanews24.com", + "pudelek.pl", + "support.wordpress.com", + "cox.com", + "xkcd.com", + "adbooth.com", + "anz.com", + "adxcore.com", + "google.com.sv", + "indeed.co.in", + "scottrade.com", + "v9.com", + "isohunt.to", + "srclick.ru", + "gharreh.com", + "zaman.com.tr", + "monsterindia.com", + "delfi.lt", + "chewen.com", + "empowernetwork.com/QUbsgqDwpjjbkpOgwgOeaw==", + "state.tx.us", + "segundamano.es", + "utro.ru", + "sitescout.com", + "justclick.ru", + "wnd.com", + "cosmopolitan.com", + "local.com", + "anitube.se", + "sport.es", + "google.com.qa", + "ads-id.com", + "google.lv", + "capitalone360.com", + "hattrick.org", + "qualtrics.com", + "inagist.com", + "filgoal.com", + "incredibar-search.com", + "adslgate.com", + "directv.com", + "ilivid.com", + "warthunder.ru", + "jasmin.com", + "cyberciti.biz", + "msn.co.jp", + "canalblog.com", + "boerse.bz", + "tnaflix.com", + "apa.az", + "prchecker.info", + "reclameaqui.com.br", + "onlyworldnews.com", + "submarino.com.br", + "kuronekoyamato.co.jp", + "paipai.com", + "realitykings.com", + "deadspin.com", + "islamweb.net", + "no-ip.com", + "lostfilm.tv", + "wattpad.com", + "wav.tv", + "citi.com", + "buysellads.com", + "prezentacya.ru", + "forocoches.com", + "donga.com", + "drive2.ru", + "netsuite.com", + "privalia.com", + "bidorbuy.co.za", + "cmbchina.com", + "searchresultsguide.com", + "odatv.com", + "skrill.com", + "en.wordpress.com", + "dojki.com", + "unibet.com", + "hotpepper.jp", + "simplyhired.com", + "vesti.ua", + "ibtimes.co.uk", + "creativebloq.com", + "filmesonlinegratis.net", + "videohive.net", + "kmart.com", + "metacritic.com", + "rikunabi.com", + "zozo.jp", + "venturebeat.com", + "1and1.es", + "banesconline.com", + "internethaber.com", + "rae.es", + "planetsuzy.org", + "wpengine.com", + "kizi.com", + "armorgames.com", + "argos.co.uk", + "dtiblog.com", + "diigo.com", + "forever21.com", + "flashscore.com", + "vedomosti.ru", + "ccavenue.com", + "att.net", + "esporte.uol.com.br", + "empowernetwork.com/PXQ7Uz1Kyg+LR1APrG7pKQ==", + "to8to.com", + "hotwire.com", + "all.biz", + "info.com", + "xhamster.com/user/video", + "000webhost.com", + "worldoftanks.ru", + "dagbladet.no", + "computerbild.de", + "nasdaq.com", + "chitika.com", + "ipeen.com.tw", + "abola.pt", + "wiley.com", + "lpcloudsvr303.com", + "tinsao.net", + "mehrnews.com", + "hugesex.tv", + "christian-dogma.com", + "search.us.com", + "garmin.com", + "tgbus.com", + "iherb.com", + "torntv-tvv.org", + "chosun.com", + "kinozal.tv", + "berkeley.edu", + "techtarget.com", + "labanquepostale.fr", + "fitbit.com", + "folkd.com", + "theonion.com", + "idealista.com", + "oscar.go.com", + "jiji.com", + "anonym.to", + "allabout.co.jp", + "wufoo.com", + "rantlifestyle.com", + "google.com.bo", + "28.com", + "rocketnews24.com", + "hotspotshield.com", + "opentable.com", + "admngronline.com", + "naturalnews.com", + "zeroredirect2.com", + "ero-video.net", + "dinamalar.com", + "fl.ru", + "mtsindia.in", + "kapook.com", + "theage.com.au", + "allmyvideos.net", + "dinodirect.com", + "videodownloadconverter.com", + "tripleclicks.com", + "brassring.com", + "fapdu.com", + "cafepress.com", + "infospace.com", + "express.com.pk", + "fumu.com", + "infibeam.com", + "etrade.com", + "meneame.net", + "seroundtable.com", + "bigpoint.com", + "chinadaily.com.cn", + "myfonts.com", + "ezdownloadpro.info", + "codeplex.com", + "xl.pt", + "kaspersky.com", + "khabarfarsi.com", + "admitad.com", + "flirchi.com", + "dpstream.net", + "miniinthebox.com", + "samsclub.com", + "charter.net", + "techbang.com", + "tiu.ru", + "fanpage.it", + "spokeo.com", + "imageshack.com", + "ijreview.com", + "bc.vc", + "lazada.co.id", + "gofirstrow.eu", + "uptobox.com", + "newsnow.co.uk", + "symantec.com", + "editor.wix.com", + "avaxhome.cc", + "canalplus.fr", + "copyblogger.com", + "vetogate.com", + "yahoo-mbga.jp", + "manoramaonline.com", + "ah-me.com", + "elheddaf.com", + "bitcointalk.org", + "haqaik.com", + "bbandt.com", + "linguee.de", + "blogspot.nl", + "minus.com", + "amarujala.com", + "openclassrooms.com", + "bigmir.net", + "koramgame.com", + "commonfloor.com", + "gayromeo.com", + "cleartrip.com", + "kompasiana.com", + "tankionline.com", + "google.co.tz", + "springer.com", + "lifenews.ru", + "sify.com", + "tvoyauda4a.ru", + "dfiles.ru", + "technorati.com", + "myorderbox.com", + "fanatik.com.tr", + "activesearchresults.com", + "laposte.net", + "whirlpool.net.au", + "stockcharts.com", + "leadimpact.com", + "cardekho.com", + "ryushare.com", + "blog.jp", + "fastcompany.com", + "eurosport.fr", + "emirates.com", + "lb.ua", + "serverfault.com", + "forbes.ru", + "bfmtv.com", + "google.jo", + "17173.com", + "wikispaces.com", + "tokopedia.com", + "liberation.fr", + "a10.com", + "kdnet.net", + "variety.com", + "blog.me", + "homeaway.com", + "ameritrade.com", + "adult-empire.com", + "national.com.au", + "haraj.com.sa", + "timewarnercable.com", + "casino.com", + "sheknows.com", + "google.com.uy", + "abv.bg", + "liputan6.com", + "etxt.ru", + "bigstockphoto.com", + "strato.de", + "cashtasks.com", + "columbia.edu", + "zdf.de", + "pptv.com", + "cricbuzz.com", + "sharesuper.info", + "radaronline.com", + "pornolab.net", + "google.ba", + "opensubtitles.org", + "abclocal.go.com", + "ansa.it", + "pbskids.org", + "vz.ru", + "iconfinder.com", + "vitaminl.tv", + "ntv.ru", + "peliculasyonkis.com", + "foto-hd.com", + "paytm.com", + "rantsports.com", + "optimum.net", + "postbank.de", + "index.hr", + "smugmug.com", + "haivl.com", + "arbeitsagentur.de", + "dailycaller.com", + "freshbooks.com", + "genieo.com", + "alnaddy.com", + "britishairways.com", + "20min.ch", + "findthebest.com", + "autoblog.com", + "warez-bb.org", + "iza.ne.jp", + "filmaffinity.com", + "megogo.net", + "soccermanager.com", + "dawanda.com", + "parallels.com", + "clickjogos.uol.com.br", + "12306.cn", + "jstv.com", + "cliphunter.com", + "pixabay.com", + "milenio.com", + "keybinary.com", + "suumo.jp", + "mediatakeout.com", + "vodafone.in", + "cheapoair.com", + "seobook.com", + "videoyoum7.com", + "yr.no", + "gofundme.com", + "ixbt.com", + "starbucks.com", + "conferenceplus.com", + "media1first.com", + "sergey-mavrodi.com", + "rafflecopter.com", + "591.com.tw", + "mangapanda.com", + "huffingtonpost.fr", + "tiboo.cn", + "bancomer.com.mx", + "handelsblatt.com", + "hpylgr.com", + "psu.edu", + "bancomercantil.com", + "sport-express.ru", + "codepen.io", + "foundationapi.com", + "ow.ly", + "vatgia.com", + "kommersant.ru", + "srvsinf.com", + "telderi.ru", + "mercadolibre.com.co", + "hsbc.com.hk", + "t3n.de", + "magicbricks.com", + "shopstyle.com", + "mudah.my", + "punchng.com", + "therichest.com", + "fansshare.com", + "lepoint.fr", + "vipzona.info", + "globaltestmarket.com", + "jqueryui.com", + "bcsh.com", + "mundodeportivo.com", + "newyorker.com", + "funnyjunk.com", + "gongchang.com", + "a8.net", + "ecollege.com", + "newhdplugin.net", + "befuck.com", + "elespectador.com", + "drugs.com", + "abplive.in", + "feelcars.com", + "psychologytoday.com", + "instaforex.com", + "strtsrv.com", + "atpworldtour.com", + "incruit.com", + "starwoodhotels.com", + "zone-telechargement.com", + "songspk.name", + "hatenablog.com", + "enfemenino.com", + "msnbc.com", + "freebitco.in", + "akairan.com", + "discovery.com", + "angieslist.com", + "lesechos.fr", + "transfermarkt.de", + "sephora.com", + "come.in", + "dailykos.com", + "deutsche-bank.de", + "warriorplus.com", + "awwwards.com", + "lomadee.com", + "365jia.cn", + "lotterypost.com", + "egrana.com.br", + "rivals.com", + "literotica.com", + "myfreshnet.com", + "ihg.com", + "fazenda.gov.br", + "tomnod.com", + "filesharefanatic.com", + "hotukdeals.com", + "bitsnoop.com", + "tenpay.com", + "putlocker.bz", + "ziddu.com", + "ntvmsnbc.com", + "surveyzrewardcenter.com", + "aliyun.com", + "media.net", + "comdirect.de", + "yoox.com", + "hotelscombined.com", + "vgsgaming-ads.com", + "robokassa.ru", + "webdesignerdepot.com", + "rotoworld.com", + "jmw.com.cn", + "seloger.com", + "dsdomination.com", + "affiliatewindow.com", + "abs-cbnnews.com", + "bmo.com", + "iconarchive.com", + "funshion.com", + "admin5.com", + "playhe.com", + "bigcommerce.com", + "yodobashi.com", + "bigfishgames.com", + "onlinecreditcenter6.com", + "homes.co.jp", + "gameninja.com", + "ebates.com", + "banamex.com.mx", + "google.com.lb", + "2chblog.jp", + "entertainment-factory.com", + "asg.to", + "walla.co.il", + "mktmobi.com", + "opensooq.com", + "adam4adam.com", + "expressen.se", + "elephanttube.com", + "ingdirect.es", + "clicrbs.com.br", + "seriespepito.com", + "skyscanner.net", + "shine.com", + "appround.us", + "washingtontimes.com", + "nrk.no", + "1stwebdesigner.com", + "gucheng.com", + "ghanaweb.com", + "jzip.com", + "rozetka.com.ua", + "wiziwig.tv", + "jobsdb.com", + "kitco.com", + "rpp.com.pe", + "aljaras.com", + "telecinco.es", + "storify.com", + "netease.com", + "business-standard.com", + "babble.com", + "noticias.uol.com.br", + "alice.it", + "bizdec.ru", + "voanews.com", + "freejobalert.com", + "origo.hu", + "list-manage2.com", + "gavick.com", + "national-lottery.co.uk", + "gazzetta.gr", + "freevideodownloadforpc.com", + "xmarks.com", + "wikibooks.org", + "sexad.net", + "alc.co.jp", + "emol.com", + "careesma.in", + "cdc.gov", + "toshiba.com", + "imgchili.net", + "rbcroyalbank.com", + "indowebster.com", + "zynga.com", + "telekom.com", + "jiameng.com", + "adsmarket.com", + "utorrent.com", + "aarp.org", + "cityadspix.com", + "ekstrabladet.dk", + "doc88.com", + "fetlife.com", + "fh21.com.cn", + "cambridge.org", + "tune.pk", + "auction.co.kr", + "patheos.com", + "search-results.com", + "lds.org", + "webrankinfo.com", + "newsit.gr", + "techtudo.com.br", + "moviepilot.com", + "mercador.ro", + "nguoiduatin.vn", + "tripadvisor.it", + "lurkmore.to", + "europapress.es", + "uspto.gov", + "excelsior.com.mx", + "myvideo.de", + "jetblue.com", + "camfrog.com", + "blick.ch", + "batepapo.uol.com.br", + "manager.co.th", + "goibibo.com", + "cornell.edu", + "apetube.com", + "nation.com", + "allmusic.com", + "naughtyamerica.com", + "obozrevatel.com", + "telegrafi.com", + "neimanmarcus.com", + "yabancidiziizle1.com", + "globalewallet.com", + "beeline.ru", + "hinkhoj.com", + "sitemeter.com", + "almesryoon.com", + "localmoxie.com", + "grotal.com", + "knowyourmeme.com", + "qiwi.ru", + "yieldmanager.com", + "yimg.com", + "horoscopedays.com", + "gfy.com", + "mxtoolbox.com", + "searchgol.com", + "inquirer.net", + "hollywoodlife.com", + "ebrun.com", + "shopbop.com", + "mysmartprice.com", + "kijiji.it", + "visual.ly", + "mop.com", + "1fichier.com", + "prlog.org", + "xjtour.com", + "shorouknews.com", + "thegioinet.net", + "hln.be", + "enom.com", + "thaqafnafsak.com", + "wahuu.com", + "ganji.com", + "russianpost.ru", + "myplaycity.com", + "dzone.com", + "dns-shop.ru", + "aif.ru", + "ssisurveys.com", + "uploadboy.com", + "madpandatv.net", + "pcauto.com.cn", + "meinestadt.de", + "tasnimnews.com", + "rockettheme.com", + "imesh.com", + "home.pl", + "lindaikeji.blogspot.com", + "zamunda.net", + "with2.net", + "calameo.com", + "myonlinearcade.com", + "xcams.com", + "unicredit.it", + "clip2net.com", + "mediatemple.net", + "nosub.tv", + "click.in", + "alluc.to", + "thestar.com.my", + "niksalehi.com", + "lastampa.it", + "itv.com", + "hihi2.com", + "digitalocean.com", + "tripadvisor.fr", + "willhaben.at", + "laodong.com.vn", + "591hx.com", + "tineye.com", + "ptt.cc", + "beatport.com", + "infoseek.co.jp", + "avangate.com", + "indiaproperty.com", + "books.com.tw", + "nj.com", + "avaaz.org", + "wikitravel.org", + "direct.gov.uk", + "wangtu.com", + "discover.com", + "slon.ru", + "startpage.com", + "thestar.com", + "meishichina.com", + "finanzen.net", + "estadao.com.br", + "indeed.co.uk", + "expansion.com", + "irpopup.ir", + "arvixe.com", + "secureinternetbank.com", + "csmonitor.com", + "carwale.com", + "mtime.com", + "ceconline.com", + "abchina.com", + "cgbchina.com.cn", + "mediotiempo.com", + "vic.gov.au", + "cnbeta.com", + "alarab.net", + "vietnamnet.vn", + "gay.com", + "watchmygf.net", + "myanimelist.net", + "bannersbroker.com", + "asklaila.com", + "heureka.cz", + "grepolis.com", + "meteofrance.com", + "bol.com", + "hasoffers.com", + "bigrock.in", + "ibanking-services.com", + "nos.nl", + "google.com.gh", + "beppegrillo.it", + "nhaccuatui.com", + "hamariweb.com", + "wikiquote.org", + "evite.com", + "jobdiagnosis.com", + "17track.net", + "baixing.com", + "awempire.com", + "healthgrades.com", + "unifiedlayer.com", + "thisav.com", + "himado.in", + "zcool.com.cn", + "tsn.ca", + "atlassian.net", + "binary500.com", + "alotporn.com", + "dnaindia.com", + "sherdog.com", + "www.nhs.uk", + "gruposantander.es", + "quantcast.com", + "usearchmedia.com", + "merchantcircle.com", + "blog.hu", + "wallstcheatsheet.com", + "iptorrents.com", + "apsense.com", + "redirsvc.com", + "indiarailinfo.com", + "mobile.ir", + "xvideo-jp.com", + "boxofficemojo.com", + "scamadviser.com", + "rotapost.ru", + "someecards.com", + "mydealz.de", + "lvye.cn", + "videoweed.es", + "xlovecam.com", + "pepperjamnetwork.com", + "khabarpu.com", + "mathrubhumi.com", + "online-convert.com", + "b92.net", + "tiptopsoft.org", + "el-balad.com", + "qihoo.com", + "iheart.com", + "campaign-archive1.com", + "photodune.net", + "labnol.org", + "kotobank.jp", + "medium.com", + "google.lu", + "tm1111.com", + "gigazine.net", + "mypcbackup.com", + "instantcheckmate.com", + "seemorgh.com", + "topky.sk", + "puu.sh", + "aeriagames.com", + "whatismyip.com", + "rising.cn", + "scotiabank.com", + "wo.com.cn", + "yootheme.com", + "channel4.com", + "heavy-r.com", + "omgpm.com", + "milli.az", + "bnpparibas.net", + "vmware.com", + "diretta.it", + "skycn.com", + "sap.com", + "zyalt.livejournal.com", + "bookryanair.com", + "kkbox.com", + "subtitleseeker.com", + "abckj123.com", + "mashreghnews.ir", + "websitewelcome.com", + "2ch-c.net", + "health.com", + "uproxx.com", + "uast.ac.ir", + "bol.uol.com.br", + "feedsportal.com", + "ip-adress.com", + "sedty.com", + "ilsistemabinario.com", + "nabble.com", + "hightail.com", + "superjob.ru", + "tokyo.jp", + "hrblock.com", + "china.cn", + "tsetmc.com", + "unfranchise.com.tw", + "bhg.com", + "htmlbook.ru", + "stardoll.com", + "crictime.com", + "hsn.com", + "royalmail.com", + "globallshare.com", + "wikiwiki.jp", + "petardas.com", + "usembassy.gov", + "rakuten-bank.co.jp", + "golem.de", + "stepstone.de", + "aucfan.com", + "stubhub.com", + "rbcdaily.ru", + "ro2.biz", + "huffingtonpost.ca", + "timeout.com", + "digitalspy.co.uk", + "foreningssparbanken.se", + "autodesk.com", + "98ia.com", + "gtbank.com", + "runetki.com", + "freshdesk.com", + "ieee.org", + "getpocket.com", + "jutarnji.hr", + "caisse-epargne.fr", + "profitcentr.com", + "51.com", + "oi.com.br", + "sina.com.tw", + "fontspace.com", + "dynamicdrive.com", + "maduradas.com", + "ligtv.com.tr", + "sport24.gr", + "stargazete.com", + "bola.net", + "template-help.com", + "codecademy.com", + "officedepot.com", + "researchgate.net", + "17u.com", + "gfxtra.com", + "weiphone.com", + "shoutmeloud.com", + "hc360.com", + "lintas.me", + "mk.ru", + "wplocker.com", + "thumbtack.com", + "szn.cz", + "yatra.com", + "societegenerale.fr", + "wyborcza.pl", + "demotywatory.pl", + "thomann.de", + "imperiaonline.org", + "magento.com", + "skillpages.com", + "cam4ads.com", + "spiceworks.com", + "homestead.com", + "locanto.in", + "hotelurbano.com", + "sinaimg.cn", + "chetxia.com", + "menshealth.com", + "ideacellular.com", + "snopes.com", + "newgrounds.com", + "autosottocosto.com", + "admob.com", + "linguee.fr", + "net-a-porter.com", + "text.ru", + "sharebeast.com", + "televisionfanatic.com", + "netlog.com", + "lufthansa.com", + "ngoisao.net", + "3911.net", + "worldssl.net", + "rabobank.nl", + "lvmama.com", + "sharethis.com", + "sambaporno.com", + "mci.ir", + "inosmi.ru", + "joyreactor.cc", + "cartfill.in", + "cooltext.com", + "qz.com", + "onthe.io", + "citilink.ru", + "apartmenttherapy.com", + "lloydsbank.com", + "metroer.com", + "koyotesoft.com", + "subdivx.com", + "alriyadh.com", + "backlinkwatch.com", + "coindesk.com", + "porntube1.xxx", + "zovi.com", + "thestreet.com", + "rtbstream.com", + "etnet.com.hk", + "creditkarma.com", + "lifebuzz.com", + "opodo.co.uk", + "developpez.net", + "tinydeal.com", + "nature.com", + "oxforddictionaries.com", + "anchorfree.net", + "tn.com.ar", + "findicons.com", + "joomlart.com", + "hmrc.gov.uk", + "btc-e.com", + "extra.com.br", + "ad.nl", + "megafon.ru", + "qafqazinfo.az", + "shahvani.com", + "googlecode.com", + "milliyet.tv", + "deadline.com", + "grindtv.com", + "logitech.com", + "nzherald.co.nz", + "ninisite.com", + "webgains.com", + "oschina.net", + "webmasters.ru", + "filmix.net", + "seowhy.com", + "met-art.com", + "discart.ru", + "keywordblocks.com", + "vodly.to", + "redvak.com", + "tomshardware.co.uk", + "2shared.com", + "zoznam.sk", + "icims.com", + "virtapay.com", + "blomaga.jp", + "wasu.cn", + "carsensor.net", + "sportsdirect.com", + "uservoice.com", + "livescience.com", + "gamebase.com.tw", + "persiangig.com", + "livesmi.com", + "eharmony.com", + "banorte.com", + "radiojavan.com", + "startv.com.tr", + "coolmath-games.com", + "downloadquick.net", + "worldoftanks.eu", + "filelist.ro", + "fontsquirrel.com", + "superpages.com", + "yolasite.com", + "funnie.st", + "51cto.com", + "goo-net.com", + "builtwith.com", + "shaparak.ir", + "nuomi.com", + "omegle.com", + "poringa.net", + "lan.com", + "desi-tashan.com", + "shabdkosh.com", + "freedigitalphotos.net", + "betradar.com", + "womenshealthmag.com", + "realsimple.com", + "maxbounty.com", + "bbva.es", + "sweetpacks.com", + "pinoy-ako.info", + "jobstreet.com", + "cafe24.com", + "goldenbirds.biz", + "anandtech.com", + "mapion.co.jp", + "rawstory.com", + "streamate.com", + "celebuzz.com", + "freepornvs.com", + "divyabhaskar.co.in", + "lifehack.org", + "holidaycheck.de", + "quizlet.com", + "zhibo8.cc", + "askmefast.com", + "manageflitter.com", + "campaign-archive2.com", + "cityheaven.net", + "uniqlo.com", + "seoclerks.com", + "tecmundo.com.br", + "the-binary-options-guide.com", + "gigaom.com", + "mywot.com", + "playcast.ru", + "tatadocomo.com", + "csfd.cz", + "ganool.com", + "kaschpo.ru", + "webdunia.com", + "philly.com", + "doctoroz.com", + "jumei.com", + "poponclick.com", + "rueducommerce.fr", + "fararu.com", + "po.st", + "nextag.com", + "manhunt.net", + "sistrix.com", + "woman.ru", + "appbank.net", + "iobit.com", + "joins.com", + "vidtomp3.com", + "un.org", + "volusion.com", + "lipsum.com", + "afkarnews.ir", + "goldenline.pl", + "clickansave.net", + "softgozar.com", + "thefind.com", + "mozzi.com", + "wenxuecity.com", + "up2c.com", + "searchfunmoods.com", + "cabelas.com", + "coffetube.com", + "otto.de", + "webalta.ru", + "tataindicom.com", + "ctvnews.ca", + "inlinkz.com", + "kajabi.com", + "greatergood.com", + "whmcs.com", + "telekom.de", + "christianpost.com", + "fiducia.de", + "bancsabadell.com", + "pirateproxy.net", + "woobox.com", + "google.cm", + "noulinx.com", + "nick.com", + "moviehuts.com", + "mvideo.ru", + "couchtuner.eu", + "wyborcza.biz", + "tradeindia.com", + "girlsgogames.com", + "healthcare.gov", + "videolan.org", + "sky.it", + "tuniu.com", + "ime.nu", + "n4g.com", + "cyberforum.ru", + "justin.tv", + "createspace.com", + "joemonster.org", + "registro.br", + "elkhabar.com", + "open24news.tv", + "irr.ru", + "sanjesh.org", + "standardbank.co.za", + "neogaf.com", + "doyo.cn", + "am15.net", + "ana.co.jp", + "amd.com", + "gidonlinekino.com", + "sitetalk.com", + "nesn.com", + "arabseed.com", + "ingbank.pl", + "webpronews.com", + "saavn.com", + "yourdictionary.com", + "mobile9.com", + "jagranjosh.com", + "www.net.cn", + "computerbase.de", + "3djuegos.com", + "htc.com", + "the-binary-theorem.com", + "google.com.np", + "n11.com", + "vivastreet.com", + "mthai.com", + "seomastering.com", + "mercadolibre.cl", + "searchmetrics.com", + "mentalfloss.com", + "russia.tv", + "ubi.com", + "dwnews.com", + "ecplaza.net", + "trafficfactory.biz", + "loopnet.com", + "refinery29.com", + "minecraftforum.net", + "moviefone.com", + "bom.gov.au", + "google.com.bh", + "eltiempo.es", + "cuantarazon.com", + "2258.com", + "google.ee", + "nwolb.com", + "bezaat.com", + "eelly.com", + "icmwebserv.com", + "techsmith.com", + "timeweb.ru", + "johnlewis.com", + "independent.ie", + "bankia.es", + "dkb.de", + "gilt.com", + "duolingo.com", + "3file.info", + "cam4.de.com", + "pcanalysis.net", + "br.de", + "vodlocker.com", + "adfoc.us", + "ymlp.com", + "dailyfx.com", + "business2community.com", + "banki.ru", + "yell.com", + "smartresponder.ru", + "yaske.to", + "bokra.net", + "mercadolibre.com", + "viewster.com", + "recipesfinder.com", + "rei.com", + "dogpile.com", + "caf.fr", + "sbrf.ru", + "soha.vn", + "voila.fr", + "rp-online.de", + "members.webs.com", + "duvamis.com", + "nazwa.pl", + "google.com.ni", + "ilovemobi.com", + "retrogamer.com", + "blogtalkradio.com", + "utexas.edu", + "sonyentertainmentnetwork.com", + "dr.dk", + "jjwxc.net", + "service-public.fr", + "care2.com", + "musavat.com", + "h12-media.com", + "smartfren.com", + "immowelt.de", + "discuz.net", + "m1905.com", + "cas.sk", + "bitcoinwisdom.com", + "monografias.com", + "mindbodygreen.com", + "getfirebug.com", + "godlikeproductions.com", + "mydrivers.com", + "voc.com.cn", + "truecaller.com", + "livemook.com", + "i8ti.com", + "agame.com", + "kurir-info.rs", + "urbanoutfitters.com", + "shopping.uol.com.br", + "2ip.ru", + "91.com", + "banquepopulaire.fr", + "rappler.com", + "mint.com", + "jz123.cn", + "zurb.com", + "sport.cz", + "justunfollow.com", + "billionuploads.com", + "thaivisa.com", + "seitwert.de", + "ciudad.com.ar", + "archdaily.com", + "jalopnik.com", + "1news.az", + "dailyfinance.com", + "okitspace.com", + "dn.se", + "el-nacional.com", + "larousse.fr", + "mojo-themes.com", + "draugiem.lv", + "teamtreehouse.com", + "xiu.com", + "ennaharonline.com", + "oricon.co.jp", + "openoffice.org", + "tny.cz", + "forumfree.it", + "youthwant.com.tw", + "khamsat.com", + "vitacost.com", + "alrakoba.net", + "marmiton.org", + "yebhi.com", + "the-binary-trader.biz", + "dominos.com", + "dice.com", + "like4like.org", + "tvmuse.com", + "standardchartered.com", + "bitbucket.org", + "driveropti.net", + "google.hn", + "indiblogger.in", + "torrenthound.com", + "wolframalpha.com", + "experienceproject.com", + "nsw.gov.au", + "olx.pt", + "sciencedaily.com", + "viglink.com", + "plala.or.jp", + "sxsw.com", + "mileroticos.com", + "namejet.com", + "1hai.cn", + "skroutz.gr", + "bilibili.tv", + "travelzoo.com", + "saksfifthavenue.com", + "get-a-fuck-tonight.com", + "barclaycardus.com", + "withgoogle.com", + "whitehouse.gov", + "oprah.com", + "fishwrapper.com", + "softbank.jp", + "slutload.com", + "latercera.cl", + "100bestbuy.com", + "nur.kz", + "topit.me", + "computerhope.com", + "snob.ru", + "rackcdn.com", + "3158.cn", + "artlebedev.ru", + "yobt.com", + "rai.it", + "hs.fi", + "tinhte.vn", + "fotocasa.es", + "nyu.edu", + "dawn.com", + "series.ly", + "movshare.net", + "fineartamerica.com", + "westernunion.com", + "leaseweb.com", + "wayn.com", + "ivi.ru", + "bloomingdales.com", + "pons.com", + "rapidtrk.com", + "bama.ir", + "hackforums.net", + "dfiles.eu", + "intercambiosvirtuales.org", + "sdo.com", + "homes.com", + "colissimo.fr", + "discuss.com.hk", + "afreeca.com", + "rbc.ua", + "novamov.com", + "jungle.gr", + "iol.co.za", + "btcclicks.com", + "mapsofindia.com", + "propellerads.com", + "fab.com", + "princeton.edu", + "reliancebroadband.co.in", + "xdf.cn", + "mako.co.il", + "protothema.gr", + "booloo.com", + "livrariasaraiva.com.br", + "efukt.com", + "acrobat.com", + "globovision.com", + "xero.com", + "sevenforums.com", + "semalt.com", + "audiojungle.net", + "e1.ru", + "quoka.de", + "chinaiiss.com", + "gonzoxxxmovies.com", + "wallpaperswide.com", + "fapvid.com", + "trk4.com", + "forosdelweb.com", + "fark.com", + "my.tv.sohu.com/user/video", + "kaixin001.com", + "ntvspor.net", + "mobafire.com", + "zigwheels.com", + "filmifullizle.com", + "8tracks.com", + "readmanga.eu", + "lelong.com.my", + "planetromeo.com", + "192.com", + "republika.co.id", + "in.gr", + "televisao.uol.com.br", + "kalerkantho.com", + "usairways.com", + "malaysiakini.com", + "anonymouse.org", + "xxxhost.me", + "stuff.co.nz", + "dek-d.com", + "bbvanet.com.mx", + "watchseries-online.eu", + "malaysiaairlines.com", + "policymic.com", + "serviporno.com", + "aprod.hu", + "gelocal.it", + "tradetracker.com", + "cibc.com", + "umich.edu", + "smartshe.com", + "sony.jp", + "taobaocdn.com", + "bestgfx.biz", + "irib.ir", + "aliimg.com", + "esuteru.com", + "healthline.com", + "cnnamador.com", + "sat.gob.mx", + "childsafedownloadx.asia", + "playmillion.com", + "strawberrynet.com", + "alnilin.com", + "trustedreviews.com", + "21cn.com", + "persianv.com", + "baomoi.com", + "firestorage.jp", + "google.co.ke", + "admaimai.com", + "sbnlife.com", + "surveyrouter.com", + "megaindex.ru", + "intodns.com", + "yiqifa.com", + "mixcloud.com", + "softonic.fr", + "bakecaincontrii.com", + "payu.in", + "rakuten-card.co.jp", + "almaany.com", + "grantland.com", + "ricardo.ch", + "heavy.com", + "niusnews.com", + "canstockphoto.com", + "acunn.com", + "diythemes.com", + "canalrcnmsn.com", + "ngs.ru", + "rassd.com", + "groupon.co.in", + "depositfiles.org", + "mango.com", + "theregister.co.uk", + "worldfree4u.com", + "f-lite.ru", + "boingboing.net", + "bangbros.com", + "neteller.com", + "tonicmovies.com", + "p2up.ir", + "cartoonnetwork.com", + "lun.com", + "nk.pl", + "webry.info", + "burningcamel.com", + "mplife.com", + "nationalreview.com", + "williamhill.es", + "sssc.cn", + "col3negoriginal.lk", + "yoast.com", + "svyaznoy.ru", + "chengdu.cn", + "listverse.com", + "lastminute.com", + "guardianlv.com", + "39yst.com", + "bahseazad.ir", + "debian.org", + "tokyo-porn-tube.com", + "ilbe.com", + "upsocl.com", + "balatarin.com", + "charter97.org", + "wpexplorer.com", + "immi.gov.au", + "yokamen.cn", + "esmas.com", + "hbr.org", + "livechatinc.com", + "crazyegg.com", + "palcomp3.com", + "calottery.com", + "wistia.com", + "locaweb.com.br", + "techspot.com", + "bit.ly", + "yammer.com", + "uscis.gov", + "bramjnet.com", + "linio.com.mx", + "tharunaya.co.uk", + "desirulez.net", + "madmimi.com", + "everydayhealth.com", + "secondlife.com", + "ceskatelevize.cz", + "enter.ru", + "glopart.ru", + "woso.cn", + "pitlap.info", + "worldoftanks.com", + "videarn.com", + "dafiti.com.br", + "segundamano.mx", + "eamroomsnacks.com", + "vulture.com", + "humblebundle.com", + "rockstargames.com", + "wsodownloads.info", + "yazete.com", + "pcadvisor.co.uk", + "07073.com", + "modcloth.com", + "attracta.com", + "iol.pt", + "travideos.com", + "sparkpeople.com", + "rankingsandreviews.com", + "entekhab.ir", + "goarticles.com", + "wonderhowto.com", + "kankanews.com", + "rzb.ir", + "p30download.com", + "infojobs.it", + "socialspark.com", + "picstopin.com", + "celebritynetworth.com", + "tweakers.net", + "gi-backoffice.com", + "isbank.com.tr", + "qiyou.com", + "templatic.com", + "cyberpresse.ca", + "consumerreports.org", + "focalprice.com", + "linkpad.ru", + "svd.se", + "desitvforum.net", + "bulbagarden.net", + "showup.tv", + "webgozar.com", + "3dnews.ru", + "spyfu.com", + "bikhir.ma", + "trovaprezzi.it", + "autov.com.cn", + "podnapisi.net", + "tocmai.ro", + "realitatea.net", + "geico.com", + "joydownload.com", + "kddi.com", + "unbounce.com", + "meb.gov.tr", + "anchorfree.us", + "gumtree.pl", + "dbs.com", + "ebayimg.com", + "ptcsolution.com", + "clip.dj", + "samplicio.us", + "47news.jp", + "todo1.com", + "anspress.com", + "24sata.hr", + "cineblog01.tv", + "sport-fm.gr", + "unetenet.com", + "tenki.jp", + "jia.com", + "filefactory.com", + "onedio.com", + "gendai.net", + "nickjr.com", + "finviz.com", + "bytes.com", + "inkthemes.com", + "oriflame.com", + "aporrea.org", + "mazika2day.com", + "baimao.com", + "logme.in", + "downloadactivate.com", + "vista.ir", + "duowan.com", + "sinaapp.com", + "proceso.com.mx", + "xxxconnect.com", + "dvdvideosoft.com", + "nomorerack.com", + "almubasher.com.sa", + "afisha.ru", + "clicksure.com", + "11st.co.kr", + "turkishairlines.com", + "freekaamaal.com", + "findwide.com", + "sbisec.co.jp", + "mythemeshop.com", + "webnode.com", + "cumhuriyet.com.tr", + "morningstar.com", + "trafficshop.com", + "gopro.com", + "jeevansathi.com", + "dasoertliche.de", + "markets.com", + "absa.co.za", + "ikman.lk", + "fmworld.net", + "hyatt.com", + "virgin-atlantic.com", + "tfl.gov.uk", + "immonet.de", + "haodf.com", + "thewrap.com", + "appgame.com", + "hdwallpapers.in", + "canon.com", + "newsle.com", + "jorudan.co.jp", + "pcwelt.de", + "coinbase.com", + "yourgirlfriends.com", + "djmaza.info", + "findagrave.com", + "lainformacion.com", + "teacup.com", + "ezilon.com", + "redbubble.com", + "guru.com", + "brothersoft.com", + "coinmarketcap.com", + "mediabistro.com", + "elfagr.org", + "glavcom.ua", + "jino.ru", + "1e100.net", + "g9g.com", + "join.me", + "ynet.com", + "news247.gr", + "rcom.co.in", + "baby.ru", + "argentglobalnetwork.com", + "hsselite.com", + "foxbusiness.com", + "cookmates.com", + "lidl.de", + "timesofindia.com", + "fakt.pl", + "bgr.com", + "ghatreh.com", + "woxikon.de", + "pontofrio.com.br", + "gizmag.com", + "signup.wordpress.com", + "tre.it", + "gardenweb.com", + "alfalfalfa.com", + "prcm.jp", + "freemail.hu", + "iteye.com", + "katproxy.com", + "kickassunblock.info", + "wisegeek.com", + "zaobao.com", + "vpsdomain4.eu", + "naij.com", + "olx.co.za", + "mihanstore.org", + "gezinti.com", + "vistaprint.in", + "dastelefonbuch.de", + "blackhatteam.com", + "yummly.com", + "minecraft.net", + "justcloud.com", + "biblehub.com", + "argentinawarez.com", + "gandul.info", + "trialpay.com", + "paruvendu.fr", + "khanacademy.org", + "topsy.com", + "angelfire.com", + "nseindia.com", + "seositecheckup.com", + "hostelworld.com", + "zalukaj.tv", + "animeflv.net", + "laptopmag.com", + "tripadvisor.de", + "sec.gov", + "tripadvisor.es", + "oreilly.com", + "kanald.com.tr", + "halifax-online.co.uk", + "extremetracking.com", + "reimageplus.com", + "jal.co.jp", + "vuiviet.net", + "yeslibertin.com", + "pichunter.com", + "empowernetwork.com/aI3zkH7s3g6tZH8TDmh8LA==", + "reforma.com", + "singlessalad.com", + "upenn.edu", + "1ting.com", + "hsbc.com.mx", + "sulia.com", + "yepporn.com", + "scrubtheweb.com", + "e-autopay.com", + "rechargeitnow.com", + "ppomppu.co.kr", + "zemtv.com", + "gofeminin.de", + "peoplestylewatch.com", + "france24.com", + "comodo.com", + "openmace.net", + "maultalk.com", + "fancy.com", + "vodafone.it", + "pokerstrategy.com", + "crunchyroll.com", + "aipai.com", + "3dcartstores.com", + "leancy.com", + "myblogguest.com", + "papajohns.com", + "tuolar.com", + "junkmail.co.za", + "nyc.gov", + "rentalcars.com", + "sovsport.ru", + "marketo.com", + "smbc.co.jp", + "yale.edu", + "pitchfork.com", + "thetoptens.com", + "joyme.com", + "linuxquestions.org", + "htmlgoodies.com", + "laredoute.fr", + "0427d7.se", + "journaldesfemmes.com", + "xici.net", + "alwafd.org", + "daniweb.com", + "mtgox.com", + "jetstar.com", + "plotek.pl", + "jobvite.com", + "adage.com", + "aukro.cz", + "ford.com", + "problogger.net", + "518.com.tw", + "blogbigtime.com", + "nieuwsblad.be", + "register.com", + "24tv.ua", + "aftenposten.no", + "weightwatchers.com", + "smartpassiveincome.com", + "radiosvoboda.org", + "web.com", + "caixin.com", + "digitalmarketer.com", + "soup.io", + "soft98.ir", + "muzofon.com", + "gao7.com", + "freefilmshd.com", + "hsbc.com", + "xhamsterhq.com", + "my.tv.sohu.com/user/reg", + "trade65.com", + "chow.com", + "google.com.kh", + "inps.it", + "seesaa.jp", + "hoovers.com", + "peru21.pe", + "sdpnoticias.com", + "schema.org", + "linode.com", + "theknot.com", + "blesk.cz", + "google.ci", + "loltrk.com", + "vod.pl", + "geenstijl.nl", + "moneymakergroup.com", + "tupaki.com", + "huvrtech.com", + "metafilter.com", + "jumia.com.ng", + "newsvine.com", + "mylant.com", + "accenture.com", + "feedjit.com", + "twipple.jp", + "getgoodlinks.ru", + "radiofarda.com", + "informador.com.mx", + "wisc.edu", + "windows.net", + "zamzar.com", + "nationalpost.com", + "epnet.com", + "naaptol.com", + "x-art.com", + "ebookbrowsee.net", + "marketingland.com", + "thedailyshow.com", + "s-oman.net", + "theme-fusion.com", + "immobiliare.it", + "allvoices.com", + "adroll.com", + "francetvinfo.fr", + "callandput.com", + "entireweb.com", + "instructure.com", + "megacinema.fr", + "djelfa.info", + "flightaware.com", + "magazineluiza.com.br", + "ighome.com", + "mature-beauty.com", + "yuku.com", + "peerfly.com", + "hardware.fr", + "dcinside.com", + "telerik.com", + "pengpeng.com", + "gazetaexpress.com", + "publico.es", + "nwsource.com", + "oneandone.co.uk", + "qoo10.sg", + "aboutus.org", + "adsupplyads.com", + "wa.gov", + "google.co.cr", + "benchmarkemail.com", + "valuedealshopper.com", + "hola.com", + "mizuhobank.co.jp", + "zzstream.li", + "kriesi.at", + "exist.ru", + "nvidia.com", + "giallozafferano.it", + "jusbrasil.com.br", + "konga.com", + "avclub.com", + "reed.co.uk", + "advertig.com", + "ripoffreport.com", + "gooddrama.net", + "pornyaz.com", + "budsgunshop.com", + "78.cn", + "livesurf.ru", + "99114.com", + "pornorama.com", + "marksandspencer.com", + "vmall.com", + "fatcow.com", + "mylife.com", + "irishtimes.com", + "medicalnewstoday.com", + "uiuc.edu", + "groupon.it", + "washington.edu", + "addictinggames.com", + "anonymz.com", + "kindgirls.com", + "jne.co.id", + "guiamais.com.br", + "lyricsfreak.com", + "uloz.to", + "tagesanzeiger.ch", + "fashionandyou.com", + "bollywoodhungama.com", + "nationwide.co.uk", + "kboing.com.br", + "python.org", + "theladbible.com", + "eurosport.com", + "webinarjam.com", + "theme.wordpress.com", + "myfxbook.com", + "allwomenstalk.com", + "ucla.edu", + "opendns.com", + "pornbb.org", + "money.pl", + "domain.com.au", + "standaard.be", + "wanelo.com", + "express.co.uk", + "exam8.com", + "zum.com", + "amtrak.com", + "boots.com", + "800notes.com", + "fabfurnish.com", + "amoureux.com", + "ebizmba.com", + "ujian.cc", + "stargames.at", + "panasonic.com", + "ge.tt", + "scout.com", + "tiexue.net", + "nanapi.jp", + "eclipse.org", + "searchquotes.com", + "wetplace.com", + "lpcloudbox300.com", + "hollyscoop.com", + "bdjobs.com", + "larepublica.pe", + "hizliresim.com", + "yepme.com", + "bitcoincharts.com", + "bsnl.co.in", + "ucwan87.net", + "tianji.com", + "hgtv.com", + "cleanfiles.net", + "moonsy.com", + "tomsguide.com", + "datpiff.com", + "net.hr", + "orange.pl", + "bankrate.com.cn", + "mafiashare.net", + "giaoduc.net.vn", + "sucuri.net", + "ringcentral.com", + "gamingwonderland.com", + "freenet.de", + "cian.ru", + "gayboystube.com", + "gog.com", + "gruenderszene.de", + "econsultancy.com", + "aktuality.sk", + "webrankstats.com", + "j-cast.com", + "popsugar.com", + "mr-guangdong.com", + "on.cc", + "jb51.net", + "lamoda.ru", + "sprashivai.ru", + "animoto.com", + "winzip.com", + "vanityfair.com", + "svt.se", + "noyapps.com", + "mnn.com", + "lancenet.com.br", + "e-monsite.com", + "gazeta.ua", + "cari.com.my", + "coub.com", + "veoh.com", + "kienthuc.net.vn", + "eldorado.ru", + "overclock.net", + "meetic.fr", + "tam.com.br", + "alfemminile.com", + "telmex.com", + "newsbomb.gr", + "funda.nl", + "netcoc.com", + "bhinneka.com", + "layalina.com", + "clubpenguin.com", + "talktalk.co.uk", + "dumpert.nl", + "almastba.com", + "clker.com", + "adweek.com", + "gigya.com", + "disponivel.uol.com.br", + "tomoson.com", + "w.org", + "rfi.fr", + "imgbox.com", + "omniture.com", + "n24.de", + "webdesignrazzi.com", + "medscape.com", + "playboy.com", + "usda.gov", + "cuevana.tv", + "trenitalia.com", + "explosm.net", + "mail.uol.com.br", + "delfi.lv", + "elektroda.pl", + "hulkshare.com", + "kotak.com", + "gi-akademie.ning.com", + "yelp.de", + "lrytas.lt", + "couchsurfing.org", + "drugstore.com", + "ssa.gov", + "seriescoco.com", + "iran-tejarat.com", + "hafiz.gov.sa", + "intellicast.com", + "sub.jp", + "paginasamarillas.es", + "anime44.com", + "babyschool.com.cn", + "advertisernets.com", + "vpsdomain2.eu", + "arcor.de", + "video2mp3.net", + "marthastewart.com", + "hawahome.com", + "articlesbase.com", + "spanishdict.com", + "meilishuo.com", + "grammarly.com", + "sportlemon.tv", + "zend.com", + "bigideamastermind.com", + "hawaaworld.com", + "pagseguro.uol.com.br", + "keywordspy.com", + "7search.com", + "cnki.net", + "aamaadmiparty.org", + "javaplayer.info", + "sidereel.com", + "azcentral.com", + "passportindia.gov.in", + "memurlar.net", + "bouyguestelecom.fr", + "buenastareas.com", + "ernmoneynow.com", + "eurosport.ru", + "blog.163.com", + "pizzahut.com", + "bossip.com", + "webdeveloper.com", + "add-anime.net", + "pimptubed.com", + "movistar.es", + "megashare.sh", + "empireavenue.com", + "btemplates.com", + "amkspor.com", + "payza.com", + "farfesh.com", + "mcgraw-hill.com", + "motor-talk.de", + "purepeople.com", + "i-gamer.net", + "sotmarket.ru", + "anthropologie.com", + "google.org", + "rai.tv", + "wikidot.com", + "canoe.ca", + "orange.es", + "umn.edu", + "emag.ro", + "webutations.org", + "ykb.com", + "canadapost.ca", + "zhubajie.com", + "nextcar.cn", + "next.co.uk", + "freemovie-hd.com", + "telegraf.com.ua", + "ajc.com", + "xsrv.jp", + "vanguard.com", + "mybroadband.co.za", + "999120.net", + "panet.co.il", + "bellemaison.jp", + "fonearena.com", + "playvid.com", + "purdue.edu", + "thesuperficial.com", + "114so.cn", + "irna.ir", + "websitetonight.com", + "edublogs.org", + "provincial.com", + "jahaniha.com", + "heroturko.me", + "dynadot.com", + "txtsrving.info", + "adclickxpress.com", + "sammobile.com", + "ebay.at", + "yaplog.jp", + "imtranslator.net", + "fotor.com", + "myvidster.com", + "williamhill.it", + "argaam.com", + "zoomby.ru", + "tcsbank.ru", + "origin.com", + "vov.vn", + "wrapbootstrap.com", + "imvu.com", + "fbsbx.com", + "elcorteingles.es", + "cerdas.com", + "google.com.om", + "dramasonline.com", + "businesswire.com", + "serpbook.com", + "santanderrio.com.ar", + "meta.ua", + "kenhgioitre.com", + "watchcartoononline.com", + "athome.co.jp", + "2checkout.com", + "moheet.com", + "jeu.info", + "ankieta-online.pl", + "triberr.com", + "wordtracker.com", + "blogher.com", + "colourlovers.com", + "maalaimalar.com", + "bakeca.it", + "thepostgame.com", + "beget.ru", + "abebooks.com", + "certified-toolbar.com", + "publico.pt", + "footmercato.net", + "indiabix.com", + "zakzak.co.jp", + "hotfile.com", + "virustotal.com", + "usgs.gov", + "tukif.com", + "banglamail24.com", + "graphicstock.com", + "svpressa.ru", + "sanalpazar.com", + "logsoku.com", + "loteriasyapuestas.es", + "youjizzlive.com", + "all-inkl.com", + "arcot.com", + "blogspot.fi", + "inbox.lv", + "anno-online.com", + "tikona.in", + "newsru.ua", + "centerblog.net", + "jahannews.com", + "joxi.ru", + "proxybay.eu", + "2gis.ru", + "indeed.fr", + "novayagazeta.ru", + "intelius.com", + "hosteurope.de", + "autoscout24.it", + "postjoint.com", + "pulsk.com", + "biobiochile.cl", + "homevv.com", + "zapbux.com", + "gsp.ro", + "priyo.com", + "jamnews.ir", + "addtoany.com", + "lookbook.nu", + "e-travel.com", + "themelock.com", + "bestsocialfeed.com", + "eqla3.com", + "klm.com", + "realtor.ca", + "tv2.no", + "jqueryrain.com", + "seo-fast.ru", + "academic.ru", + "clicksia.com", + "lpcloudbox30.com", + "worldpay.com", + "gogoanime.com", + "photoshelter.com", + "mlive.com", + "wetteronline.de", + "jkforum.net", + "secure.ipage.com", + "antena3.com", + "elsevier.com", + "thaiseoboard.com", + "addic7ed.com", + "rookee.ru", + "jstor.org", + "rajanews.com", + "uline.com", + "o2online.de", + "fbdownloader.com", + "wetpaint.com", + "nnm.me", + "50onred.com", + "tvtropes.org", + "philips.com", + "watchseries.to", + "perfectinter.net", + "progressive.com", + "stcn.com", + "golsearch.com", + "sarayanews.com", + "screenrant.com", + "macworld.com", + "classifiedads.com", + "ip138.com", + "izlesene.com", + "ovguide.com", + "gametop.com", + "urlm.co", + "isitdownrightnow.com", + "redhat.com", + "stafaband.info", + "biglion.ru", + "twitterfeed.com", + "ttnet.com.tr", + "panasonic.jp", + "loc.gov", + "telstra.com.au", + "jiathis.com", + "perfil.com.ar", + "inquisitr.com", + "ratp.fr", + "libertaddigital.com", + "bni.co.id", + "ycombinator.com", + "paginegialle.it", + "momoshop.com.tw", + "theweek.com", + "tuoitre.vn", + "scriptmafia.org", + "megavod.fr", + "indiavisiontv.com", + "history.com", + "flyeralarm.com", + "salespider.com", + "ard.de", + "dslreports.com", + "tokyo-tube.com", + "brazzersnetwork.com", + "bonanza.com", + "storenvy.com", + "37signals.com", + "jxnews.com.cn", + "1sale.com", + "allanalpass.com", + "yiiframework.com", + "kimsufi.com", + "nastygal.com", + "immoral.jp", + "icq.com", + "loxblog.com", + "jcrew.com", + "diamond.jp", + "nissen.co.jp", + "fxstreet.com", + "15min.lt", + "lifo.gr", + "alef.ir", + "iis.net", + "giphy.com", + "mypopup.ir", + "bsnl.in", + "distractify.com", + "foro20.com", + "chachaba.com", + "fx-trend.com", + "imanhua.com", + "playxn.com", + "gocomics.com", + "lcl.fr", + "hsw.cn", + "ellislab.com", + "persiantools.com", + "coupondunia.in", + "fengniao.com", + "coinmill.com", + "freelancer.in", + "blogdetik.com", + "data.com", + "trafficjunky.net", + "neverblue.com", + "flvto.com", + "lijit.com", + "zaycev.net", + "salamnews.org", + "siliconrus.com", + "dv37.com", + "conrad.de", + "ascii.jp", + "yesfreeporn.com", + "globalpost.com", + "d4000.com", + "dobreprogramy.pl", + "hammihan.com", + "wjunction.com", + "liverpoolfc.tv", + "nordea.fi", + "mail2web.com", + "songkick.com", + "comicbookresources.com", + "jwplayer.com", + "moi.gov.sa", + "iranecar.com", + "kayako.com", + "listal.com", + "technet.com", + "infonews.com", + "fun698.com", + "frys.com", + "vectorstock.com", + "vbox7.com", + "leroymerlin.fr", + "gpotato.eu", + "gulfnews.com", + "hot-sex-tube.com", + "buzzle.com", + "uludagsozluk.com", + "onlinefastpaydayloan.com", + "forumcommunity.net", + "potins.net", + "bwin.es", + "lobstertube.com", + "katestube.com", + "endomondo.com", + "navalny.livejournal.com", + "wayport.net", + "dealspl.us", + "pixhost.org", + "webopedia.com", + "flagcounter.com", + "hotnewhiphop.com", + "matomy.com", + "privat24.ua", + "fuq.com", + "readserver.net", + "haiwainet.cn", + "light-dark.net", + "decolar.com", + "tlbb8.com", + "tomtom.com", + "fontanka.ru", + "tchibo.de", + "slutfinder.com", + "rbc.cn", + "pepperfry.com", + "freshersworld.com", + "mob.org", + "brobible.com", + "phim3s.net", + "parsiblog.com", + "link-assistant.com", + "smotri.com", + "flyertalk.com", + "iefimerida.gr", + "pornyeah.com", + "trustpilot.com", + "wowslider.com", + "sekindo.com", + "shape.com", + "pizap.com", + "bluedart.com", + "cmu.edu", + "shueisha.co.jp", + "royal-search.com", + "123greetings.com", + "albawabhnews.com", + "holiday-weather.com", + "4travel.jp", + "lpcloudsvr203.com", + "panorama.com.ve", + "htcmania.com", + "skorer.tv", + "mymovies.it", + "fileice.net", + "1and1.fr", + "legiaodosherois.com.br", + "tomsguide.fr", + "baymirror.com", + "thesun.co.uk", + "huffingtonpost.es", + "61baobao.com", + "juegos.com", + "joyclub.de", + "qatarairways.com", + "ayosdito.ph", + "translate.ru", + "yithemes.com", + "buyvip.com", + "pearltrees.com", + "thinkprogress.org", + "twitcasting.tv", + "lusongsong.com", + "irecommend.ru", + "aukro.ua", + "eldiario.es", + "pop-music.ir", + "libertytimes.com.tw", + "themalaysianinsider.com", + "paddypower.it", + "delfi.ee", + "appthemes.com", + "tdameritrade.com", + "flashback.org", + "tubelib.com", + "claro.com.br", + "jotform.com", + "bigresource.com", + "libsyn.com", + "sendgrid.com", + "silikonvadisi.tv", + "geo.tv", + "pricegrabber.com", + "futhead.com", + "testberichte.de", + "skybet.com", + "wpcentral.com", + "lesnumeriques.com", + "clientoo.com", + "mathsisfun.com", + "expert.ru", + "maxptp.com", + "mediaite.com", + "regions.com", + "fast-torrent.ru", + "enlacespepito.com", + "redtram.com", + "benesse.ne.jp", + "jappy.de", + "wizzair.com", + "adevarul.ro", + "mhlw.go.jp", + "dev-point.com", + "ibtimes.co.in", + "coinwarz.com", + "slidesharecdn.com", + "classmates.com", + "tsite.jp", + "niazerooz.com", + "jma.go.jp", + "motherjones.com", + "easports.com", + "elbotola.com", + "tripadvisor.com.au", + "rozee.pk", + "vivanuncios.com.mx", + "lashou.com", + "theaustralian.com.au", + "superstarmagazine.com", + "zedge.net", + "hardwarezone.com.sg", + "yyets.com", + "nowgamez.com", + "blogspot.ch", + "gq.com", + "adidas.com", + "uyan.cc", + "dailydot.com", + "xenforo.com", + "ilmessaggero.it", + "state.nj.us", + "16888.com", + "searchengines.guru", + "nascar.com", + "dnb.no", + "smosh.com", + "shinyinnovation.com", + "who.int", + "mybet.com", + "yoo7.com", + "xrea.com", + "fotolog.net", + "smartprix.com", + "esquire.com", + "google.com.cy", + "santander.com.br", + "realclearpolitics.com", + "financereports24.com", + "onlinesoccermanager.com", + "noticiaaldia.com", + "kelkoo.com", + "drakulastream.eu", + "vodafone.de", + "bt.dk", + "greenwichmeantime.com", + "ufc.com", + "webstatsdomain.org", + "taoche.com", + "thinkgeek.com", + "caranddriver.com", + "123-reg.co.uk", + "translit.ru", + "w3school.com.cn", + "zwinky.com", + "inboxdollars.com", + "gratka.pl", + "vecernji.hr", + "taikang.com", + "bolshoyvopros.ru", + "urbita.com", + "api.ning.com", + "alltop.com", + "readwrite.com", + "medhelp.org", + "totaljobs.com", + "accorhotels.com", + "prom.ua", + "cuny.edu", + "livemint.com", + "berlin.de", + "blogspot.hk", + "orkut.com.br", + "lzjl.com", + "metric-conversions.org", + "nationalrail.co.uk", + "oxu.az", + "mql5.com", + "chinaluxus.com", + "linguee.es", + "saudiairlines.com", + "standardmedia.co.ke", + "alkislarlayasiyorum.com", + "apk.tw", + "lesoir.be", + "whatculture.com", + "indiewire.com", + "pccomponentes.com", + "paytm.in", + "ebaypartnernetwork.com", + "haivl.tv", + "e-junkie.com", + "tvp.pl", + "ifilez.org", + "aristeguinoticias.com", + "bangkokpost.com", + "whatmobile.com.pk", + "prodavalnik.com", + "arsenal.com", + "buyma.com", + "torrentday.com", + "sammydress.com", + "blogcu.com", + "imore.com", + "shitaraba.com", + "pasadrexam2014.in", + "songspk.at", + "eforosh.com", + "nocoty.pl", + "koreus.com", + "verticalresponse.com", + "arte.tv", + "ocnk.net", + "cryptsy.com", + "haaretz.com", + "straitstimes.com", + "2domains.ru", + "usnetads.com", + "pracuj.pl", + "edreams.it", + "sba.gov", + "instabang.com", + "domainnamesales.com", + "teensnow.com", + "visualwebsiteoptimizer.com", + "blogos.com", + "santander.com.mx", + "solidfiles.com", + "authorstream.com", + "teslamotors.com", + "tema.livejournal.com", + "kolesa.kz", + "startribune.com", + "vevo.com", + "clien.net", + "3asq.com", + "tvnet.lv", + "mouthshut.com", + "binary-machine.com", + "adultwork.com", + "hypebeast.com", + "itrack.it", + "network-tools.com", + "brandsoftheworld.com", + "comedycentral.com", + "hotscripts.com", + "meristation.com", + "rlsbb.com", + "uzai.com", + "volkskrant.nl", + "terra.com.mx", + "howtoforge.com", + "178.com", + "wickedfire.com", + "dilandau.eu", + "seriales.us", + "xataka.com", + "hktdc.com", + "express.pk", + "surfcanyon.com", + "buildhr.com", + "ouest-france.fr", + "stltoday.com", + "alternet.org", + "site5.com", + "payserve.com", + "society6.com", + "douguo.com", + "prosieben.de", + "verywed.com", + "enikos.gr", + "tubewolf.com", + "openrice.com", + "blankrefer.com", + "gouv.qc.ca", + "torrentfreak.com", + "craveonline.com", + "unfollowers.com", + "deser.pl", + "quanjing.com", + "runetki.tv", + "yepi.com", + "socialbakers.com", + "webmotors.com.br", + "mmo-champion.com", + "globososo.com", + "whois.sc", + "sportskeeda.com", + "socialblade.com", + "jin115.com", + "avjavjav.com", + "thenewstribe.com", + "pinkrod.com", + "blox.pl", + "mediamarkt.de", + "vivo.com.br", + "facilisimo.com", + "sinarharian.com.my", + "leguide.com", + "voegol.com.br", + "j.gs", + "okgj.com", + "revolveclothing.com", + "lolinez.com", + "go2cloud.org", + "vmoptions.com", + "myip.ms", + "ay.gy", + "liquidweb.com", + "sbi.co.in", + "alamaula.com", + "reshareable.tv", + "stirileprotv.ro", + "siriusxm.com", + "banvenez.com", + "sergey-mavrodi-mmm.net", + "ocj.com.cn", + "elderscrollsonline.com", + "webaslan.com", + "dereferer.org", + "newsbeast.gr", + "778669.com", + "yeucahat.com", + "guitarcenter.com", + "mercurynews.com", + "channeladvisor.com", + "go2000.com", + "google.ge", + "pandora.tv", + "haqqin.az", + "google.tt", + "32d1d3b9c.se", + "sexdatenow.net", + "befunky.com", + "micromaxinfo.com", + "jquerymobile.com", + "radikal.ru", + "wigetmedia.com", + "girlsplay.com", + "pureleverage.com", + "mathxl.com", + "themefuse.com", + "giga.de", + "freevideo.cz", + "stylebistro.com", + "iwriter.com", + "winporn.com", + "tripadvisor.ca", + "atresplayer.com", + "igma.tv", + "ravelry.com", + "semana.com", + "verycd.com", + "sblo.jp", + "fansided.com", + "goalunited.org", + "petfinder.com", + "worthofweb.com", + "memuruz.net", + "njuskalo.hr", + "yellowpages.ca", + "91jm.com", + "webconfs.com", + "interpals.net", + "erepublik.com", + "akismet.com", + "gaadi.com", + "casasbahia.com.br", + "techsupportalert.com", + "bostonglobe.com", + "uploadable.ch", + "smartprofitsystem.com", + "cimbclicks.com.my", + "uwants.com", + "gamestar.de", + "neowin.net", + "inilah.com", + "toster.ru", + "gosuslugi.ru", + "windguru.cz", + "3366.com", + "beinsports.net", + "vector.co.jp", + "memecenter.com", + "hotnews.ro", + "webgame.web.id", + "llnw.com", + "jobstreet.co.id", + "congratulations-you-won.com", + "libertatea.ro", + "app111.com", + "scientificamerican.com", + "strava.com", + "iranjib.ir", + "coneco.net", + "fdrmx.com", + "nps.gov", + "businessinsider.in", + "uniblue.com", + "proporn.com", + "dm5.com", + "qld.gov.au", + "nexusmods.com", + "mandatory.com", + "moskva.fm", + "prosperityteam.com", + "lent.az", + "appbrain.com", + "24smi.org", + "avaxsearch.com", + "gorillavid.in", + "realgm.com", + "favicon.cc", + "astro.com", + "joomlaforum.ru", + "joystiq.com", + "computerworld.com", + "tvspielfilm.de", + "centos.org", + "bugun.com.tr", + "amctv.com", + "relianceada.com", + "papystreaming.com", + "clickindia.com", + "sayyac.com", + "q.gs", + "bravoerotica.com", + "bibsonomy.org", + "netload.in", + "shopatron.com", + "iautos.cn", + "banggood.com", + "commerzbanking.de", + "legacyclix.com", + "intesasanpaolo.com", + "awesomescreenshot.com", + "desidime.com", + "eporner.com", + "alwatanvoice.com", + "ok.ru", + "europe1.fr", + "karnaval.com", + "tornn-tv.com", + "frmtr.com", + "pulscen.ru", + "groupon.co.uk", + "tradera.com", + "comingsoon.net", + "speckyboy.com", + "cargurus.com", + "citysearch.com", + "brother.com", + "acfun.tv", + "jamejamonline.ir", + "enterprise.com", + "elotrolado.net", + "userscripts.org", + "confirmit.com", + "compete.com", + "auctiva.com", + "potterybarn.com", + "ivoox.com", + "multiupload.nl", + "glavnoe.ua", + "p30world.com", + "snapnames.com", + "filmon.com", + "flipkey.com", + "rhhbschool.com", + "worldbank.org", + "proz.com", + "docusign.net", + "akakce.com", + "empflix.com", + "androidforums.com", + "mos.ru", + "contenko.com", + "malwarebytes.org", + "voyeurhit.com", + "filmvz.com", + "windowsazure.com", + "rlslog.net", + "zulagames.com", + "onlinefinder.net", + "blekko.com", + "tvb.com", + "mojomarketplace.com", + "warnerbros.com", + "rogers.com", + "sparkasse.at", + "bigcinema.tv", + "mattcutts.com", + "vemale.com", + "pgatour.com", + "bakusai.com", + "lavozdegalicia.es", + "style.com", + "torrentino.com", + "activeden.net", + "sweetpacks-search.com", + "pcstore.com.tw", + "starmedia.com", + "lycos.com", + "uncomo.com", + "caribbeancom.com", + "googleping.com", + "sondakika.com", + "premiumwp.com", + "tribune.com.pk", + "sc.com", + "91mobiles.com", + "elle.com", + "motortrend.com", + "starsports.com", + "otlan.com", + "planetminecraft.com", + "oregonlive.com", + "publichd.se", + "financialexpress.com", + "huxiu.com", + "hotwords.com", + "asda.com", + "impiego24.it", + "tunisia-sat.com", + "xojane.com", + "shiftdelete.net", + "hamshahrionline.ir", + "mp3.es", + "minutebuzz.com", + "footlocker.com", + "rusnovosti.ru", + "defencenet.gr", + "ndr.de", + "blogosfera.uol.com.br", + "quibids.com", + "soft32.com", + "davidwalsh.name", + "blogun.ru", + "webbirga.net", + "dict.cn", + "groupon.jp", + "abovetopsecret.com", + "contra.gr", + "zn.ua", + "jetbrains.com", + "myus.com", + "redbus.in", + "creativemarket.com", + "uainfo.org", + "rtbf.be", + "forexpf.ru", + "mainlink.ru", + "fantasti.cc", + "usagc.org", + "narutoget.com", + "trendyol.com", + "carsales.com.au", + "fujitv.co.jp", + "dardarkom.com", + "corrieredellosport.it", + "mcanime.net", + "nolo.com", + "beareyes.com.cn", + "familysearch.org", + "eprice.com.tw", + "indonetwork.co.id", + "geizhals.at", + "watchfreemovies.ch", + "siweiw.com", + "elnuevoherald.com", + "codecupdaters.com", + "p1.com", + "imhonet.ru", + "spox.com", + "spreadshirt.com", + "bittorrent.com", + "airberlin.com", + "epicurious.com", + "adverstitial.com", + "researchnow.com", + "lolnexus.com", + "xbabe.com", + "designmodo.com", + "hamusoku.com", + "radioshack.com", + "teamliquid.net", + "helpster.de", + "globalsources.com", + "fasttech.com", + "dickssportinggoods.com", + "j-sen.jp", + "smashwords.com", + "adversal.com", + "musiciansfriend.com", + "whoishostingthis.com", + "ads8.com", + "trend4pay.com", + "tribune.com", + "xsrving.com", + "youngleafs.com", + "gamersky.com", + "podio.com", + "state.pa.us", + "iphoneogram.com", + "datehookup.com", + "hbs.edu", + "ally.com", + "mitbbs.com", + "siasat.pk", + "miratuserie.tv", + "active.com", + "ricardoeletro.com.br", + "html.it", + "minnano-av.com", + "meetly.in", + "denverpost.com", + "supersport.com", + "grupobancolombia.com", + "freemake.com", + "bankier.pl", + "instapaper.com", + "derwesten.de", + "blogspot.hu", + "tamindir.com", + "play.pl", + "warthunder.com", + "team-bhp.com", + "freepeople.com", + "laposte.fr", + "cnews.ru", + "fayerwayer.com", + "hitta.se", + "hao123.com.eg", + "it-ebooks.info", + "freep.com", + "newser.com", + "lexilogos.com", + "polldaddy.com", + "auspost.com.au", + "aib.ie", + "cs.com.cn", + "providesupport.com", + "unblocksit.es", + "twittercounter.com", + "luisaviaroma.com", + "imgbabes.com", + "tharunee.lk", + "nexon.com", + "airliners.net", + "srf.ch", + "angel.co", + "tokyo-sports.co.jp", + "mt5.com", + "down1oads.com", + "vodonet.net", + "axar.az", + "taknaz.ir", + "google.com.py", + "ss.lv", + "stuffgate.com", + "giveawayoftheday.com", + "climatempo.com.br", + "xnxxmovies.com", + "heartinternet.co.uk", + "digikey.com", + "zimbra.free.fr", + "line.me", + "talkingpointsmemo.com", + "dyn.com", + "exacttarget.com", + "yourtango.com", + "shopping.com", + "king.com", + "crackberry.com", + "sm3na.com", + "matchesfashion.com", + "rk.com", + "ems.com.cn", + "xiaomi.cn", + "hillnews.com", + "geforce.com", + "internetslang.com", + "theoldreader.com", + "digitaljournal.com", + "aol.co.uk", + "straightdope.com", + "farfetch.com", + "lupoporno.com", + "ilgiornale.it", + "binzhi.com", + "loveplanet.ru", + "sogi.com.tw", + "googlevideo.com", + "nintendo.com", + "jreast.co.jp", + "coinad.com", + "keek.com", + "chegg.com", + "sparknotes.com", + "mywapblog.com", + "idlebrain.com", + "boardgamegeek.com", + "daserste.de", + "nicozon.net", + "ampnetzwerk.de", + "agenziaentrate.gov.it", + "apec.fr", + "redbull.com", + "listentoyoutube.com", + "diepresse.com", + "gohappy.com.tw", + "morguefile.com", + "dallasnews.com", + "adxpansion.com", + "almos3a.com", + "updatetube.com", + "lowyat.net", + "lolipop.jp", + "terafile.co", + "eversave.com", + "sportingnews.com", + "517dv.com", + "milfmovs.com", + "myflorida.com", + "brooonzyah.net", + "cdn-cachefront.net", + "ig.com", + "indiapost.gov.in", + "hangame.co.jp", + "ithemes.com", + "monova.org", + "udmserve.net", + "impactradius.com", + "teasernet.com", + "gmx.at", + "mmotraffic.com", + "citehr.com", + "viator.com", + "rt.ru", + "japannetbank.co.jp", + "zonealarm.com", + "ebayclassifieds.com", + "safecart.com", + "proptp.net", + "51hejia.com", + "telkomsel.com", + "deutschepost.de", + "startpagina.nl", + "alexaboostup.com", + "istgah.com", + "aufreeads.com", + "thinkstockphotos.com", + "similarsitesearch.com", + "gossiplankanews.com", + "venere.com", + "javascriptkit.com", + "square-enix.com", + "tvtoday.de", + "netaffiliation.com", + "computrabajo.com.mx", + "arioo.com", + "fromdoctopdf.com", + "lookany.com", + "bleepingcomputer.com", + "perfectmoney.com", + "dorkly.com", + "macmillandictionary.com", + "fotka.pl", + "porntubevidz.com", + "rj.gov.br", + "1.1.1.1", + "ebay.be", + "divxplanet.com", + "cyworld.com", + "biography.com", + "p1.cn", + "bazos.sk", + "55.la", + "lockerdome.com", + "yola.com", + "ccbill.com", + "groupon.de", + "okazii.ro", + "izismile.com", + "velvet.hu", + "news-postseven.com", + "ardmediathek.de", + "sagawa-exp.co.jp", + "sarzamindownload.com", + "pdfonline.com", + "gaaks.com", + "azhibo.com", + "pensador.uol.com.br", + "surveygizmo.com", + "familydoctor.com.cn", + "lazada.vn", + "guokr.com", + "enjoydressup.com", + "sky.de", + "afp.com", + "imujer.com", + "livescore.net", + "xinnet.com", + "mypageresults.com", + "safaribooksonline.com", + "extremetech.com", + "ecnavi.jp", + "babyblog.ru", + "practicalecommerce.com", + "vidspot.net", + "studymode.com", + "nation.co.ke", + "cpmrocket.com", + "es.wix.com", + "google.com.cu", + "pravda.ru", + "cda.pl", + "appszoom.com", + "selfhtml.org", + "zmovie.tw", + "dba.dk", + "domain.com", + "brightcove.com", + "lol55.com", + "textsale.ru", + "casualclub.com", + "gudvin.tv", + "torrentreactor.net", + "downloadcamp.com", + "eset.com", + "softonic.it", + "internations.org", + "retre.org", + "3quan.com", + "companieshouse.gov.uk", + "hautelook.com", + "edx.org", + "ono.es", + "jango.com", + "7sur7.be", + "spinrewriter.com", + "hqxnxx.com", + "elperiodico.com", + "arabiaweather.com", + "liansuo.com", + "pcgamer.com", + "offervault.com", + "mytheresa.com", + "memegenerator.net", + "gsm.ir", + "britannica.com", + "mensfitness.com", + "flaticon.com", + "newrelic.com", + "greatmmos.com", + "ifixit.com", + "aiyellow.com", + "my.tv.sohu.com/user/card", + "ce4arab.com", + "news-us.jp", + "slando.kz", + "redflagdeals.com", + "gsmhosting.com", + "raiffeisen.at", + "tagesspiegel.de", + "epravda.com.ua", + "bell.ca", + "sleazyneasy.com", + "dhnet.be", + "webcars.com.cn", + "freepik.es", + "androidpolice.com", + "cbr.ru", + "thanhnien.com.vn", + "shoptime.com.br", + "dailytelegraph.com.au", + "fastcodesign.com", + "full-stream.net", + "google.al", + "creativecow.net", + "centrum24.pl", + "openstat.ru", + "unfollowed.me", + "brb.to", + "babal.net", + "ibotoolbox.com", + "torrentdownloads.me", + "miami.com", + "mubasher.info", + "patient.co.uk", + "ayudawordpress.com", + "makepolo.com", + "exactseek.com", + "echosign.com", + "epson.com", + "somo.vn", + "tripadvisor.jp", + "bikroy.com", + "postimees.ee", + "band.uol.com.br", + "adopteunmec.com", + "imgserve.net", + "toofab.com", + "neeu.com", + "mailjet.com", + "kinja.com", + "qwertypay.com", + "cosme.net", + "dreammovies.com", + "avvo.com", + "wenyard.com", + "dir.bg", + "digital-photography-school.com", + "peru.com", + "thomsonreuters.com", + "grazia.com.cn", + "vivastreet.co.in", + "officemax.com", + "creditmutuel.fr", + "themify.me", + "ait-themes.com", + "share-links.biz", + "graphixshare.com", + "theoutnet.com", + "revolvermaps.com", + "careers360.com", + "tyroodr.com", + "escapistmagazine.com", + "ofreegames.com", + "surveryewadcentrez.eu", + "notebookcheck.net", + "k2s.cc", + "barstoolsports.com", + "townhall.com", + "mk.co.kr", + "epochtimes.com", + "arduino.cc", + "blogcms.jp", + "udacity.com", + "habervaktim.com", + "funweek.it", + "techtunes.com.bd", + "shopzilla.com", + "sun-sentinel.com", + "tfile.me", + "novafile.com", + "eurogamer.net", + "thenewporn.com", + "tuttosport.com", + "sverve.com", + "simplemachines.org", + "nginx.org", + "kepu.com.cn", + "jxedt.com", + "southparkstudios.com", + "gusuwang.com", + "utrace.de", + "peperonity.de", + "hvg.hu", + "cairodar.com", + "mappy.com", + "kouclo.com", + "my.tv.sohu.com/user/lucky", + "lushstories.com", + "stocktwits.com", + "atlantico.fr", + "baihe.com", + "wowkeren.com", + "v7n.com", + "mozilla.com", + "centurylink.net", + "1001freefonts.com", + "pubdirecte.com", + "mercadolibre.com.pe", + "vandelaydesign.com", + "cpaelites.com", + "wanyh.com", + "propertyguru.com.sg", + "esy.es", + "torrentbutler.eu", + "final.ir", + "53.com", + "clips4sale.com", + "freerepublic.com", + "huffingtonpost.de", + "boards.ie", + "fluege.de", + "parents.com", + "gimp.org", + "adorocinema.com", + "yelp.ca", + "twicsy.com", + "kuaibo.com", + "gnu.org", + "parsine.com", + "jpc.com", + "cloudapp.net", + "expatriates.com", + "sproutsocial.com", + "natemat.pl", + "livingrichwithcoupons.com", + "x-ho.com", + "adv-adserver.com", + "downloadchop.com", + "sagepub.com", + "eleconomista.com.mx", + "formula1.com", + "quackit.com", + "dlsite.com", + "powned.tv", + "stream-tv.me", + "mindbodyonline.com", + "mindmeister.com", + "twitlonger.com", + "ebay.ie", + "deccanchronicle.com", + "domaintuno.com", + "thethirdmedia.com", + "laiguana.tv", + "flurry.com", + "eloqua.com", + "createsend.com", + "hrloo.com", + "interfax.com.ua", + "admin.ch", + "zgzcw.com", + "bancoestado.cl", + "fda.gov", + "chinayes.com", + "beslist.nl", + "crossfit.com", + "skai.gr", + "covers.com", + "antpoker.com", + "perfectworld.com", + "momdot.com", + "1c-bitrix.ru", + "feiren.com", + "navitime.co.jp", + "siliconindia.com", + "warning.or.kr", + "qatarliving.com", + "uber.com", + "ing-diba.de", + "boldsky.com", + "animeid.tv", + "tom.com", + "whatsmyserp.com", + "ftbpro.com", + "yobt.tv", + "toluna.com", + "burrp.com", + "viber.com", + "df.eu", + "vatera.hu", + "songmeanings.com", + "smbc-card.com", + "hip2save.com", + "wmzona.com", + "banamex.com", + "chinaacc.com", + "t-online.hu", + "indianpornvideos.com", + "runescape.com", + "wapka.mobi", + "115.com", + "blogspot.no", + "aksam.com.tr", + "bankcomm.com", + "giantbomb.com", + "maxcdn.com", + "topshop.com", + "livescores.com", + "rosbalt.ru", + "gandi.net", + "ioffer.com", + "mihandownload.com", + "eweb4.com", + "britishcouncil.org", + "cheetahmail.com", + "vbulletin.com", + "bradsdeals.com", + "empowernetwork.com/commissionloophole", + "vueling.com", + "raventools.com", + "yext.com", + "everychina.com", + "reduxmediia.com", + "openstreetmap.org", + "wed114.cn", + "dzwww.com", + "miibeian.gov.cn", + "ufl.edu", + "deseretnews.com", + "presstv.ir", + "copy.com", + "fourhourworkweek.com", + "buzztheme.net", + "bollywoodlife.com", + "redtubelive.com", + "pengyou.com", + "antaranews.com", + "selectornews.com", + "lavoz.com.ar", + "avm.de", + "flalottery.com", + "jmp9.com", + "baltimoresun.com", + "mozillazine.org", + "dnevnik.hr", + "aebn.net", + "mightydeals.com", + "livescore.eu", + "publipt.com", + "xbmc.org", + "scmp.com", + "sbobet.com", + "alpari.ru", + "harborfreight.com", + "linio.com.pe", + "2500sz.com", + "rdio.com", + "bearshare.com", + "thetrainline.com", + "888poker.es", + "filecrop.com", + "twiends.com", + "elnuevodia.com", + "rasekhoon.net", + "36.cn", + "axeso5.com", + "mzamin.com", + "webmastersitesi.com", + "thinkdigit.com", + "lifescript.com", + "experian.com", + "adorama.com", + "d1net.com", + "torrentz.pro", + "fullhdfilmizle.org", + "space.com", + "collider.com", + "zalando.it", + "slate.fr", + "carmax.com", + "recode.net", + "gfan.com", + "fonts.com", + "honda.com", + "ecwid.com", + "debate.com.mx", + "bmail.uol.com.br", + "santandernet.com.br", + "coderanch.com", + "lyricsmode.com", + "gametrailers.com", + "3600.com", + "designboom.com", + "131.com", + "finam.ru", + "df.gob.mx", + "85dcf732d593.se", + "coches.net", + "dhs.gov", + "neurs.com", + "poppen.de", + "public-api.wordpress.com", + "magnovideo.com", + "squareup.com", + "balagana.net", + "goodsearch.com", + "blog.ir", + "ne10.uol.com.br", + "di.se", + "sinembargo.mx", + "k618.cn", + "eventim.de", + "mysavings.com", + "futureshop.ca", + "spinding.com", + "landsend.com", + "oqenadserving.com", + "here.com", + "upi.com", + "picresize.com", + "abnamro.nl", + "filenuke.com", + "yxku.com", + "mypearson.com", + "dinakaran.com", + "correos.es", + "hotchatdirect.com", + "markafoni.com", + "gofuckbiz.com", + "webfindpage.com", + "cancan.ro", + "hostgator.in", + "latribune.fr", + "adxite.com", + "mofos.com", + "bluewin.ch", + "24ur.com", + "dion.ne.jp", + "vpsdomain3.eu", + "newsweek.com", + "oasgames.com", + "mtv3.fi", + "internetworld.de", + "yatedo.com", + "globaltimes.cn", + "paddypower.com", + "berlin1.de", + "norwegian.com", + "opteck.com", + "zenfolio.com", + "kakprosto.ru", + "ecosia.org", + "check24.de", + "idbibank.co.in", + "zoomit.ir", + "notebooksbilliger.de", + "torontosun.com", + "egopay.com", + "cnnexpansion.com", + "emoneyspace.com", + "rsport.ru", + "fok.nl", + "mql4.com", + "inhabitat.com", + "tqn.com", + "noticierodigital.com", + "wrike.com", + "bazos.cz", + "phonegap.com", + "microlancer.com", + "anipo.jp", + "fotocommunity.de", + "kuwo.cn", + "chinacaipu.com", + "terra.cl", + "500px.org", + "qantas.com.au", + "advertising.com", + "push2check.net", + "livefyre.com", + "philstar.com", + "erail.in", + "mywebgrocer.com", + "der-postillon.com", + "ru-board.com", + "saramin.co.kr", + "yjbys.com", + "aaa.com", + "flavorwire.com", + "fcbarcelona.com", + "lacentrale.fr", + "googlegroups.com", + "luck4.me", + "catho.com.br", + "centauro.com.br", + "sia.az", + "forumactif.com", + "paltalk.com", + "beyond.com", + "occ.com.mx", + "stamps.com", + "getoffmyinternets.net", + "mbok.jp", + "cleveland.com", + "ucdavis.edu", + "tielabs.com", + "hkgolden.com", + "vandal.net", + "lyst.com", + "mrskin.com", + "bunshun.jp", + "netcarshow.com", + "b1.org", + "hromadske.tv", + "sf-express.com", + "pirateproxy.ca", + "getcashforsurveys.com", + "clikz4freakz.com", + "adsupply.com", + "truste.org", + "boxuu.com", + "webartex.ru", + "usc.edu", + "moo.com", + "winkal.com", + "deloitte.com", + "xvideos-field5.com", + "suomi24.fi", + "flexmls.com", + "weeklystandard.com", + "debenhams.com", + "mejortorrent.com", + "vconnect.com", + "ligatus.com", + "skynewsarabia.com", + "herschina.com", + "92lux.cn", + "care.com", + "chip.com.tr", + "tangdou.com", + "vatanbilgisayar.com", + "uppit.com", + "metronews.fr", + "parenting.com.tw", + "meteo.gr", + "meetgee.com", + "ldlc.com", + "ubs.com", + "elcolombiano.com", + "mafengwo.cn", + "moodle.org", + "asiaone.com", + "huffingtonpost.it", + "ipas2free.com", + "casa.it", + "kaiserpermanente.org", + "listindiario.com", + "treehugger.com", + "payeer.com", + "mypoints.com", + "pjmedia.com", + "foreca.com", + "luxup.ru", + "halifax.co.uk", + "webinarjam.net", + "webmeup.com", + "webdesignledger.com", + "rte.ie", + "18andabused.com", + "vbulletin.org", + "apne.tv", + "immoweb.be", + "colonelcassad.livejournal.com", + "atlassian.com", + "investors.com", + "globalbux.net", + "wechat.com", + "kanoon.ir", + "mawaly.com", + "self.com", + "drive.ru", + "autozone.com", + "creditonebank.com", + "fdj.fr", + "hsbc.com.br", + "desk.com", + "dlvr.it", + "wpml.org", + "newmobilelife.com", + "crosswalk.com", + "thehun.com", + "hobbyking.com", + "tiantian.com", + "hichina.com", + "cyanogenmod.org", + "horoscope.com", + "bizsugar.com", + "popularmechanics.com", + "egaliteetreconciliation.fr", + "eol.cn", + "rzd.ru", + "escalatenetwork.net", + "yad2.co.il", + "cna.com.tw", + "zi-m.com", + "leonardo.it", + "ap.gov.in", + "rakuten.de", + "wallsave.com", + "netzwelt.de", + "bitrix24.ru", + "techinasia.com", + "bitstamp.net", + "hostelbookers.com", + "shoplocal.com", + "200please.com", + "tune-up.com", + "mapy.cz", + "dealnews.com", + "livescore.co.uk", + "seocentro.com", + "rstyle.me", + "neoseeker.com", + "kaban.tv", + "visualstudio.com", + "cinetux.org", + "groupon.com.br", + "lastpass.com", + "rincondelvago.com", + "popsci.com", + "2144.cn", + "clickfair.com", + "dsebd.org", + "banesco.com", + "spi0n.com", + "blogspot.cz", + "tnews.ir", + "nme.com", + "paperblog.com", + "firstcry.com", + "tophotels.ru", + "liepin.com", + "korabia.com", + "ifttt.com", + "aemet.es", + "alot.com", + "manutd.com", + "edreams.es", + "turkcell.com.tr", + "eva.vn", + "techpowerup.com", + "vkrugudruzei.ru", + "feed2all.eu", + "thehindubusinessline.com", + "express.de", + "ixquick.com", + "thrillist.com", + "iqilu.com", + "seriouseats.com", + "edgesuite.net", + "telexads.com", + "alza.cz", + "en-japan.com", + "al.com", + "dota2lounge.com", + "totalping.com", + "seocheki.net", + "iceporn.com", + "col3negoriginel.lk", + "porsyar.com", + "property24.com", + "madamenoire.com", + "markethealth.com", + "alphacoders.com", + "webempresa.com", + "empireonline.com", + "downforeveryoneorjustme.com", + "lankadeepa.lk", + "darty.com", + "census.gov", + "wapka.me", + "kdslife.com", + "jpost.com", + "cricfree.tv", + "7xxxtube.com", + "businesscatalyst.com", + "dilbert.com", + "gaymaletube.com", + "bellanaija.com", + "renfe.es", + "equifax.com", + "pornmaki.com", + "lolesports.com", + "yunfan.com", + "everybitcity.com", + "9yao.com", + "avantlink.com", + "paginebianche.it", + "xrosview.com", + "newsday.com", + "usportnews.com", + "petapixel.com", + "pistonheads.com", + "lidovky.cz", + "cvent.com", + "adlandpro.com", + "wikisource.org", + "ename.com", + "prosport.ro", + "sharebuilder.com", + "prisjakt.nu", + "cw.com.tw", + "datafilehost.com", + "aircanada.com", + "osu.edu", + "linuxmint.com", + "toyota.com", + "google.am", + "adobeconnect.com", + "h33t.to", + "companycheck.co.uk", + "juno.com", + "beitaichufang.com", + "alaskaair.com", + "tipsandtricks-hq.com", + "yourstory.com", + "wow-impulse.ru", + "wishpond.com", + "promosite.ru", + "weddingwire.com", + "icicidirect.com", + "mouser.com", + "shopstyle.co.uk", + "sinemalar.com", + "addurl.nu", + "seccionamarilla.com.mx", + "yllix.com", + "motorola.com", + "huawei.com", + "mp3juices.com", + "fitday.com", + "pakwheels.com", + "uploading.com", + "snapwidget.com", + "rsb.ru", + "mturk.com", + "libreoffice.org", + "acer.com", + "rd.com", + "aa.com.tr", + "glamour.com", + "docnhat.net", + "cnbb.com.cn", + "piwik.org", + "mycompanyadmin.com", + "ohozaa.com", + "fox.com", + "mastercard.com.au", + "microsofttranslator.com", + "myhabit.com", + "acesso.uol.com.br", + "cqnews.net", + "default-search.net", + "juntadeandalucia.es", + "carigold.com", + "tweepi.com", + "gamedog.cn", + "videomega.tv", + "softarchive.net", + "akamai.com", + "adorika.net", + "zorpia.com", + "bitdefender.com", + "formstack.com", + "al3abbarq.com", + "ruelala.com", + "andhrajyothy.com", + "siteheart.com", + "spankbang.com", + "buxp.org", + "subtlepatterns.com", + "cucirca.eu", + "apontador.com.br", + "sbs.co.kr", + "rong360.com", + "billmelater.com", + "nowdownload.ch", + "pingmyurl.com", + "main.jp", + "allabolag.se", + "fastspring.com", + "20d625b48e.se", + "wpzoom.com", + "dl-protect.com", + "onvista.de", + "iberia.com", + "learni.st", + "minijuegos.com", + "ae.com", + "india-forums.com", + "port.hu", + "truelocal.com.au", + "ziprecruiter.com", + "toyokeizai.net", + "24timezones.com", + "tzetze.it", + "the-village.ru", + "ptcapusa.com", + "indiaresults.com", + "desjardins.com", + "nchsoftware.com", + "yasdl.com", + "delo.ua", + "baskino.com", + "salary.com", + "freecontact.com", + "wumii.com", + "ssc.nic.in", + "synology.com", + "nttdocomo.co.jp", + "racing-games.com", + "freeonlinegames.com", + "aftabnews.ir", + "zumi.pl", + "efshop.com.tw", + "hawamer.com", + "eastbay.com", + "izvestia.ru", + "mosaiquefm.net", + "twitchy.com", + "slaati.com", + "bookingbuddy.com", + "networksolutionsemail.com", + "etsystatic.com", + "sina.com", + "asiandatingbeauties.com", + "blogs.com", + "france3.fr", + "healthcentral.com", + "downloadatoz.com", + "matthewwoodward.co.uk", + "legalzoom.com", + "phun.org", + "campaignmonitor.com", + "cifraclub.com.br", + "hir24.hu", + "twoplustwo.com", + "hotshame.com", + "arvixededicated.com", + "designcrowd.com", + "mrexcel.com", + "blu-ray.com", + "bundesliga.de", + "comments.ua", + "filmstarts.de", + "3sk.tv", + "donedeal.ie", + "natunbarta.com", + "forex-mmcis.com", + "lifehacker.ru", + "sitepronews.com", + "tudogostoso.com.br", + "titanfall.com", + "brainpickings.org", + "saharareporters.com", + "vidto.me", + "mlit.go.jp", + "terapeak.com", + "techweb.com.cn", + "premiere.fr", + "kanui.com.br", + "asianetnews.tv", + "cric.lk", + "exxxtrasmall.com", + "hiphopdx.com", + "5617.com", + "namepros.com", + "humanmetrics.com", + "allin1convert.com", + "ox.ac.uk", + "msecnd.net", + "cathaypacific.com", + "bet365affiliates.com", + "tcs.com", + "trafficestimate.com", + "lmgtfy.com", + "finance.ua", + "find404.com", + "pagesperso-orange.fr", + "curbed.com", + "tasteofhome.com", + "ar15.com", + "mydigitallife.info", + "promiflash.de", + "technobuffalo.com", + "gamestorrents.com", + "labirint.ru", + "pclab.pl", + "indiatvnews.com", + "finya.de", + "redmondpie.com", + "rabota.ru", + "share-online.biz", + "packtpub.com", + "techgig.com", + "shaw.ca", + "apkmania.co", + "bet-at-home.com", + "barclaycard.co.uk", + "onefloorserve.com", + "raiffeisen.ru", + "t-nation.com", + "mbalib.com", + "staseraintv.com", + "uswitch.com", + "smartadserver.com", + "bbcgoodfood.com", + "elitetorrent.net", + "backlinko.com", + "naszemiasto.pl", + "submitexpress.com", + "savings.com", + "gem.pl", + "ahlamontada.com", + "fotomac.com.tr", + "gougou.com", + "payamsara.com", + "klix.ba", + "doostiha.ir", + "bibliocommons.com", + "wealthyaffiliate.com", + "emgn.com", + "sifyitest.com", + "washingtonexaminer.com", + "rakuten-sec.co.jp", + "mysurvey.com", + "uuu9.com", + "uscourts.gov", + "showroomprive.com", + "cargocollective.com", + "hsoub.com", + "afterbuy.de", + "marunadanmalayali.com", + "jumponhottie.com", + "avon.com", + "lazada.com.my", + "51netu.com.cn", + "ria.com", + "sankakucomplex.com", + "tvline.com", + "devshed.com", + "superherohype.com", + "tv-series.me", + "stylecraze.com", + "wizards.com", + "linkcollider.com", + "xinjunshi.com", + "bestchange.ru", + "1111.com.tw", + "fakenamegenerator.com", + "newsmth.net", + "noupe.com", + "marketingprofs.com", + "bluestacks.com", + "jemtube.com", + "bestbuy.ca", + "backcountry.com", + "designshack.net", + "pond5.com", + "highsnobiety.com", + "rtl.fr", + "pearsoncmg.com", + "hellowork.go.jp", + "koimoi.com", + "soali.ir", + "incentria.com", + "vagas.com.br", + "huaxi100.com", + "cheaa.com", + "lohaco.jp", + "gov.on.ca", + "fabthemes.com", + "pipl.com", + "comscore.com", + "pcfinancial.ca", + "craigslist.co.in", + "michaels.com", + "jibjab.com", + "sankeibiz.jp", + "dominos.co.in", + "supermoney.eu", + "itusozluk.com", + "sdchina.com", + "allkpop.com", + "cam4.com.br", + "stayfriends.de", + "futbol24.com", + "searchina.net", + "sgcpanel.com", + "informe21.com", + "alsacreations.com", + "crateandbarrel.com", + "alliancewarfare.com", + "filerio.in", + "emailsrvr.com", + "reventmedia.com", + "vietcombank.com.vn", + "rxlist.com", + "acidcow.com", + "orange.co.uk", + "hellocoton.fr", + "boldchat.com", + "psychcentral.com", + "surfline.com", + "xxxkinky.com", + "es.wordpress.com", + "publika.az", + "shufoo.net", + "hertz.com", + "businessweekly.com.tw", + "virgula.uol.com.br", + "linkis.com", + "ixwebhosting.com", + "usa.gov", + "linguee.com", + "yengo.com", + "huffingtonpost.jp", + "1x3x.com", + "mediametrics.ru", + "ec21.com", + "80018.cn", + "get-tune.net", + "yupoo.com", + "moviepilot.de", + "ihned.cz", + "fio.cz", + "pubted.com", + "cinemablend.com", + "stooorage.com", + "thevault.bz", + "journaldugeek.com", + "sommer-sommer.com", + "travelchannel.com", + "softonic.de", + "petsmart.com", + "ufxmarkets.com", + "e24.no", + "spirit.com", + "dabi.ir", + "admin5.net", + "serialu.net", + "vancouversun.com", + "submanga.com", + "sbicard.com", + "affaritaliani.it", + "idownloadblog.com", + "castorama.fr", + "sudouest.fr", + "payscale.com", + "serebii.net", + "storypick.com", + "jobkorea.co.kr", + "gowildcasino.com", + "hmetro.com.my", + "parimatch.com", + "51pinwei.com", + "globalnews.ca", + "mercadopago.com", + "sixrevisions.com", + "saisoncard.co.jp", + "gov.kz", + "gossip-tv.gr", + "zbozi.cz", + "aliorbank.pl", + "huanqiuauto.com", + "okaz.com.sa", + "cplusplus.com", + "mochimedia.com", + "google.sn", + "jquery-plugins.net", + "peoplesmart.com", + "mmafighting.com", + "ponpare.jp", + "porsche.com", + "charter.com", + "scrabblefinder.com", + "unpcn.com", + "loveaholics.com", + "geocities.co.jp", + "ladbrokes.com", + "52che.com", + "swansonvitamins.com", + "sweetwater.com", + "ali213.net", + "savenkeep.com", + "hotair.com", + "orgasmatrix.com", + "runrun.es", + "filezilla-project.org", + "looti.net", + "pagesix.com", + "twentytwowords.com", + "gingersoftware.com", + "youxiduo.com", + "isimtescil.net", + "rui.jp", + "d1g.com", + "2dbook.com", + "zigzig.ir", + "123telugu.com", + "wdr.de", + "hankyung.com", + "pr.com", + "search.ch", + "iranproud.com", + "raaga.com", + "alt1040.com", + "okpay.com", + "recordchina.co.jp", + "dreamincode.net", + "bendibao.com", + "creativelive.com", + "socialoomph.com", + "cssdeck.com", + "taxactonline.com", + "pb.com", + "fnac.es", + "ucsd.edu", + "tmart.com", + "whorush.com", + "spicejet.com", + "socialadr.com", + "tutorialzine.com", + "christianmingle.com", + "torrentleech.org", + "statefarm.com", + "orkut.com", + "whoscored.com", + "truthaboutonlinesluts.com", + "32red.com", + "wp-themes.com", + "adpost.com", + "cnr.cn", + "180upload.com", + "snagajob.com", + "textbroker.com", + "freshome.com", + "talkgold.com", + "dudamobile.com", + "weblancer.net", + "newone.org", + "nacion.com", + "takepart.com", + "voici.fr", + "gizmodo.jp", + "viki.com", + "symbaloo.com", + "topface.com", + "businessdictionary.com", + "adtech.info", + "elandroidelibre.com", + "fux.com", + "21-sun.com", + "cpmfx.com", + "siemens.com", + "edmodo.com", + "notitarde.com", + "babypips.com", + "silkroad.com", + "onextrapixel.com", + "notdoppler.com", + "walmart.ca", + "marvel.com", + "groupon.fr", + "us1.com", + "bunte.de", + "findlaw.com", + "topito.com", + "carrefour.fr", + "aawsat.com", + "super.ae", + "kicktipp.de", + "simplyrecipes.com", + "i-mobile.co.jp", + "podrobnosti.ua", + "snn.ir", + "successfactors.com", + "paixie.net", + "wiwo.de", + "glowgaze.com", + "mapsofworld.com", + "limetorrents.com", + "plarium.com", + "tvi.ua", + "corel.com", + "adhitprofits.com", + "findthecompany.com", + "noticiasaldiayalahora.co", + "160by2.com", + "jobberman.com", + "rus.ec", + "fujitsu.com", + "ladepeche.fr", + "pravda.sk", + "wwtdd.com", + "b9dm.com", + "marathonbet.com", + "sexlunch.com", + "komputronik.pl", + "gutenberg.org", + "dizo.com.cn", + "comunio.de", + "naked.com", + "gamesradar.com", + "moneysupermarket.com", + "cheaptickets.com", + "assembla.com", + "timesonline.co.uk", + "mckinsey.com", + "ebook3000.com", + "videoblocks.com", + "ruseller.com", + "pideo.net", + "joomlacode.org", + "pciconcursos.com.br", + "channelnewsasia.com", + "cnnturk.com", + "consultant.ru", + "michigan.gov", + "manoto1.com", + "10010.com", + "wholefoodsmarket.com", + "globalgrind.com", + "pichak.net", + "morpakampus.com", + "crazydomains.com.au", + "uptodown.com", + "polygon.com", + "raspberrypi.org", + "atmarkit.co.jp", + "heftig.co", + "informationweek.com", + "trendhunter.com", + "state.ny.us", + "pornpros.com", + "tnt.com", + "sportal.bg", + "spritzinc.com", + "theladders.com", + "lulu.com", + "applesfera.com", + "qoo10.jp", + "notebookreview.com", + "startertv.fr", + "healthkart.com", + "imgsin.com", + "mp3olimp.net", + "readms.com", + "casadellibro.com", + "nalog.ru", + "4gamer.net", + "jquery4u.com", + "betfred.com", + "3dwwwgame.com", + "appleinsider.com", + "dailystar.co.uk", + "swalif.com", + "hushmail.com", + "worldtimebuddy.com", + "sportschau.de", + "mediatraffic.com", + "gismeteo.ua", + "record.com.mx", + "putnik1.livejournal.com", + "nextbigwhat.com", + "vinescope.com", + "jarchi.ir", + "yidio.com", + "dunyanews.tv", + "hangseng.com", + "interpark.com", + "scholastic.com", + "penny-arcade.com", + "geilundlive.com", + "budbi.com", + "stop55.com", + "jaidefinichon.com", + "smartsheet.com", + "vector.me", + "farecompare.com", + "vodafone.com.eg", + "craftsy.com", + "theresumator.com", + "downloadab.com", + "abendzeitung-muenchen.de", + "dicio.com.br", + "fobshanghai.com", + "2dehands.be", + "thethao247.vn", + "cams.com", + "gothamist.com", + "moneynews.com", + "zocdoc.com", + "rol.ro", + "nic.ar", + "avenues.info", + "cleverbridge.com", + "usajobs.gov", + "divxstage.eu", + "jsticket.net", + "himasoku.com", + "thrivethemes.com", + "orientaltrading.com", + "premiumpress.com", + "house365.com", + "drugoi.livejournal.com", + "monster.co.uk", + "quickanddirtytips.com", + "virtuemart.net", + "huffpost.com", + "real.com", + "teacherspayteachers.com", + "t24.com.tr", + "zakon.kz", + "shoppinglifestyle.com", + "trendmicro.com", + "surfingbird.ru", + "cam.ac.uk", + "navyfederal.org", + "rateyourmusic.com", + "bravenet.com", + "polo.com", + "cl.ly", + "nanacast.com", + "cnfol.com", + "24option.com", + "myscienceacademy.org", + "getsoftfree.com", + "cba.pl", + "templateism.com", + "actudesfinances.org", + "1.254.254.254", + "jobtalk.jp", + "barbie.com", + "rahnama.com", + "gigporno.com", + "buddypress.org", + "corporationwiki.com", + "enorth.com.cn", + "thepioneerwoman.com", + "cam4ultimate.com", + "phpclasses.org", + "uplus.metroer.com/~content", + "komando.com", + "iha.com.tr", + "televisa.com", + "tmtpost.com", + "classifiedsgiant.com", + "sportinglife.com", + "askul.co.jp", + "travelagency.travel", + "jqueryscript.net", + "rusfolder.com", + "netcq.net", + "irangrand.ir", + "interaztv.com", + "downvids.net", + "mongodb.org", + "nasgo.net", + "thesitewizard.com", + "songspk.cc", + "travelandleisure.com", + "d-h.st", + "wasanga.com", + "cgg.gov.in", + "silverclix.com", + "almogaz.com", + "sexmob.es", + "mistreci.com", + "nukistream.com", + "postaffiliatepro.com", + "dish.com", + "ulta.com", + "worldcat.org", + "crackle.com", + "cineblog01.net", + "parispornmovies.com", + "avito.ma", + "nethouse.ru", + "elfinanciero.com.mx", + "ab-in-den-urlaub.de", + "pixeden.com", + "thetimenow.com", + "divar.ir", + "coolrom.com", + "akbank.com", + "saturn.de", + "dstv.com", + "mttbsystem.com", + "hujiang.com", + "bash.im", + "sextgem.com", + "subaonet.com", + "cnsnews.com", + "informationng.com", + "utoronto.ca", + "hetzner.de", + "vend-o.com", + "cybozu.com", + "autotimes.com.cn", + "5giay.vn", + "theepochtimes.com", + "penesalud.com", + "livenation.com", + "qoinpro.com", + "myway.com", + "safe-swaps.com", + "elephantjournal.com", + "curse.com", + "17zwd.com", + "hitleap.com", + "mec.gov.br", + "freewebcams.com", + "westelm.com", + "imagegals.com", + "streeteasy.com", + "ekitan.com", + "git-scm.com", + "p30day.com", + "kapaza.be", + "svoboda.org", + "google.mg", + "timesofisrael.com", + "roodo.com", + "malwaretips.com", + "dumpaday.com", + "dha.com.tr", + "diary.ru", + "epa.gov", + "jonloomer.com", + "holidaylettings.co.uk", + "oem.com.mx", + "oxfordjournals.org", + "3bmeteo.com", + "iwebtool.com", + "yinyuetai.com", + "ixl.com", + "rezultati.com", + "51sole.com", + "moudamepo.com", + "macromill.com", + "nzz.ch", + "buzznet.com", + "roku.com", + "posta.com.tr", + "letsbonus.com", + "theoatmeal.com", + "artofmanliness.com", + "tubepornkiss.com", + "aviny.com", + "sabresonicweb.com", + "tech-wd.com", + "qbank.ru", + "getsatisfaction.com", + "prokerala.com", + "ebc.com.br", + "typiol.com", + "photo.net", + "rockpapershotgun.com", + "netgear.com", + "mg.co.za", + "impressrd.jp", + "jkbk.cn", + "bakufu.jp", + "lgmi.com", + "tnt-online.ru", + "frequency.com", + "zip-codes.com", + "sport.ro", + "wolfram.com", + "pgmediaserve.com", + "icann.org", + "twistedsifter.com", + "mopo.de", + "vogue.co.uk", + "chatrandom.com", + "checkpagerank.net", + "colorzilla.com", + "autobip.com", + "laban.vn", + "pricecheck.co.za", + "notimex.com.mx", + "pik.ba", + "monster.de", + "google.cd", + "economia.uol.com.br", + "vsnl.net.in", + "futura-sciences.com", + "appstorm.net", + "icefilms.info", + "dicelacancion.com", + "hypovereinsbank.de", + "piratestreaming.tv", + "101domain.com", + "google.mn", + "rutgers.edu", + "behindwoods.com", + "downloadmaster.ru", + "smartinsights.com", + "wiziq.com", + "ftc.gov", + "animenewsnetwork.com", + "tandfonline.com", + "seagate.com", + "famitsu.com", + "onekingslane.com", + "zalando.fr", + "convio.com", + "seochat.com", + "qq163.com", + "capital.gr", + "tamin.ir", + "phpfreaks.com", + "cricketcountry.com", + "ubersuggest.org", + "ntv.co.jp", + "olark.com", + "1001fonts.com", + "appsgeyser.com", + "elsiglodetorreon.com.mx", + "lyricsmint.com", + "tovima.gr", + "petco.com", + "campograndenews.com.br", + "amadeus.com", + "tinychat.com", + "astrology.com", + "idg.se", + "nordea.se", + "gelbeseiten.de", + "nrc.nl", + "houseoffraser.co.uk", + "hepsibahis3.com", + "empowernetwork.com/almostasecret", + "phpnuke.org", + "xfwed.com", + "gulte.com", + "msi.com", + "netfirms.com", + "ovcanada.com", + "smzdm.com", + "wwwhatsnew.com", + "mydomainadvisor.com", + "newindianexpress.com", + "luxtarget.com", + "evz.ro", + "otodom.pl", + "linkin.net", + "moneysavingmom.com", + "uploadbaz.com", + "egyup.com", + "three.co.uk", + "co-operativebank.co.uk", + "redad.ru", + "ipsosinteractive.com", + "all-union.com", + "trustlink.ru", + "softango.com", + "toucharcade.com", + "tv2.dk", + "thisissouthwales.co.uk", + "jra.go.jp", + "alfavita.gr", + "ibigdan.livejournal.com", + "gtarcade.com", + "jc001.cn", + "microcenter.com", + "optimizepress.com", + "beyebe.com", + "muyzorras.com", + "expedia.co.uk", + "volvocars.com", + "lyd.com.cn", + "korben.info", + "disput.az", + "aeroflot.ru", + "betanews.com", + "avangard.ru", + "wrzko.eu", + "cakephp.org", + "majorgeeks.com", + "dreamteammoney.com", + "foroactivo.com", + "ut.ac.ir", + "eonet.jp", + "vn-zoom.com", + "footytube.com", + "expedia.de", + "barneys.com", + "lieyunwang.com", + "gartner.com", + "lazada.com.ph", + "ourtime.com", + "ohnotheydidnt.livejournal.com", + "e-rewards.com", + "updatestar.com", + "cafef.vn", + "cookinglight.com", + "expressdownload.net", + "shockmansion.com", + "adserverpub.com", + "ipko.pl", + "gsa-online.de", + "car.gr", + "cqcounter.com", + "thenews.com.pk", + "gnc.com", + "teambeachbody.com", + "kobobooks.com", + "cwan.com", + "ca.com", + "list.ly", + "baijob.com", + "gunbroker.com", + "rtl.be", + "myadvertisingpays.com", + "mediapost.com", + "groupalia.com", + "anquan.org", + "mixshowblast.com", + "myscore.ru", + "bancochile.cl", + "a2hosting.com", + "hayneedle.com", + "myfc.ir", + "aktifhaber.com", + "eater.com", + "anymeeting.com", + "cylex.de", + "sayidaty.net", + "synonym.com", + "comprendrechoisir.com", + "prlog.ru", + "solidtrustpay.com", + "cinejosh.com", + "yelp.co.uk", + "olx.com.ar", + "dihitt.com", + "donkeymails.com", + "chainreactioncycles.com", + "wearehairy.com", + "ebuyer.com", + "bplans.com", + "ponparemall.com", + "readthedocs.org", + "tehparadox.com", + "source-wave.com", + "tbs.co.jp", + "redcoon.de", + "francetv.fr", + "freelogoservices.com", + "ogone.com", + "jeanmarcmorandini.com", + "lasexta.com", + "sponsoredreviews.com", + "govome.com", + "vecteezy.com", + "alhayat.com", + "cnhubei.com", + "mumayi.com", + "webfail.com", + "eluniverso.com", + "moddb.com", + "gaiaonline.com", + "gordonua.com", + "liveadexchanger.com", + "zhe800.com", + "softonic.com.br", + "cnyes.com", + "cumlouder.com", + "krakow.pl", + "nullrefer.com", + "zaluu.com", + "diretube.com", + "seattlepi.com", + "eanswers.com", + "gostorego.com", + "play.com", + "lenskart.com", + "unblog.fr", + "chatwork.com", + "bronto.com", + "jobisjob.co.in", + "mercadolibre.com.uy", + "overdrive.com", + "runkeeper.com", + "smartshopping.com", + "getrichradio.com", + "grader.com", + "101greatgoals.com", + "elbilad.net", + "kopp-verlag.de", + "ranksignals.com", + "trome.pe", + "jobstreet.com.my", + "farnell.com", + "fastmail.fm", + "faithit.com", + "blogdohotelurbano.com", + "sencha.com", + "daisycon.com", + "random.org", + "tportal.hr", + "rkanr.com", + "fc2-erodouga.com", + "youngpornvideos.com", + "bravoteens.com", + "mobile.free.fr", + "mitele.es", + "edis.at", + "questionablecontent.net", + "indiangilma.com", + "comunio.es", + "bitnami.com", + "sliptalk.com", + "sourceforge.jp", + "lyoness.net", + "nespresso.com", + "ultrafarma.com.br", + "lik.cl", + "jsoftj.com", + "metoffice.gov.uk", + "androidauthority.com", + "360safe.com", + "wikimart.ru", + "tutu.ru", + "truetwit.com", + "xinruijunshi.com", + "online-sweepstakes.com", + "singaporeair.com", + "cwtv.com", + "politiken.dk", + "alaan.tv", + "tuttomercatoweb.com", + "imagehost123.com", + "drakensang.com", + "frenchweb.fr", + "syosetu.com", + "zhifang.com", + "viptube.com", + "theme123.net", + "statista.com", + "51bi.com", + "clickz.com", + "kingworldnews.com", + "qunar.com", + "pimpandhost.com", + "pagina12.com.ar", + "xinmin.cn", + "kidshealth.org", + "pics.livejournal.com", + "kabum.com.br", + "anandabazar.com", + "pnu.ac.ir", + "scene7.com", + "paperpkads.com", + "mylikes.com", + "longtailvideo.com", + "firmy.cz", + "bitcoinity.org", + "inopressa.ru", + "expat-blog.com", + "governmentjobs.com", + "airdroid.com", + "mid-day.com", + "frandroid.com", + "webceo.com", + "cadenaser.com", + "minutouno.com", + "onamae.com", + "onlinekhabar.com", + "williams-sonoma.com", + "freewebsubmission.com", + "vozforums.com", + "bigpicture.ru", + "mymodernmet.com", + "presseportal.de", + "licindia.in", + "ismedia.jp", + "depor.pe", + "sing365.com", + "v2cigs.com", + "postimage.org", + "gencat.cat", + "west263.com", + "alohatube.com", + "eenadupratibha.net", + "terra.com", + "bri.co.id", + "silktide.com", + "anyang.gov.cn", + "speedanalysis.com", + "bitcoin.org", + "toodledo.com", + "topgear.com", + "rtvslo.si", + "hotpads.com", + "nedsecure.co.za", + "expedia.ca", + "thairath.co.th", + "gizbot.com", + "naukrigulf.com", + "guffins.com", + "twilio.com", + "avsforum.com", + "sharpnews.ru", + "inoreader.com", + "stgeorge.com.au", + "shoebuy.com", + "sbwire.com", + "bfm.ru", + "dongtaiwang.com", + "mandrillapp.com", + "176.com", + "olx.com", + "trustpilot.co.uk", + "tgju.org", + "pap.fr", + "iphonehacks.com", + "gry-online.pl", + "mp3xd.com", + "viabcp.com", + "bizcommunity.com", + "chillingeffects.org", + "thomasnet.com", + "performersoft.com", + "paymaster.ru", + "comdotgame.com", + "bseindia.com", + "foodgawker.com", + "clicktale.com", + "dot.tk", + "smbc-comics.com", + "vvmembers.co", + "c-sharpcorner.com", + "acdcads.com", + "goldporntube.com", + "abakus-internet-marketing.de", + "babbel.com", + "fzg360.com", + "99inf.com", + "cduniverse.com", + "autobild.de", + "tvrage.com", + "phoenix.edu", + "hurriyetemlak.com", + "va.gov", + "maxmind.com", + "lifehacker.jp", + "nola.com", + "niroensani.ir", + "ihotelier.com", + "mianbao.com", + "powerball.com", + "express.com", + "freshdesignweb.com", + "o2.co.uk", + "utusan.com.my", + "overclockers.ru", + "fsiblog.com", + "launchpad.net", + "prizee.com", + "alalam.ir", + "imtalk.org", + "vavel.com", + "nyc.ny.us", + "youmob.com", + "dailythanthi.com", + "ksu.edu.sa", + "nlayer.net", + "kurier.at", + "expert-offers.com", + "marry52.com", + "cityads.ru", + "darkorbit.com", + "cio.com", + "a9.com", + "symfony.com", + "crobo.com", + "shatel.ir", + "opposingviews.com", + "myvoffice.com", + "vkmag.com", + "starpulse.com", + "bls.gov", + "lifebettering.com", + "fanhuan.com", + "upload7.ir", + "infoplease.com", + "suruga-ya.jp", + "deredactie.be", + "shangdu.com", + "portail.free.fr", + "smartaddons.com", + "w3layouts.com", + "wallstreet-online.de", + "yapo.cl", + "standard.co.uk", + "atlas.sk", + "seowizard.ru", + "currys.co.uk", + "nova.cz", + "mygully.com", + "favstar.fm", + "themuse.com", + "yudu.com", + "urlopener.com", + "ellentv.com", + "imgsrc.ru", + "km.ru", + "guildwars2.com", + "google.mu", + "androidpit.de", + "mrporter.com", + "ttt4.com", + "cbox.ws", + "hf365.com", + "1mobile.com", + "punjabkesari.in", + "msu.edu", + "grasscity.com", + "abduzeedo.com", + "sublimetext.com", + "jtb.co.jp", + "mensxp.com", + "myheritage.com", + "onvasortir.com", + "safeway.com", + "comicvine.com", + "cpubenchmark.net", + "nn.ru", + "animefreak.tv", + "angularjs.org", + "managewp.com", + "ameli.fr", + "merrjep.com", + "christianbook.com", + "nubiles.net", + "klmty.net", + "247sports.com", + "aramex.com", + "tubent.com", + "cognitiveseo.com", + "bankpasargad.com", + "pingler.com", + "compareja.com.br", + "surveyzrewardcenter.eu", + "allyes.com", + "graaam.com", + "poriborton.com", + "seslisozluk.net", + "shopyourway.com", + "awd.ru", + "wa.gov.au", + "slrclub.com", + "apollo.lv", + "girls-ly.com", + "totalfilm.com", + "cam4.it", + "gogecapital.com", + "sketchup.com", + "muscleandfitness.com", + "m24.ru", + "blinklist.com", + "artisteer.com", + "nettavisen.no", + "enjin.com", + "pc6.com", + "citrix.com", + "indgovtjobs.in", + "phpbb.com", + "laughingsquid.com", + "fblife.com", + "stansberryresearch.com", + "hugefiles.net", + "mp3monkey.net", + "mcdonalds.com", + "vodafone.co.uk", + "t-mobile.de", + "tp-link.com.cn", + "iflscience.com", + "nst.com.my", + "zoom.com.br", + "dsw.com", + "tigerair.com", + "doityourself.com", + "bongdainfo.com", + "imacros.net", + "paperlesspost.com", + "sprinthost.ru", + "lovoo.net", + "kadinlarkulubu.com", + "championselect.net", + "jcb.co.jp", + "miui.com", + "impots.gouv.fr", + "linkshop.com.cn", + "pando.com", + "ckeditor.com", + "arabylife.com", + "ml.com", + "sheldonsfans.com", + "freecharge.in", + "magicmovies.com", + "laweekly.com", + "highrisehq.com", + "tr.gg", + "vidbull.com", + "diy.com", + "yieldtraffic.com", + "cima4u.com", + "gendama.jp", + "netpnb.com", + "kannaway.com", + "soft112.com", + "die-boersenformel.com", + "movie25.so", + "footyroom.com", + "dostor.org", + "aol.de", + "desimartini.com", + "themeko.org", + "danarimedia.com", + "toroporno.com", + "stylemepretty.com", + "urlm.de", + "demotivation.me", + "gentside.com", + "carfax.com", + "huzhou.gov.cn", + "hotline.ua", + "fullmoneysystem.com", + "pornomovies.com", + "fsymbols.com", + "blog.de", + "clickpoint.com", + "tv-asahi.co.jp", + "flightstats.com", + "sonico.com", + "afamily.vn", + "anadolu.edu.tr", + "rs-online.com", + "androidpit.com", + "a-telecharger.com", + "wikifeet.com", + "nix.ru", + "tvmao.com", + "groupon.es", + "hitfix.com", + "weathernews.jp", + "dig.do", + "googledrive.com", + "fodors.com", + "melon.com", + "testflightapp.com", + "markt.de", + "mahua.com", + "sedo.co.uk", + "tuenti.com", + "comm100.com", + "olx.co.id", + "lefrecce.it", + "gov.cl", + "wplift.com", + "unn.com.ua", + "arizona.edu", + "msn.com.cn", + "k7x.com", + "techz.vn", + "jobomas.com", + "extranetinvestment.com", + "tengrinews.kz", + "comicbookmovie.com", + "4porn.com", + "rubiconproject.com", + "gametracker.com", + "otcmarkets.com", + "mismarcadores.com", + "trojmiasto.pl", + "cleverreach.com", + "contactform7.com", + "weloveshopping.com", + "runnersworld.com", + "falabella.com", + "airtelbroadband.in", + "twistys.com", + "ebesucher.de", + "belastingdienst.nl", + "orlandosentinel.com", + "th3professional.com", + "duke.edu", + "opensubtitles.us", + "clickme.net", + "infor.pl", + "unesco.org", + "socialfabric.us", + "ename.net", + "alternativeto.net", + "rotahaber.com", + "johnchow.com", + "pervclips.com", + "linkfeed.ru", + "dtvideo.com", + "kinoman.tv", + "siteprice.org", + "lacuerda.net", + "amulyam.in", + "mandghomebusiness.com", + "infojobs.com.br", + "hirufm.lk", + "mybloggertricks.com", + "athemes.com", + "moikrug.ru", + "fybersearch.com", + "wine-searcher.com", + "davidicke.com", + "dotabuff.com", + "sainsburys.co.uk", + "ovaustralia.com", + "updatesoftnow.com", + "desarrolloweb.com", + "elaph.com", + "icc-cricket.com", + "gaytube.com", + "di.fm", + "99wed.com", + "c-and-a.com", + "mlxchange.com", + "realgfporn.com", + "synxis.com", + "optymalizacja.com", + "ibtesama.com", + "hankooki.com", + "shiksha.com", + "anoox.com", + "seamless.com", + "stripe.com", + "ets.org", + "fresherslive.com", + "webcoinpay.net", + "oscommerce.com", + "gratisprogramas.org", + "football365.com", + "mkyong.com", + "antichat.ru", + "spamarrest.com", + "ubc.ca", + "36kr.com", + "startv.in", + "shoutcast.com", + "heureka.sk", + "entheosweb.com", + "51wan.com", + "madadsmedia.com", + "parse.com", + "ngacn.cc", + "techbargains.com", + "tvmovie.de", + "cpmstar.com", + "torproject.org", + "residentadvisor.net", + "genbeta.com", + "hulu.jp", + "pluralsight.com", + "postini.com", + "zombie.jp", + "skimlinks.com", + "liverail.com", + "phys.org", + "slashfilm.com", + "livemaster.ru", + "idwebgame.com", + "pho.to", + "dealfish.co.th", + "s1979.com", + "designfloat.com", + "live365.com", + "pbase.com", + "eniro.se", + "irannaz.com", + "socialmonkee.com", + "uidai.gov.in", + "joomlashine.com", + "allhyipmon.ru", + "upbulk.com", + "diapers.com", + "flypgs.com", + "hotmart.com.br", + "globus-inter.com", + "airfrance.fr", + "t3.com", + "unetepubli.com", + "yahoo-help.jp", + "iphones.ru", + "95559.com.cn", + "glamsham.com", + "gophoto.it", + "statmyweb.com", + "aftermarket.pl", + "forumotion.com", + "iafd.com", + "hotlog.ru", + "drclix.com", + "wawa-mania.ec", + "nichepursuits.com", + "imp.free.fr", + "baofeng.com", + "binsearch.info", + "neswangy.net", + "parperfeito.com.br", + "theeroticreview.com", + "sabayacafe.com", + "maplestage.com", + "icook.tw", + "customerhub.net", + "uid.me", + "viperchill.com", + "askfrank.net", + "juegosjuegos.com", + "debonairblog.com", + "coingeneration.com", + "onetravel.com", + "slutroulette.com", + "jetpack.me", + "embedupload.com", + "bancodevenezuela.com", + "mysavingsmedia.net", + "smallbiztrends.com", + "emirates247.com", + "bu.edu", + "fineco.it", + "netbarg.com", + "gatech.edu", + "zik.ua", + "peliculascoco.com", + "hkjc.com", + "turkiyegazetesi.com.tr", + "cooperativa.cl", + "challenges.fr", + "usingenglish.com", + "vouchercodes.co.uk", + "bonprix.de", + "disneylatino.com", + "townwork.net", + "rentanything.com", + "krypt.com", + "wral.com", + "globes.co.il", + "designtaxi.com", + "mp-success.com", + "invisionpower.com", + "liontravel.com", + "classicrummy.com", + "mt.co.kr", + "inccel.com", + "santander.cl", + "afip.gov.ar", + "yellowpages.com.au", + "osclass.org", + "couriermail.com.au", + "stream.cz", + "wizaz.pl", + "linkresearchtools.com", + "cam4.co.uk", + "allafrica.com", + "gezginler.net", + "free-ebooks.net", + "hopesandfears.com", + "ticketmaster.com.mx", + "ohio.gov", + "liberoquotidiano.it", + "neurs.net", + "forumophilia.com", + "odnako.org", + "gamekult.com", + "vh1.com", + "zxart.cn", + "mass.gov", + "tv-tokyo.co.jp", + "mundopromocion.com", + "theme-junkie.com", + "asu.edu", + "lalibre.be", + "pornokopilka.info", + "fx678.com", + "netbeans.org", + "chinabidding.com.cn", + "lunapic.com", + "dramafever.com", + "hbogo.com", + "torrents.net", + "woopra.com", + "justfab.com", + "fitnessmagazine.com", + "tripadvisor.com.mx", + "183.com.cn", + "adscendmedia.com", + "geek.com", + "thepetitionsite.com", + "skyscanner.ru", + "morningpost.com.cn", + "concursolutions.com", + "camplace.com", + "smarturl.it", + "browsershots.org", + "piktochart.com", + "elcorreo.com", + "collegeboard.org", + "kasikornbank.com", + "adsoftheworld.com", + "fakku.net", + "jpn.org", + "sahafah.net", + "rubias19.com", + "fc2web.com", + "redsurf.ru", + "iproperty.com.my", + "browsersafeguard.com", + "mmajunkie.com", + "bangkokbank.com", + "ovi.com", + "fap.to", + "filmygyan.in", + "edaily.vn", + "affilorama.com", + "valuecommerce.ne.jp", + "softaculous.com", + "exchanger.ru", + "html-color-codes.info", + "hd-xvideos.com", + "realself.com", + "geocaching.com", + "mom.me", + "stc.com.sa", + "video-i365.com", + "umd.edu", + "jeffbullas.com", + "kora.com", + "cyberchimps.com", + "popupads.ir", + "chatango.com", + "gearslutz.com", + "fout.jp", + "contactmusic.com", + "linkcrypt.ws", + "sophos.com", + "forum-auto.com", + "svtplay.se", + "newsbusters.org", + "fileswap.com", + "phpfox.com", + "denic.de", + "riverisland.com", + "encuentra24.com", + "foxnewsinsider.com", + "dtdc.com", + "tayyar.org", + "thepushbuttonmillionaire.com", + "brokenlinkcheck.com", + "ju51.com", + "stihi.ru", + "psdgraphics.com", + "mommyfucktube.com", + "mangocity.com", + "routard.com", + "whicdn.com", + "socialtriggers.com", + "e-bookspdf.org", + "songspk3.in", + "paginasamarillas.com", + "webgame.in.th", + "xxxdessert.com", + "materiel.net", + "skillshare.com", + "tubepleasure.com", + "paypal.de", + "yeahmobi.com", + "torrentz-proxy.com", + "aircel.com", + "openask.com", + "trafficg.com", + "anthem.com", + "aleseriale.pl", + "f-page.ru", + "hrsmart.com", + "cbengine.com", + "startlap.com", + "spamhaus.org", + "trovit.com", + "sporcle.com", + "xs8.cn", + "romwe.com", + "powtoon.com", + "cybozulive.com", + "zbiornik.com", + "cebit.de", + "flipboard.com", + "news.am", + "wm-panel.com", + "topnews.ru", + "usp.br", + "realmadrid.com", + "fastdist.net", + "unian.ua", + "youtube.com/user/PewDiePie", + "unc.edu", + "tamu.edu", + "ip2location.com", + "americanapparel.net", + "virtualedge.com", + "vikatan.com", + "goodlayers.com", + "feedblitz.com", + "dateinasia.com", + "freepdfconvert.com", + "iweb.com", + "lachainemeteo.com", + "aetna.com", + "ti.com", + "gratisjuegos.org", + "webhostinghub.com", + "preev.com", + "holidayiq.com", + "elpais.com.uy", + "uchicago.edu", + "telcel.com", + "feebbo.com", + "webhallen.com", + "dmir.ru", + "emailmg.ipage.com", + "hrs.de", + "propakistani.pk", + "theme.co", + "bigpara.com", + "finishline.com", + "fardanews.com", + "nat.gov.tw", + "stoloto.ru", + "sermepa.es", + "radaris.com", + "softportal.com", + "turkiye.gov.tr", + "nnn.ru", + "e-familynet.com", + "wenkang.cn", + "teamworkpm.net", + "videohelp.com", + "pixmania.com", + "games.com", + "guns.ru", + "plus28.com", + "pf.pl", + "pbworks.com", + "sedo.de", + "freedownloadscenter.com", + "backpackers.com.tw", + "mycokerewards.com", + "chinaunix.net", + "invisionapp.com", + "wordhippo.com", + "unitezz.com", + "yan.vn", + "sonhoo.com", + "spielaffe.de", + "d.pr", + "technologyreview.com", + "democraticunderground.com", + "molotok.ru", + "watchever.de", + "wdc.com", + "torg.com", + "ivillage.com", + "portableapps.com", + "ovh.es", + "vse.kz", + "alrajhibank.com.sa", + "dhl-usa.com", + "pingan.com", + "excite.com", + "cincodias.com", + "marksdailyapple.com", + "bter.com", + "nationaljournal.com", + "fao.org", + "oddee.com", + "digitalriver.com", + "livescore.in", + "siilu.com", + "gofirstrowus.eu", + "alquds.co.uk", + "autoevolution.com", + "zerx.ru", + "trovit.it", + "hvylya.org", + "carters.com", + "shejis.com", + "radio-canada.ca", + "vodafone.es", + "sky.fm", + "maturetube.com", + "virtualtourist.com", + "line25.com", + "rzeczpospolita.pl", + "megacurioso.com.br", + "beliefnet.com", + "eklablog.com", + "hbo.com", + "bsi.ir", + "fastweb.it", + "webrazzi.com", + "telam.com.ar", + "downloadming.me", + "bluefly.com", + "thewire.com", + "erotube.org", + "vt.edu", + "jsbin.com", + "ibosocial.com", + "brides.com.cn", + "jn.pt", + "togetter.com", + "olhardigital.uol.com.br", + "ebookee.org", + "socialgamenet.com", + "romaniatv.net", + "epweike.com", + "pronto.com", + "blog.pl", + "top81.cn", + "flagfox.wordpress.com", + "unionbank.com", + "visitkorea.or.kr", + "blogspot.dk", + "fermasosedi.ru", + "inmobi.com", + "abc.com.py", + "iqoo.me", + "17k.com", + "onlineapplicationsdownloads.com", + "komli.com", + "tala.ir", + "videopremium.me", + "job.ru", + "sunbiz.org", + "tw116.com", + "browserstack.com", + "youtu.be", + "yardbarker.com", + "flvmplayer.com", + "kulichki.net", + "gravity.com", + "levelclix.com", + "kissanime.com", + "insightexpressai.com", + "colorhexa.com", + "citizensbankonline.com", + "hjenglish.com", + "voeazul.com.br", + "paraskhnio.gr", + "es.tl", + "busuu.com", + "appsumo.com", + "metacrawler.com", + "ciku5.com", + "android-hilfe.de", + "laterooms.com", + "google.com.bn", + "gamefront.com", + "rev2pub.com", + "bharatiyamobile.com", + "publicidees.com", + "jossandmain.com", + "babycentre.co.uk", + "zetabux.com", + "movieweb.com", + "timescity.com", + "dnevnik.ru", + "nlcafe.hu", + "magazine3k.com", + "irancell.ir", + "kalaydo.de", + "e5.ru", + "lecai.com", + "sbs.com.au", + "sierratradingpost.com", + "girlfriendvideos.com", + "ink361.com", + "corporate-ir.net", + "allgameshome.com", + "povarenok.ru", + "typo3.org", + "turbosquid.com", + "miniurls.co", + "thinkwithgoogle.com", + "haber3.com", + "newsmeback.com", + "sipse.com", + "osxdaily.com", + "9lessons.info", + "cyclopaedia.net", + "reallifecam.com", + "gameblog.fr", + "colourbox.com", + "mixedmartialarts.com", + "prostoporno.net", + "chanel.com", + "maxim.com", + "cam4.es", + "olx.com.mx", + "newscientist.com", + "netcombo.com.br", + "serienjunkies.org", + "shablol.com", + "bnpparibasfortis.be", + "canada.com", + "timeslive.co.za", + "cinematoday.jp", + "21cineplex.com", + "bodisparking.com", + "cruisecritic.com", + "vertoz.com", + "glosbe.com", + "nstarikov.ru", + "epinions.com", + "colbertnation.com", + "marketglory.com", + "emailmeform.com", + "angloinfo.com", + "filfan.com", + "yougetsignal.com", + "broker.to", + "quickbux.net", + "gottabemobile.com", + "beyondtherack.com", + "tripadvisor.ru", + "jschina.com.cn", + "registraduria.gov.co", + "thisoldhouse.com", + "appcelerator.com", + "noticias24carabobo.com", + "skelbiu.lt", + "ru.wix.com", + "iransong.com", + "i-sux.com", + "telerama.fr", + "mydala.com", + "pia.jp", + "fusebux.com", + "biquge.com", + "microworkers.com", + "onlywire.com", + "fanbox.com", + "ambitoweb.com", + "tripadvisor.com.br", + "postgresql.org", + "telenet.be", + "thegeekstuff.com", + "primelocation.com", + "ee.co.uk", + "phoenixads.co.in", + "brigitte.de", + "360kad.com", + "kathimerini.gr", + "batoto.net", + "babebuns.com", + "webimpresion.com", + "olx.com.ng", + "which.co.uk", + "f5haber.com", + "cic.fr", + "talkfusion.com", + "ctrlq.org", + "caracol.com.co", + "wer-weiss-was.de", + "invisionzone.com", + "head-fi.org", + "thingiverse.com", + "manager-magazin.de", + "bzwbk.pl", + "f1news.ru", + "tweetreach.com", + "sj998.com", + "streetdirectory.com", + "asos.fr", + "kalahari.com", + "classiccars.com", + "bitacoras.com", + "bravotv.com", + "beanfun.com", + "bonappetit.com", + "fashionara.com", + "techdirt.com", + "newlook.com", + "iyinet.com", + "mogujie.com", + "carros.com.br", + "starfall.com", + "rp5.ru", + "pocket-lint.com", + "homeadvisor.com", + "webhostbox.net", + "cameraboys.com", + "pricerunner.com", + "worldcarfans.com", + "meganovosti.net", + "taxheaven.gr", + "freewebsitetemplates.com", + "mr90.ir", + "cheapflights.co.uk", + "bankinter.com", + "euroresidentes.com", + "bettycrocker.com", + "filmey.com", + "sheinside.com", + "2ememain.be", + "tu.tv", + "kugou.com", + "destructoid.com", + "todoist.com", + "karmaloop.com", + "appadvice.com", + "html5rocks.com", + "osdir.com", + "webisgreat.info", + "dailyblogtips.com", + "mca.gov.in", + "e-estekhdam.com", + "hlntv.com", + "proprofs.com", + "his-j.com", + "im286.com", + "mmorpg.com", + "shooshtime.com", + "terra.es", + "lpcloudbox301.com", + "tubepornstars.com", + "tableausoftware.com", + "soccersuck.com", + "websurf.ru", + "indiafreestuff.in", + "pimei.com", + "colatour.com.tw", + "fssnet.co.in", + "maxpark.com", + "foodandwine.com", + "apachefriends.org", + "standardchartered.co.in", + "waveapps.com", + "gosong.net", + "spring.me", + "weatherbug.com", + "iw33.com", + "apserver.net", + "thenationonlineng.net", + "tjournal.ru", + "greatschools.net", + "3movs.com", + "61.com", + "directpaybiz.com", + "w3snoop.com", + "jsonline.com", + "grainger.com", + "prevention.com", + "blizzard.com", + "baseball-reference.com", + "cjn.cn", + "fasthosts.co.uk", + "kym-cdn.com", + "cuponation.in", + "cam4.fr", + "lalawan67.net", + "videovantage.co", + "elimparcial.com", + "edlen24.com", + "donya-e-eqtesad.com", + "englishforums.com", + "dom2.ru", + "cinepolis.com", + "healthtap.com", + "astroawani.com", + "autosport.com", + "finalfantasyxiv.com", + "valueclickmedia.com", + "vitaminshoppe.com", + "apartmentguide.com", + "notjustok.com", + "gratispeliculas.org", + "intporn.com", + "eroticbeauties.net", + "egloos.com", + "nujij.nl", + "godvine.com", + "punishtube.com", + "wisegeek.org", + "somuch.com", + "taz.de", + "zetaboards.com", + "gravityforms.com", + "telegraf.rs", + "odn.ne.jp", + "topeleven.com", + "peekyou.com", + "razerzone.com", + "furaffinity.net", + "mobikwik.com", + "eventful.com", + "sextube.fm", + "treccani.it", + "phatograph.com", + "feedthebot.com", + "netdoctor.co.uk", + "collarme.com", + "reformal.ru", + "hemnet.se", + "jacquieetmicheltv.net", + "9ku.com", + "kraloyun.com", + "directadmin.com", + "bongda.com.vn", + "ddizi.org", + "tedata.net", + "fb.org", + "pagemodo.com", + "satu.kz", + "nodejs.org", + "tiberiumalliances.com", + "wallst.com", + "dezeen.com", + "rense.com", + "hawkhost.com", + "vonage.com", + "zjol.com.cn", + "housefun.com.tw", + "ad1.ru", + "myredbook.com", + "rarlab.com", + "audiopoisk.com", + "pbebank.com", + "whocallsme.com", + "playground.ru", + "tnr.com", + "firstdirect.com", + "xinhua.jp", + "gmane.org", + "verseriesynovelas.com", + "broadwayworld.com", + "thefrisky.com", + "rapmls.com", + "skapiec.pl", + "wholesale-dress.net", + "alison.com", + "n4hr.com", + "prefiles.com", + "vtc.vn", + "coral.co.uk", + "azyya.com", + "smithsonianmag.com", + "ticksy.com", + "theync.com", + "pcinpact.com", + "eventbrite.co.uk", + "buenosaires.gob.ar", + "a5cee7.se", + "bazingamob.com", + "pp.cc", + "shortnews.de", + "responsinator.com", + "filepost.com", + "securefreedom.com", + "notepad-plus-plus.org", + "thekrazycouponlady.com", + "apktops.ir", + "nr2.ru", + "timinternet.it", + "man.lv", + "forexpeacearmy.com", + "plius.lt", + "vcp.ir", + "mysitecost.ru", + "yourfiledownloader.com", + "dealguardian.com", + "sql.ru", + "laravel.com", + "shape5.com", + "visa.com", + "vocus.com", + "stackthatmoney.com", + "pornicom.com", + "my.tv.sohu.com/user/cc128", + "urban-rivals.com", + "robotstxt.org", + "colorlabsproject.com", + "mg.gov.br", + "local.ch", + "adbooth.net", + "se.pl", + "al-akhbar.com", + "he.net", + "covoiturage.fr", + "sakshieducation.com", + "thisdaylive.com", + "thestudentroom.co.uk", + "pzy.be", + "designyoutrust.com", + "forbes.ua", + "fandongxi.com", + "expertreviews.co.uk", + "dream-demo.com", + "barchart.com", + "ht.ly", + "burbuja.info", + "edgecastcdn.net", + "amazinglytimedphotos.com", + "value-domain.com", + "shareaholic.com", + "promptfile.com", + "voetbalzone.nl", + "ziare.com", + "trafficbroker.com", + "coolsport.tv", + "vanguardia.com.mx", + "makeshop.jp", + "mobilism.org", + "rebelmouse.com", + "brisbanetimes.com.au", + "publimetro.com.mx", + "coolkora.com", + "realsparrow.com", + "honda.co.jp", + "dealcatcher.com", + "sinoptik.ua", + "lefeng.com", + "mamaclub.com", + "bezuzyteczna.pl", + "smn.gov.ar", + "manhub.com", + "pcgameshardware.de", + "shipstation.com", + "zive.cz", + "disneystore.com", + "despegar.com.mx", + "addictivetips.com", + "path.com", + "pathofexile.com", + "seitenreport.de", + "pardot.com", + "decathlon.fr", + "flvrunner.com", + "xat.com", + "matchendirect.fr", + "roem.ru", + "wat.tv", + "edline.net", + "znds.com", + "northwestern.edu", + "friendscout24.de", + "movoto.com", + "dengiprosto.info", + "dlisted.com", + "sports.fr", + "maxifoot.fr", + "hubspot.net", + "natalie.mu", + "tabloidpulsa.co.id", + "polki.pl", + "gamasutra.com", + "matomeantena.com", + "adwords-community.com", + "gallup.com", + "redtubenacional.com", + "mangastream.com", + "zulutrade.com", + "wunderlist.com", + "taste.com.au", + "myhosting.com", + "totalbeauty.com", + "8pic.ir", + "sltrib.com", + "88db.com", + "minikoyuncu.com", + "net4.in", + "nuevoloquo.com", + "cago365.com", + "afip.gob.ar", + "keep2share.cc", + "kw.com", + "terra.com.pe", + "profi-forex.org", + "filecloud.io", + "peliculas4.com", + "mysitemyway.com", + "ilmattino.it", + "geizhals.de", + "sheershanews.com", + "whatwpthemeisthat.com", + "teknosa.com", + "myshopping.com.au", + "teamskeet.com", + "gandalfporn.com", + "2670.com", + "peoplefinders.com", + "elo7.com.br", + "sofoot.com", + "uhaul.com", + "sagepay.com", + "unb.br", + "jhu.edu", + "barrons.com", + "hasznaltauto.hu", + "winfxstrategy.com", + "spamcop.net", + "az.pl", + "op.fi", + "istruzione.it", + "eveonline.com", + "imgnip.com", + "jjoobb.cn", + "itesm.mx", + "wptavern.com", + "kproxy.com", + "pulptastic.com", + "quidco.com", + "ekantipur.com", + "joann.com", + "whattoexpect.com", + "tomshw.it", + "internetbookshop.it", + "followerwonk.com", + "cisionpoint.com", + "cint.com", + "quondos.com", + "suntimes.com", + "saveinter.net", + "eiga.com", + "jdzj.com", + "goldprice.org", + "websitemagazine.com", + "051jk.com", + "inweb24.com", + "gamgos.ae", + "elog-ch.com", + "trovit.com.mx", + "webnode.cz", + "ethnos.gr", + "oodle.com", + "subtitulos.es", + "gameinformer.com", + "9to5mac.com", + "youwatch.org", + "ibps.in", + "biggerpockets.com", + "sport24.co.za", + "my.tv.sohu.com/user/cc133", + "capsulecrm.com", + "fuett.mx", + "poznan.pl", + "melateiran.com", + "divxtotal.com", + "aftabir.com", + "cyberlink.com", + "ulozto.cz", + "jetswap.com", + "premium.wix.com", + "eprize.com", + "huntington.com", + "careerlink.vn", + "allhyipmonitors.com", + "autorambler.ru", + "jamieoliver.com", + "minube.com", + "credomatic.com", + "oddschecker.com", + "listia.com", + "mrrebates.com", + "8684.cn", + "kabam.com", + "tripit.com", + "gry.pl", + "ecvv.com", + "utanbaby.com", + "lavoixdunord.fr", + "just-eat.co.uk", + "go-for-files.com", + "afpbb.com", + "mybb.com", + "madmoizelle.com", + "sensacine.com", + "jtl-software.de", + "worldtimeserver.com", + "sunmaker.com", + "marieforleo.com", + "123sdfsdfsdfsd.ru", + "duga.jp", + "avery.com", + "tvguide.co.uk", + "salliemae.com", + "zap.com.br", + "my.tv.sohu.com/user/cc112", + "bookmark4you.com", + "twodollarclick.com", + "encontreinarede.com", + "joomshaper.com", + "marinetraffic.com", + "feedermatrix.com", + "nowvideo.at", + "millenium.org", + "newalbumreleases.net", + "frankkern.com", + "onlineconversion.com", + "ahlalhdeeth.com", + "mediawiki.org", + "xseo.in", + "generation-nt.com", + "naftemporiki.gr", + "hardforum.com", + "hornbunny.com", + "my.tv.sohu.com/user/cc124", + "housing.com", + "vogue.es", + "safemls.net", + "cuisineaz.com", + "estekhtam.com", + "coqnu.com", + "despegar.com.ar", + "fedoraproject.org", + "france2.fr", + "autovit.ro", + "tradetang.com", + "levelupgames.uol.com.br", + "dnforum.com", + "homebank.kz", + "carnival.com", + "hzycsj.com", + "army.mil", + "bootsnipp.com", + "istockimg.com", + "po-kaki-to.com", + "qiushibaike.com", + "tsb.co.uk", + "gzmama.com", + "aitnews.com", + "tripwiremagazine.com", + "torrenty.org", + "djangoproject.com", + "chelseafc.com", + "gamesgames.com", + "herold.at", + "baur.de", + "kauppalehti.fi", + "nrelate.com", + "clickwebinar.com", + "entropay.com", + "gridserver.com", + "virginia.gov", + "tuan800.com", + "trueactivist.com", + "caras.uol.com.br", + "fontawesome.io", + "haodou.com", + "reshareworthy.com", + "royalcaribbean.com", + "crakrevenue.com", + "motika.com.mk", + "xovi.de", + "deutsche-startups.de", + "inven.co.kr", + "atrapalo.com", + "ictv.ua", + "muji.net", + "kingplayer.com", + "adworkmedia.com", + "xjtu.edu.cn", + "thenounproject.com", + "professionali.ru", + "xizhi.com", + "boo-box.com", + "customink.com", + "groupon.my", + "spartoo.com", + "bannersdontwork.com", + "ncore.cc", + "reklama5.mk", + "macrojuegos.com", + "zenhabits.net", + "te3p.com", + "utah.gov", + "telesurtv.net", + "101.ru", + "5yi.com", + "lide.cz", + "ancestry.co.uk", + "sana.sy", + "siteslike.com", + "vg247.com", + "tyzhden.ua", + "ncsu.edu", + "apherald.com", + "taaza.com", + "traffic-delivery.com", + "uuyoyo.com", + "hwupgrade.it", + "game-debate.com", + "jetpack.wordpress.com", + "anycodes.com", + "femina.hu", + "zattoo.com", + "acm.org", + "comenity.net", + "tarot.com", + "azadliq.org", + "advertiserdigital.com", + "osym.gov.tr", + "empornium.me", + "netzero.net", + "myfico.com", + "nolix.ru", + "cnwnews.com", + "springpad.com", + "ahangestan.in", + "localbitcoins.com", + "nikkei.co.jp", + "youlikehits.com", + "boyfriendtv.com", + "wampserver.com", + "elnorte.com", + "codeschool.com", + "si.edu", + "nosis.com", + "downloadhelper.net", + "global-free-classified-ads.com", + "flagmantube.com", + "elnuevodiario.com.ni", + "handelsbanken.se", + "sverigesradio.se", + "femjoy.com", + "444.hu", + "calcalist.co.il", + "asiatech.ir", + "tv.nu", + "installmac.com", + "programmableweb.com", + "fotki.com", + "vidivodo.com", + "websquash.com", + "selfgrowth.com", + "wehkamp.nl", + "amawebs.com", + "3dlat.com", + "comunidades.net", + "streamin.to", + "idbi.com", + "cshtracker.com", + "cdbaby.com", + "mycommerce.com", + "united-domains.de", + "tradingview.com", + "niniweblog.com", + "avn.info.ve", + "apa.tv", + "pinnaclesports.com", + "adafruit.com", + "ipower.com", + "lebuteur.com", + "utah.edu", + "mobeoffice.com", + "lingualeo.com", + "fuub.net", + "tvmongol.com", + "namasthetelangaana.com", + "secretsearchenginelabs.com", + "whowhatwear.com", + "hiapk.com", + "torrentz.sx", + "php.su", + "sodahead.com", + "sbb.ch", + "k12.ca.us", + "jecontacte.com", + "thehollywoodgossip.com", + "pekao24.pl", + "yourtest-india.com", + "screwfix.com", + "humoron.com", + "yiwugou.com", + "mulher.uol.com.br", + "thehackernews.com", + "shopmania.ro", + "dlink.com", + "despegar.com", + "archlinux.org", + "nielsen.com", + "rosnet.ru", + "appsapk.com", + "funfarsi.ir", + "4over.com", + "subscribe.wordpress.com", + "lewrockwell.com", + "portalnet.cl", + "antenam.info", + "letribunaldunet.fr", + "see-tube.com", + "tureng.com", + "topcashback.co.uk", + "contactcars.com", + "jeux.fr", + "khan.co.kr", + "ffffound.com", + "gmail.com", + "laprensa.com.ni", + "jizzhut.com", + "liilas.com", + "muare.vn", + "kting.cn", + "heteml.jp", + "genericsteps.com", + "searchcompletion.com", + "dwayir.com", + "dicionarioinformal.com.br", + "vcita.com", + "fitsugar.com", + "kleiderkreisel.de", + "collective-evolution.com", + "ethz.ch", + "sendreach.com", + "abidjan.net", + "islamicfinder.org", + "elong.com", + "yonhapnews.co.kr", + "seratnews.ir", + "stream2watch.me", + "content-watch.ru", + "seotechnocrat.com", + "todaoferta.uol.com.br", + "toyota.jp", + "purevid.com", + "incredimail.com", + "kia.com", + "intensedebate.com", + "kaufmich.com", + "servis24.cz", + "brusheezy.com", + "rtbtraf.com", + "tejiawang.com", + "expedia.co.in", + "food52.com", + "top-channel.tv", + "jpnn.com", + "desitorrents.com", + "faxingw.cn", + "crutchfield.com", + "seneweb.com", + "usenet.nl", + "aviasales.ru", + "nesine.com", + "appshopper.com", + "dressupgamesite.com", + "lowendtalk.com", + "muslima.com", + "v-webs.com", + "linkomanija.net", + "geniuzz.com", + "caringbridge.org", + "gooya.com", + "dospy.com", + "siol.net", + "games.co.id", + "archiveofourown.org", + "rocketlawyer.com", + "free-downloadz.net", + "pastemagazine.com", + "invest-system.net", + "el-ahly.com", + "todayhumor.co.kr", + "racingpost.com", + "stereogum.com", + "soompi.com", + "pof.com.br", + "brainabundance.com", + "fontpalace.com", + "canon.jp", + "eldeforma.com", + "sacbee.com", + "jobscore.com", + "fashionista.com", + "mywork.vn", + "thisis50.com", + "cubadebate.cu", + "healthguru.com", + "instatheme.com", + "apotheken-umschau.de", + "blizko.ru", + "tinymce.com", + "virtualbox.org", + "tehran.ir", + "pr.gov.br", + "mlmleadsystempro.com", + "resbux.com", + "komonews.com", + "childrensplace.com", + "yoyopress.com", + "cloudify.cc", + "24livenewspaper.com", + "w4.com", + "islamway.net", + "fantagazzetta.com", + "imgspice.com", + "bovada.lv", + "payback.de", + "peb.pl", + "hotnigerianjobs.com", + "dev7studios.com", + "tejaratbank.net", + "takuhai.jp", + "travelmath.com", + "cultofmac.com", + "wakeupnow.com", + "insidefacebook.com", + "mediamarkt.es", + "500wan.com", + "rumah123.com", + "contentmarketinginstitute.com", + "ed.ac.uk", + "phimvang.com", + "womansday.com", + "lookatme.ru", + "citizensbank.com", + "esam.ir", + "phandroid.com", + "canadiantire.ca", + "serienjunkies.de", + "bbspink.com", + "yaranehkala.ir", + "vesti.bg", + "el-carabobeno.com", + "smarty.net", + "6tie.com", + "antpedia.com", + "p-world.co.jp", + "camelcamelcamel.com", + "sudu.cn", + "priberam.pt", + "infoworld.com", + "myrecipes.com", + "metrodeal.com", + "widgetbox.com", + "krone.at", + "outfox.tv", + "mymp4.in", + "685wo.com", + "sadanduseless.com", + "cgd.pt", + "mrmlsmatrix.com", + "parenting.com", + "tradepub.com", + "linkvehicle.com", + "mobiledia.com", + "rghost.ru", + "xxsy.net", + "goanimate.com", + "pikacn.com", + "metropcs.com", + "byu.edu", + "bitelia.com", + "designscrazed.com", + "wpde.org", + "paheal.net", + "nulled.cc", + "hmv.co.jp", + "openx.com", + "hyundai.com", + "vvvdj.com", + "reason.com", + "livesports.pl", + "polskieradio.pl", + "oszone.net", + "chinhphu.vn", + "performancehorizon.com", + "internetretailer.com", + "skoob.com.br", + "mediaworld.it", + "imgrind.com", + "bancopopular.es", + "seogadget.ru", + "m6.fr", + "rongbay.com", + "niazpardaz.com", + "rewity.com", + "ssense.com", + "sky-fire.com", + "flibusta.net", + "eat24hours.com", + "lotto.pl", + "cnw.com.cn", + "takvim.com.tr", + "englishtown.com", + "letudiant.fr", + "peliculasmas.com", + "askme.com", + "linksmanagement.com", + "webseoanalytics.com", + "presse-citron.net", + "eldiariodeamerica.com", + "instantshift.com", + "ampxchange.com", + "xe.gr", + "experts-exchange.com", + "sportcategory.com", + "sharecash.org", + "linksys.com", + "yninfo.com", + "onlinelic.in", + "aflamneek.com", + "22.cn", + "ubuntu-fr.org", + "cjs.com.cn", + "mp3clan.com", + "grani.ru", + "zen-cart.com", + "shippingchina.com", + "jsfor.net", + "wanadoo.es", + "zurker.com", + "chotot.vn", + "masaladesi.com", + "insight.ly", + "trivago.de", + "neue-sexpartner.com", + "boe.es", + "military.com", + "moonbasa.com", + "langlaoda.com", + "tnooz.com", + "zacks.com", + "liverpool.com.mx", + "internic.net", + "ecuavisa.com", + "autonews.ru", + "mcafeesecure.com", + "peopleclick.com", + "madthumbs.com", + "hot-live-chat.com", + "sugarcrm.com", + "notonthehighstreet.com", + "linio.com.co", + "smartbrief.com", + "auto-motor-und-sport.de", + "kyivpost.com", + "instantteleseminar.com", + "dillards.com", + "5i5j.com", + "runtastic.com", + "danawa.com", + "ladunliadi.blogspot.com", + "getnews.jp", + "romedic.ro", + "rodfile.com", + "instyle.com", + "swoodoo.com", + "bannersnack.com", + "evolife.cn", + "ktonanovenkogo.ru", + "office.com", + "zamalekfans.com", + "magiran.com", + "ithome.com", + "ktrmr.com", + "spoonful.com", + "olleh.com", + "bgr.in", + "industrialthemes.com", + "adbkm.com", + "tsa-algerie.com", + "bloggang.com", + "mojang.com", + "geoiptool.com", + "autocarindia.com", + "ajansspor.com", + "onmeda.de", + "midwayusa.com", + "alicdn.com", + "sportdog.gr", + "ideeli.com", + "haspa.de", + "gladbux.com", + "porn-star.com", + "experiandirect.com", + "yicheshi.com", + "acervoamador.com", + "designwall.com", + "balkanweb.com", + "response.jp", + "nettoos.com", + "beruby.com", + "manageyourloans.com", + "kidstaff.com.ua", + "indeed.co.za", + "monoprice.com", + "chsi.com.cn", + "boorsekala.com", + "mstaml.com", + "trafficvance.com", + "tatatele.in", + "startbootstrap.com", + "graphicburger.com", + "ad-vid-webs.com", + "jp.dk", + "one.co.il", + "athensvoice.gr", + "payu2blog.com", + "epidemz.net", + "dondominio.com", + "doviz.com", + "disquscdn.com", + "work.ua", + "vsemayki.ru", + "ikyu.com", + "songlyrics.com", + "onlinebank.com", + "thebump.com", + "travian.com.tr", + "java2s.com", + "twittmate.com", + "ignou.ac.in", + "relink.us", + "4738.com", + "printvenue.com", + "tekstowo.pl", + "natro.com", + "dengi-tut.info", + "freeservers.com", + "inbound.org", + "free-press-release.com", + "mydirtyhobby.com", + "gamefly.com", + "overclockers.co.uk", + "eci.nic.in", + "196.1.211.6", + "versus.com", + "batdongsan.com.vn", + "vrisko.gr", + "albayan.ae", + "trendcounter.com", + "500.com", + "pagomiscuentas.com", + "wankoz.com", + "duote.com", + "javascript.ru", + "chevrolet.com", + "coach.com", + "decidatriunfar.net", + "rememberthemilk.com", + "virginmobileusa.com", + "google.com.jm", + "ucm.es", + "ninja.co.jp", + "rqzao.com", + "periodistadigital.com", + "heritage.org", + "momtubesex.xxx", + "vocabulary.com", + "kupujemprodajem.com", + "e-cigarette-forum.com", + "paxum.com", + "ilpost.it", + "abercrombie.com", + "pearsonmylabandmastering.com", + "echoecho.com", + "expedia.co.jp", + "ticketfly.com", + "colostate.edu", + "sjtu.edu.cn", + "seobudget.ru", + "gigabyte.com", + "gsmspain.com", + "misr5.com", + "enterfactory.com", + "ciao.de", + "wuv.de", + "dagospia.com", + "slashgear.com", + "urdupoint.com", + "themepunch.com", + "travian.com", + "discuz.com", + "pixroute.com", + "otzovik.com", + "ubergizmo.com", + "edreams.fr", + "internet-positif.org", + "asmcentral.com", + "copadomundo.uol.com.br", + "adjal.com", + "gotomypc.com", + "partycity.com", + "leggo.it", + "blogosfere.it", + "teamcoco.com", + "pricedealsindia.com", + "glennbeck.com", + "allyou.com", + "china.org.cn", + "xitek.com", + "photoshopessentials.com", + "infopraca.pl", + "boardingarea.com", + "geni.com", + "rotaban.ru", + "foxtab.com", + "sadistic.pl", + "socialbro.com", + "tradesparq.com", + "itp.ne.jp", + "swefilmer.com", + "jobsite.co.uk", + "topwar.ru", + "yemeksepeti.com", + "tokfm.pl", + "businessinsider.com.au", + "moe.gov.eg", + "swedbank.lt", + "jxgdw.com", + "bayern.de", + "alistapart.com", + "bebinin.com", + "annunci69.it", + "plimus.com", + "cuevana2.tv", + "viamichelin.fr", + "whatsmydns.net", + "tarad.com", + "hostgator.com.br", + "hasbro.com", + "hi-chic.com", + "driverscollection.com", + "onetad.com", + "game2.com.cn", + "elitepvpers.com", + "tvuol.uol.com.br", + "caclubindia.com", + "diariocorreo.pe", + "c-rewards.com", + "business.gov.au", + "chooseauto.com.cn", + "timetrade.com", + "alternate.de", + "syracuse.com", + "advanceautoparts.com", + "shopware.de", + "newpct.com", + "proranktracker.com", + "cex.io", + "thebot.net", + "tradekorea.com", + "legifrance.gouv.fr", + "cpan.org", + "rightel.ir", + "247wallst.com", + "goldentowns.com", + "bankifsccode.com", + "color-hex.com", + "consumerist.com", + "juegosdiarios.com", + "on24.com", + "stockfreeimages.com", + "m4.cn", + "sponsoredtweets.com", + "open.ac.uk", + "bilyoner.com", + "lexisnexis.com", + "gsu.edu", + "popscreen.com", + "stiftung-warentest.de", + "education.com", + "leckerficken.de", + "hostinger.ru", + "staples.ca", + "greenpeace.org", + "mes-meilleurs-films.fr", + "delish.com", + "register.it", + "idiva.com", + "static.squarespace.com", + "ololo.fm", + "basketball-reference.com", + "tro-ma-ktiko.blogspot.gr", + "arabianbusiness.com", + "avianca.com", + "watchuseek.com", + "6play.fr", + "kora-online.tv", + "armagedomfilmes.biz", + "531314.com", + "craigslist.co.uk", + "inchallah.com", + "bongdaso.com", + "toprankblog.com", + "k12.com", + "itimes.com", + "html.net", + "utsandiego.com", + "gyakorikerdesek.hu", + "viddyhddownload.com", + "wannonce.com", + "qudong.com", + "ibicn.com", + "w3resource.com", + "socialsecurity.gov", + "tvn.pl", + "momsexclipz.com", + "fstoppers.com", + "kafeteria.pl", + "boulanger.fr", + "guj.nic.in", + "divaina.com", + "desktopnexus.com", + "topseda.ir", + "payumoney.com", + "klicktel.de", + "foxtv.es", + "cuatro.com", + "publix.com", + "astrosage.com", + "kompass.com", + "web-hosting.com", + "nus.edu.sg", + "jamiiforums.com", + "lancers.jp", + "peixeurbano.com.br", + "buysub.com", + "yp.com", + "enstage.com", + "6eat.com", + "1ent.com.cn", + "unionpaysecure.com", + "pcgames.de", + "ccidcom.com", + "lavenir.net", + "novaposhta.ua", + "hotpornshow.com", + "telebank.ru", + "avaz.ba", + "doit.com.cn", + "setlinks.ru", + "zagat.com", + "sportmaster.ru", + "utarget.ru", + "lingualeo.ru", + "compucalitv.com", + "anastasiadate.com", + "webmaster-rank.info", + "fastcoexist.com", + "lavasoft.com", + "ppvguru.com", + "greatist.com", + "knack.be", + "wowwiki.com", + "ilcorsaronero.info", + "jword.jp", + "750g.com", + "pantipmarket.com", + "top.de", + "photofunia.com", + "dryicons.com", + "alweeam.com.sa", + "dnfight.com", + "wpolityce.pl", + "vimeocdn.com", + "visit-x.net", + "takungpao.com", + "perfectworld.eu", + "kat.ph", + "hefei.cc", + "cmse.ru", + "virginia.edu", + "fudan.edu.cn", + "sethgodin.typepad.com", + "caracaschronicles.com", + "18qt.com", + "be2.com.br", + "rakuten.tw", + "bukkit.org", + "miss-no1.com", + "nts.org.pk", + "ulozto.net", + "mixpanel.com", + "glavred.info", + "vui.vn", + "mindspark.com", + "worldmarket.com", + "walmart.com.mx", + "deperu.com", + "taxact.com", + "m5zn.com", + "navy.mil", + "hibapress.com", + "cpasbien.com", + "interjet.com.mx", + "llbean.com", + "kenrockwell.com", + "japan-guide.com", + "financialpost.com", + "rankingsinstitute.com", + "master-x.com", + "pandawill.com", + "marketingweek.co.uk", + "freeforums.org", + "ysear.ch", + "pokerstars.com", + "wired.co.uk", + "amino.dk", + "rapidcrush.com", + "vivanuncios.com", + "blogsvertise.com", + "cwb.gov.tw", + "piter.tv", + "gistmania.com", + "topdocumentaryfilms.com", + "shoghlanty.com", + "bankmillennium.pl", + "burberry.com", + "youporngay.com", + "webresourcesdepot.com", + "beachbody.com", + "asstr.org", + "pwc.com", + "competitor.com", + "rss2search.com", + "vocuspr.com", + "behindthename.com", + "moniker.com", + "jayde.com", + "opensuse.org", + "poemhunter.com", + "toranoana.jp", + "interaksyon.com", + "aeon.co.jp", + "gungho.jp", + "fgov.be", + "xpg.uol.com.br", + "logic-immo.com", + "worldsex.com", + "watchonlineseries.eu", + "google.co.mz", + "discas.net", + "chmail.ir", + "consumercomplaints.in", + "allstate.com", + "twelveskip.com", + "ibibo.com", + "noelshack.com", + "bonprix.ru", + "directupload.net", + "equipobimlatino.com", + "weather2umbrella.com", + "aibang.com", + "blog.wordpress.com", + "turner.com", + "mediapart.fr", + "bloog.pl", + "monotaro.com", + "online.net", + "bodmillenium.com", + "distancesfrom.com", + "naosalvo.com.br", + "ap7am.com", + "focus.ua", + "cokeandpopcorn.ch", + "qwant.com", + "megaplan.ru", + "sinhvienit.net", + "dream-marriage.com", + "voicefive.com", + "forex.com.cn", + "xabbs.com", + "netmums.com", + "tuxboard.com", + "cs-cart.com", + "bitcoin.it", + "boblil.com", + "nirsoft.net", + "neopets.com", + "spin.com", + "costco.ca", + "mirraw.com", + "ara.cat", + "klamm.de", + "glam.com", + "guenstiger.de", + "citruspay.com", + "dnslink.com", + "guyism.com", + "shopotam.ru", + "tim.it", + "3suisses.fr", + "gooroops.com", + "kau.edu.sa", + "ukbusinessforums.co.uk", + "gree.jp", + "komikid.com", + "redakcja.pl", + "qpic.cn", + "voyeurweb.com", + "mathworks.com", + "monster.fr", + "seniat.gob.ve", + "computrabajo.com.co", + "xilu.com", + "madrid.org", + "ostraining.com", + "bharian.com.my", + "telegram.org", + "sumofus.org", + "whosdatedwho.com", + "moreofit.com", + "meetic.it", + "femina.mk", + "itworld.com", + "indiaglitz.com", + "cheatcc.com", + "filmfanatic.com", + "the-bux.net", + "very.co.uk", + "fetishshrine.com", + "speakingtree.in", + "iu.edu", + "modern.az", + "tak.ru", + "internetmarketingninjas.com", + "example.com", + "sportgeza.hu", + "wrestlezone.com", + "jameda.de", + "caikuu.com", + "gioco.it", + "yourtv.com.au", + "euro.com.pl", + "anz.co.nz", + "daft.ie", + "tirerack.com", + "vivareal.com.br", + "definebabe.com", + "ittefaq.com.bd", + "lastfm.es", + "zocalo.com.mx", + "dpd.de", + "somethingawful.com", + "virgin.com", + "shtyle.fm", + "viralforest.com", + "dntrck.com", + "its-mo.com", + "q.cc", + "kinghost.net", + "elpais.com.co", + "joomlaspanish.org", + "sopitas.com", + "wallbase.cc", + "cpalead.com", + "torrentfunk.com", + "bizcom.com.ru", + "quizony.com", + "rcgroups.com", + "spring.io", + "kuaidi100.com", + "xatakandroid.com", + "mlstatic.com", + "borsaat.com", + "jagobd.com", + "cosmiq.de", + "crucial.com", + "cdstm.cn", + "betclic.fr", + "telewebion.com", + "exhentai.org", + "gnezdo.ru", + "cebupacificair.com", + "fusionmls.com", + "shafaf.ir", + "ticketmaster.co.uk", + "adslzone.net", + "k8.cn", + "recipdonor.com", + "in.gov", + "mforos.com", + "asscj.com", + "linkconnector.com", + "ohfreesex.com", + "cntraveler.com", + "scambioetico.org", + "ladenzeile.de", + "ntn24.com", + "beyazperde.com", + "motherearthnews.com", + "yupptv.com", + "220tube.com", + "fizzle.co", + "lakii.com", + "deutsche-wirtschafts-nachrichten.de", + "saaid.net", + "bimlatino.com", + "verisign.com", + "funpatogh.com", + "matadornetwork.com", + "seatguru.com", + "lululemon.com", + "uzise.com", + "networkworld.com", + "hottube.me", + "jobsdb.com.hk", + "life.hu", + "bonusvid.com", + "incometaxindiaefiling.gov.in", + "ey.com", + "alraimedia.com", + "allposters.com", + "authorityroi.com", + "bmwusa.com", + "ebaystatic.com", + "entertainmentcrave.com", + "ehow.com.br", + "prisonplanet.com", + "elnashra.com", + "email.cz", + "yes123.com.tw", + "uitzendinggemist.nl", + "mindtools.com", + "atv.com.tr", + "shoes.net.cn", + "joomlaportal.de", + "themoneyconverter.com", + "meteomedia.com", + "bankaustria.at", + "advertise.com", + "trafficswarm.com", + "aztecaporno.com", + "fourseasons.com", + "movie-blog.org", + "govdelivery.com", + "didigames.com", + "invideo.biz", + "linux.org.ru", + "omelete.uol.com.br", + "babybus.cn", + "oursogo.com", + "ero-an.com", + "mediafax.ro", + "football.ua", + "sii.cl", + "dreamamateurs.com", + "cheaperthandirt.com", + "iplocation.net", + "insideview.com", + "hihe.vn", + "stop-sex.com", + "fubiz.net", + "url.org", + "greenmangaming.com", + "pornup.me", + "indofeed.com", + "forumhouse.ru", + "restaurant.com", + "key.com", + "windstream.net", + "brightedge.com", + "foreignpolicy.com", + "noticiasdatv.uol.com.br", + "logopond.com", + "datemule.com", + "webrootanywhere.com", + "stomp.com.sg", + "trthaber.com", + "bitterstrawberry.com", + "turbo.az", + "kbs.co.kr", + "joblo.com", + "seatimes.com.vn", + "kuwait.tt", + "258.com", + "kp.ua", + "moviesmobile.net", + "flamingtext.com", + "youngt.com", + "etradenow.cn", + "copart.com", + "tuanweihui.com", + "zinkwaphd.com", + "adsl.free.fr", + "infomaniak.ch", + "re-direcciona.me", + "mejorenvo.com", + "instantservice.com", + "harpersbazaar.com", + "colorado.edu", + "belboon.com", + "telelistas.net", + "photofans.cn", + "51seer.com", + "danjur.com", + "wunderweib.de", + "extratorrentlive.com", + "serpfox.com", + "androidkade.com", + "raja.ir", + "tampabay.com", + "ser-mujer.org", + "imasters.com.br", + "coachfactory.com", + "mojopages.com", + "makezine.com", + "forexschoolonline.com", + "bochk.com", + "siamsport.co.th", + "mdpr.jp", + "serialssolutions.com", + "videosexarchive.com", + "enlnks.com", + "cision.com", + "scratchinginfo.com", + "skidrowgames.net", + "optimizely.com", + "video2brain.com", + "ariva.de", + "audiomack.com", + "pimproll.com", + "house.gov", + "acs.org", + "pijamasurf.com", + "autoc-one.jp", + "southcn.com", + "vesti.az", + "300mbfilms.com", + "speedmystream.com", + "wooservers.com", + "siteliner.com", + "tinmoi.vn", + "extremepornvideos.com", + "cqsq.com", + "hello-today.com", + "turkcealtyazi.org", + "tvyo.com", + "dealmoon.com", + "openenglish.com", + "golfchannel.com", + "irancloob.com", + "ebs.in", + "portalcorreio.uol.com.br", + "beemp3s.org", + "condenast.com", + "mtwebcenters.com.tw", + "hatelabo.jp", + "pathci.net", + "mamsy.ru", + "noticiasdelmundo.org", + "guru3d.com", + "logomaker.com", + "adhitz.com", + "swiki.jp", + "turnitin.com", + "patoghu.com", + "carnaval.uol.com.br", + "cancer.org", + "clickprime8.com", + "fahrinfo-berlin.de", + "unisender.com", + "flashkhor.com", + "goodfon.ru", + "ethiotube.net", + "cunbang.com", + "ti-da.net", + "1phads.com", + "bien.hu", + "home77.com", + "mbabycare.com", + "vudu.com", + "fantasy8.com", + "landrover.com", + "opencartforum.ru", + "antena3.ro", + "getapp.com", + "torlock.com", + "wind.it", + "expatads.com", + "bloglines.com", + "sexytube.me", + "frontier.com", + "asandownload.com", + "groupon.pl", + "storesonlinepro.com", + "brands4friends.de", + "infogr.am", + "webeffector.ru", + "google.com.mm", + "ppchero.com", + "privacystar.com", + "ocregister.com", + "liex.ru", + "kopatheme.com", + "toggl.com", + "raywenderlich.com", + "hecha.cn", + "vpls.net", + "manpianyi.com", + "1881.no", + "scbeasy.com", + "plex.tv", + "selfridges.com", + "anumex.com", + "postplanner.com", + "thisiscolossal.com", + "you-will-date.com", + "idealist.org", + "emarketer.com", + "anibis.ch", + "dansmovies.com", + "footballitarin.com", + "fragrantica.com", + "10minutemail.com", + "ntu.edu.tw", + "clasicooo.com", + "onsugar.com", + "vr-zone.com", + "walkerplus.com", + "easymobilerecharge.com", + "cz001.com.cn", + "sportsseoul.com", + "inazumanews2.com", + "marketingdirecto.com", + "chartboost.com", + "unblocked.co", + "rhymezone.com", + "portalinmobiliario.com", + "afrointroductions.com", + "transunion.com", + "panorama.it", + "powershow.com", + "avval.ir", + "onlinemeetingnow.com", + "xoom.com", + "wnbc.com", + "tlen.pl", + "jetairways.com", + "vtb24.ru", + "offcn.com", + "crx7601.com", + "adverts.ie", + "kasserver.com", + "minhavida.com.br", + "jkpj.com", + "123contactform.com", + "imgtiger.com", + "folha.com.br", + "npcgo.com", + "semprot.com", + "moonfruit.com", + "jizzbell.com", + "online-stopwatch.com", + "allhiphop.com", + "hackaday.com", + "digitalplayground.com", + "careers24.com", + "cwq.com", + "wondershare.com", + "filesend.to", + "puromarketing.com", + "workopolis.com", + "mudainodocument.com", + "home.ne.jp", + "shorte.st", + "tanea.gr", + "sporza.be", + "vgorode.ua", + "google.co.zm", + "argumentua.com", + "3m.com", + "komputerswiat.pl", + "bongdaplus.vn", + "supersonicads.com", + "soundclick.com", + "lollipop-network.com", + "lpcloudsvr304.com", + "313.cn", + "rtl2.de", + "ts.cn", + "mglradio.com", + "diynetwork.com", + "komikcaps.net", + "all-that-is-interesting.com", + "ultipro.com", + "frombar.com", + "sitedeals.nl", + "codingforums.com", + "kansascity.com", + "twtrland.com", + "cengage.com", + "lolspotsarticles.com", + "jackthreads.com", + "jobstreet.com.sg", + "diffen.com", + "eme2000.com", + "superbru.com", + "droid-life.com", + "itb-berlin.de", + "estibot.com", + "yourepeat.com", + "112.ua", + "70e.com", + "grid.mk", + "cromaretail.com", + "jobstreet.com.ph", + "gloadmarket.com", + "gemius.com", + "huuto.net", + "vogue.it", + "divxonline.info", + "mytoys.de", + "cashnhits.com", + "minkchan.com", + "talabat.com", + "helpareporter.com", + "grandascent.com", + "catalunyacaixa.com", + "sparwelt.de", + "tvboxnow.com", + "imagecurl.org", + "coocan.jp", + "eatingwell.com", + "truelife.com", + "binaryoptionsbrands.com", + "foxsportsla.com", + "jjshouse.com", + "makaan.com", + "yamaha.com", + "activerain.com", + "excelforum.com", + "mobinnet.ir", + "kasikornbankgroup.com", + "googleplex.com", + "medianama.com", + "fullsail.edu", + "makeupandbeauty.com", + "marketwired.com", + "beachbodycoach.com", + "taloussanomat.fi", + "youngliving.us", + "dana.ir", + "adsgostar.com", + "esquire.com.cn", + "meyerweb.com", + "positivemed.com", + "harvestapp.com", + "tim.com.br", + "sumorobo.net", + "zbigz.com", + "schulferien.org", + "quzhao.com", + "tsinghua.edu.cn", + "vogue.com", + "ecrater.com", + "internetbs.net", + "oper.ru", + "kingstone.com.tw", + "olympic.org", + "code.org", + "wp.tv", + "adchakra.net", + "passarela.com.br", + "damn.com", + "spn.com.cn", + "sacitaslan.com", + "uplod.ir", + "kununu.com", + "englishclub.com", + "ibood.com", + "buzzfed.com", + "peopledaily.com.cn", + "vivastreet.it", + "adshostnet.com", + "npmjs.org", + "lovethatsex.com", + "garena.tw", + "hq-sex-tube.com", + "tvsubtitles.net", + "trademarkia.com", + "96down.com", + "morhipo.com", + "chuguoqu.com", + "free-css.com", + "getsecuredfiles.com", + "justia.com", + "paypal-community.com", + "wezoner.com", + "google-analytics.com", + "outsideonline.com", + "simplymeasured.com", + "wattsupwiththat.com", + "vancl.com", + "leadership.ng", + "plaisio.gr", + "fastcocreate.com", + "fewo-direkt.de", + "dedecms.com", + "bostonherald.com", + "elmundo.com.ve", + "idhostinger.com", + "animaljam.com", + "infoq.com", + "exler.ru", + "leprosorium.ru", + "avis.com", + "ulusalpost.com", + "namnak.com", + "goindigo.in", + "activeboard.com", + "fatsecret.com", + "4umf.com", + "porn-w.org", + "sarkariexam.co.in", + "patagonia.com", + "3u5.net", + "roshd.ir", + "netechangisme.com", + "ojogo.pt", + "ujipin.com", + "topuniversities.com", + "consequenceofsound.net", + "no-ip.biz", + "webdesignerwall.com", + "fin24.com", + "openculture.com", + "pbh2.com", + "dota2.com", + "secureupload.eu", + "alfajertv.com", + "canlidizihdtv.com", + "muffingroup.com", + "imageforum.com", + "paris.fr", + "kaufda.de", + "pelis24.com", + "ixian.cn", + "ebenpagan.com", + "sportsauthority.com", + "wish.com", + "ganeshaspeaks.com", + "meritnation.com", + "ijie.com", + "vodafone.com.tr", + "trovit.es", + "farsisubtitle.com", + "musawvir.com", + "resellerratings.com", + "soyentrepreneur.com", + "samakal.net", + "dietnavi.com", + "55tuan.com", + "elcomercio.com", + "hereisthecity.com", + "buienradar.nl", + "arenabg.com", + "indiansexstories.net", + "slideboom.com", + "findsection.net", + "rankrecon.com", + "e-radio.gr", + "cnn.co.jp", + "gucci.com", + "natura.net", + "googlesyndication.com", + "advancedwebranking.com", + "lib.ru", + "sfora.pl", + "uci.edu", + "haaretz.co.il", + "ing.be", + "yokboylebirsey.com.tr", + "myfact.tv", + "yenibiris.com", + "stuff.tv", + "dn.pt", + "whydontyoutrythis.com", + "nediyor.com", + "worldoftanks.asia", + "megamillions.com", + "elemanonline.net", + "computrabajo.com.pe", + "arxiv.org", + "livescore.tv", + "aintitcool.com", + "girlschannel.net", + "madbid.com", + "tadawul.com.sa", + "liqpay.com", + "softonic.jp", + "alhilal.com", + "bizpowa.com", + "thatguywiththeglasses.com", + "yemeneconomist.com", + "pazar3.mk", + "repai.com", + "1jux.net", + "solvusoft.com", + "yotpo.com", + "cuantocabron.com", + "ba.gov.br", + "arin.net", + "loginza.ru", + "homebank.ro", + "0755car.com", + "carscoops.com", + "antarvasna.com", + "tizag.com", + "offerpop.com", + "techmeme.com", + "ipress.ua", + "emuparadise.me", + "sexvidx.com", + "whatseek.com", + "become.co.jp", + "snapfish.com", + "gsis.gr", + "speedyshare.com", + "uncrate.com", + "doda.jp", + "straighttalk.com", + "rsjoomla.com", + "vozpopuli.com", + "gotprint.net", + "finansbank.com.tr", + "chinatrust.com.tw", + "stratoserver.net", + "icnetwork.co.uk", + "getpopcornti.me", + "pornper.com", + "3dmgame.com", + "squirt.org", + "mbusa.com", + "katespade.com", + "skat.dk", + "radiko.jp", + "dexonline.ro", + "bicaps.net", + "bitsoma.com", + "brasil247.com", + "alittlemarket.com", + "bd-pratidin.com", + "amorincontro.com", + "bigxvideos.com", + "nissan.co.jp", + "incomediary.com", + "theranking.com", + "el7l.co", + "webcamtoy.com", + "steamgifts.com", + "miles-and-more.com", + "szonline.net", + "blocked-website.com", + "kaztorka.org", + "avforums.com", + "indulgy.com", + "extendcp.co.uk", + "yonkis.com", + "ad1111.com", + "unionbankph.com", + "job.com", + "samanepay.com", + "aceona.com", + "kar.nic.in", + "tipico.com", + "sa.ae", + "froma.com", + "songza.com", + "calciomercato.com", + "besaba.com", + "x-rates.com", + "arsys.es", + "sisal.it", + "amateur.tv", + "designyourway.net", + "alpha.gr", + "nimble.com", + "livefreefun.com", + "wipo.int", + "webssearches.com", + "vodjk.com", + "91tiger.com", + "swisscom.com", + "tuvaro.com", + "parsonline.net", + "uolhost.com.br", + "cnwest.com", + "roksa.pl", + "socialmention.com", + "unibytes.com", + "screamingfrog.co.uk", + "owncloud.org", + "jacquielawson.com", + "openclipart.org", + "zimbra.com", + "poczta-polska.pl", + "hayah.cc", + "ringtonematcher.com", + "emai.com", + "wealink.com", + "celebzen.com", + "pichost.me", + "rediffmail.com", + "dinos.co.jp", + "netvasco.com.br", + "meilele.com", + "career.ru", + "signupgenius.com", + "screencast-o-matic.com", + "nav.no", + "reactiongifs.com", + "italki.com", + "mo.gov", + "bandsintown.com", + "elwatan.com", + "jdate.com", + "quiente.net", + "skynet.be", + "googlekeywordtool.com", + "nubilefilms.com", + "memedeportes.com", + "rewardingzonez.com", + "litmus.com", + "iyaxin.com", + "collegeconfidential.com", + "semperplugins.com", + "sofort.com", + "ineedhits.com", + "live24.gr", + "acronymfinder.com", + "jobui.com", + "9show.com", + "thedirty.com", + "tsutaya.co.jp", + "9787.com", + "brighthouse.com", + "boxingscene.com", + "indeed.com.br", + "morazzia.com", + "privatejobshub.blogspot.in", + "searchenginepeople.com", + "pozdravok.ru", + "watchstore.com.cn", + "rts.ch", + "pluska.sk", + "villagevoice.com", + "sprintrade.com", + "conversionxl.com", + "evsuite.com", + "bci.cl", + "lampsplus.com", + "gossipcop.com", + "valuecommerce.com", + "zalora.co.id", + "fastshop.com.br", + "hockeysfuture.com", + "bootply.com", + "chinavasion.com", + "menards.com", + "kinobar.net", + "tokyodisneyresort.jp", + "knownhost.com", + "ozbargain.com.au", + "olx.com.ve", + "sgk.gov.tr", + "berliner-sparkasse.de", + "bancogalicia.com.ar", + "joomla-master.org", + "augsburger-allgemeine.de", + "kroger.com", + "pulse.ng", + "putlocker.com", + "jrtj.com", + "tapuz.co.il", + "madhyamam.com", + "donews.com", + "showhaber.com", + "allxnxx.com", + "uned.es", + "adsharebux.com", + "d-addicts.com", + "banki.ir", + "levi.com", + "e97527f0.se", + "entertainmentwise.com", + "xvideos-field.com", + "naver.net", + "urbia.de", + "fashionsfriend.com", + "emuch.net", + "yelp.fr", + "metatube.com", + "sina.com.hk", + "omb100.com", + "grameenphone.com", + "stylebook.de", + "funny-games.biz", + "googlewebmastercentral.blogspot.com", + "vogella.com", + "surveymonkey.net", + "forex4you.org", + "mex.tl", + "online-fish-games.com", + "millenniumbcp.pt", + "fileom.com", + "friendorfollow.com", + "downloads.nl", + "typekit.com", + "gongkong.com", + "iqoption.com", + "tori.fi", + "smartsource.com", + "1616.net", + "1shoppingcart.com", + "novosti.rs", + "yofond.com", + "idokep.hu", + "motor.ru", + "xbiao.com", + "colorcombos.com", + "pway.cn", + "egynews.net", + "elshaab.org", + "telus.com", + "olx.com.co", + "cctvcj.com", + "kpopstarz.com", + "razorsocial.com", + "ncrypt.in", + "zonetheme.com", + "gumroad.com", + "e-shop.gr", + "kugli.com", + "levif.be", + "bookfi.org", + "globalresearch.ca", + "sas.com", + "cloudaccess.net", + "uplooder.net", + "exposedwebcams.com", + "1prime.ru", + "webappers.com", + "crocko.com", + "remax.com", + "ikco.com", + "dinside.no", + "winbank.gr", + "mijnwoordenboek.nl", + "weatherzone.com.au", + "allday2.com", + "sunat.gob.pe", + "getit.in", + "entrance-exam.net", + "i2ya.com", + "tlife.gr", + "qyer.com", + "calibre-ebook.com", + "internetcorkboard.com", + "unitedhyipleague.com", + "spyrestudios.com", + "metal-archives.com", + "aeromexico.com", + "cv-library.co.uk", + "bdr1.net", + "aremo.com.br", + "blip.tv", + "afilio.com.br", + "renewalcoupons.com", + "proxfree.com", + "magix.com", + "jobs.net", + "souism.com", + "adtcstrk.com", + "goodhousekeeping.com", + "lastfm.ru", + "sharecare.com", + "porn.xxx", + "deathandtaxesmag.com", + "unocero.com", + "wer-kennt-wen.de", + "hotfrog.com", + "intraship.de", + "press24.mk", + "yournewscorner.com", + "rbc.com", + "eventure.com", + "minglebox.com", + "legendas.tv", + "drp.su", + "voicefrom.me", + "venezuelaaldia.com", + "cooks.com", + "numbeo.com", + "chilehardware.cl", + "cryptocointalk.com", + "venusfactor.com", + "recruitmentcareer.in", + "larazon.es", + "sptechs.com", + "asx.com.au", + "ahlife.com", + "st001.com", + "actudesfinances.info", + "talkarcades.com", + "nitori-net.jp", + "chinahr.com", + "websitetestlink.com", + "hypem.com", + "demorgen.be", + "sharefile.com", + "prensalibre.com", + "eldia.com.ar", + "billiger.de", + "3docean.net", + "streamsend.com", + "tuaw.com", + "portafolio.co", + "trivago.com", + "olxpix.com", + "geotrust.com", + "torrentgun.net", + "enha.kr", + "pcastuces.com", + "t.cn", + "dimsemenov.com", + "cam4.nl", + "basspro.com", + "macupdate.com", + "strawpoll.me", + "elintransigente.com", + "homeaway.co.uk", + "my.ecwid.com", + "graphpaperpress.com", + "architonic.com", + "flowplayer.org", + "syshl.com", + "18schoolgirlz.com" + }); + + return urls; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/urls_large_data.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/urls_large_data.hpp new file mode 100644 index 0000000..06be4ac --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/crawl/urls_large_data.hpp @@ -0,0 +1,18 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP +#define BOOST_BEAST_EXAMPLE_HTTP_CLIENT_CRAWL_URLS_LARGE_DATA_HPP + +#include + +std::vector const& +urls_large_data(); + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/CMakeLists.txt new file mode 100644 index 0000000..2e9fcdc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-methods + Jamfile + http_client_methods.cpp) + +source_group("" FILES + Jamfile + http_client_methods.cpp) + +target_link_libraries(http-client-methods PRIVATE Boost::beast) + +set_target_properties(http-client-methods + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/Jamfile new file mode 100644 index 0000000..e16fd57 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-client-methods : + http_client_methods.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/http_client_methods.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/http_client_methods.cpp new file mode 100644 index 0000000..f48cf99 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/methods/http_client_methods.cpp @@ -0,0 +1,225 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous for every method on httpbin +// +//------------------------------------------------------------------------------ + +//[example_http_client_methods + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = net::ip::tcp; // from + + +// perform a get request +void do_get(beast::tcp_stream & stream, + http::request & req, + beast::flat_buffer buffer, + http::response & res) +{ + req.target("/get"); + req.method(beast::http::verb::get); + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a head request +void do_head(beast::tcp_stream & stream, + http::request & req, + beast::flat_buffer buffer, + http::response & res) +{ + // we reuse the get endpoint + req.target("/get"); + req.method(beast::http::verb::head); + http::write(stream, req); + + /* the head response will send back a content-length + * without a body. The other requests don't set content-length when not + * sending a body back. + * + * the response parser doesn't know that we sent head, + * so we need to manually make sure we're only reading the header + * otherwise we're waiting forever for data. + */ + + http::response_parser p; + http::read_header(stream, buffer, p); + // move the result over + res = p.release(); +} + + +// perform a patch request +void do_patch(beast::tcp_stream & stream, + http::request & req, + beast::flat_buffer buffer, + http::response & res) +{ + req.target("/patch"); + req.method(beast::http::verb::patch); + req.body() = "Some random patch data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + + +// perform a put request +void do_put(beast::tcp_stream & stream, + http::request & req, + beast::flat_buffer buffer, + http::response & res) +{ + req.target("/put"); + req.method(beast::http::verb::put); + req.body() = "Some random put data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + +// perform a post request +void do_post(beast::tcp_stream & stream, + http::request & req, + beast::flat_buffer buffer, + http::response & res) +{ + req.target("/post"); + req.method(beast::http::verb::post); + req.body() = "Some random post data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + + +// perform a delete request +void do_delete(beast::tcp_stream & stream, + http::request & req, + beast::flat_buffer buffer, + http::response & res) +{ + req.target("/delete"); + req.method(beast::http::verb::delete_); + // NOTE: delete doesn't require a body + req.body() = "Some random delete data"; + req.prepare_payload(); // set content-length based on the body + http::write(stream, req); + http::read(stream, buffer, res); +} + + +// Performs an HTTP request against httpbin.cpp.al and prints request & response +int main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 2) + { + std::cerr << + "Usage: http-client-method \n" << + "Example:\n" << + " http-client-method get\n" << + " http-client-method post\n"; + return EXIT_FAILURE; + } + + for (char * c = argv[1]; *c != '\0'; c++) + *c = static_cast(std::tolower(*c)); + beast::string_view method{argv[1]}; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve("httpbin.cpp.al", "http"); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + + // Set up an HTTP GET request message + http::request req; + req.set(http::field::host, "httpbin.cpp.al"); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + if (method == "get") + do_get(stream, req, buffer, res); + else if (method == "head") + do_head(stream, req, buffer, res); + else if (method == "patch") + do_patch(stream, req, buffer, res); + else if (method == "put") + do_put(stream, req, buffer, res); + else if (method == "post") + do_post(stream, req, buffer, res); + else if (method == "delete") + do_delete(stream, req, buffer, res); + else + { + std::cerr << "Unknown method: " << method << std::endl; + return EXIT_FAILURE; + } + + // Write the message to standard out + std::cout << "Request send:\n-----------------------------\n" + << req << std::endl; + + + // Write the message to standard out + std::cout << "\n\nResponse received:\n-----------------------------\n" + << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if(ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/CMakeLists.txt new file mode 100644 index 0000000..42e4d75 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-sync-ssl + Jamfile + http_client_sync_ssl.cpp) + +source_group("" FILES + Jamfile + http_client_sync_ssl.cpp) + +target_include_directories(http-client-sync-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-client-sync-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-client-sync-ssl + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/Jamfile new file mode 100644 index 0000000..8f14c52 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-client-sync-ssl : + http_client_sync_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/http_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/http_client_sync_ssl.cpp new file mode 100644 index 0000000..7cb768c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -0,0 +1,139 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using tcp = net::ip::tcp; // from + +// Performs an HTTP GET and prints the response +int main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-sync-ssl []\n" << + "Example:\n" << + " http-client-sync-ssl www.example.com 443 /\n" << + " http-client-sync-ssl www.example.com 443 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx(ssl::context::tlsv12_client); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // These objects perform our I/O + tcp::resolver resolver(ioc); + ssl::stream stream(ioc, ctx); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(stream.native_handle(), host)) + { + throw beast::system_error( + static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + stream.set_verify_callback(ssl::host_name_verification(host)); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(stream).connect(results); + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::client); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the stream + beast::error_code ec; + stream.shutdown(ec); + + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec != net::ssl::error::stream_truncated) + throw beast::system_error{ec}; + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/CMakeLists.txt new file mode 100644 index 0000000..f1765ef --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-client-sync + Jamfile + http_client_sync.cpp) + +source_group("" FILES + Jamfile + http_client_sync.cpp) + +target_link_libraries(http-client-sync PRIVATE Boost::beast) + +set_target_properties(http-client-sync + PROPERTIES FOLDER "example-http-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/Jamfile new file mode 100644 index 0000000..969246f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-client-sync : + http_client_sync.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/http_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/http_client_sync.cpp new file mode 100644 index 0000000..7956181 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/client/sync/http_client_sync.cpp @@ -0,0 +1,105 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_http_client + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = net::ip::tcp; // from + +// Performs an HTTP GET and prints the response +int main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4 && argc != 5) + { + std::cerr << + "Usage: http-client-sync []\n" << + "Example:\n" << + " http-client-sync www.example.com 80 /\n" << + " http-client-sync www.example.com 80 / 1.0\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const target = argv[3]; + int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + beast::tcp_stream stream(ioc); + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + stream.connect(results); + + // Set up an HTTP GET request message + http::request req{http::verb::get, target, version}; + req.set(http::field::host, host); + req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); + + // Send the HTTP request to the remote host + http::write(stream, req); + + // This buffer is used for reading and must be persisted + beast::flat_buffer buffer; + + // Declare a container to hold the response + http::response res; + + // Receive the HTTP response + http::read(stream, buffer, res); + + // Write the message to standard out + std::cout << res << std::endl; + + // Gracefully close the socket + beast::error_code ec; + stream.socket().shutdown(tcp::socket::shutdown_both, ec); + + // not_connected happens sometimes + // so don't bother reporting it. + // + if(ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; + + // If we get here then the connection is closed gracefully + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/CMakeLists.txt new file mode 100644 index 0000000..79e80b8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(async) +add_subdirectory(async-local) +add_subdirectory(awaitable) +add_subdirectory(coro) +add_subdirectory(fast) +add_subdirectory(small) +add_subdirectory(stackless) +add_subdirectory(sync) + +if (OPENSSL_FOUND) + add_subdirectory(async-ssl) + add_subdirectory(coro-ssl) + add_subdirectory(flex) + add_subdirectory(stackless-ssl) + add_subdirectory(sync-ssl) +endif () diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/Jamfile new file mode 100644 index 0000000..8a2df2b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/Jamfile @@ -0,0 +1,24 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project async ; +build-project async-local ; +build-project coro ; +build-project fast ; +build-project small ; +build-project stackless ; +build-project sync ; +build-project awaitable ; + +# SSL +build-project async-ssl ; +build-project coro-ssl ; +build-project flex ; +build-project stackless-ssl ; +build-project sync-ssl ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/CMakeLists.txt new file mode 100644 index 0000000..be555d8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-async-local + Jamfile + http_server_async_local.cpp) + +source_group("" FILES + Jamfile + http_server_async_local.cpp) + +target_link_libraries(http-server-async-local PRIVATE Boost::beast) + +set_target_properties(http-server-async-local + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/Jamfile new file mode 100644 index 0000000..e3a8fee --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-async-local : + http_server_async_local.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/http_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/http_server_async_local.cpp new file mode 100644 index 0000000..b958b89 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-local/http_server_async_local.cpp @@ -0,0 +1,454 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using stream_protocol = net::local::stream_protocol; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this +{ + beast::basic_stream< + stream_protocol, + net::any_io_executor, + beast::unlimited_rate_policy> stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session( + stream_protocol::socket&& socket, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)) + , doc_root_(doc_root) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler( + &session::do_read, + shared_from_this())); + } + + void + do_read() + { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if(ec == http::error::end_of_stream) + return do_close(); + + if(ec) + return fail(ec, "read"); + + // Send the response + send_response( + handle_request(*doc_root_, std::move(req_))); + } + + void + send_response(http::message_generator&& msg) + { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, + std::move(msg), + beast::bind_front_handler( + &session::on_write, shared_from_this(), keep_alive)); + } + + void + on_write( + bool keep_alive, + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); + } + + // Read another request + do_read(); + } + + void + do_close() + { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(stream_protocol::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + stream_protocol::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + stream_protocol::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , acceptor_(net::make_strand(ioc), std::move(endpoint)) + , doc_root_(doc_root) + { + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, stream_protocol::socket socket) + { + if(ec) + { + fail(ec, "accept"); + return; // To avoid infinite loop + } + else + { + // Create the session and run it + std::make_shared( + std::move(socket), + doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: http-server-async-local \n" << + "Example:\n" << + " http-server-async-local /tmp/http.sock . 1\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; + auto const doc_root = std::make_shared(argv[2]); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Remove previous binding + std::remove(path); + + // Create and launch a listening port + std::make_shared( + ioc, + stream_protocol::endpoint{path}, + doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; + } + catch(std::exception const& e) + { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; + } +} + +#else + +int +main(int, char*[]) +{ +std::cerr << + "Local sockets not available on this platform" << std::endl; +return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/CMakeLists.txt new file mode 100644 index 0000000..a225deb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-async-ssl + Jamfile + http_server_async_ssl.cpp) + +source_group("" FILES + Jamfile + http_server_async_ssl.cpp) + +target_include_directories(http-server-async-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-server-async-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-server-async-ssl + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/Jamfile new file mode 100644 index 0000000..aac0ffa --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-server-async-ssl : + http_server_async_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/http_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/http_server_async_ssl.cpp new file mode 100644 index 0000000..b6498d3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async-ssl/http_server_async_ssl.cpp @@ -0,0 +1,534 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this +{ + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the socket + explicit + session( + tcp::socket&& socket, + ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx) + , doc_root_(doc_root) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch( + stream_.get_executor(), + beast::bind_front_handler( + &session::on_run, + shared_from_this())); + } + + void + on_run() + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after( + std::chrono::seconds(30)); + + // Perform the SSL handshake + stream_.async_handshake( + ssl::stream_base::server, + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + do_read(); + } + + void + do_read() + { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if(ec == http::error::end_of_stream) + return do_close(); + + if(ec) + return fail(ec, "read"); + + // Send the response + send_response( + handle_request(*doc_root_, std::move(req_))); + } + + void + send_response(http::message_generator&& msg) + { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, + std::move(msg), + beast::bind_front_handler( + &session::on_write, + this->shared_from_this(), + keep_alive)); + } + + void + on_write( + bool keep_alive, + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); + } + + // Read another request + do_read(); + } + + void + do_close() + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler( + &session::on_shutdown, + shared_from_this())); + } + + void + on_shutdown(beast::error_code ec) + { + if(ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , ctx_(ctx) + , acceptor_(ioc) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + return; // To avoid infinite loop + } + else + { + // Create the session and run it + std::make_shared( + std::move(socket), + ctx_, + doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-async-ssl
\n" << + "Example:\n" << + " http-server-async-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared( + ioc, + ctx, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/CMakeLists.txt new file mode 100644 index 0000000..c3a13b1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-async + Jamfile + http_server_async.cpp) + +source_group("" FILES + Jamfile + http_server_async.cpp) + +target_link_libraries(http-server-async PRIVATE Boost::beast) + +set_target_properties(http-server-async + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/Jamfile new file mode 100644 index 0000000..f36d1ad --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-async : + http_server_async.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/http_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/http_server_async.cpp new file mode 100644 index 0000000..617701d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/async/http_server_async.cpp @@ -0,0 +1,459 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session : public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + +public: + // Take ownership of the stream + session( + tcp::socket&& socket, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)) + , doc_root_(doc_root) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler( + &session::do_read, + shared_from_this())); + } + + void + do_read() + { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read(stream_, buffer_, req_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if(ec == http::error::end_of_stream) + return do_close(); + + if(ec) + return fail(ec, "read"); + + // Send the response + send_response( + handle_request(*doc_root_, std::move(req_))); + } + + void + send_response(http::message_generator&& msg) + { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + stream_, + std::move(msg), + beast::bind_front_handler( + &session::on_write, shared_from_this(), keep_alive)); + } + + void + on_write( + bool keep_alive, + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return do_close(); + } + + // Read another request + do_read(); + } + + void + do_close() + { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , acceptor_(net::make_strand(ioc)) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + return; // To avoid infinite loop + } + else + { + // Create the session and run it + std::make_shared( + std::move(socket), + doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-async
\n" << + "Example:\n" << + " http-server-async 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared( + ioc, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/CMakeLists.txt new file mode 100644 index 0000000..ed0aaa7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-awaitable + Jamfile + http_server_awaitable.cpp) + +source_group("" FILES + Jamfile + http_server_awaitable.cpp) + +target_link_libraries(http-server-awaitable PRIVATE Boost::beast) + +set_target_properties(http-server-awaitable + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/Jamfile new file mode 100644 index 0000000..3c3fada --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-awaitable : + http_server_awaitable.cpp + : + coverage:no + ubasan:no + no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/http_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/http_server_awaitable.cpp new file mode 100644 index 0000000..0933bd5 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/awaitable/http_server_awaitable.cpp @@ -0,0 +1,337 @@ +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace net = boost::asio; + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +// Handles an HTTP server connection +net::awaitable +do_session( + beast::tcp_stream stream, + std::shared_ptr doc_root) +{ + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for(;;) + { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + co_await http::async_read(stream, buffer, req); + + // Handle the request + http::message_generator msg = handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + // Send the response + co_await beast::async_write(stream, std::move(msg)); + + if(!keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(net::ip::tcp::socket::shutdown_send); + + // At this point the connection is closed gracefully + // we ignore the error because the client might have + // dropped the connection already. +} + +// Accepts incoming connections and launches the sessions +net::awaitable +do_listen(net::ip::tcp::endpoint endpoint, std::shared_ptr doc_root) +{ + auto executor = co_await net::this_coro::executor; + auto acceptor = net::ip::tcp::acceptor{ executor, endpoint }; + + for(;;) + { + net::co_spawn( + executor, + do_session( + beast::tcp_stream{ co_await acceptor.async_accept() }, + doc_root), + [](std::exception_ptr e) + { + if(e) + { + try + { + std::rethrow_exception(e); + } + catch(std::exception const& e) + { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +int +main(int argc, char* argv[]) +{ + // Check command line arguments. + if(argc != 5) + { + std::cerr << "Usage: http-server-awaitable
\n" + << "Example:\n" + << " http-server-awaitable 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{ threads }; + + // Spawn a listening port + net::co_spawn( + ioc, + do_listen(net::ip::tcp::endpoint{ address, port }, doc_root), + [](std::exception_ptr e) + { + if(e) + { + try + { + std::rethrow_exception(e); + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { ioc.run(); }); + ioc.run(); + + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif \ No newline at end of file diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/CMakeLists.txt new file mode 100644 index 0000000..19846a8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-coro-ssl + Jamfile + http_server_coro_ssl.cpp) + +source_group("" FILES + Jamfile + http_server_coro_ssl.cpp) + +target_include_directories(http-server-coro-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-server-coro-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-server-coro-ssl + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/Jamfile new file mode 100644 index 0000000..18d5cce --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/Jamfile @@ -0,0 +1,23 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-server-coro-ssl : + http_server_coro_ssl.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/http_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/http_server_coro_ssl.cpp new file mode 100644 index 0000000..93e3b2f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -0,0 +1,413 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void +do_session( + ssl::stream& stream, + std::shared_ptr const& doc_root, + net::yield_context yield) +{ + bool keep_alive = true; + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + stream.async_handshake(ssl::stream_base::server, yield[ec]); + if(ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for(;;) + { + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if(ec == http::error::end_of_stream) + break; + if(ec) + return fail(ec, "read"); + + // Handle the request + http::message_generator res = + handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + keep_alive = res.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(res), yield[ec]); + + if(ec) + return fail(ec, "write"); + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream.async_shutdown(yield[ec]); + if(ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void +do_listen( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root, + net::yield_context yield) +{ + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if(ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if(ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + return fail(ec, "listen"); + + for(;;) + { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if(ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind( + &do_session, + ssl::stream( + std::move(socket), ctx), + doc_root, + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-coro-ssl
\n" << + "Example:\n" << + " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind( + &do_listen, + std::ref(ioc), + std::ref(ctx), + tcp::endpoint{address, port}, + doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/CMakeLists.txt new file mode 100644 index 0000000..c7b24be --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-coro + Jamfile + http_server_coro.cpp) + +source_group("" FILES + Jamfile + http_server_coro.cpp) + +target_link_libraries(http-server-coro PRIVATE Boost::beast) + +set_target_properties(http-server-coro + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/Jamfile new file mode 100644 index 0000000..b323258 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-coro : + http_server_coro.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/http_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/http_server_coro.cpp new file mode 100644 index 0000000..213bb41 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/coro/http_server_coro.cpp @@ -0,0 +1,370 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + + +// Handles an HTTP server connection +void +do_session( + beast::tcp_stream& stream, + std::shared_ptr const& doc_root, + net::yield_context yield) +{ + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + for(;;) + { + // Set the timeout. + stream.expires_after(std::chrono::seconds(30)); + + // Read a request + http::request req; + http::async_read(stream, buffer, req, yield[ec]); + if(ec == http::error::end_of_stream) + break; + if(ec) + return fail(ec, "read"); + + // Handle the request + http::message_generator msg = + handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + // Send the response + beast::async_write(stream, std::move(msg), yield[ec]); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void +do_listen( + net::io_context& ioc, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root, + net::yield_context yield) +{ + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if(ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if(ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + return fail(ec, "listen"); + + for(;;) + { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if(ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind( + &do_session, + beast::tcp_stream(std::move(socket)), + doc_root, + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-coro
\n" << + "Example:\n" << + " http-server-coro 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind( + &do_listen, + std::ref(ioc), + tcp::endpoint{address, port}, + doc_root, + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/CMakeLists.txt new file mode 100644 index 0000000..6c907ae --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-fast + Jamfile + http_server_fast.cpp) + +source_group("" FILES + Jamfile + http_server_fast.cpp) + +target_link_libraries(http-server-fast PRIVATE Boost::beast) + +set_target_properties(http-server-fast + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/Jamfile new file mode 100644 index 0000000..8a9dd44 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-fast : + http_server_fast.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/fields_alloc.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/fields_alloc.hpp new file mode 100644 index 0000000..0245ba6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/fields_alloc.hpp @@ -0,0 +1,205 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP +#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP + +#include +#include +#include +#include + +namespace detail { + +struct static_pool +{ + std::size_t size_; + std::size_t refs_ = 1; + std::size_t count_ = 0; + char* p_; + + char* + end() + { + return reinterpret_cast(this + 1) + size_; + } + + explicit + static_pool(std::size_t size) + : size_(size) + , p_(reinterpret_cast(this + 1)) + { + } + +public: + static + static_pool& + construct(std::size_t size) + { + auto p = new char[sizeof(static_pool) + size]; + return *(::new(p) static_pool{size}); + } + + static_pool& + share() + { + ++refs_; + return *this; + } + + void + destroy() + { + if(--refs_) + return; + this->~static_pool(); + delete[] reinterpret_cast(this); + } + + void* + alloc(std::size_t n) + { + auto last = p_ + n; + if(last >= end()) + BOOST_THROW_EXCEPTION(std::bad_alloc{}); + ++count_; + auto p = p_; + p_ = last; + return p; + } + + void + dealloc() + { + if(--count_) + return; + p_ = reinterpret_cast(this + 1); + } +}; + +} // detail + +/** A non-thread-safe allocator optimized for @ref basic_fields. + + This allocator obtains memory from a pre-allocated memory block + of a given size. It does nothing in deallocate until all + previously allocated blocks are deallocated, upon which it + resets the internal memory block for re-use. + + To use this allocator declare an instance persistent to the + connection or session, and construct with the block size. + A good rule of thumb is 20% more than the maximum allowed + header size. For example if the application only allows up + to an 8,000 byte header, the block size could be 9,600. + + Then, for every instance of `message` construct the header + with a copy of the previously declared allocator instance. +*/ +template +struct fields_alloc +{ + detail::static_pool* pool_; + +public: + using value_type = T; + using is_always_equal = std::false_type; + using pointer = T*; + using reference = T&; + using const_pointer = T const*; + using const_reference = T const&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template + struct rebind + { + using other = fields_alloc; + }; + +#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) + // Workaround for g++ + // basic_string assumes that allocators are default-constructible + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 + fields_alloc() = default; +#endif + + explicit + fields_alloc(std::size_t size) + : pool_(&detail::static_pool::construct(size)) + { + } + + fields_alloc(fields_alloc const& other) + : pool_(&other.pool_->share()) + { + } + + template + fields_alloc(fields_alloc const& other) + : pool_(&other.pool_->share()) + { + } + + ~fields_alloc() + { + pool_->destroy(); + } + + value_type* + allocate(size_type n) + { + return static_cast( + pool_->alloc(n * sizeof(T))); + } + + void + deallocate(value_type*, size_type) + { + pool_->dealloc(); + } + +#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 + template + void + construct(U* ptr, Args&&... args) + { + ::new(static_cast(ptr)) U( + std::forward(args)...); + } + + template + void + destroy(U* ptr) + { + ptr->~U(); + } +#endif + + template + friend + bool + operator==( + fields_alloc const& lhs, + fields_alloc const& rhs) + { + return &lhs.pool_ == &rhs.pool_; + } + + template + friend + bool + operator!=( + fields_alloc const& lhs, + fields_alloc const& rhs) + { + return ! (lhs == rhs); + } +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/http_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/http_server_fast.cpp new file mode 100644 index 0000000..3ddd8bb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/fast/http_server_fast.cpp @@ -0,0 +1,351 @@ +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, fast +// +//------------------------------------------------------------------------------ + +#include "fields_alloc.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +class http_worker +{ +public: + http_worker(http_worker const&) = delete; + http_worker& operator=(http_worker const&) = delete; + + http_worker(tcp::acceptor& acceptor, const std::string& doc_root) : + acceptor_(acceptor), + doc_root_(doc_root) + { + } + + void start() + { + accept(); + check_deadline(); + } + +private: + using alloc_t = fields_alloc; + //using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::string_body; + + // The acceptor used to listen for incoming connections. + tcp::acceptor& acceptor_; + + // The path to the root of the document directory. + std::string doc_root_; + + // The socket for the currently connected client. + tcp::socket socket_{acceptor_.get_executor()}; + + // The buffer for performing reads + beast::flat_static_buffer<8192> buffer_; + + // The allocator used for the fields in the request and reply. + alloc_t alloc_{8192}; + + // The parser for reading the requests + boost::optional> parser_; + + // The timer putting a time limit on requests. + net::steady_timer request_deadline_{ + acceptor_.get_executor(), (std::chrono::steady_clock::time_point::max)()}; + + // The string-based response message. + boost::optional>> string_response_; + + // The string-based response serializer. + boost::optional>> string_serializer_; + + // The file-based response message. + boost::optional>> file_response_; + + // The file-based response serializer. + boost::optional>> file_serializer_; + + void accept() + { + // Clean up any previous connection. + beast::error_code ec; + socket_.close(ec); + buffer_.consume(buffer_.size()); + + acceptor_.async_accept( + socket_, + [this](beast::error_code ec) + { + if (ec) + { + accept(); + } + else + { + // Request must be fully processed within 60 seconds. + request_deadline_.expires_after( + std::chrono::seconds(60)); + + read_request(); + } + }); + } + + void read_request() + { + // On each read the parser needs to be destroyed and + // recreated. We store it in a boost::optional to + // achieve that. + // + // Arguments passed to the parser constructor are + // forwarded to the message object. A single argument + // is forwarded to the body constructor. + // + // We construct the dynamic body with a 1MB limit + // to prevent vulnerability to buffer attacks. + // + parser_.emplace( + std::piecewise_construct, + std::make_tuple(), + std::make_tuple(alloc_)); + + http::async_read( + socket_, + buffer_, + *parser_, + [this](beast::error_code ec, std::size_t) + { + if (ec) + accept(); + else + process_request(parser_->get()); + }); + } + + void process_request(http::request> const& req) + { + switch (req.method()) + { + case http::verb::get: + send_file(req.target()); + break; + + default: + // We return responses indicating an error if + // we do not recognize the request method. + send_bad_response( + http::status::bad_request, + "Invalid request-method '" + std::string(req.method_string()) + "'\r\n"); + break; + } + } + + void send_bad_response( + http::status status, + std::string const& error) + { + string_response_.emplace( + std::piecewise_construct, + std::make_tuple(), + std::make_tuple(alloc_)); + + string_response_->result(status); + string_response_->keep_alive(false); + string_response_->set(http::field::server, "Beast"); + string_response_->set(http::field::content_type, "text/plain"); + string_response_->body() = error; + string_response_->prepare_payload(); + + string_serializer_.emplace(*string_response_); + + http::async_write( + socket_, + *string_serializer_, + [this](beast::error_code ec, std::size_t) + { + socket_.shutdown(tcp::socket::shutdown_send, ec); + string_serializer_.reset(); + string_response_.reset(); + accept(); + }); + } + + void send_file(beast::string_view target) + { + // Request path must be absolute and not contain "..". + if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) + { + send_bad_response( + http::status::not_found, + "File not found\r\n"); + return; + } + + std::string full_path = doc_root_; + full_path.append( + target.data(), + target.size()); + + http::file_body::value_type file; + beast::error_code ec; + file.open( + full_path.c_str(), + beast::file_mode::read, + ec); + if(ec) + { + send_bad_response( + http::status::not_found, + "File not found\r\n"); + return; + } + + file_response_.emplace( + std::piecewise_construct, + std::make_tuple(), + std::make_tuple(alloc_)); + + file_response_->result(http::status::ok); + file_response_->keep_alive(false); + file_response_->set(http::field::server, "Beast"); + file_response_->set(http::field::content_type, mime_type(std::string(target))); + file_response_->body() = std::move(file); + file_response_->prepare_payload(); + + file_serializer_.emplace(*file_response_); + + http::async_write( + socket_, + *file_serializer_, + [this](beast::error_code ec, std::size_t) + { + socket_.shutdown(tcp::socket::shutdown_send, ec); + file_serializer_.reset(); + file_response_.reset(); + accept(); + }); + } + + void check_deadline() + { + // The deadline may have moved, so check it has really passed. + if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) + { + // Close socket to cancel any outstanding operation. + socket_.close(); + + // Sleep indefinitely until we're given a new deadline. + request_deadline_.expires_at( + (std::chrono::steady_clock::time_point::max)()); + } + + request_deadline_.async_wait( + [this](beast::error_code) + { + check_deadline(); + }); + } +}; + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 6) + { + std::cerr << "Usage: http_server_fast
{spin|block}\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " http_server_fast 0.0.0.0 80 . 100 block\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " http_server_fast 0::0 80 . 100 block\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + unsigned short port = static_cast(std::atoi(argv[2])); + std::string doc_root = argv[3]; + int num_workers = std::atoi(argv[4]); + bool spin = (std::strcmp(argv[5], "spin") == 0); + + net::io_context ioc{1}; + tcp::acceptor acceptor{ioc, {address, port}}; + + std::list workers; + for (int i = 0; i < num_workers; ++i) + { + workers.emplace_back(acceptor, doc_root); + workers.back().start(); + } + + if (spin) + for (;;) ioc.poll(); + else + ioc.run(); + } + catch (const std::exception& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/CMakeLists.txt new file mode 100644 index 0000000..1cc4b48 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-flex + Jamfile + http_server_flex.cpp) + +source_group("" FILES + Jamfile + http_server_flex.cpp) + +target_include_directories(http-server-flex + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-server-flex + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-server-flex + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/Jamfile new file mode 100644 index 0000000..185f1e1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-server-flex : + http_server_flex.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/http_server_flex.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/http_server_flex.cpp new file mode 100644 index 0000000..b586fb7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/flex/http_server_flex.cpp @@ -0,0 +1,681 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP flex server (plain and SSL), asynchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection. +// This uses the Curiously Recurring Template Pattern so that +// the same code works with both SSL streams and regular sockets. +template +class session +{ + // Access the derived class, this is part of + // the Curiously Recurring Template Pattern idiom. + Derived& + derived() + { + return static_cast(*this); + } + + std::shared_ptr doc_root_; + http::request req_; + +protected: + beast::flat_buffer buffer_; + +public: + // Take ownership of the buffer + session( + beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : doc_root_(doc_root) + , buffer_(std::move(buffer)) + { + } + + void + do_read() + { + // Set the timeout. + beast::get_lowest_layer( + derived().stream()).expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + derived().stream(), + buffer_, + req_, + beast::bind_front_handler( + &session::on_read, + derived().shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This means they closed the connection + if(ec == http::error::end_of_stream) + return derived().do_eof(); + + if(ec) + return fail(ec, "read"); + + // Send the response + send_response( + handle_request(*doc_root_, std::move(req_))); + } + + void + send_response(http::message_generator&& msg) + { + bool keep_alive = msg.keep_alive(); + + // Write the response + beast::async_write( + derived().stream(), + std::move(msg), + beast::bind_front_handler( + &session::on_write, + derived().shared_from_this(), + keep_alive)); + } + + void + on_write( + bool keep_alive, + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + return derived().do_eof(); + } + + // Read another request + do_read(); + } +}; + +// Handles a plain HTTP connection +class plain_session + : public session + , public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + +public: + // Create the session + plain_session( + tcp::socket&& socket, + beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session( + std::move(buffer), + doc_root) + , stream_(std::move(socket)) + { + } + + // Called by the base class + beast::tcp_stream& + stream() + { + return stream_; + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler( + &session::do_read, + shared_from_this())); + } + + void + do_eof() + { + // Send a TCP shutdown + beast::error_code ec; + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully + } +}; + +// Handles an SSL HTTP connection +class ssl_session + : public session + , public std::enable_shared_from_this +{ + ssl::stream stream_; + +public: + // Create the session + ssl_session( + tcp::socket&& socket, + ssl::context& ctx, + beast::flat_buffer buffer, + std::shared_ptr const& doc_root) + : session( + std::move(buffer), + doc_root) + , stream_(std::move(socket), ctx) + { + } + + // Called by the base class + ssl::stream& + stream() + { + return stream_; + } + + // Start the asynchronous operation + void + run() + { + auto self = shared_from_this(); + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. + net::dispatch(stream_.get_executor(), [self]() { + // Set the timeout. + beast::get_lowest_layer(self->stream_).expires_after( + std::chrono::seconds(30)); + + // Perform the SSL handshake + // Note, this is the buffered version of the handshake. + self->stream_.async_handshake( + ssl::stream_base::server, + self->buffer_.data(), + beast::bind_front_handler( + &ssl_session::on_handshake, + self)); + }); + } + + void + on_handshake( + beast::error_code ec, + std::size_t bytes_used) + { + if(ec) + return fail(ec, "handshake"); + + // Consume the portion of the buffer used by the handshake + buffer_.consume(bytes_used); + + do_read(); + } + + void + do_eof() + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + stream_.async_shutdown( + beast::bind_front_handler( + &ssl_session::on_shutdown, + shared_from_this())); + } + + void + on_shutdown(beast::error_code ec) + { + if(ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully + } +}; + +//------------------------------------------------------------------------------ + +// Detects SSL handshakes +class detect_session : public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + ssl::context& ctx_; + std::shared_ptr doc_root_; + beast::flat_buffer buffer_; + +public: + detect_session( + tcp::socket&& socket, + ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)) + , ctx_(ctx) + , doc_root_(doc_root) + { + } + + // Launch the detector + void + run() + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Detect a TLS handshake + async_detect_ssl( + stream_, + buffer_, + beast::bind_front_handler( + &detect_session::on_detect, + shared_from_this())); + } + + void + on_detect(beast::error_code ec, bool result) + { + if(ec) + return fail(ec, "detect"); + + if(result) + { + // Launch SSL session + std::make_shared( + stream_.release_socket(), + ctx_, + std::move(buffer_), + doc_root_)->run(); + return; + } + + // Launch plain session + std::make_shared( + stream_.release_socket(), + std::move(buffer_), + doc_root_)->run(); + } +}; + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , ctx_(ctx) + , acceptor_(net::make_strand(ioc)) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the detector session and run it + std::make_shared( + std::move(socket), + ctx_, + doc_root_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-flex
\n" << + "Example:\n" << + " http-server-flex 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared( + ioc, + ctx, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/CMakeLists.txt new file mode 100644 index 0000000..f2dc894 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-small + Jamfile + http_server_small.cpp) + +source_group("" FILES + Jamfile + http_server_small.cpp) + +target_link_libraries(http-server-small PRIVATE Boost::beast) + +set_target_properties(http-server-small + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/Jamfile new file mode 100644 index 0000000..48e9fd1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-small : + http_server_small.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/http_server_small.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/http_server_small.cpp new file mode 100644 index 0000000..c4f526f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/small/http_server_small.cpp @@ -0,0 +1,251 @@ +// +// Copyright (c) 2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, small +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +namespace my_program_state +{ + std::size_t + request_count() + { + static std::size_t count = 0; + return ++count; + } + + std::time_t + now() + { + return std::time(0); + } +} + +class http_connection : public std::enable_shared_from_this +{ +public: + http_connection(tcp::socket socket) + : socket_(std::move(socket)) + { + } + + // Initiate the asynchronous operations associated with the connection. + void + start() + { + read_request(); + check_deadline(); + } + +private: + // The socket for the currently connected client. + tcp::socket socket_; + + // The buffer for performing reads. + beast::flat_buffer buffer_{8192}; + + // The request message. + http::request request_; + + // The response message. + http::response response_; + + // The timer for putting a deadline on connection processing. + net::steady_timer deadline_{ + socket_.get_executor(), std::chrono::seconds(60)}; + + // Asynchronously receive a complete request message. + void + read_request() + { + auto self = shared_from_this(); + + http::async_read( + socket_, + buffer_, + request_, + [self](beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + if(!ec) + self->process_request(); + }); + } + + // Determine what needs to be done with the request message. + void + process_request() + { + response_.version(request_.version()); + response_.keep_alive(false); + + switch(request_.method()) + { + case http::verb::get: + response_.result(http::status::ok); + response_.set(http::field::server, "Beast"); + create_response(); + break; + + default: + // We return responses indicating an error if + // we do not recognize the request method. + response_.result(http::status::bad_request); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) + << "Invalid request-method '" + << std::string(request_.method_string()) + << "'"; + break; + } + + write_response(); + } + + // Construct a response message based on the program state. + void + create_response() + { + if(request_.target() == "/count") + { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Request count\n" + << "\n" + << "

Request count

\n" + << "

There have been " + << my_program_state::request_count() + << " requests so far.

\n" + << "\n" + << "\n"; + } + else if(request_.target() == "/time") + { + response_.set(http::field::content_type, "text/html"); + beast::ostream(response_.body()) + << "\n" + << "Current time\n" + << "\n" + << "

Current time

\n" + << "

The current time is " + << my_program_state::now() + << " seconds since the epoch.

\n" + << "\n" + << "\n"; + } + else + { + response_.result(http::status::not_found); + response_.set(http::field::content_type, "text/plain"); + beast::ostream(response_.body()) << "File not found\r\n"; + } + } + + // Asynchronously transmit the response message. + void + write_response() + { + auto self = shared_from_this(); + + response_.content_length(response_.body().size()); + + http::async_write( + socket_, + response_, + [self](beast::error_code ec, std::size_t) + { + self->socket_.shutdown(tcp::socket::shutdown_send, ec); + self->deadline_.cancel(); + }); + } + + // Check whether we have spent enough time on this connection. + void + check_deadline() + { + auto self = shared_from_this(); + + deadline_.async_wait( + [self](beast::error_code ec) + { + if(!ec) + { + // Close socket to cancel any outstanding operation. + self->socket_.close(ec); + } + }); + } +}; + +// "Loop" forever accepting new connections. +void +http_server(tcp::acceptor& acceptor, tcp::socket& socket) +{ + acceptor.async_accept(socket, + [&](beast::error_code ec) + { + if(!ec) + std::make_shared(std::move(socket))->start(); + http_server(acceptor, socket); + }); +} + +int +main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if(argc != 3) + { + std::cerr << "Usage: " << argv[0] << "
\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80\n"; + return EXIT_FAILURE; + } + + auto const address = net::ip::make_address(argv[1]); + unsigned short port = static_cast(std::atoi(argv[2])); + + net::io_context ioc{1}; + + tcp::acceptor acceptor{ioc, {address, port}}; + tcp::socket socket{ioc}; + http_server(acceptor, socket); + + ioc.run(); + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/CMakeLists.txt new file mode 100644 index 0000000..2c4aa2c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-stackless-ssl + Jamfile + http_server_stackless_ssl.cpp) + +source_group("" FILES + Jamfile + http_server_stackless_ssl.cpp) + +target_include_directories(http-server-stackless-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-server-stackless-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-server-stackless-ssl + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/Jamfile new file mode 100644 index 0000000..3f29861 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-server-stackless-ssl : + http_server_stackless_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/http_server_stackless_ssl.cpp new file mode 100644 index 0000000..8573022 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -0,0 +1,515 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + // ssl::error::stream_truncated, also known as an SSL "short read", + // indicates the peer closed the connection without performing the + // required closing handshake (for example, Google does this to + // improve performance). Generally this can be a security issue, + // but if your communication protocol is self-terminated (as + // it is with both HTTP and WebSocket) then you may simply + // ignore the lack of close_notify. + // + // https://github.com/boostorg/beast/issues/38 + // + // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown + // + // When a short read would cut off the end of an HTTP message, + // Beast returns the error beast::http::error::partial_message. + // Therefore, if we see a short read here, it has occurred + // after the message has been completed, so it is safe to ignore it. + + if(ec == net::ssl::error::stream_truncated) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + ssl::stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit + session( + tcp::socket&& socket, + ssl::context& ctx, + std::shared_ptr const& doc_root) + : stream_(std::move(socket), ctx) + , doc_root_(doc_root) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session.Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::loop, + shared_from_this(), + beast::error_code{}, + 0)); + } + + #include + + void + loop(beast::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + reenter(*this) + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield stream_.async_handshake( + ssl::stream_base::server, + std::bind( + &session::loop, shared_from_this(), + std::placeholders::_1, 0)); + if(ec) + return fail(ec, "handshake"); + + for(;;) + { + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Read a request + yield http::async_read( + stream_, buffer_, req_, + beast::bind_front_handler( + &session::loop, shared_from_this())); + + if (ec == http::error::end_of_stream) { + // The remote host closed the connection + break; + } + if(ec) + return fail(ec, "read"); + + yield { + // Handle request + http::message_generator msg = + handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + beast::bind_front_handler( + &session::loop, shared_from_this())); + } + + if(ec) + return fail(ec, "write"); + if(! keep_alive_) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Set the timeout. + beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL shutdown + yield stream_.async_shutdown( + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + 0)); + if(ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , ctx_(ctx) + , acceptor_(net::make_strand(ioc)) + , socket_(net::make_strand(ioc)) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + loop(); + } + +private: + + #include + + void + loop(beast::error_code ec = {}) + { + reenter(*this) + { + for(;;) + { + yield acceptor_.async_accept( + socket_, + std::bind( + &listener::loop, + shared_from_this(), + std::placeholders::_1)); + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the session and run it + std::make_shared( + std::move(socket_), + ctx_, + doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-stackless-ssl
\n" << + "Example:\n" << + " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared( + ioc, + ctx, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/CMakeLists.txt new file mode 100644 index 0000000..77d7123 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-stackless + Jamfile + http_server_stackless.cpp) + +source_group("" FILES + Jamfile + http_server_stackless.cpp) + +target_link_libraries(http-server-stackless PRIVATE Boost::beast) + +set_target_properties(http-server-stackless + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/Jamfile new file mode 100644 index 0000000..f82934f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-stackless : + http_server_stackless.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/http_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/http_server_stackless.cpp new file mode 100644 index 0000000..87d0fcc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/stackless/http_server_stackless.cpp @@ -0,0 +1,457 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +class session + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + std::shared_ptr doc_root_; + http::request req_; + bool keep_alive_ = true; + +public: + // Take ownership of the socket + explicit + session( + tcp::socket&& socket, + std::shared_ptr const& doc_root) + : stream_(std::move(socket)) + , doc_root_(doc_root) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(stream_.get_executor(), + beast::bind_front_handler(&session::loop, + shared_from_this(), + beast::error_code{}, + 0)); + } + + #include + + void + loop(beast::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + reenter(*this) + { + for(;;) + { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + yield http::async_read(stream_, buffer_, req_, + beast::bind_front_handler( + &session::loop, + shared_from_this())); + + if(ec == http::error::end_of_stream) + { + // The remote host closed the connection + break; + } + if(ec) + return fail(ec, "read"); + + yield { + // Handle request + http::message_generator msg = + handle_request(*doc_root_, std::move(req_)); + + // Determine if we should close the connection + keep_alive_ = msg.keep_alive(); + + // Send the response + beast::async_write( + stream_, + std::move(msg), + beast::bind_front_handler( + &session::loop, shared_from_this())); + } + + if(ec) + return fail(ec, "write"); + if(! keep_alive_) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::shared_ptr doc_root_; + +public: + listener( + net::io_context& ioc, + tcp::endpoint endpoint, + std::shared_ptr const& doc_root) + : ioc_(ioc) + , acceptor_(net::make_strand(ioc)) + , socket_(net::make_strand(ioc)) + , doc_root_(doc_root) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen(net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + loop(); + } + +private: + + #include + + void + loop(beast::error_code ec = {}) + { + reenter(*this) + { + for(;;) + { + yield acceptor_.async_accept( + socket_, + beast::bind_front_handler( + &listener::loop, + shared_from_this())); + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the session and run it + std::make_shared( + std::move(socket_), + doc_root_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: http-server-stackless
\n" << + "Example:\n" << + " http-server-stackless 0.0.0.0 8080 . 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared( + ioc, + tcp::endpoint{address, port}, + doc_root)->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/CMakeLists.txt new file mode 100644 index 0000000..7d2b2e8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-sync-ssl + Jamfile + http_server_sync_ssl.cpp) + +source_group("" FILES + Jamfile + http_server_sync_ssl.cpp) + +target_include_directories(http-server-sync-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(http-server-sync-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(http-server-sync-ssl + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/Jamfile new file mode 100644 index 0000000..79455f0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe http-server-sync-ssl : + http_server_sync_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/http_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/http_server_sync_ssl.cpp new file mode 100644 index 0000000..3571638 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -0,0 +1,323 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void +do_session( + tcp::socket& socket, + ssl::context& ctx, + std::shared_ptr const& doc_root) +{ + beast::error_code ec; + + // Construct the stream around the socket + ssl::stream stream{socket, ctx}; + + // Perform the SSL handshake + stream.handshake(ssl::stream_base::server, ec); + if(ec) + return fail(ec, "handshake"); + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for(;;) + { + // Read a request + http::request req; + http::read(stream, buffer, req, ec); + if(ec == http::error::end_of_stream) + break; + if(ec) + return fail(ec, "read"); + + // Handle request + http::message_generator msg = + handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + // Send the response + beast::write(stream, std::move(msg), ec); + + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Perform the SSL shutdown + stream.shutdown(ec); + if(ec) + return fail(ec, "shutdown"); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: http-server-sync-ssl
\n" << + "Example:\n" << + " http-server-sync-ssl 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for(;;) + { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread{std::bind( + &do_session, + std::move(socket), + std::ref(ctx), + doc_root)}.detach(); + } + } + catch (const std::exception& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/CMakeLists.txt new file mode 100644 index 0000000..7ba1f08 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(http-server-sync + Jamfile + http_server_sync.cpp) + +source_group("" FILES + Jamfile + http_server_sync.cpp) + +target_link_libraries(http-server-sync PRIVATE Boost::beast) + +set_target_properties(http-server-sync + PROPERTIES FOLDER "example-http-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/Jamfile new file mode 100644 index 0000000..30e4f02 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe http-server-sync : + http_server_sync.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/http_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/http_server_sync.cpp new file mode 100644 index 0000000..09a3af3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/http/server/sync/http_server_sync.cpp @@ -0,0 +1,301 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: HTTP server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if (base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == beast::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handles an HTTP server connection +void +do_session( + tcp::socket& socket, + std::shared_ptr const& doc_root) +{ + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + for(;;) + { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if(ec == http::error::end_of_stream) + break; + if(ec) + return fail(ec, "read"); + + // Handle request + http::message_generator msg = + handle_request(*doc_root, std::move(req)); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + // Send the response + beast::write(socket, std::move(msg), ec); + + if(ec) + return fail(ec, "write"); + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; + } + } + + // Send a TCP shutdown + socket.shutdown(tcp::socket::shutdown_send, ec); + + // At this point the connection is closed gracefully +} + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: http-server-sync
\n" << + "Example:\n" << + " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for(;;) + { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread{std::bind( + &do_session, + std::move(socket), + doc_root)}.detach(); + } + } + catch (const std::exception& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/CMakeLists.txt new file mode 100644 index 0000000..e057d48 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/CMakeLists.txt @@ -0,0 +1,11 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(client) +add_subdirectory(server) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/Jamfile new file mode 100644 index 0000000..32f2c51 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/Jamfile @@ -0,0 +1,11 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project client ; +build-project server ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/CMakeLists.txt new file mode 100644 index 0000000..e399c3d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(async) +add_subdirectory(async-local) +add_subdirectory(awaitable) +add_subdirectory(coro) +add_subdirectory(sync) + +if (OPENSSL_FOUND) + add_subdirectory(async-ssl) + add_subdirectory(async-ssl-system-executor) + add_subdirectory(coro-ssl) + add_subdirectory(sync-ssl) +endif () diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/Jamfile new file mode 100644 index 0000000..bd44021 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/Jamfile @@ -0,0 +1,20 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project async ; +build-project async-local ; +build-project awaitable ; +build-project coro ; +build-project sync ; + +# SSL +build-project async-ssl ; +build-project async-ssl-system-executor ; +build-project coro-ssl ; +build-project sync-ssl ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/CMakeLists.txt new file mode 100644 index 0000000..d028cd7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-async-local + Jamfile + websocket_client_async_local.cpp) + +source_group("" FILES + Jamfile + websocket_client_async_local.cpp) + +target_link_libraries(websocket-client-async-local PRIVATE Boost::beast) + +set_target_properties(websocket-client-async-local + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/Jamfile new file mode 100644 index 0000000..e086952 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-client-async-local : + websocket_client_async_local.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/websocket_client_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/websocket_client_async_local.cpp new file mode 100644 index 0000000..0cfdf2f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-local/websocket_client_async_local.cpp @@ -0,0 +1,210 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using stream_protocol = net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this +{ + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit + session(net::io_context& ioc) + : ws_(net::make_strand(ioc)) + { + } + + // Start the asynchronous operation + void + run( + char const* path, + char const* host, + char const* port, + char const* text) + { + // Save for later + host_ = std::string{host} + ":" + port; + text_ = text; + + // Make the connection + beast::get_lowest_layer(ws_).async_connect( + stream_protocol::endpoint{path}, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec) + { + if(ec) + return fail(ec, "connect"); + + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-async-local"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Send the message + ws_.async_write( + net::buffer(text_), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler( + &session::on_close, + shared_from_this())); + } + + void + on_close(beast::error_code ec) + { + if(ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << std::endl; + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 5) + { + std::cerr << + "Usage: websocket-client-async-local \n" << + "Example:\n" << + " websocket-client-async-local /tmp/ws.sock localhost 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; + auto const host = argv[2]; + auto const port = argv[3]; + auto const text = argv[4]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(path, host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); + + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ +std::cerr << + "Local sockets not available on this platform" << std::endl; +return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/CMakeLists.txt new file mode 100644 index 0000000..4f8c9c8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-async-ssl-system-executor + Jamfile + websocket_client_async_ssl_system_executor.cpp) + +source_group("" FILES + Jamfile + websocket_client_async_ssl_system_executor.cpp) + +target_include_directories(websocket-client-async-ssl-system-executor + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-client-async-ssl-system-executor + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-client-async-ssl-system-executor + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/Jamfile new file mode 100644 index 0000000..e0e20d1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-client-async-ssl-system-executor : + websocket_client_async_ssl_system_executor.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp new file mode 100644 index 0000000..627bb99 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -0,0 +1,273 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous, using system_executor +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this +{ + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + // Objects are constructed with a strand to + // ensure that handlers do not execute concurrently. + session(net::strand ex, ssl::context& ctx) + : resolver_(ex) + , ws_(ex, ctx) + { + } +public: + // Delegate construction to a prive constructor to be able to use + // the same strand for both I/O objects. + explicit + session(ssl::context& ctx) + : session(net::make_strand(net::system_executor{}), ctx) + { + } + + // Start the asynchronous operation + void + run( + char const* host, + char const* port, + char const* text) + { + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) + { + beast::error_code ec{ + static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, + port, + beast::bind_front_handler( + &session::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) + { + if(ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler( + &session::on_ssl_handshake, + shared_from_this())); + } + + void + on_ssl_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Send the message + ws_.async_write( + net::buffer(text_), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler( + &session::on_close, + shared_from_this())); + } + + void + on_close(beast::error_code ec) + { + if(ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << std::endl; + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-async-ssl \n" << + "Example:\n" << + " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ctx)->run(host, port, text); + + // The async operations will run on the system_executor. + // Because the main thread has nothing to do in this example, we just wait + // for the system_executor to run out of work. + net::query(net::system_executor(), net::execution::context).join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/CMakeLists.txt new file mode 100644 index 0000000..49f5aad --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-async-ssl + Jamfile + websocket_client_async_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_client_async_ssl.cpp) + +target_include_directories(websocket-client-async-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-client-async-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-client-async-ssl + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/Jamfile new file mode 100644 index 0000000..3f34af9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-client-async-ssl : + websocket_client_async_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/websocket_client_async_ssl.cpp new file mode 100644 index 0000000..22525c2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -0,0 +1,266 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, asynchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this +{ + tcp::resolver resolver_; + websocket::stream> ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit + session(net::io_context& ioc, ssl::context& ctx) + : resolver_(net::make_strand(ioc)) + , ws_(net::make_strand(ioc), ctx) + { + } + + // Start the asynchronous operation + void + run( + char const* host, + char const* port, + char const* text) + { + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(ws_.next_layer().native_handle(), host)) + { + beast::error_code ec{ + static_cast(::ERR_get_error()), + net::error::get_ssl_category()}; + std::cerr << ec.message() << "\n"; + return; + } + + // Set the expected hostname in the peer certificate for verification + ws_.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, + port, + beast::bind_front_handler( + &session::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) + { + if(ec) + return fail(ec, "connect"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::client, + beast::bind_front_handler( + &session::on_ssl_handshake, + shared_from_this())); + } + + void + on_ssl_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-async-ssl"); + })); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Send the message + ws_.async_write( + net::buffer(text_), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler( + &session::on_close, + shared_from_this())); + } + + void + on_close(beast::error_code ec) + { + if(ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << std::endl; + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-async-ssl \n" << + "Example:\n" << + " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + std::make_shared(ioc, ctx)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/CMakeLists.txt new file mode 100644 index 0000000..2fd98e7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-async + Jamfile + websocket_client_async.cpp) + +source_group("" FILES + Jamfile + websocket_client_async.cpp) + +target_link_libraries(websocket-client-async PRIVATE Boost::beast) + +set_target_properties(websocket-client-async + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/Jamfile new file mode 100644 index 0000000..e5359db --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-client-async : + websocket_client_async.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/websocket_client_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/websocket_client_async.cpp new file mode 100644 index 0000000..5fcf721 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/async/websocket_client_async.cpp @@ -0,0 +1,223 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +class session : public std::enable_shared_from_this +{ + tcp::resolver resolver_; + websocket::stream ws_; + beast::flat_buffer buffer_; + std::string host_; + std::string text_; + +public: + // Resolver and socket require an io_context + explicit + session(net::io_context& ioc) + : resolver_(net::make_strand(ioc)) + , ws_(net::make_strand(ioc)) + { + } + + // Start the asynchronous operation + void + run( + char const* host, + char const* port, + char const* text) + { + // Save these for later + host_ = host; + text_ = text; + + // Look up the domain name + resolver_.async_resolve( + host, + port, + beast::bind_front_handler( + &session::on_resolve, + shared_from_this())); + } + + void + on_resolve( + beast::error_code ec, + tcp::resolver::results_type results) + { + if(ec) + return fail(ec, "resolve"); + + // Set the timeout for the operation + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + beast::get_lowest_layer(ws_).async_connect( + results, + beast::bind_front_handler( + &session::on_connect, + shared_from_this())); + } + + void + on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep) + { + if(ec) + return fail(ec, "connect"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-async"); + })); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + + // Perform the websocket handshake + ws_.async_handshake(host_, "/", + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Send the message + ws_.async_write( + net::buffer(text_), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws_.async_close(websocket::close_code::normal, + beast::bind_front_handler( + &session::on_close, + shared_from_this())); + } + + void + on_close(beast::error_code ec) + { + if(ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer_.data()) << std::endl; + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-async \n" << + "Example:\n" << + " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + std::make_shared(ioc)->run(host, port, text); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/CMakeLists.txt new file mode 100644 index 0000000..eeb2971 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-awaitable + Jamfile + websocket_client_awaitable.cpp) + +source_group("" FILES + Jamfile + websocket_client_awaitable.cpp) + +target_link_libraries(websocket-client-awaitable PRIVATE Boost::beast) + +set_target_properties(websocket-client-awaitable + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/Jamfile new file mode 100644 index 0000000..7c79aec --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-client-awaitable : + websocket_client_awaitable.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/websocket_client_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/websocket_client_awaitable.cpp new file mode 100644 index 0000000..684d297 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/awaitable/websocket_client_awaitable.cpp @@ -0,0 +1,148 @@ +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Sends a WebSocket message and prints the response +net::awaitable +do_session(std::string host, std::string port, std::string text) +{ + auto executor = co_await net::this_coro::executor; + auto resolver = net::ip::tcp::resolver{ executor }; + auto stream = websocket::stream{ executor }; + + // Look up the domain name + auto const results = co_await resolver.async_resolve(host, port); + + // Set a timeout on the operation + beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = co_await beast::get_lowest_layer(stream).async_connect(results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(stream).expires_never(); + + // Set suggested timeout settings for the websocket + stream.set_option( + websocket::stream_base::timeout::suggested(beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + stream.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set( + http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-coro"); + })); + + // Perform the websocket handshake + co_await stream.async_handshake(host, "/"); + + // Send the message + co_await stream.async_write(net::buffer(text)); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + co_await stream.async_read(buffer); + + // Close the WebSocket connection + co_await stream.async_close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +int +main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4) + { + std::cerr + << "Usage: websocket-client-awaitable \n" + << "Example:\n" + << " websocket-client-awaitable echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + net::co_spawn( + ioc, + do_session(host, port, text), + [](std::exception_ptr e) + { + if(e) + std::rethrow_exception(e); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/CMakeLists.txt new file mode 100644 index 0000000..a6673eb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-coro-ssl + Jamfile + websocket_client_coro_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_client_coro_ssl.cpp) + +target_include_directories(websocket-client-coro-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-client-coro-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-client-coro-ssl + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/Jamfile new file mode 100644 index 0000000..ad2d756 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/Jamfile @@ -0,0 +1,23 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-client-coro-ssl : + websocket_client_coro_ssl.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp new file mode 100644 index 0000000..b253092 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -0,0 +1,198 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, coroutine +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void +do_session( + std::string host, + std::string const& port, + std::string const& text, + net::io_context& ioc, + ssl::context& ctx, + net::yield_context yield) +{ + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream> ws(ioc, ctx); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if(ec) + return fail(ec, "connect"); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) + { + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); + return fail(ec, "connect"); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-coro"); + })); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::client, yield[ec]); + if(ec) + return fail(ec, "ssl_handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::client)); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if(ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if(ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if(ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if(ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-coro-ssl \n" << + "Example:\n" << + " websocket-client-coro-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // Launch the asynchronous operation + boost::asio::spawn(ioc, std::bind( + &do_session, + std::string(host), + std::string(port), + std::string(text), + std::ref(ioc), + std::ref(ctx), + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/CMakeLists.txt new file mode 100644 index 0000000..0d7c78f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-coro + Jamfile + websocket_client_coro.cpp) + +source_group("" FILES + Jamfile + websocket_client_coro.cpp) + +target_link_libraries(websocket-client-coro PRIVATE Boost::beast) + +set_target_properties(websocket-client-coro + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/Jamfile new file mode 100644 index 0000000..a0d7c51 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-client-coro : + websocket_client_coro.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/websocket_client_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/websocket_client_coro.cpp new file mode 100644 index 0000000..0a4cdf3 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/coro/websocket_client_coro.cpp @@ -0,0 +1,164 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Sends a WebSocket message and prints the response +void +do_session( + std::string host, + std::string const& port, + std::string const& text, + net::io_context& ioc, + net::yield_context yield) +{ + beast::error_code ec; + + // These objects perform our I/O + tcp::resolver resolver(ioc); + websocket::stream ws(ioc); + + // Look up the domain name + auto const results = resolver.async_resolve(host, port, yield[ec]); + if(ec) + return fail(ec, "resolve"); + + // Set a timeout on the operation + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Make the connection on the IP address we get from a lookup + auto ep = beast::get_lowest_layer(ws).async_connect(results, yield[ec]); + if(ec) + return fail(ec, "connect"); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::client)); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.async_handshake(host, "/", yield[ec]); + if(ec) + return fail(ec, "handshake"); + + // Send the message + ws.async_write(net::buffer(std::string(text)), yield[ec]); + if(ec) + return fail(ec, "write"); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.async_read(buffer, yield[ec]); + if(ec) + return fail(ec, "read"); + + // Close the WebSocket connection + ws.async_close(websocket::close_code::normal, yield[ec]); + if(ec) + return fail(ec, "close"); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; +} + +//------------------------------------------------------------------------------ + +int main(int argc, char** argv) +{ + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-coro \n" << + "Example:\n" << + " websocket-client-coro echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + auto const host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // Launch the asynchronous operation + boost::asio::spawn(ioc, std::bind( + &do_session, + std::string(host), + std::string(port), + std::string(text), + std::ref(ioc), + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service. The call will return when + // the socket is closed. + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/CMakeLists.txt new file mode 100644 index 0000000..8edc3e9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-sync-ssl + Jamfile + websocket_client_sync_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_client_sync_ssl.cpp) + +target_include_directories(websocket-client-sync-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-client-sync-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-client-sync-ssl + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/Jamfile new file mode 100644 index 0000000..8ac7bb4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-client-sync-ssl : + websocket_client_sync_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp new file mode 100644 index 0000000..ce8de67 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -0,0 +1,129 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL client, synchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/root_certificates.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +int main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-sync-ssl \n" << + "Example:\n" << + " websocket-client-sync-ssl echo.websocket.org 443 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12_client}; + + // Verify the remote server's certificate + ctx.set_verify_mode(ssl::verify_peer); + + // This holds the root certificate used for verification + load_root_certificates(ctx); + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream> ws{ioc, ctx}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto ep = net::connect(beast::get_lowest_layer(ws), results); + + // Set SNI Hostname (many hosts need this to handshake successfully) + if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str())) + { + throw beast::system_error( + static_cast(::ERR_get_error()), + net::error::get_ssl_category()); + } + + // Set the expected hostname in the peer certificate for verification + ws.next_layer().set_verify_callback(ssl::host_name_verification(host)); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::client); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/CMakeLists.txt new file mode 100644 index 0000000..859617d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-client-sync + Jamfile + websocket_client_sync.cpp) + +source_group("" FILES + Jamfile + websocket_client_sync.cpp) + +target_link_libraries(websocket-client-sync PRIVATE Boost::beast) + +set_target_properties(websocket-client-sync + PROPERTIES FOLDER "example-websocket-client") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/Jamfile new file mode 100644 index 0000000..ea71a0c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-client-sync : + websocket_client_sync.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/websocket_client_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/websocket_client_sync.cpp new file mode 100644 index 0000000..07409b7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/client/sync/websocket_client_sync.cpp @@ -0,0 +1,105 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket client, synchronous +// +//------------------------------------------------------------------------------ + +//[example_websocket_client + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +// Sends a WebSocket message and prints the response +int main(int argc, char** argv) +{ + try + { + // Check command line arguments. + if(argc != 4) + { + std::cerr << + "Usage: websocket-client-sync \n" << + "Example:\n" << + " websocket-client-sync echo.websocket.org 80 \"Hello, world!\"\n"; + return EXIT_FAILURE; + } + std::string host = argv[1]; + auto const port = argv[2]; + auto const text = argv[3]; + + // The io_context is required for all I/O + net::io_context ioc; + + // These objects perform our I/O + tcp::resolver resolver{ioc}; + websocket::stream ws{ioc}; + + // Look up the domain name + auto const results = resolver.resolve(host, port); + + // Make the connection on the IP address we get from a lookup + auto ep = net::connect(ws.next_layer(), results); + + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host += ':' + std::to_string(ep.port()); + + // Set a decorator to change the User-Agent of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::request_type& req) + { + req.set(http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-client-coro"); + })); + + // Perform the websocket handshake + ws.handshake(host, "/"); + + // Send the message + ws.write(net::buffer(std::string(text))); + + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message into our buffer + ws.read(buffer); + + // Close the WebSocket connection + ws.close(websocket::close_code::normal); + + // If we get here then the connection is closed gracefully + + // The make_printable() function helps print a ConstBufferSequence + std::cout << beast::make_printable(buffer.data()) << std::endl; + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +//] diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/CMakeLists.txt new file mode 100644 index 0000000..a4ecc7e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_subdirectory(async) +add_subdirectory(async-local) +add_subdirectory(awaitable) +add_subdirectory(chat-multi) +add_subdirectory(coro) +add_subdirectory(fast) +add_subdirectory(stackless) +add_subdirectory(sync) + +if (OPENSSL_FOUND) + add_subdirectory(async-ssl) + add_subdirectory(coro-ssl) + add_subdirectory(stackless-ssl) + add_subdirectory(sync-ssl) +endif () diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/Jamfile new file mode 100644 index 0000000..c1f80c6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/Jamfile @@ -0,0 +1,23 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +build-project async ; +build-project async-local ; +build-project awaitable ; +build-project chat-multi ; +build-project coro ; +build-project fast ; +build-project stackless ; +build-project sync ; + +# SSL +build-project async-ssl ; +build-project coro-ssl ; +build-project stackless-ssl ; +build-project sync-ssl ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/CMakeLists.txt new file mode 100644 index 0000000..de64253 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-async-local + Jamfile + websocket_server_async_local.cpp) + +source_group("" FILES + Jamfile + websocket_server_async_local.cpp) + +target_link_libraries(websocket-server-async-local PRIVATE Boost::beast) + +set_target_properties(websocket-server-async-local + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/Jamfile new file mode 100644 index 0000000..3ac73a4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2025 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-async-local : + websocket_server_async_local.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/websocket_server_async_local.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/websocket_server_async_local.cpp new file mode 100644 index 0000000..95dbc9f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-local/websocket_server_async_local.cpp @@ -0,0 +1,274 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2025 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous Unix domain sockets +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using stream_protocol = net::local::stream_protocol; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this +{ + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit + session(stream_protocol::socket&& socket) + : ws_(std::move(socket)) + { + } + + // Get on the correct executor + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler( + &session::on_run, + shared_from_this())); + } + + // Start the asynchronous operation + void + on_run() + { + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-async-local"); + })); + // Accept the websocket handshake + ws_.async_accept( + beast::bind_front_handler( + &session::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec) + { + if(ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void + do_read() + { + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if(ec == websocket::error::closed) + return; + + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write( + buffer_.data(), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + stream_protocol::acceptor acceptor_; + +public: + listener( + net::io_context& ioc, + stream_protocol::endpoint endpoint) + : ioc_(ioc) + , acceptor_(ioc, std::move(endpoint)) + { + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, stream_protocol::socket socket) + { + if(ec) + { + fail(ec, "accept"); + return; + } + else + { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 3) + { + std::cerr << + "Usage: websocket-server-async-local \n" << + "Example:\n" << + " websocket-server-async-local /tmp/ws.sock 1\n"; + return EXIT_FAILURE; + } + auto const path = argv[1]; + auto const threads = std::max(1, std::atoi(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Remove previous binding + std::remove(path); + + // Create and launch a listening port + std::make_shared(ioc, stream_protocol::endpoint{path})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; + } + catch(std::exception const& e) + { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; + } +} + +#else + +int +main(int, char*[]) +{ + std::cerr << + "Local sockets not available on this platform" << std::endl; + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/CMakeLists.txt new file mode 100644 index 0000000..6ff3c8b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-async-ssl + Jamfile + websocket_server_async_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_server_async_ssl.cpp) + +target_include_directories(websocket-server-async-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-server-async-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-server-async-ssl + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/Jamfile new file mode 100644 index 0000000..b66da67 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-server-async-ssl : + websocket_server_async_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/websocket_server_async_ssl.cpp new file mode 100644 index 0000000..1eabe4c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -0,0 +1,315 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, asynchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this +{ + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) + : ws_(std::move(socket), ctx) + { + } + + // Get on the correct executor + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler( + &session::on_run, + shared_from_this())); + } + + // Start the asynchronous operation + void + on_run() + { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws_.next_layer().async_handshake( + ssl::stream_base::server, + beast::bind_front_handler( + &session::on_handshake, + shared_from_this())); + } + + void + on_handshake(beast::error_code ec) + { + if(ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-async-ssl"); + })); + + // Accept the websocket handshake + ws_.async_accept( + beast::bind_front_handler( + &session::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec) + { + if(ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void + do_read() + { + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if(ec == websocket::error::closed) + return; + + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write( + buffer_.data(), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + +public: + listener( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint) + : ioc_(ioc) + , ctx_(ctx) + , acceptor_(net::make_strand(ioc)) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the session and run it + std::make_shared(std::move(socket), ctx_)->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-async-ssl
\n" << + "Example:\n" << + " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/CMakeLists.txt new file mode 100644 index 0000000..854ed96 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-async + Jamfile + websocket_server_async.cpp) + +source_group("" FILES + Jamfile + websocket_server_async.cpp) + +target_link_libraries(websocket-server-async PRIVATE Boost::beast) + +set_target_properties(websocket-server-async + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/Jamfile new file mode 100644 index 0000000..e1e63e1 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-async : + websocket_server_async.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/websocket_server_async.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/websocket_server_async.cpp new file mode 100644 index 0000000..c50ac0c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/async/websocket_server_async.cpp @@ -0,0 +1,281 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, asynchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session : public std::enable_shared_from_this +{ + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit + session(tcp::socket&& socket) + : ws_(std::move(socket)) + { + } + + // Get on the correct executor + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler( + &session::on_run, + shared_from_this())); + } + + // Start the asynchronous operation + void + on_run() + { + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-async"); + })); + // Accept the websocket handshake + ws_.async_accept( + beast::bind_front_handler( + &session::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec) + { + if(ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void + do_read() + { + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This indicates that the session was closed + if(ec == websocket::error::closed) + return; + + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write( + buffer_.data(), + beast::bind_front_handler( + &session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + listener( + net::io_context& ioc, + tcp::endpoint endpoint) + : ioc_(ioc) + , acceptor_(ioc) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-async
\n" << + "Example:\n" << + " websocket-server-async 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/CMakeLists.txt new file mode 100644 index 0000000..0c20d00 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-awaitable + Jamfile + websocket_server_awaitable.cpp) + +source_group("" FILES + Jamfile + websocket_server_awaitable.cpp) + +target_link_libraries(websocket-server-awaitable PRIVATE Boost::beast) + +set_target_properties(websocket-server-awaitable + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/Jamfile new file mode 100644 index 0000000..0eddbe2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-awaitable : + websocket_server_awaitable.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/websocket_server_awaitable.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/websocket_server_awaitable.cpp new file mode 100644 index 0000000..9d021f2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/awaitable/websocket_server_awaitable.cpp @@ -0,0 +1,165 @@ +// +// Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + +namespace beast = boost::beast; +namespace http = beast::http; +namespace websocket = beast::websocket; +namespace net = boost::asio; + +// Echoes back all received WebSocket messages +net::awaitable +do_session(websocket::stream stream) +{ + // Set suggested timeout settings for the websocket + stream.set_option( + websocket::stream_base::timeout::suggested(beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set( + http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-coro"); + })); + + // Accept the websocket handshake + co_await stream.async_accept(); + + for(;;) + { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + auto [ec, _] = co_await stream.async_read(buffer, net::as_tuple); + + if(ec == websocket::error::closed) + co_return; + + if(ec) + throw boost::system::system_error{ ec }; + + // Echo the message back + stream.text(stream.got_text()); + co_await stream.async_write(buffer.data()); + } +} + +// Accepts incoming connections and launches the sessions +net::awaitable +do_listen(net::ip::tcp::endpoint endpoint) +{ + auto executor = co_await net::this_coro::executor; + auto acceptor = net::ip::tcp::acceptor{ executor, endpoint }; + + for(;;) + { + net::co_spawn( + executor, + do_session(websocket::stream{ + co_await acceptor.async_accept() }), + [](std::exception_ptr e) + { + if(e) + { + try + { + std::rethrow_exception(e); + } + catch(std::exception& e) + { + std::cerr << "Error in session: " << e.what() << "\n"; + } + } + }); + } +} + +int +main(int argc, char* argv[]) +{ + // Check command line arguments. + if(argc != 4) + { + std::cerr + << "Usage: websocket-server-awaitable
\n" + << "Example:\n" + << " websocket-server-awaitable 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc(threads); + + // Spawn a listening port + net::co_spawn( + ioc, + do_listen(net::ip::tcp::endpoint{ address, port }), + [](std::exception_ptr e) + { + if(e) + { + try + { + std::rethrow_exception(e); + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + } + } + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back([&ioc] { ioc.run(); }); + ioc.run(); + + return EXIT_SUCCESS; +} + +#else + +int +main(int, char*[]) +{ + std::printf("awaitables require C++20\n"); + return EXIT_FAILURE; +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/CMakeLists.txt new file mode 100644 index 0000000..355004d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/CMakeLists.txt @@ -0,0 +1,44 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-chat-multi + beast.hpp + chat_client.html + http_session.cpp + http_session.hpp + Jamfile + listener.cpp + listener.hpp + main.cpp + net.hpp + shared_state.cpp + shared_state.hpp + websocket_session.cpp + websocket_session.hpp) + +source_group("" FILES + beast.hpp + chat_client.html + http_session.cpp + http_session.hpp + Jamfile + listener.cpp + listener.hpp + main.cpp + net.hpp + shared_state.cpp + shared_state.hpp + websocket_session.cpp + websocket_session.hpp) + +target_link_libraries(websocket-chat-multi PRIVATE Boost::beast) + +set_target_properties(websocket-chat-multi + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/Jamfile new file mode 100644 index 0000000..a8d49bf --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/Jamfile @@ -0,0 +1,19 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-chat-multi : + http_session.cpp + listener.cpp + main.cpp + shared_state.cpp + websocket_session.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/beast.hpp new file mode 100644 index 0000000..0b7a9c6 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/beast.hpp @@ -0,0 +1,19 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_BEAST_HPP + +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/chat_client.html b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/chat_client.html new file mode 100644 index 0000000..2be69cd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/chat_client.html @@ -0,0 +1,60 @@ + + + + + Boost.Beast WebSocket Chat Client + + +

Boost.Beast WebSocket Chat Client

+

+ Boost.Beast + Source Code +

+ Server URI: + +
+ Your Name:
+

+  
+ Message
+ + +
+ + + diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/http_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/http_session.cpp new file mode 100644 index 0000000..ee6cb0c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/http_session.cpp @@ -0,0 +1,300 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "http_session.hpp" +#include "websocket_session.hpp" +#include +#include + +//------------------------------------------------------------------------------ + +// Return a reasonable mime type based on the extension of a file. +beast::string_view +mime_type(beast::string_view path) +{ + using beast::iequals; + auto const ext = [&path] + { + auto const pos = path.rfind("."); + if(pos == beast::string_view::npos) + return beast::string_view{}; + return path.substr(pos); + }(); + if(iequals(ext, ".htm")) return "text/html"; + if(iequals(ext, ".html")) return "text/html"; + if(iequals(ext, ".php")) return "text/html"; + if(iequals(ext, ".css")) return "text/css"; + if(iequals(ext, ".txt")) return "text/plain"; + if(iequals(ext, ".js")) return "application/javascript"; + if(iequals(ext, ".json")) return "application/json"; + if(iequals(ext, ".xml")) return "application/xml"; + if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if(iequals(ext, ".flv")) return "video/x-flv"; + if(iequals(ext, ".png")) return "image/png"; + if(iequals(ext, ".jpe")) return "image/jpeg"; + if(iequals(ext, ".jpeg")) return "image/jpeg"; + if(iequals(ext, ".jpg")) return "image/jpeg"; + if(iequals(ext, ".gif")) return "image/gif"; + if(iequals(ext, ".bmp")) return "image/bmp"; + if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if(iequals(ext, ".tiff")) return "image/tiff"; + if(iequals(ext, ".tif")) return "image/tiff"; + if(iequals(ext, ".svg")) return "image/svg+xml"; + if(iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; +} + +// Append an HTTP rel-path to a local filesystem path. +// The returned path is normalized for the platform. +std::string +path_cat( + beast::string_view base, + beast::string_view path) +{ + if(base.empty()) + return std::string(path); + std::string result(base); +#ifdef BOOST_MSVC + char constexpr path_separator = '\\'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for(auto& c : result) + if(c == '/') + c = path_separator; +#else + char constexpr path_separator = '/'; + if(result.back() == path_separator) + result.resize(result.size() - 1); + result.append(path.data(), path.size()); +#endif + return result; +} + +// Return a response for the given request. +// +// The concrete type of the response message (which depends on the +// request), is type-erased in message_generator. +template +http::message_generator +handle_request( + beast::string_view doc_root, + http::request>&& req) +{ + // Returns a bad request response + auto const bad_request = + [&req](beast::string_view why) + { + http::response res{http::status::bad_request, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = + [&req](beast::string_view target) + { + http::response res{http::status::not_found, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = + [&req](beast::string_view what) + { + http::response res{http::status::internal_server_error, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if( req.method() != http::verb::get && + req.method() != http::verb::head) + return bad_request("Unknown HTTP-method"); + + // Request path must be absolute and not contain "..". + if( req.target().empty() || + req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return bad_request("Illegal request-target"); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if(req.target().back() == '/') + path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if(ec == boost::system::errc::no_such_file_or_directory) + return not_found(req.target()); + + // Handle an unknown error + if(ec) + return server_error(ec.message()); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if(req.method() == http::verb::head) + { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, + std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return res; +} + +//------------------------------------------------------------------------------ + +http_session:: +http_session( + tcp::socket&& socket, + boost::shared_ptr const& state) + : stream_(std::move(socket)) + , state_(state) +{ +} + +void +http_session:: +run() +{ + do_read(); +} + +// Report a failure +void +http_session:: +fail(beast::error_code ec, char const* what) +{ + // Don't report on canceled operations + if(ec == net::error::operation_aborted) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void +http_session:: +do_read() +{ + // Construct a new parser for each message + parser_.emplace(); + + // Apply a reasonable limit to the allowed size + // of the body in bytes to prevent abuse. + parser_->body_limit(10000); + + // Set the timeout. + stream_.expires_after(std::chrono::seconds(30)); + + // Read a request + http::async_read( + stream_, + buffer_, + parser_->get(), + beast::bind_front_handler( + &http_session::on_read, + shared_from_this())); +} + +void +http_session:: +on_read(beast::error_code ec, std::size_t) +{ + // This means they closed the connection + if(ec == http::error::end_of_stream) + { + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + return; + } + + // Handle the error, if any + if(ec) + return fail(ec, "read"); + + // See if it is a WebSocket Upgrade + if(websocket::is_upgrade(parser_->get())) + { + // Create a websocket session, transferring ownership + // of both the socket and the HTTP request. + boost::make_shared( + stream_.release_socket(), + state_)->run(parser_->release()); + return; + } + + // Handle request + http::message_generator msg = + handle_request(state_->doc_root(), parser_->release()); + + // Determine if we should close the connection + bool keep_alive = msg.keep_alive(); + + auto self = shared_from_this(); + + // Send the response + beast::async_write( + stream_, std::move(msg), + [self, keep_alive](beast::error_code ec, std::size_t bytes) + { + self->on_write(ec, bytes, keep_alive); + }); +} + +void +http_session:: +on_write(beast::error_code ec, std::size_t, bool keep_alive) +{ + // Handle the error, if any + if(ec) + return fail(ec, "write"); + + if(! keep_alive) + { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + stream_.socket().shutdown(tcp::socket::shutdown_send, ec); + return; + } + + // Read another request + do_read(); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/http_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/http_session.hpp new file mode 100644 index 0000000..637a5d8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/http_session.hpp @@ -0,0 +1,48 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_HTTP_SESSION_HPP + +#include "net.hpp" +#include "beast.hpp" +#include "shared_state.hpp" +#include +#include +#include +#include + +/** Represents an established HTTP connection +*/ +class http_session : public boost::enable_shared_from_this +{ + beast::tcp_stream stream_; + beast::flat_buffer buffer_; + boost::shared_ptr state_; + + // The parser is stored in an optional container so we can + // construct it from scratch it at the beginning of each new message. + boost::optional> parser_; + + struct send_lambda; + + void fail(beast::error_code ec, char const* what); + void do_read(); + void on_read(beast::error_code ec, std::size_t); + void on_write(beast::error_code ec, std::size_t, bool close); + +public: + http_session( + tcp::socket&& socket, + boost::shared_ptr const& state); + + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/listener.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/listener.cpp new file mode 100644 index 0000000..8bbecb4 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/listener.cpp @@ -0,0 +1,101 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "listener.hpp" +#include "http_session.hpp" +#include + +listener:: +listener( + net::io_context& ioc, + tcp::endpoint endpoint, + boost::shared_ptr const& state) + : ioc_(ioc) + , acceptor_(ioc) + , state_(state) +{ + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } +} + +void +listener:: +run() +{ + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); +} + +// Report a failure +void +listener:: +fail(beast::error_code ec, char const* what) +{ + // Don't report on canceled operations + if(ec == net::error::operation_aborted) + return; + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Handle a connection +void +listener:: +on_accept(beast::error_code ec, tcp::socket socket) +{ + if(ec) + return fail(ec, "accept"); + else + // Launch a new session for this connection + boost::make_shared( + std::move(socket), + state_)->run(); + + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &listener::on_accept, + shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/listener.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/listener.hpp new file mode 100644 index 0000000..a0c536e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/listener.hpp @@ -0,0 +1,42 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP + +#include "beast.hpp" +#include "net.hpp" +#include +#include +#include + +// Forward declaration +class shared_state; + +// Accepts incoming connections and launches the sessions +class listener : public boost::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + boost::shared_ptr state_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec, tcp::socket socket); + +public: + listener( + net::io_context& ioc, + tcp::endpoint endpoint, + boost::shared_ptr const& state); + + // Start accepting incoming connections + void run(); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/main.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/main.cpp new file mode 100644 index 0000000..8645f1d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/main.cpp @@ -0,0 +1,84 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +//------------------------------------------------------------------------------ +/* + WebSocket chat server, multi-threaded + + This implements a multi-user chat room using WebSocket. The + `io_context` runs on any number of threads, specified at + the command line. + +*/ +//------------------------------------------------------------------------------ + +#include "listener.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +int +main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 5) + { + std::cerr << + "Usage: websocket-chat-multi
\n" << + "Example:\n" << + " websocket-chat-server 0.0.0.0 8080 . 5\n"; + return EXIT_FAILURE; + } + auto address = net::ip::make_address(argv[1]); + auto port = static_cast(std::atoi(argv[2])); + auto doc_root = argv[3]; + auto const threads = std::max(1, std::atoi(argv[4])); + + // The io_context is required for all I/O + net::io_context ioc; + + // Create and launch a listening port + boost::make_shared( + ioc, + tcp::endpoint{address, port}, + boost::make_shared(doc_root))->run(); + + // Capture SIGINT and SIGTERM to perform a clean shutdown + net::signal_set signals(ioc, SIGINT, SIGTERM); + signals.async_wait( + [&ioc](boost::system::error_code const&, int) + { + // Stop the io_context. This will cause run() + // to return immediately, eventually destroying the + // io_context and any remaining handlers in it. + ioc.stop(); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + // (If we get here, it means we got a SIGINT or SIGTERM) + + // Block until all the threads exit + for(auto& t : v) + t.join(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/net.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/net.hpp new file mode 100644 index 0000000..48a2153 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/net.hpp @@ -0,0 +1,18 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_NET_HPP + +#include + +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/shared_state.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/shared_state.cpp new file mode 100644 index 0000000..9fceecc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/shared_state.cpp @@ -0,0 +1,59 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "shared_state.hpp" +#include "websocket_session.hpp" + +shared_state:: +shared_state(std::string doc_root) + : doc_root_(std::move(doc_root)) +{ +} + +void +shared_state:: +join(websocket_session* session) +{ + std::lock_guard lock(mutex_); + sessions_.insert(session); +} + +void +shared_state:: +leave(websocket_session* session) +{ + std::lock_guard lock(mutex_); + sessions_.erase(session); +} + +// Broadcast a message to all websocket client sessions +void +shared_state:: +send(std::string message) +{ + // Put the message in a shared pointer so we can re-use it for each client + auto const ss = boost::make_shared(std::move(message)); + + // Make a local list of all the weak pointers representing + // the sessions, so we can do the actual sending without + // holding the mutex: + std::vector> v; + { + std::lock_guard lock(mutex_); + v.reserve(sessions_.size()); + for(auto p : sessions_) + v.emplace_back(p->weak_from_this()); + } + + // For each session in our local list, try to acquire a strong + // pointer. If successful, then send the message on that session. + for(auto const& wp : v) + if(auto sp = wp.lock()) + sp->send(ss); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/shared_state.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/shared_state.hpp new file mode 100644 index 0000000..08f4b2d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/shared_state.hpp @@ -0,0 +1,48 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP + +#include +#include +#include +#include +#include + +// Forward declaration +class websocket_session; + +// Represents the shared server state +class shared_state +{ + std::string const doc_root_; + + // This mutex synchronizes all access to sessions_ + std::mutex mutex_; + + // Keep a list of all the connected clients + std::unordered_set sessions_; + +public: + explicit + shared_state(std::string doc_root); + + std::string const& + doc_root() const noexcept + { + return doc_root_; + } + + void join (websocket_session* session); + void leave (websocket_session* session); + void send (std::string message); +}; + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/websocket_session.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/websocket_session.cpp new file mode 100644 index 0000000..4807a5f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/websocket_session.cpp @@ -0,0 +1,135 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#include "websocket_session.hpp" +#include + +websocket_session:: +websocket_session( + tcp::socket&& socket, + boost::shared_ptr const& state) + : ws_(std::move(socket)) + , state_(state) +{ +} + +websocket_session:: +~websocket_session() +{ + // Remove this session from the list of active sessions + state_->leave(this); +} + +void +websocket_session:: +fail(beast::error_code ec, char const* what) +{ + // Don't report these + if( ec == net::error::operation_aborted || + ec == websocket::error::closed) + return; + + std::cerr << what << ": " << ec.message() << "\n"; +} + +void +websocket_session:: +on_accept(beast::error_code ec) +{ + // Handle the error, if any + if(ec) + return fail(ec, "accept"); + + // Add this session to the list of active sessions + state_->join(this); + + // Read a message + ws_.async_read( + buffer_, + beast::bind_front_handler( + &websocket_session::on_read, + shared_from_this())); +} + +void +websocket_session:: +on_read(beast::error_code ec, std::size_t) +{ + // Handle the error, if any + if(ec) + return fail(ec, "read"); + + // Send to all connections + state_->send(beast::buffers_to_string(buffer_.data())); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Read another message + ws_.async_read( + buffer_, + beast::bind_front_handler( + &websocket_session::on_read, + shared_from_this())); +} + +void +websocket_session:: +send(boost::shared_ptr const& ss) +{ + // Post our work to the strand, this ensures + // that the members of `this` will not be + // accessed concurrently. + + net::post( + ws_.get_executor(), + beast::bind_front_handler( + &websocket_session::on_send, + shared_from_this(), + ss)); +} + +void +websocket_session:: +on_send(boost::shared_ptr const& ss) +{ + // Always add to queue + queue_.push_back(ss); + + // Are we already writing? + if(queue_.size() > 1) + return; + + // We are not currently writing, so send this immediately + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler( + &websocket_session::on_write, + shared_from_this())); +} + +void +websocket_session:: +on_write(beast::error_code ec, std::size_t) +{ + // Handle the error, if any + if(ec) + return fail(ec, "write"); + + // Remove the string from the queue + queue_.erase(queue_.begin()); + + // Send the next message if any + if(! queue_.empty()) + ws_.async_write( + net::buffer(*queue_.front()), + beast::bind_front_handler( + &websocket_session::on_write, + shared_from_this())); +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/websocket_session.hpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/websocket_session.hpp new file mode 100644 index 0000000..c47d48a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/chat-multi/websocket_session.hpp @@ -0,0 +1,86 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/CppCon2018 +// + +#ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP +#define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_WEBSOCKET_SESSION_HPP + +#include "net.hpp" +#include "beast.hpp" +#include "shared_state.hpp" + +#include +#include +#include +#include + +// Forward declaration +class shared_state; + +/** Represents an active WebSocket connection to the server +*/ +class websocket_session : public boost::enable_shared_from_this +{ + beast::flat_buffer buffer_; + websocket::stream ws_; + boost::shared_ptr state_; + std::vector> queue_; + + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); + +public: + websocket_session( + tcp::socket&& socket, + boost::shared_ptr const& state); + + ~websocket_session(); + + template + void + run(http::request> req); + + // Send a message + void + send(boost::shared_ptr const& ss); + +private: + void + on_send(boost::shared_ptr const& ss); +}; + +template +void +websocket_session:: +run(http::request> req) +{ + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-chat-multi"); + })); + + // Accept the websocket handshake + ws_.async_accept( + req, + beast::bind_front_handler( + &websocket_session::on_accept, + shared_from_this())); +} + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/CMakeLists.txt new file mode 100644 index 0000000..ff76ffe --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-coro-ssl + Jamfile + websocket_server_coro_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_server_coro_ssl.cpp) + +target_include_directories(websocket-server-coro-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-server-coro-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-server-coro-ssl + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/Jamfile new file mode 100644 index 0000000..c5e0966 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/Jamfile @@ -0,0 +1,23 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-server-coro-ssl : + websocket_server_coro_ssl.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp new file mode 100644 index 0000000..ae988a0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -0,0 +1,219 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, coroutine +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void +do_session( + websocket::stream>& ws, + net::yield_context yield) +{ + beast::error_code ec; + + // Set the timeout. + beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + ws.next_layer().async_handshake(ssl::stream_base::server, yield[ec]); + if(ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws).expires_never(); + + // Set suggested timeout settings for the websocket + ws.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-coro-ssl"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if(ec) + return fail(ec, "accept"); + + for(;;) + { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if(ec == websocket::error::closed) + break; + + if(ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if(ec) + return fail(ec, "write"); + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void +do_listen( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint, + net::yield_context yield) +{ + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if(ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if(ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + return fail(ec, "listen"); + + for(;;) + { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if(ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind( + &do_session, + websocket::stream>(std::move(socket), ctx), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-coro-ssl
\n" << + "Example:\n" << + " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind( + &do_listen, + std::ref(ioc), + std::ref(ctx), + tcp::endpoint{address, port}, + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/CMakeLists.txt new file mode 100644 index 0000000..87eb5cb --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-coro + Jamfile + websocket_server_coro.cpp) + +source_group("" FILES + Jamfile + websocket_server_coro.cpp) + +target_link_libraries(websocket-server-coro PRIVATE Boost::beast) + +set_target_properties(websocket-server-coro + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/Jamfile new file mode 100644 index 0000000..0ef1350 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-coro : + websocket_server_coro.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/websocket_server_coro.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/websocket_server_coro.cpp new file mode 100644 index 0000000..ca62c56 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/coro/websocket_server_coro.cpp @@ -0,0 +1,195 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +void +do_session( + websocket::stream& ws, + net::yield_context yield) +{ + beast::error_code ec; + + // Set suggested timeout settings for the websocket + ws.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-coro"); + })); + + // Accept the websocket handshake + ws.async_accept(yield[ec]); + if(ec) + return fail(ec, "accept"); + + for(;;) + { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.async_read(buffer, yield[ec]); + + // This indicates that the session was closed + if(ec == websocket::error::closed) + break; + + if(ec) + return fail(ec, "read"); + + // Echo the message back + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if(ec) + return fail(ec, "write"); + } +} + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +void +do_listen( + net::io_context& ioc, + tcp::endpoint endpoint, + net::yield_context yield) +{ + beast::error_code ec; + + // Open the acceptor + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if(ec) + return fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + return fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if(ec) + return fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + return fail(ec, "listen"); + + for(;;) + { + tcp::socket socket(ioc); + acceptor.async_accept(socket, yield[ec]); + if(ec) + fail(ec, "accept"); + else + boost::asio::spawn( + acceptor.get_executor(), + std::bind( + &do_session, + websocket::stream< + beast::tcp_stream>(std::move(socket)), + std::placeholders::_1), + // we ignore the result of the session, + // most errors are handled with error_code + boost::asio::detached); + } +} + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-coro
\n" << + "Example:\n" << + " websocket-server-coro 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc(threads); + + // Spawn a listening port + boost::asio::spawn(ioc, + std::bind( + &do_listen, + std::ref(ioc), + tcp::endpoint{address, port}, + std::placeholders::_1), + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/CMakeLists.txt new file mode 100644 index 0000000..562407f --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-fast + Jamfile + websocket_server_fast.cpp) + +source_group("" FILES + Jamfile + websocket_server_fast.cpp) + +target_link_libraries(websocket-server-fast PRIVATE Boost::beast) + +set_target_properties(websocket-server-fast + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/Jamfile new file mode 100644 index 0000000..a310f6c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/Jamfile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-fast : + websocket_server_fast.cpp + : + coverage:no + ubasan:no + /boost/context//boost_context + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/websocket_server_fast.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/websocket_server_fast.cpp new file mode 100644 index 0000000..239f83c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/fast/websocket_server_fast.cpp @@ -0,0 +1,481 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, fast +// +//------------------------------------------------------------------------------ + +/* This server contains the following ports: + + Synchronous + Asynchronous + Coroutine + + This program is optimized for the Autobahn|Testsuite + benchmarking and WebSocket compliants testing program. + + See: + https://github.com/crossbario/autobahn-testsuite +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << (std::string(what) + ": " + ec.message() + "\n"); +} + +// Adjust settings on the stream +template +void +setup_stream(websocket::stream& ws) +{ + // These values are tuned for Autobahn|Testsuite, and + // should also be generally helpful for increased performance. + + websocket::permessage_deflate pmd; + pmd.client_enable = true; + pmd.server_enable = true; + pmd.compLevel = 3; + ws.set_option(pmd); + + ws.auto_fragment(false); + + // Autobahn|Testsuite needs this + ws.read_message_max(64 * 1024 * 1024); +} + +//------------------------------------------------------------------------------ + +void +do_sync_session(websocket::stream& ws) +{ + beast::error_code ec; + + setup_stream(ws); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, std::string( + BOOST_BEAST_VERSION_STRING) + "-Sync"); + })); + + ws.accept(ec); + if(ec) + return fail(ec, "accept"); + + for(;;) + { + beast::flat_buffer buffer; + + ws.read(buffer, ec); + if(ec == websocket::error::closed) + break; + if(ec) + return fail(ec, "read"); + ws.text(ws.got_text()); + ws.write(buffer.data(), ec); + if(ec) + return fail(ec, "write"); + } +} + +void +do_sync_listen( + net::io_context& ioc, + tcp::endpoint endpoint) +{ + beast::error_code ec; + tcp::acceptor acceptor{ioc, endpoint}; + for(;;) + { + tcp::socket socket{ioc}; + + acceptor.accept(socket, ec); + if(ec) + return fail(ec, "accept"); + + std::thread(std::bind( + &do_sync_session, + websocket::stream( + std::move(socket)))).detach(); + } +} + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +class async_session : public std::enable_shared_from_this +{ + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit + async_session(tcp::socket&& socket) + : ws_(std::move(socket)) + { + setup_stream(ws_); + } + + // Start the asynchronous operation + void + run() + { + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, std::string( + BOOST_BEAST_VERSION_STRING) + "-Async"); + })); + + // Accept the websocket handshake + ws_.async_accept( + beast::bind_front_handler( + &async_session::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec) + { + if(ec) + return fail(ec, "accept"); + + // Read a message + do_read(); + } + + void + do_read() + { + // Read a message into our buffer + ws_.async_read( + buffer_, + beast::bind_front_handler( + &async_session::on_read, + shared_from_this())); + } + + void + on_read( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + // This indicates that the async_session was closed + if(ec == websocket::error::closed) + return; + + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + ws_.async_write( + buffer_.data(), + beast::bind_front_handler( + &async_session::on_write, + shared_from_this())); + } + + void + on_write( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + + // Do another read + do_read(); + } +}; + +// Accepts incoming connections and launches the sessions +class async_listener : public std::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + +public: + async_listener( + net::io_context& ioc, + tcp::endpoint endpoint) + : ioc_(ioc) + , acceptor_(net::make_strand(ioc)) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + do_accept(); + } + +private: + void + do_accept() + { + // The new connection gets its own strand + acceptor_.async_accept( + net::make_strand(ioc_), + beast::bind_front_handler( + &async_listener::on_accept, + shared_from_this())); + } + + void + on_accept(beast::error_code ec, tcp::socket socket) + { + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the async_session and run it + std::make_shared(std::move(socket))->run(); + } + + // Accept another connection + do_accept(); + } +}; + +//------------------------------------------------------------------------------ + +void +do_coro_session( + websocket::stream& ws, + net::yield_context yield) +{ + beast::error_code ec; + + setup_stream(ws); + + // Set suggested timeout settings for the websocket + ws.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, std::string( + BOOST_BEAST_VERSION_STRING) + "-Fiber"); + })); + + ws.async_accept(yield[ec]); + if(ec) + return fail(ec, "accept"); + + for(;;) + { + beast::flat_buffer buffer; + + ws.async_read(buffer, yield[ec]); + if(ec == websocket::error::closed) + break; + if(ec) + return fail(ec, "read"); + + ws.text(ws.got_text()); + ws.async_write(buffer.data(), yield[ec]); + if(ec) + return fail(ec, "write"); + } +} + +void +do_coro_listen( + net::io_context& ioc, + tcp::endpoint endpoint, + net::yield_context yield) +{ + beast::error_code ec; + + tcp::acceptor acceptor(ioc); + acceptor.open(endpoint.protocol(), ec); + if(ec) + return fail(ec, "open"); + + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + return fail(ec, "set_option"); + + acceptor.bind(endpoint, ec); + if(ec) + return fail(ec, "bind"); + + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + return fail(ec, "listen"); + + for(;;) + { + tcp::socket socket(ioc); + + acceptor.async_accept(socket, yield[ec]); + if(ec) + { + fail(ec, "accept"); + continue; + } + + boost::asio::spawn( + acceptor.get_executor(), + std::bind( + &do_coro_session, + websocket::stream< + beast::tcp_stream>(std::move(socket)), + std::placeholders::_1), boost::asio::detached); + } +} + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-fast
\n" << + "Example:\n" + " websocket-server-fast 0.0.0.0 8080 1\n" + " Connect to:\n" + " starting-port+0 for synchronous,\n" + " starting-port+1 for asynchronous,\n" + " starting-port+2 for coroutine.\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create sync port + std::thread(beast::bind_front_handler( + &do_sync_listen, + std::ref(ioc), + tcp::endpoint{ + address, + static_cast(port + 0u)} + )).detach(); + + // Create async port + std::make_shared( + ioc, + tcp::endpoint{ + address, + static_cast(port + 1u)})->run(); + + // Create coro port + boost::asio::spawn(ioc, + std::bind( + &do_coro_listen, + std::ref(ioc), + tcp::endpoint{ + address, + static_cast(port + 2u)}, + std::placeholders::_1), boost::asio::detached); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/CMakeLists.txt new file mode 100644 index 0000000..148b101 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-stackless-ssl + Jamfile + websocket_server_stackless_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_server_stackless_ssl.cpp) + +target_include_directories(websocket-server-stackless-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-server-stackless-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-server-stackless-ssl + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/Jamfile new file mode 100644 index 0000000..7133f12 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-server-stackless-ssl : + websocket_server_stackless_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp new file mode 100644 index 0000000..3669147 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -0,0 +1,314 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + websocket::stream> ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + session(tcp::socket&& socket, ssl::context& ctx) + : ws_(std::move(socket), ctx) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::loop, + shared_from_this(), + beast::error_code{}, + 0)); + } + + #include + + void + loop( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + + reenter(*this) + { + // Set the timeout. + beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); + + // Perform the SSL handshake + yield ws_.next_layer().async_handshake( + ssl::stream_base::server, + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + 0)); + if(ec) + return fail(ec, "handshake"); + + // Turn off the timeout on the tcp_stream, because + // the websocket stream has its own timeout system. + beast::get_lowest_layer(ws_).expires_never(); + + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless-ssl"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + 0)); + if(ec) + return fail(ec, "accept"); + + for(;;) + { + // Read a message into our buffer + yield ws_.async_read( + buffer_, + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2)); + if(ec == websocket::error::closed) + { + // This indicates that the session was closed + return; + } + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2)); + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + net::io_context& ioc_; + ssl::context& ctx_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + listener( + net::io_context& ioc, + ssl::context& ctx, + tcp::endpoint endpoint) + : ioc_(ioc) + , ctx_(ctx) + , acceptor_(ioc) + , socket_(ioc) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + loop(); + } + +private: + + #include + + void + loop(beast::error_code ec = {}) + { + reenter(*this) + { + for(;;) + { + yield acceptor_.async_accept( + socket_, + std::bind( + &listener::loop, + shared_from_this(), + std::placeholders::_1)); + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the session and run it + std::make_shared(std::move(socket_), ctx_)->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-async-ssl
\n" << + "Example:\n" << + " websocket-server-async-ssl 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // Create and launch a listening port + std::make_shared(ioc, ctx, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/CMakeLists.txt new file mode 100644 index 0000000..9afa752 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-stackless + Jamfile + websocket_server_stackless.cpp) + +source_group("" FILES + Jamfile + websocket_server_stackless.cpp) + +target_link_libraries(websocket-server-stackless PRIVATE Boost::beast) + +set_target_properties(websocket-server-stackless + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/Jamfile new file mode 100644 index 0000000..ce9ab89 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-stackless : + websocket_server_stackless.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/websocket_server_stackless.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/websocket_server_stackless.cpp new file mode 100644 index 0000000..ff1fd09 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/stackless/websocket_server_stackless.cpp @@ -0,0 +1,282 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, stackless coroutine +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Report a failure +void +fail(beast::error_code ec, char const* what) +{ + std::cerr << what << ": " << ec.message() << "\n"; +} + +// Echoes back all received WebSocket messages +class session + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + websocket::stream ws_; + beast::flat_buffer buffer_; + +public: + // Take ownership of the socket + explicit + session(tcp::socket socket) + : ws_(std::move(socket)) + { + } + + // Start the asynchronous operation + void + run() + { + // We need to be executing within a strand to perform async operations + // on the I/O objects in this session. Although not strictly necessary + // for single-threaded contexts, this example code is written to be + // thread-safe by default. + net::dispatch(ws_.get_executor(), + beast::bind_front_handler(&session::loop, + shared_from_this(), + beast::error_code{}, + 0)); + } + + #include + + void + loop( + beast::error_code ec, + std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + reenter(*this) + { + // Set suggested timeout settings for the websocket + ws_.set_option( + websocket::stream_base::timeout::suggested( + beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + ws_.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-stackless"); + })); + + // Accept the websocket handshake + yield ws_.async_accept( + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + 0)); + if(ec) + return fail(ec, "accept"); + + for(;;) + { + // Read a message into our buffer + yield ws_.async_read( + buffer_, + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2)); + if(ec == websocket::error::closed) + { + // This indicates that the session was closed + return; + } + if(ec) + return fail(ec, "read"); + + // Echo the message + ws_.text(ws_.got_text()); + yield ws_.async_write( + buffer_.data(), + std::bind( + &session::loop, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2)); + if(ec) + return fail(ec, "write"); + + // Clear the buffer + buffer_.consume(buffer_.size()); + } + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +// Accepts incoming connections and launches the sessions +class listener + : public boost::asio::coroutine + , public std::enable_shared_from_this +{ + net::io_context& ioc_; + tcp::acceptor acceptor_; + tcp::socket socket_; + +public: + listener( + net::io_context& ioc, + tcp::endpoint endpoint) + : ioc_(ioc) + , acceptor_(net::make_strand(ioc)) + , socket_(net::make_strand(ioc)) + { + beast::error_code ec; + + // Open the acceptor + acceptor_.open(endpoint.protocol(), ec); + if(ec) + { + fail(ec, "open"); + return; + } + + // Allow address reuse + acceptor_.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + { + fail(ec, "set_option"); + return; + } + + // Bind to the server address + acceptor_.bind(endpoint, ec); + if(ec) + { + fail(ec, "bind"); + return; + } + + // Start listening for connections + acceptor_.listen( + net::socket_base::max_listen_connections, ec); + if(ec) + { + fail(ec, "listen"); + return; + } + } + + // Start accepting incoming connections + void + run() + { + loop(); + } + +private: + + #include + + void + loop(beast::error_code ec = {}) + { + reenter(*this) + { + for(;;) + { + yield acceptor_.async_accept( + socket_, + std::bind( + &listener::loop, + shared_from_this(), + std::placeholders::_1)); + if(ec) + { + fail(ec, "accept"); + } + else + { + // Create the session and run it + std::make_shared(std::move(socket_))->run(); + } + + // Make sure each session gets its own strand + socket_ = tcp::socket(net::make_strand(ioc_)); + } + } + } + + #include +}; + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + // Check command line arguments. + if (argc != 4) + { + std::cerr << + "Usage: websocket-server-stackless
\n" << + "Example:\n" << + " websocket-server-stackless 0.0.0.0 8080 1\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const threads = std::max(1, std::atoi(argv[3])); + + // The io_context is required for all I/O + net::io_context ioc{threads}; + + // Create and launch a listening port + std::make_shared(ioc, tcp::endpoint{address, port})->run(); + + // Run the I/O service on the requested number of threads + std::vector v; + v.reserve(threads - 1); + for(auto i = threads - 1; i > 0; --i) + v.emplace_back( + [&ioc] + { + ioc.run(); + }); + ioc.run(); + + return EXIT_SUCCESS; +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/CMakeLists.txt new file mode 100644 index 0000000..4b32c89 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-sync-ssl + Jamfile + websocket_server_sync_ssl.cpp) + +source_group("" FILES + Jamfile + websocket_server_sync_ssl.cpp) + +target_include_directories(websocket-server-sync-ssl + PRIVATE ${PROJECT_SOURCE_DIR}) + +target_link_libraries(websocket-server-sync-ssl + PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto) + +set_target_properties(websocket-server-sync-ssl + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/Jamfile new file mode 100644 index 0000000..a33c15d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/Jamfile @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +import ac ; + +project + : requirements + [ ac.check-library /boost/beast/test//lib-asio-ssl : /boost/beast/test//lib-asio-ssl/static : no ] + ; + +exe websocket-server-sync-ssl : + websocket_server_sync_ssl.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp new file mode 100644 index 0000000..64ef233 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -0,0 +1,136 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket SSL server, synchronous +// +//------------------------------------------------------------------------------ + +#include "example/common/server_certificate.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +void +do_session(tcp::socket socket, ssl::context& ctx) +{ + try + { + // Construct the websocket stream around the socket + websocket::stream> ws{socket, ctx}; + + // Perform the SSL handshake + ws.next_layer().handshake(ssl::stream_base::server); + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-sync-ssl"); + })); + + // Accept the websocket handshake + ws.accept(); + + for(;;) + { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } + catch(beast::system_error const& se) + { + // This indicates that the session was closed + if(se.code() != websocket::error::closed) + std::cerr << "Error: " << se.code().message() << std::endl; + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + } +} + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 3) + { + std::cerr << + "Usage: websocket-server-sync-ssl
\n" << + "Example:\n" << + " websocket-server-sync-ssl 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The SSL context is required, and holds certificates + ssl::context ctx{ssl::context::tlsv12}; + + // This holds the self-signed certificate used by the server + load_server_certificate(ctx); + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for(;;) + { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread( + &do_session, + std::move(socket), + std::ref(ctx)).detach(); + } + } + catch (const std::exception& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/CMakeLists.txt b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/CMakeLists.txt new file mode 100644 index 0000000..7e20305 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2024 Mohammad Nejati +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +add_executable(websocket-server-sync + Jamfile + websocket_server_sync.cpp) + +source_group("" FILES + Jamfile + websocket_server_sync.cpp) + +target_link_libraries(websocket-server-sync PRIVATE Boost::beast) + +set_target_properties(websocket-server-sync + PROPERTIES FOLDER "example-websocket-server") diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/Jamfile new file mode 100644 index 0000000..7fd14ce --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/Jamfile @@ -0,0 +1,15 @@ +# +# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/beast +# + +exe websocket-server-sync : + websocket_server_sync.cpp + : + coverage:no + ubasan:no + ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/websocket_server_sync.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/websocket_server_sync.cpp new file mode 100644 index 0000000..74ce6b9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/upstream/websocket/server/sync/websocket_server_sync.cpp @@ -0,0 +1,121 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +//------------------------------------------------------------------------------ +// +// Example: WebSocket server, synchronous +// +//------------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from + +//------------------------------------------------------------------------------ + +// Echoes back all received WebSocket messages +void +do_session(tcp::socket socket) +{ + try + { + // Construct the stream by moving in the socket + websocket::stream ws{std::move(socket)}; + + // Set a decorator to change the Server of the handshake + ws.set_option(websocket::stream_base::decorator( + [](websocket::response_type& res) + { + res.set(http::field::server, + std::string(BOOST_BEAST_VERSION_STRING) + + " websocket-server-sync"); + })); + + // Accept the websocket handshake + ws.accept(); + + for(;;) + { + // This buffer will hold the incoming message + beast::flat_buffer buffer; + + // Read a message + ws.read(buffer); + + // Echo the message back + ws.text(ws.got_text()); + ws.write(buffer.data()); + } + } + catch(beast::system_error const& se) + { + // This indicates that the session was closed + if(se.code() != websocket::error::closed) + std::cerr << "Error: " << se.code().message() << std::endl; + } + catch(std::exception const& e) + { + std::cerr << "Error: " << e.what() << std::endl; + } +} + +//------------------------------------------------------------------------------ + +int main(int argc, char* argv[]) +{ + try + { + // Check command line arguments. + if (argc != 3) + { + std::cerr << + "Usage: websocket-server-sync
\n" << + "Example:\n" << + " websocket-server-sync 0.0.0.0 8080\n"; + return EXIT_FAILURE; + } + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for(;;) + { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread( + &do_session, + std::move(socket)).detach(); + } + } + catch (const std::exception& e) + { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/Jamfile new file mode 100644 index 0000000..f8f00ef --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/Jamfile @@ -0,0 +1,11 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +project : requirements /webcpp/beast//wasi-http ; +import webcpp ; +webcpp.targets wasip2 wasip3 ; +webcpp.serve http_echo.cpp ; +webcpp.lane http : http_echo : wasip2 wasip3 ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.cpp b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.cpp new file mode 100644 index 0000000..a4c244c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#include + +namespace http = webcpp::beast::http; + +namespace { +/** Application routing and response construction, independent of listener ownership. */ +http::response handle_request(http::request request) { + http::response response{http::status::ok, request.version()}; + response.set(http::field::content_type, "text/plain"); + if (request.target() == "/health") { + response.body() = "ready\n"; + } else { + response.body() = request.body(); + } + response.prepare_payload(); + return response; +} +} // namespace + +// The host owns the listener and any HTTPS trust policy. +WEBCPP_BEAST_WASI_HTTP_EXPORT(handle_request) diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.expected b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.expected new file mode 100644 index 0000000..37fa829 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.expected @@ -0,0 +1,6 @@ +$ curl -i -X GET http://localhost:8080/health +HTTP/1.1 200 OK +content-length: 6 +content-type: text/plain + +ready diff --git a/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.requests b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.requests new file mode 100644 index 0000000..9937ad7 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/example/wasi/http_echo.requests @@ -0,0 +1 @@ +GET /health diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast.hpp new file mode 100644 index 0000000..6ffe027 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +/** + Portable Beast buffers and HTTP data interfaces. + + Socket transport, WebSocket and TLS headers are explicit dependencies; this + header does not enable a platform socket backend or link OpenSSL. +*/ +#ifndef WEBCPP_BEAST_HPP +#define WEBCPP_BEAST_HPP + +#include + +#include +#include + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/detail/imports.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/detail/imports.hpp new file mode 100644 index 0000000..6a32cbd --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/detail/imports.hpp @@ -0,0 +1,164 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_DETAIL_IMPORTS_HPP +#define WEBCPP_BEAST_BROWSER_DETAIL_IMPORTS_HPP + +#include + +#include +#include +#include +#include +#include +#include + +// EM_ASM supports definitions in inline functions across translation units. +// Browser exceptions are caught in JavaScript before they can cross a Wasm frame. +// clang-format off +inline emscripten::EM_VAL webcpp_beast_open(emscripten::EM_VAL url, emscripten::EM_VAL protocols, emscripten::EM_VAL callback) { + return reinterpret_cast(EM_ASM_PTR({ + const url = $0; + const protocols = $1; + const callback = $2; + + const deliver = Emval.toValue(callback); + try { + const socket = new WebSocket(Emval.toValue(url), Emval.toValue(protocols)); + socket.binaryType = 'arraybuffer'; + for (const type of ['open', 'message', 'close', 'error']) + socket['on' + type] = event => deliver(event); + return Emval.toHandle({socket, error: 0}); + } catch (error) { + return Emval.toHandle({error: error.name === 'SyntaxError' ? 1 : + error.name === 'SecurityError' ? 2 : 3}); + } + }, url, protocols, callback)); +} +inline int webcpp_beast_send(emscripten::EM_VAL handle, const void* data, std::size_t size, bool text) { + return EM_ASM_INT({ + const handle = $0; + const data = $1; + const size = $2; + const text = $3; + + const socket = Emval.toValue(handle); + if (socket.readyState !== WebSocket.OPEN) return 1; + try { + const bytes = HEAPU8.subarray(data, data + size); + socket.send(text ? new TextDecoder().decode(bytes) : bytes); + return 0; + } catch (_) { return 1; } + }, handle, data, size, text); +} +inline void webcpp_beast_close(emscripten::EM_VAL handle, int code, emscripten::EM_VAL reason) { + EM_ASM({ + const handle = $0; + const code = $1; + const reason = $2; + + const socket = Emval.toValue(handle); + if (!socket) return; + try { if (code) socket.close(code, Emval.toValue(reason)); else socket.close(); } catch (_) {} + }, handle, code, reason); +} +inline std::size_t webcpp_beast_message_size(emscripten::EM_VAL value) { + return static_cast(EM_ASM_INT({ + const value = $0; + + const data = Emval.toValue(value); + return typeof data === 'string' ? new TextEncoder().encode(data).length : data.byteLength; + }, value)); +} +// NOLINTNEXTLINE(misc-const-correctness): JavaScript writes to the pointed Wasm storage +inline void webcpp_beast_copy(emscripten::EM_VAL value, void* data, std::size_t size) { + EM_ASM({ + const value = $0; + const data = $1; + const size = $2; + + const source = Emval.toValue(value); + // Take the Wasm view after C++ has prepared storage and may have grown memory. + const destination = HEAPU8.subarray(data, data + size); + if (typeof source === 'string') new TextEncoder().encodeInto(source, destination); + else destination.set(new Uint8Array(source)); + }, value, data, size); +} +inline emscripten::EM_VAL webcpp_beast_fetch(emscripten::EM_VAL url, emscripten::EM_VAL init, emscripten::EM_VAL callback) { + return reinterpret_cast(EM_ASM_PTR({ + const url = $0; + const init = $1; + const callback = $2; + + const controller = new AbortController(); + const options = Emval.toValue(init); + options.signal = controller.signal; + const limit = options.webcppBodyLimit; + delete options.webcppBodyLimit; + const deliver = Emval.toValue(callback); + fetch(Emval.toValue(url), options).then(async response => { + const headers = Array.from(response.headers); + const metadata = {status: response.status, statusText: response.statusText, + redirected: response.redirected, headers}; + deliver({type: 'fetch-header', ...metadata}); + const parts = []; + let size = 0; + if (response.body) { + const reader = response.body.getReader(); + for (;;) { + const chunk = await reader.read(); + if (chunk.done) break; + if (chunk.value.byteLength > limit - size) { + await reader.cancel(); + deliver({type: 'fetch-limit'}); + return; + } + parts.push(chunk.value); + size += chunk.value.byteLength; + } + } + const bytes = new Uint8Array(size); + let offset = 0; + for (const part of parts) { bytes.set(part, offset); offset += part.byteLength; } + const body = bytes.buffer; + deliver({type: 'fetch', ...metadata, body}); + }).catch(() => deliver({type: 'fetch-error'})); + return Emval.toHandle(controller); + }, url, init, callback)); +} +// clang-format on + +namespace webcpp::beast::detail::browser_strings { +/** Copies a bounded UTF-8 view directly into JavaScript without a temporary C++ string. */ +inline emscripten::val js_string(std::string_view text) { + return emscripten::val::take_ownership(reinterpret_cast( + EM_ASM_PTR({ return Emval.toHandle(UTF8ToString($0, $1)); }, text.data(), text.size()))); +} + +/** Copies a JavaScript string into caller-allocated UTF-8 storage. */ +inline std::pmr::string js_text(const emscripten::val& text, std::pmr::memory_resource* resource) { + std::pmr::string result(webcpp_beast_message_size(text.as_handle()), '\0', resource); + webcpp_beast_copy(text.as_handle(), result.data(), result.size()); + return result; +} +} // namespace webcpp::beast::detail::browser_strings + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::detail { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace browser { +/** Copies a bounded UTF-8 view without allocating temporary C++ storage. */ +using browser_strings::js_string; +/** Copies JavaScript text with the stream's memory resource. */ +using browser_strings::js_text; +} // namespace browser +} +} // namespace webcpp::beast::detail +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/detail/support.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/detail/support.hpp new file mode 100644 index 0000000..299a84c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/detail/support.hpp @@ -0,0 +1,298 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_DETAIL_SUPPORT_HPP +#define WEBCPP_BEAST_BROWSER_DETAIL_SUPPORT_HPP + +#include + +#include +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::detail { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace browser { +/** Monotonic clock used only to enforce browser operation deadlines. */ +using clock_type = std::chrono::steady_clock; // lint-world: browser operation deadlines +/** + Whether advisory browser limitations are ignored in this translation unit. + */ +inline constexpr bool ignore_unsupported = +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE + true; +#else + false; +#endif +/** + Error value shared by browser operations. + */ +using boost::system::error_code; +/** + Executor used to schedule stream operations and their completions. + */ +using executor_type = boost::asio::any_io_executor; + +/** + Maps an unsupported request to the selected compatibility policy. + */ +inline error_code unsupported(bool condition = true) { + return condition && !ignore_unsupported + ? error_code(boost::asio::error::operation_not_supported) + : error_code{}; +} + +/** + Throws a system error when the supplied error code is nonzero. + */ +inline void throw_error(error_code ec) { + if (ec) { + boost::throw_exception(boost::system::system_error(ec)); + } +} + +/** + Posts a completion while preserving the handler associations. + */ +template +void post(const executor_type& executor, Handler&& handler, Values&&... values) { + webcpp::asio::detail::post_completion( + executor, + boost::asio::append(std::forward(handler), std::forward(values)...)); +} + +/** + Erases the stream allocator while retaining it for all variable-sized state. + */ +template +class allocator_resource final : public std::pmr::memory_resource { + using unit = std::max_align_t; + using allocator_type = std::allocator_traits::template rebind_alloc; + allocator_type allocator_; + + static std::size_t units(std::size_t bytes, std::size_t alignment) { + const auto overhead = + std::max(alignment, alignof(unit*)) + sizeof(unit*) + sizeof(unit) - 1; + if (bytes > std::numeric_limits::max() - overhead) { + boost::throw_exception(std::bad_alloc()); + } + return (bytes + overhead) / sizeof(unit); + } + + void* do_allocate(std::size_t bytes, std::size_t alignment) override { + alignment = std::max(alignment, alignof(unit*)); + const auto count = units(bytes, alignment); + auto* storage = std::allocator_traits::allocate(allocator_, count); + void* value = reinterpret_cast(storage) + sizeof(unit*); + auto available = (count * sizeof(unit)) - sizeof(unit*); + void* aligned = std::align(alignment, bytes, value, available); + static_cast(aligned)[-1] = storage; + return aligned; + } + + void do_deallocate(void* pointer, std::size_t bytes, std::size_t alignment) override { + auto* storage = static_cast(pointer)[-1]; + std::allocator_traits::deallocate(allocator_, storage, + units(bytes, alignment)); + } + + [[nodiscard]] bool do_is_equal(const std::pmr::memory_resource& other) const noexcept override { + return this == &other; + } + +public: + /** + Initializes retained state and its executor or allocation resource. + */ + explicit allocator_resource(const Allocator& allocator) : allocator_(allocator) {} +}; + +/** + Keeps a resource alive until the last queued allocation is released. + */ +template +struct owning_allocator { + /** + Element type allocated by this allocator. + */ + using value_type = T; + /** + Allocation resource kept alive while queued callbacks can access storage. + */ + std::shared_ptr resource; + + /** + Initializes retained state and its executor or allocation resource. + */ + explicit owning_allocator(std::shared_ptr value) + : resource(std::move(value)) {} + + /** + Initializes retained state and its executor or allocation resource. + */ + template + explicit owning_allocator(const owning_allocator& other) : resource(other.resource) {} + + /** + Allocates aligned storage for the requested number of elements. + */ + T* allocate(std::size_t count) { + return static_cast(resource->allocate(count * sizeof(T), alignof(T))); + } + + /** + Returns element storage to the retained resource. + */ + void deallocate(T* pointer, std::size_t count) { + resource->deallocate(pointer, count * sizeof(T), alignof(T)); + } + + /** + Reports whether two allocators share the same resource. + */ + template + bool operator==(const owning_allocator& other) const { + return resource == other.resource; + } +}; + +/** + Type-erased completion owned by its associated handler allocator. + */ +struct pending { + /** + Releases operation storage and posts exactly one completion. + */ + virtual void complete(error_code ec = {}, std::size_t count = 0) = 0; + /** + Releases operation storage without invoking the handler during context destruction. + */ + virtual void discard() = 0; + /** + Releases registration and retained state during destruction. + */ + virtual ~pending() = default; +}; + +/** + Owns a pending handler, its work guards, and cancellation registration. + */ +template +class operation final : public pending { + using allocator_type = std::allocator_traits< + boost::asio::associated_allocator_t>::template rebind_alloc; + Handler handler_; + Action action_; + pending*& slot_; + executor_type executor_; + boost::asio::executor_work_guard work_; + boost::asio::executor_work_guard> + completion_work_; + + void destroy() { + allocator_type allocator(boost::asio::get_associated_allocator(handler_)); + std::allocator_traits::destroy(allocator, this); + std::allocator_traits::deallocate(allocator, this, 1); + } + +public: + /** + Initializes retained state and its executor or allocation resource. + */ + operation(Handler handler, Action action, pending*& slot, executor_type executor) + : handler_(std::move(handler)), + action_(std::move(action)), + slot_(slot), + executor_(std::move(executor)), + work_(executor_), + completion_work_(boost::asio::get_associated_executor(handler_, executor_)) { + slot_ = this; + } + + /** + Installs cancellation handling for a pending operation. + */ + void start(boost::asio::cancellation_type mask, const auto& cancel) { + auto cancellation = boost::asio::get_associated_cancellation_slot(handler_); + if (cancellation.is_connected()) { + cancellation.assign([this, mask, cancel](auto kind) { + if ((kind & mask) != boost::asio::cancellation_type::none) { + cancel(); + complete(boost::asio::error::operation_aborted); + } + }); + } + } + + /** + Releases operation storage without invoking the handler during context destruction. + */ + void discard() override { + boost::asio::get_associated_cancellation_slot(handler_).clear(); + slot_ = nullptr; + destroy(); + } + + /** + Releases operation storage and posts exactly one completion. + */ + void complete(error_code ec = {}, std::size_t count = 0) override { + boost::asio::get_associated_cancellation_slot(handler_).clear(); + slot_ = nullptr; + action_(ec, count); + allocator_type allocator(boost::asio::get_associated_allocator(handler_)); + auto handler = std::move(handler_); + const auto executor = executor_; + // Post before releasing work; the queued completion then owns the wakeup. + if constexpr (Sized) { + post(executor, std::move(handler), ec, count); + } else { + post(executor, std::move(handler), ec); + } + std::allocator_traits::destroy(allocator, this); + std::allocator_traits::deallocate(allocator, this, 1); + } +}; + +/** + Installs cancellation handling for a pending operation. + */ +template +void start(pending*& slot, const executor_type& executor, Handler&& handler, Action action, + boost::asio::cancellation_type mask, const Cancel& cancel) { + using type = operation, Sized, Action>; + using allocator_type = std::allocator_traits< + boost::asio::associated_allocator_t>>::template rebind_alloc; + allocator_type allocator(boost::asio::get_associated_allocator(handler)); + auto* object = std::allocator_traits::allocate(allocator, 1); + std::allocator_traits::construct( + allocator, object, std::forward(handler), std::move(action), slot, executor); + object->start(mask, std::move(cancel)); +} +} // namespace browser +} +} // namespace webcpp::beast::detail +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/error.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/error.hpp new file mode 100644 index 0000000..a7e28be --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/error.hpp @@ -0,0 +1,102 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_ERROR_HPP +#define WEBCPP_BEAST_BROWSER_ERROR_HPP + +#include + +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +/** + Browser failures without a corresponding Beast or Asio error. + */ +enum class browser_errc { + /** + The browser rejected a URL or WebSocket subprotocol syntax. + */ + invalid_url = 1, + /** + Browser security policy blocked the operation. + */ + blocked = 2, + /** + The browser could not establish the WebSocket connection. + */ + connection_failed = 3, + /** + The outgoing WebSocket queue exceeded its configured bound. + */ + send_limit = 4, + /** + Unread WebSocket messages exceeded their configured queue bound. + */ + receive_limit = 5, + /** + Fetch failed without an exposed cause, including network and CORS failures. + */ + fetch_failed = 6, + /** + The operation has no usable recorded destination authority. + */ + no_host = 7, +}; + +namespace detail::browser_errors { +/** + Stable error category for failures reported by browser host APIs. + */ +class error_category final : public boost::system::error_category { +public: + /** + Returns the stable browser error category name. + */ + const char* name() const noexcept override { return "webcpp.beast"; } + + /** + Returns an English description of a browser error value. + */ + std::string message(int value) const override { + switch (static_cast(value)) { + case browser_errc::invalid_url: return "Invalid browser URL or subprotocol"; + case browser_errc::blocked: return "Operation blocked by browser security"; + case browser_errc::connection_failed: return "Browser connection failed"; + case browser_errc::send_limit: return "Browser send queue limit exceeded"; + case browser_errc::receive_limit: return "Browser receive queue limit exceeded"; + case browser_errc::fetch_failed: return "Browser fetch failed"; + case browser_errc::no_host: return "No host was supplied"; + } + return "Unknown browser error"; + } +}; +} // namespace detail::browser_errors + +/** + Returns the stable browser error category. + @return The process-lifetime browser error category. + */ +inline const boost::system::error_category& browser_category() noexcept { + static const detail::browser_errors::error_category category; + return category; +} + +/** + Converts a browser failure into its stable error-code representation. + @param code Browser error enumerator. + @return The code associated with browser_category(). + */ +inline boost::system::error_code make_error_code(browser_errc code) noexcept { + return {static_cast(code), browser_category()}; +} +} // namespace webcpp::beast + +namespace boost::system { +template <> +struct is_error_code_enum : std::true_type {}; +} // namespace boost::system +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/http.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/http.hpp new file mode 100644 index 0000000..03d8617 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/http.hpp @@ -0,0 +1,820 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_HTTP_HPP +#define WEBCPP_BEAST_BROWSER_HTTP_HPP + +#include + +#include +#include +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include +#include +#include +#include +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::detail { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace browser { +/** + One fetch exchange; browser response metadata maps directly into a Beast message. + */ +// Registry lookup and shared ownership have independent lifetimes. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class http_state final : public webcpp::asio::browser::intrusive_registration, + public std::enable_shared_from_this { +public: + /** + Retains the resource backing the fetch state and its queued callbacks. + */ + std::shared_ptr memory; + /** + Allocation resource kept alive while queued callbacks can access storage. + */ + std::pmr::memory_resource* resource; + /** + Executor that serializes state changes and completion posting. + */ + executor_type executor; + /** + Browser event registry owned by the execution context. + */ + webcpp::asio::browser::bridge* bridge; + /** + Timer enforcing the current operation deadline. + */ + boost::asio::steady_timer timer; // lint-world: browser operation deadline + /** + Registration key used to reject events from detached operations. + */ + std::uint64_t key = 0; + /** + Pending application read completion, or null when no read is outstanding. + */ + pending* read = nullptr; + /** + JavaScript AbortController for the active fetch. + */ + emscripten::val controller = emscripten::val::undefined(); + /** + JavaScript response metadata and decoded body retained until consumption. + */ + emscripten::val response = emscripten::val::undefined(); + /** + Terminal error retained for the next pending completion. + */ + error_code failure; + /** + Whether the owning stream still accepts browser events. + */ + bool alive = true; + /** + Whether a fetch promise is outstanding. + */ + bool active = false; + /** + Whether a completed fetch is waiting for a read. + */ + bool ready = false; + /** Whether fetch has exposed the response status and fields. */ + bool headers_ready = false; + /** Whether the current pending read requests metadata without consuming the body. */ + bool header_only = false; + /** + Whether the request method forbids a response body. + */ + bool head = false; + + /** + Initializes retained state and its executor or allocation resource. + */ + explicit http_state(executor_type ex, std::shared_ptr storage) + : memory(std::move(storage)), + resource(memory.get()), + executor(std::move(ex)), + bridge(&boost::asio::use_service( + boost::asio::query(executor, boost::asio::execution::context))), + timer(executor) {} + + /** + Releases registration and retained state during destruction. + */ + ~http_state() { detach(); } + + /** Cancels the deadline without throwing during stream destruction. */ + void cancel_timer() noexcept { +#ifndef WEBCPP_BEAST_NO_EXCEPTIONS + try { + timer.cancel(); + } catch (...) { // NOLINT(bugprone-empty-catch): cleanup must still detach and abort the + // host resource + // Cleanup still detaches callbacks and aborts the host resource. + } +#else + timer.cancel(); +#endif + } + + /** + Removes the registration so later browser events cannot reach this state. + */ + void detach() { + if ((bridge != nullptr) && (key != 0u)) { + bridge->remove(std::exchange(key, 0)); + } + } + + /** + Asks the browser to abort the current fetch. + */ + void abort() const { + if (!controller.isUndefined()) { + controller.call("abort"); + } + } + + /** + Cancels the active host operation and posts its aborted completion. + */ + void cancel() { + abort(); + detach(); + cancel_timer(); + active = false; + failure = boost::asio::error::operation_aborted; + ready = true; + if (read != nullptr) { + read->complete(failure); + } + } + + /** + Detaches the host resource and aborts all pending operations. + */ + void stop() { + alive = false; + cancel(); + } + + /** + Closes the browser operation and its authority record. + */ + void shutdown() noexcept override { + bridge = nullptr; + key = 0; + alive = false; + abort(); + if (read != nullptr) { + read->discard(); + } + } + + /** + Queues a browser event on the stream executor while retaining state ownership. + */ + bool deliver(const emscripten::val& event) override { + post(executor, boost::asio::bind_allocator( + owning_allocator(memory), + [self = shared_from_this(), event, generation = key] { + if (!self->alive || !self->active || self->key != generation) { + return; + } + const auto type = js_text(event["type"], self->resource); + if (type == "fetch-header") { + self->response = event; + self->headers_ready = true; + self->failure = unsupported(event["redirected"].as()); + if (self->read && self->header_only) { + self->read->complete(self->failure); + } + return; + } + self->active = false; + self->ready = true; + self->cancel_timer(); + self->detach(); + if (type == "fetch-error") { + self->failure = make_error_code(browser_errc::fetch_failed); + } else if (type == "fetch-limit") { + self->failure = boost::beast::http::error::body_limit; + } else { + self->response = event; + self->failure = unsupported(event["redirected"].as()); + } + if (self->read) { + self->read->complete(self->failure); + } + })); + return false; + } + + /** + Schedules the absolute deadline for the active host operation. + */ + void arm(::webcpp::beast::detail::browser::clock_type::time_point deadline) { + if (deadline == ::webcpp::beast::detail::browser::clock_type::time_point::max()) { + return; + } + timer.expires_at(deadline); + timer.async_wait(boost::asio::bind_allocator( + owning_allocator(memory), + [weak = weak_from_this(), generation = key](error_code ec) { + if (auto const self = weak.lock(); + self && !ec && self->alive && self->key == generation) { + self->abort(); + self->detach(); + self->active = false; + self->ready = true; + self->failure = boost::beast::error::timeout; + if (self->read) { + self->read->complete(self->failure); + } + } + })); + } +}; + +/** + Obtains or creates the fetch state attached to an authority record. + */ +inline std::shared_ptr http(tcp_stream& stream) { + if (!stream.http_state) { + auto const state = + std::allocate_shared(owning_allocator(stream.resource_owner()), + stream.get_executor(), stream.resource_owner()); + stream.http_state = state; + stream.bind( + state.get(), [](void* value) { static_cast(value)->cancel(); }, + [](void* value) { static_cast(value)->stop(); }); + } + return std::static_pointer_cast(stream.http_state); +} +/** + Identifies a browser authority record or its TLS-intent layer. + */ +template +concept host_stream = std::same_as, tcp_stream> || + std::same_as, ssl_stream>; + +/** Detects forbidden methods in a Fetch method-override field value. */ +inline bool forbidden_method_override(boost::beast::string_view value) { + // Fetch splits comma-separated values while preserving HTTP quoted strings. + // https://fetch.spec.whatwg.org/#forbidden-request-header + while (!value.empty()) { + std::size_t length = 0; + bool quoted = false; + for (; length != value.size(); ++length) { + const auto character = value[length]; + if (quoted && character == '\\' && length + 1 != value.size()) { + ++length; + } else if (character == '"') { + quoted = !quoted; + } else if (character == ',' && !quoted) { + break; + } + } + auto method = value.substr(0, length); + while (!method.empty() && (method.front() == ' ' || method.front() == '\t')) { + method.remove_prefix(1); + } + while (!method.empty() && (method.back() == ' ' || method.back() == '\t')) { + method.remove_suffix(1); + } + if (boost::beast::iequals(method, "CONNECT") || boost::beast::iequals(method, "TRACE") || + boost::beast::iequals(method, "TRACK")) { + return true; + } + if (length == value.size()) { + break; + } + value.remove_prefix(length + 1); + } + return false; +} + +/** + Detects request headers that the browser owns or may overwrite. + */ +inline bool forbidden_header(boost::beast::string_view name, boost::beast::string_view value) { + // Fetch's forbidden request headers plus User-Agent, which browsers may overwrite. + constexpr std::array names = { + "accept-charset", + "accept-encoding", + "access-control-request-headers", + "access-control-request-method", + "cookie", + "cookie2", + "date", + "dnt", + "expect", + "origin", + "referer", + "set-cookie", + "te", + "trailer", + "upgrade", + "via", + "user-agent", + "permissions-policy", + }; + for (auto const item : names) { + if (boost::beast::iequals(name, {item.data(), item.size()})) { + return true; + } + } + if (name.size() >= 4 && + (boost::beast::iequals(name.substr(0, 4), "sec-") || + (name.size() >= 6 && boost::beast::iequals(name.substr(0, 6), "proxy-")))) { + return true; + } + if (!boost::beast::iequals(name, "x-http-method") && + !boost::beast::iequals(name, "x-http-method-override") && + !boost::beast::iequals(name, "x-method-override")) { + return false; + } + return forbidden_method_override(value); +} + +/** Builds fetch headers after applying authority and forbidden-field policy. */ +template +emscripten::val fetch_headers(const tcp_stream& stream, + const boost::beast::http::request& request, + std::size_t& count, error_code& ec) { + namespace http = boost::beast::http; + auto const headers = emscripten::val::array(); + for (const auto& field : request) { + count += field.name_string().size() + field.value().size() + 4; + if (field.name() == http::field::host) { + ec = unsupported( + !stream.authority_matches({field.value().data(), field.value().size()})); + if (ec) { + return headers; + } + continue; + } + if (field.name() == http::field::connection || field.name() == http::field::keep_alive || + field.name() == http::field::content_length || + field.name() == http::field::transfer_encoding) { + continue; + } + if (forbidden_header(field.name_string(), field.value())) { + ec = unsupported(); + if (ec) { + return headers; + } + continue; + } + auto pair = emscripten::val::array(); + pair.call("push", js_string(field.name_string())); + pair.call("push", js_string(field.value())); + headers.call("push", pair); + } + return headers; +} + +/** + Validates and buffers a complete request before initiating fetch. + */ +template +std::size_t start_fetch(tcp_stream& stream, boost::beast::http::request& request, + error_code& ec) { + namespace http = boost::beast::http; + ec.clear(); + if (!stream.is_open()) { + ec = boost::asio::error::not_connected; + return 0; + } + auto const state = detail::browser::http(stream); + if (state->active || state->ready || state->read) { + ec = boost::asio::error::already_started; + return 0; + } + const auto method = request.method(); + if (method == http::verb::connect || method == http::verb::trace || + request.method_string() == "TRACK") { + ec = boost::asio::error::operation_not_supported; + return 0; + } + auto init = emscripten::val::object(); + std::size_t count = request.method_string().size() + request.target().size() + 12; + const auto headers = fetch_headers(stream, request, count, ec); + if (ec) { + return 0; + } + std::pmr::vector body(stream.resource()); + typename Body::writer writer(request.base(), request.body()); + writer.init(ec); + if (ec) { + return 0; + } + while (auto next = writer.get(ec)) { + if (ec) { + return 0; + } + const auto size = boost::asio::buffer_size(next->first); + const auto old = body.size(); + body.resize(old + size); + boost::asio::buffer_copy(boost::asio::buffer(body.data() + old, size), next->first); + if (!next->second) { + break; + } + } + if (ec) { + return 0; + } + if (!body.empty() && (method == http::verb::get || method == http::verb::head)) { + ec = boost::asio::error::operation_not_supported; + return 0; + } + if (request.has_content_length() && request.payload_size() && + request[http::field::content_length] != std::to_string(body.size())) { + ec = http::error::bad_content_length; + return 0; + } + init.set("webcppBodyLimit", static_cast(stream.response_body_limit())); + init.set("method", js_string(request.method_string())); + init.set("headers", headers); + init.set("mode", js_string("cors")); + init.set("redirect", js_string("follow")); + if (!body.empty()) { + init.set("body", + emscripten::val(emscripten::typed_memory_view( + body.size(), reinterpret_cast(body.data()))) + .call("slice")); + } + state->head = method == http::verb::head; + state->headers_ready = false; + state->failure.clear(); + state->response = emscripten::val::undefined(); + state->active = true; + state->key = state->bridge->add(*state); + const auto target = request.target(); + auto const url = js_string(stream.url({target.data(), target.size()})); + state->controller = emscripten::val::take_ownership(webcpp_beast_fetch( + url.as_handle(), init.as_handle(), state->bridge->function(state->key).as_handle())); + state->arm(stream.expiry()); + return count + 2 + body.size(); +} + +/** + Copies decoded fetch metadata and body into a Beast response. + */ +template +void map_response(http_state& state, boost::beast::http::response& response, + error_code& ec, std::size_t& count, bool header_only = false) { + if (ec) { + return; + } + namespace http = boost::beast::http; + response.clear(); + response.version(11); + response.result(state.response["status"].as()); + response.reason({}); + auto const reason = js_text(state.response["statusText"], state.resource); + if (!reason.empty()) { + response.reason(reason); + } + const auto headers = state.response["headers"]; + for (std::size_t i = 0; i < headers["length"].as(); ++i) { + const auto pair = headers[i]; + const auto name = js_text(pair[0], state.resource); + const auto value = js_text(pair[1], state.resource); + if (boost::beast::iequals(name, "content-length") || + boost::beast::iequals(name, "content-encoding") || + boost::beast::iequals(name, "transfer-encoding")) { + continue; + } + response.insert(name, value); + } + const bool bodyless = + state.head || response.result_int() == 204 || response.result_int() == 304; + count = 0; + if (header_only) { + count = 13 + response.reason().size(); + for (const auto& field : response) { + count += field.name_string().size() + field.value().size() + 4; + } + return; + } + const auto body = state.response["body"]; + const auto size = bodyless ? 0 : body["byteLength"].as(); + // Preserve the body's allocator while replacing the previous exchange's bytes. + if constexpr (requires { response.body().clear(); }) { + response.body().clear(); + } else if constexpr (requires { response.body().consume(response.body().size()); }) { + response.body().consume(response.body().size()); + } + typename Body::reader reader(response.base(), response.body()); + reader.init(size, ec); + if (!ec && size) { + std::pmr::vector bytes(size, state.resource); + webcpp_beast_copy(body.as_handle(), bytes.data(), size); + count = reader.put(boost::asio::buffer(bytes), ec); + } + if (!ec) { + reader.finish(ec); + } + if (!bodyless) { + response.content_length(size); + } + state.ready = false; + state.response = emscripten::val::undefined(); +} + +/** + Pumps a suspendable context until a fetch read completes. + */ +template +void sync_http(tcp_stream& stream, Begin begin, error_code& ec, std::size_t& size) { + auto& context = static_cast( + boost::asio::query(stream.get_executor(), boost::asio::execution::context)); + if (context.get_executor().running_in_this_thread() || + boost::asio::use_service(context).delivering()) { + ec = boost::asio::error::operation_not_supported; + return; + } + bool done = false; + begin([&](error_code error, std::size_t count) { + ec = error; + size = count; + done = true; + }); + context.restart(); + // NOLINTNEXTLINE(bugprone-infinite-loop): run_one invokes the callback that sets done + while (!done) { + context.run_one(); + } +} + +/** Starts a metadata-only or complete response read with the handler associations. */ +template +auto receive_response( + Stream& stream, + boost::beast::http::response>& response, + Token&& token) { + return boost::asio::async_initiate( + [&stream, &response](auto handler) { + auto const state = detail::browser::http(get_lowest_layer(stream)); + if (state->read || (!state->active && !state->ready)) { + detail::browser::post( + stream.get_executor(), std::move(handler), + boost::system::error_code(boost::asio::error::already_started), std::size_t{}); + return; + } + state->header_only = HeaderOnly; + detail::browser::start( + state->read, stream.get_executor(), std::move(handler), + [state, &response](auto& ec, auto& count) { + if (ec) { + state->ready = false; + return; + } + detail::browser::map_response(*state, response, ec, count, HeaderOnly); + }, + boost::asio::cancellation_type::all, + [state] { + state->abort(); + state->detach(); + state->cancel_timer(); + state->active = false; + state->ready = false; + }); + if (state->ready || (HeaderOnly && state->headers_ready)) { + state->read->complete(state->failure); + } + }, + token); +} + +} // namespace browser +} +} // namespace webcpp::beast::detail + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::http { +/** + Submits one complete request to fetch after validating browser restrictions. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + @tparam Stream Browser authority record or TLS-intent stream. + @tparam Body Beast body model used to encode or receive the message body. + @tparam Allocator Allocator used by the HTTP message fields. + @tparam Token Asio completion token selecting the asynchronous result type. + @param stream Browser stream whose recorded authority selects the host operation. + @param request Complete request, kept alive until asynchronous completion when applicable. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ +template +auto async_write( + Stream& stream, + boost::beast::http::request>& request, + Token&& token) { + return boost::asio::async_initiate( + [&stream, &request](auto handler) { + boost::system::error_code ec; + const auto size = detail::browser::start_fetch(get_lowest_layer(stream), request, ec); + detail::browser::post(stream.get_executor(), std::move(handler), ec, size); + }, + token); +} + +/** + Submits one complete request to fetch after validating browser restrictions. + @tparam Stream Browser authority record or TLS-intent stream. + @tparam Body Beast body model used to encode or receive the message body. + @tparam Allocator Allocator used by the HTTP message fields. + @param stream Browser stream whose recorded authority selects the host operation. + @param request Complete request, kept alive until asynchronous completion when applicable. + @param ec Receives the operation error, or is cleared on success. + @return The accepted body and synthetic header byte count. + */ +template +std::size_t write( + Stream& stream, + boost::beast::http::request>& request, + boost::system::error_code& ec) { + return detail::browser::start_fetch(get_lowest_layer(stream), request, ec); +} + +/** + Submits one complete request to fetch after validating browser restrictions. + @tparam Stream Browser authority record or TLS-intent stream. + @tparam Body Beast body model used to encode or receive the message body. + @tparam Allocator Allocator used by the HTTP message fields. + @param stream Browser stream whose recorded authority selects the host operation. + @param request Complete request, kept alive until asynchronous completion when applicable. + @return The accepted body and synthetic header byte count. + */ +template +std::size_t write( + Stream& stream, + boost::beast::http::request>& request) { + boost::system::error_code ec; + const auto n = write(stream, request, ec); + detail::browser::throw_error(ec); + return n; +} + +/** + Receives the complete decoded fetch response into a Beast message. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + Fetch decoding precedes message delivery, and wire framing headers are normalized. + The authority record response_body_limit bounds the decoded body before allocation. + @tparam Stream Browser authority record or TLS-intent stream. + @tparam Buffer Dynamic buffer type retained for Beast call compatibility. + @tparam Body Beast body model used to encode or receive the message body. + @tparam Allocator Allocator used by the HTTP message fields. + @tparam Token Asio completion token selecting the asynchronous result type. + @param stream Browser stream whose recorded authority selects the host operation. + @param response Destination message, kept alive until asynchronous completion when applicable. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ +template +auto async_read( + Stream& stream, Buffer& /*unused*/, + boost::beast::http::response>& response, + Token&& token) { + return detail::browser::receive_response(stream, response, std::forward(token)); +} + +/** + Receives the complete decoded fetch response into a Beast message. + + Fetch decoding precedes message delivery, and wire framing headers are normalized. + The authority record response_body_limit bounds the decoded body before allocation. + @tparam Stream Browser authority record or TLS-intent stream. + @tparam Buffer Dynamic buffer type retained for Beast call compatibility. + @tparam Body Beast body model used to encode or receive the message body. + @tparam Allocator Allocator used by the HTTP message fields. + @param stream Browser stream whose recorded authority selects the host operation. + @param buffer Compatibility buffer; direct fetch reads do not consume or append wire bytes. + @param response Destination message, kept alive until asynchronous completion when applicable. + @param ec Receives the operation error, or is cleared on success. + @return The number of decoded body bytes delivered. + */ +template +std::size_t read( + Stream& stream, Buffer& buffer, + boost::beast::http::response>& response, + boost::system::error_code& ec) { + std::size_t size = 0; + detail::browser::sync_http( + get_lowest_layer(stream), + [&](auto handler) { async_read(stream, buffer, response, std::move(handler)); }, ec, size); + return size; +} + +/** + Receives the complete decoded fetch response into a Beast message. + + Fetch decoding precedes message delivery, and wire framing headers are normalized. + The authority record response_body_limit bounds the decoded body before allocation. + @tparam Stream Browser authority record or TLS-intent stream. + @tparam Buffer Dynamic buffer type retained for Beast call compatibility. + @tparam Body Beast body model used to encode or receive the message body. + @tparam Allocator Allocator used by the HTTP message fields. + @param stream Browser stream whose recorded authority selects the host operation. + @param buffer Compatibility buffer; direct fetch reads do not consume or append wire bytes. + @param response Destination message, kept alive until asynchronous completion when applicable. + @return The number of decoded body bytes delivered. + */ +template +std::size_t read( + Stream& stream, Buffer& buffer, + boost::beast::http::response>& response) { + boost::system::error_code ec; + const auto n = read(stream, buffer, response, ec); + detail::browser::throw_error(ec); + return n; +} + +/** Receives response metadata before fetch has consumed its body. + + The next complete read consumes the retained response body; a metadata read leaves it untouched. + The buffer parameter is retained for Beast call compatibility and receives no wire bytes. + @tparam Stream Browser authority or TLS-intent stream. + @tparam Buffer Dynamic buffer type accepted for call compatibility. + @tparam Body Beast body model of the destination response. + @tparam Allocator Allocator of the destination fields. + @tparam Token Completion token for void(error_code, std::size_t). + @param stream Stream with an outstanding fetch request. + @param response Destination for status and exposed fields; kept alive until completion. + @param token Completion token determining the operation result type. + @return The result determined by the completion token. + */ +template +auto async_read_header( + Stream& stream, Buffer& /*unused*/, + boost::beast::http::response>& response, + Token&& token) { + return detail::browser::receive_response(stream, response, std::forward(token)); +} + +/** Suspends the main stack until fetch exposes response metadata. + + The complete body remains available to a later read, and executing handlers cannot reenter + this synchronous facade. + @tparam Stream Browser authority or TLS-intent stream. + @tparam Buffer Dynamic buffer type accepted for call compatibility. + @tparam Body Beast body model of the destination response. + @tparam Allocator Allocator of the destination fields. + @param stream Stream with an outstanding fetch request. + @param buffer Compatibility buffer, whose contents are unchanged. + @param response Destination for response status and exposed fields. + @param ec Receives the operation error, or is cleared on success. + @return The logical HTTP status-line and field byte count, excluding the body. + */ +template +std::size_t read_header( + Stream& stream, Buffer& buffer, + boost::beast::http::response>& response, + boost::system::error_code& ec) { + std::size_t count = 0; + detail::browser::sync_http( + get_lowest_layer(stream), + [&](auto handler) { async_read_header(stream, buffer, response, std::move(handler)); }, ec, + count); + return count; +} + +/** Suspends until response metadata is available and throws on failure. + @tparam Stream Browser authority or TLS-intent stream. + @tparam Buffer Dynamic buffer type accepted for call compatibility. + @tparam Body Beast body model of the destination response. + @tparam Allocator Allocator of the destination fields. + @param stream Stream with an outstanding fetch request. + @param buffer Compatibility buffer, whose contents are unchanged. + @param response Destination for response status and exposed fields. + @return The logical HTTP status-line and field byte count, excluding the body. + */ +template +std::size_t read_header( + Stream& stream, Buffer& buffer, + boost::beast::http::response>& response) { + boost::system::error_code ec; + auto count = read_header(stream, buffer, response, ec); + detail::browser::throw_error(ec); + return count; +} +} // namespace webcpp::beast::http +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/http_byte_stream.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/http_byte_stream.hpp new file mode 100644 index 0000000..8e3a718 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/http_byte_stream.hpp @@ -0,0 +1,308 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_HTTP_BYTE_STREAM_HPP +#define WEBCPP_BEAST_BROWSER_HTTP_BYTE_STREAM_HPP + +#include + +#include +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include +#include +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace browser { +/** + Explicit synthetic HTTP/1.1 adapter for upstream parser and serializer algorithms. + + Fetch owns real framing. This adapter decodes an outgoing serialized request and + exposes a synthetic chunked response. HEAD, 204 and 304 have no body framing. + The adapter and its next layer must outlive every outstanding operation. + @tparam NextLayer Underlying browser authority or TLS-intent layer. + */ +template +class http_byte_stream { + using allocator_type = std::pmr::polymorphic_allocator; + using body_type = + boost::beast::http::basic_string_body, allocator_type>; + using fields_type = boost::beast::http::basic_fields; + NextLayer& next_; + std::optional> request_; + boost::beast::http::response response_; + boost::beast::basic_flat_buffer unused_; + std::pmr::string wire_; + std::size_t offset_ = 0; + bool head_ = false; + bool response_pending_ = false; + + void frame(boost::system::error_code& ec) { + namespace http = boost::beast::http; + wire_.clear(); + offset_ = 0; + const bool bodyless = + head_ || response_.result_int() == 204 || response_.result_int() == 304; + response_.erase(http::field::content_length); + response_.erase(http::field::content_encoding); + if (bodyless) { + response_.body().clear(); + response_.erase(http::field::transfer_encoding); + } else { + response_.chunked(true); + } + http::response_serializer serializer(response_); + serializer.split(true); + while (!serializer.is_header_done()) { + std::size_t consumed = 0; + serializer.next(ec, [&](auto&, const auto& buffers) { + for (const auto buffer : boost::beast::buffers_range_ref(buffers)) { + wire_.append(static_cast(buffer.data()), buffer.size()); + consumed += buffer.size(); + } + }); + if (ec) { + return; + } + serializer.consume(consumed); + } + if (!bodyless) { + // Beast's chunk-size helper uses make_shared without an allocator hook. + // Format this single buffered synthetic chunk in fixed storage instead. + if (!response_.body().empty()) { + std::array digits{}; + const auto converted = std::to_chars(digits.data(), digits.data() + digits.size(), + response_.body().size(), 16); + wire_.append(digits.data(), converted.ptr); + wire_.append("\r\n"); + wire_.append(response_.body()); + wire_.append("\r\n"); + } + wire_.append("0\r\n\r\n"); + } + response_pending_ = false; + } + + template + std::size_t copy(const Buffers& buffers) { + auto const count = boost::asio::buffer_copy( + buffers, boost::asio::buffer(wire_.data() + offset_, wire_.size() - offset_)); + offset_ += count; + return count; + } + +public: + /** + Executor used to schedule stream operations and their completions. + */ + using executor_type = NextLayer::executor_type; + /** + Type of the layer immediately below this stream. + */ + using next_layer_type = NextLayer; + + /** + Attaches a synthetic HTTP byte view to the supplied browser layer. + @param next Underlying layer that must outlive this adapter and its operations. + */ + explicit http_byte_stream(NextLayer& next) + : next_(next), + response_(std::piecewise_construct, + std::make_tuple(allocator_type(get_lowest_layer(next).resource())), + std::make_tuple(allocator_type(get_lowest_layer(next).resource()))), + unused_(allocator_type(get_lowest_layer(next).resource())), + wire_(get_lowest_layer(next).resource()) {} + + /** + Returns the executor used for asynchronous completions. + @return The executor associated with the underlying context. + */ + [[nodiscard]] executor_type get_executor() const { return next_.get_executor(); } + + /** + Returns the immediately underlying layer. + @return A reference to the underlying stream. + */ + NextLayer& next_layer() noexcept { return next_; } + + /** + Consumes serialized request bytes and starts fetch when the request is complete. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @param buffers Buffer sequence whose storage remains valid until completion. + @param ec Receives the operation error, or is cleared on success. + @return The number of input bytes accepted, or zero on failure. + */ + template + std::size_t write_some(const Buffers& buffers, boost::system::error_code& ec) { + namespace http = boost::beast::http; + ec.clear(); + if (response_pending_ || offset_ < wire_.size()) { + ec = boost::asio::error::already_started; + return 0; + } + if (!request_) { + const auto allocator = allocator_type(get_lowest_layer(next_).resource()); + request_.emplace(std::piecewise_construct, std::make_tuple(allocator), + std::make_tuple(allocator)); + request_->eager(true); + } + auto const count = request_->put(buffers, ec); + if (ec == http::error::need_more) { + ec.clear(); + } + if (ec) { + return count; + } + if (request_->is_done()) { + auto request = request_->release(); + head_ = request.method() == http::verb::head; + detail::browser::start_fetch(get_lowest_layer(next_), request, ec); + request_.reset(); + if (!ec) { + response_pending_ = true; + } + } + return count; + } + + /** + Consumes serialized request bytes and starts fetch when the request is complete. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @param buffers Buffer sequence whose storage remains valid until completion. + @return The number of input bytes accepted, or zero on failure. + */ + template + std::size_t write_some(const Buffers& buffers) { + boost::system::error_code ec; + auto n = write_some(buffers, ec); + detail::browser::throw_error(ec); + return n; + } + + /** + Consumes serialized request bytes and starts fetch when the request is complete. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param buffers Buffer sequence whose storage remains valid until completion. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_write_some(const Buffers& buffers, Token&& token) { + return boost::asio::async_initiate( + [this, buffers](auto handler) { + boost::system::error_code ec; + const auto n = write_some(buffers, ec); + detail::browser::post(get_executor(), std::move(handler), ec, n); + }, + token); + } + + /** + Reads bytes from the synthetic HTTP response after fetch completes. + @tparam Buffers MutableBufferSequence receiving response or message bytes. + @param buffers Buffer sequence whose storage remains valid until completion. + @param ec Receives the operation error, or is cleared on success. + @return The number of bytes delivered to the destination. + */ + template + std::size_t read_some(const Buffers& buffers, boost::system::error_code& ec) { + ec.clear(); + if (offset_ == wire_.size()) { + if (!response_pending_) { + ec = boost::asio::error::eof; + return 0; + } + webcpp::beast::http::read(next_, unused_, response_, ec); + if (ec) { + return 0; + } + frame(ec); + if (ec) { + return 0; + } + } + return copy(buffers); + } + + /** + Reads bytes from the synthetic HTTP response after fetch completes. + @tparam Buffers MutableBufferSequence receiving response or message bytes. + @param buffers Buffer sequence whose storage remains valid until completion. + @return The number of bytes delivered to the destination. + */ + template + std::size_t read_some(const Buffers& buffers) { + boost::system::error_code ec; + auto n = read_some(buffers, ec); + detail::browser::throw_error(ec); + return n; + } + + /** + Reads bytes from the synthetic HTTP response after fetch completes. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + @tparam Buffers MutableBufferSequence receiving response or message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param buffers Buffer sequence whose storage remains valid until completion. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_read_some(const Buffers& buffers, Token&& token) { + return boost::asio::async_compose( + [this, buffers, started = false, posted = false]( + auto& self, boost::system::error_code ec = {}, std::size_t = 0) mutable { + if (!posted) { + posted = true; + detail::browser::post(get_executor(), std::move(self), + boost::system::error_code{}, std::size_t{}); + return; + } + if (ec) { + self.complete(ec, 0); + return; + } + if (started) { + frame(ec); + } + if (ec) { + self.complete(ec, 0); + return; + } + if (offset_ < wire_.size()) { + self.complete({}, copy(buffers)); + return; + } + if (!response_pending_) { + self.complete(boost::asio::error::eof, 0); + return; + } + started = true; + webcpp::beast::http::async_read(next_, unused_, response_, std::move(self)); + }, + token, next_); + } +}; +} // namespace browser +} +} // namespace webcpp::beast +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/ssl_stream.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/ssl_stream.hpp new file mode 100644 index 0000000..3e7aa11 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/ssl_stream.hpp @@ -0,0 +1,307 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_SSL_STREAM_HPP +#define WEBCPP_BEAST_BROWSER_SSL_STREAM_HPP + +#include + +#include +#include +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +/** + TLS intent validated before the browser owns the secure connection. + @tparam NextLayer Underlying browser authority or TLS-intent layer. + */ +template +class ssl_stream { + NextLayer next_; + + struct tls_record { + webcpp::asio::ssl::context::method method{}; + int mode{}; + webcpp::asio::ssl::verify_callback_kind callback{}; + std::pmr::string host; + bool roots{}; + bool credentials{}; + webcpp::asio::ssl::context::options options{}; + } context_; + + std::pmr::string server_name_; + std::optional verify_mode_; + webcpp::asio::ssl::verify_callback_kind callback_ = + webcpp::asio::ssl::verify_callback_kind::none; + std::pmr::string verification_host_; + +public: + /** + Type of the layer immediately below this stream. + */ + using next_layer_type = NextLayer; + /** + Executor used to schedule stream operations and their completions. + */ + using executor_type = NextLayer::executor_type; + + /** + Selects the stream type for a different executor. + @tparam Executor Executor type to bind to the underlying layer. + */ + template + struct rebind_executor { + /** + Stream type with the requested executor binding. + */ + using other = ssl_stream::other>; + }; + + /** + Constructs the next layer and snapshots browser TLS policy. + @tparam Arg Argument forwarded to construct the next layer. + @param arg Argument forwarded to the underlying layer constructor. + @param context TLS context whose configuration is copied at construction. + */ + template + ssl_stream(Arg&& arg, webcpp::asio::ssl::context& context) + : next_(std::forward(arg)), + context_{ + context.recorded_method(), + context.recorded_verify_mode(), + context.recorded_callback(), + std::pmr::string(context.verification_host(), get_lowest_layer(next_).resource()), + context.roots_added(), + context.client_credentials(), + context.recorded_options(), + }, + server_name_(get_lowest_layer(next_).resource()), + verification_host_(get_lowest_layer(next_).resource()) {} + + /** Constructs every layer and copied TLS name with the supplied allocator. + @tparam Allocator Allocator retained for owned stream state. + @tparam Arg Argument forwarded to the next layer. + @param allocator Allocator used by the layer and its TLS metadata. + @param arg Argument forwarded to the next layer constructor. + @param context TLS configuration copied before opening the host connection. + */ + template + ssl_stream(std::allocator_arg_t /*unused*/, const Allocator& allocator, Arg&& arg, + webcpp::asio::ssl::context& context) + : next_(std::allocator_arg, allocator, std::forward(arg)), + context_{ + context.recorded_method(), + context.recorded_verify_mode(), + context.recorded_callback(), + std::pmr::string(context.verification_host(), get_lowest_layer(next_).resource()), + context.roots_added(), + context.client_credentials(), + context.recorded_options(), + }, + server_name_(get_lowest_layer(next_).resource()), + verification_host_(get_lowest_layer(next_).resource()) {} + + /** + Returns the executor used for asynchronous completions. + @return The executor associated with the underlying context. + */ + [[nodiscard]] executor_type get_executor() const { return next_.get_executor(); } + + /** + Returns the immediately underlying layer. + @return A reference to the underlying stream. + */ + NextLayer& next_layer() noexcept { return next_; } + + /** + Returns the immediately underlying layer. + @return A reference to the underlying stream. + */ + [[nodiscard]] const NextLayer& next_layer() const noexcept { return next_; } + + /** + Records the verification policy for the next TLS-intent validation. + @param mode Requested verification flags; strict browser TLS requires verify_peer. + */ + void set_verify_mode(int mode) { verify_mode_ = mode; } + + /** + Records the verification policy for the next TLS-intent validation. + @param mode Requested verification flags; strict browser TLS requires verify_peer. + @param ec Receives the operation error, or is cleared on success. + */ + void set_verify_mode(int mode, boost::system::error_code& ec) { + set_verify_mode(mode); + ec.clear(); + } + + /** + Records hostname verification or marks a custom callback unsupported. + @tparam Callback Verification callable type; only host_name_verification is representable. + @param callback Hostname-verification record or unsupported custom callable. + */ + template + void set_verify_callback(const Callback& callback) { + if constexpr (std::is_same_v) { + callback_ = webcpp::asio::ssl::verify_callback_kind::host_name_verification; + verification_host_ = callback.host(); + } else { + callback_ = webcpp::asio::ssl::verify_callback_kind::other; + } + } + + /** + Records hostname verification or marks a custom callback unsupported. + @tparam Callback Verification callable type; only host_name_verification is representable. + @param callback Hostname-verification record or unsupported custom callable. + @param ec Receives the operation error, or is cleared on success. + */ + template + void set_verify_callback(const Callback& callback, boost::system::error_code& ec) { + set_verify_callback(callback); + ec.clear(); + } + + /** + Validates TLS intent and marks the authority secure without opening a TLS socket. + + The browser performs certificate validation when fetch or WebSocket opens the URL. + Under ERROR, custom roots, credentials, version pins, callbacks, or mismatched names + produce operation_not_supported; IGNORE leaves those choices to the browser. + @param type Requested TLS role; only client is representable by browser host APIs. + @param ec Receives the operation error, or is cleared on success. + */ + void handshake(webcpp::asio::ssl::stream_base::handshake_type type, + boost::system::error_code& ec) { + namespace ssl = webcpp::asio::ssl; + auto& record = get_lowest_layer(next_); + const auto mode = verify_mode_.value_or(context_.mode); + const auto callback = + callback_ == ssl::verify_callback_kind::none ? context_.callback : callback_; + const auto host = callback_ == ssl::verify_callback_kind::none + ? std::string_view(context_.host) + : std::string_view(verification_host_); + ec = detail::browser::unsupported( + type != ssl::stream_base::client || + (context_.method != ssl::context::tls_client && + context_.method != ssl::context::sslv23_client) || + mode != ssl::verify_peer || context_.roots || context_.credentials || + context_.options != 0 || callback == ssl::verify_callback_kind::other || + (callback == ssl::verify_callback_kind::host_name_verification && + host != record.host()) || + (!server_name_.empty() && server_name_ != record.host())); + if (!ec) { + record.secure(true); + } + } + + /** + Validates TLS intent and marks the authority secure without opening a TLS socket. + + The browser performs certificate validation when fetch or WebSocket opens the URL. + Under ERROR, custom roots, credentials, version pins, callbacks, or mismatched names + produce operation_not_supported; IGNORE leaves those choices to the browser. + @param type Requested TLS role; only client is representable by browser host APIs. + */ + void handshake(webcpp::asio::ssl::stream_base::handshake_type type) { + boost::system::error_code ec; + handshake(type, ec); + detail::browser::throw_error(ec); + } + + /** + Validates TLS intent and marks the authority secure without opening a TLS socket. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + The browser performs certificate validation when fetch or WebSocket opens the URL. + Under ERROR, custom roots, credentials, version pins, callbacks, or mismatched names + produce operation_not_supported; IGNORE leaves those choices to the browser. + @tparam Token Asio completion token selecting the asynchronous result type. + @param type Requested TLS role; only client is representable by browser host APIs. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_handshake(webcpp::asio::ssl::stream_base::handshake_type type, Token&& token) { + return boost::asio::async_initiate( + [this, type](auto handler) { + boost::system::error_code ec; + handshake(type, ec); + detail::browser::post(get_executor(), std::move(handler), ec); + }, + token); + } + + /** + Closes the browser operation associated with the underlying authority. + @param ec Receives the operation error, or is cleared on success. + */ + void shutdown(boost::system::error_code& ec) { get_lowest_layer(next_).close(ec); } + + /** + Closes the browser operation associated with the underlying authority. + */ + void shutdown() { + boost::system::error_code ec; + shutdown(ec); + } + + /** + Closes the browser operation associated with the underlying authority. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_shutdown(Token&& token) { + return boost::asio::async_initiate( + [this](auto handler) { + boost::system::error_code ec; + shutdown(ec); + detail::browser::post(get_executor(), std::move(handler), ec); + }, + token); + } + + /** + Records the requested TLS server name for authority validation. + @param host Hostname to match against the recorded destination authority. + @return Success, or invalid_argument for an invalid server-name record. + */ + boost::system::result set_server_name(std::string_view host) { + if (host.empty() || host.size() > 255 || host.find('\0') != std::string_view::npos) { + return boost::asio::error::invalid_argument; + } + server_name_ = host; + return {}; + } +}; + +/** + Records the requested TLS server name for authority validation. + @tparam NextLayer Underlying browser authority or TLS-intent layer. + @param stream Browser stream whose recorded authority selects the host operation. + @param host Hostname to match against the recorded destination authority. + @return Success, or invalid_argument for an invalid server-name record. + */ +template +boost::system::result set_server_name(ssl_stream& stream, std::string_view host) { + return stream.set_server_name(host); +} +} +} // namespace webcpp::beast +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/tcp_stream.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/tcp_stream.hpp new file mode 100644 index 0000000..dfd829e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/tcp_stream.hpp @@ -0,0 +1,522 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_TCP_STREAM_HPP +#define WEBCPP_BEAST_BROWSER_TCP_STREAM_HPP + +#include + +#include // lint-world: allocation-free numeric address formatting, without I/O +#include +#include // lint-world: portable protocol data and explicit stream algorithms +#include +#include +#include +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +/** Finds the innermost layer of a composed stream. */ +using boost::beast::get_lowest_layer; +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +/** + A browser authority record, with Beast's connection and deadline interface. + */ +class tcp_stream { +public: + /** + Executor used to schedule stream operations and their completions. + */ + using executor_type = boost::asio::any_io_executor; + /** + Address and service value recorded by connect. + */ + using endpoint_type = webcpp::asio::ip::tcp::endpoint; + /** + The authority record at the bottom of a browser stream stack. + */ + using lowest_layer_type = tcp_stream; + + /** + Selects the stream type for a different executor. + @tparam Executor Executor type to bind to the underlying layer. + */ + template + struct rebind_executor { + /** + Stream type with the requested executor binding. + */ + using other = tcp_stream; + }; + + /** + Constructs an authority record with no active connection. + @param executor Executor used to post asynchronous completions. + */ + explicit tcp_stream(executor_type executor) + : tcp_stream(std::allocator_arg, std::allocator{}, std::move(executor)) {} + + /** + Constructs an authority record with no active connection. + @tparam Context Execution context providing get_executor(). + @param context Execution context owning the stream executor. + */ + template + requires requires(Context& context) { context.get_executor(); } + explicit tcp_stream(Context& context) : tcp_stream(context.get_executor()) {} + + /** + Constructs an authority record with no active connection. + @tparam Allocator Allocator used for owned state and variable-sized stream storage. + @param allocator Allocator retained for stream-owned storage. + @param executor Executor used to post asynchronous completions. + */ + template + tcp_stream(std::allocator_arg_t /*unused*/, const Allocator& allocator, executor_type executor) + : executor_(std::move(executor)), + memory_(std::allocate_shared>(allocator, + allocator)), + host_(memory_.get()) {} + + /** + Constructs an authority record with no active connection. + @tparam Allocator Allocator used for owned state and variable-sized stream storage. + @tparam Context Execution context providing get_executor(). + @param tag Selects the allocator-aware constructor. + @param allocator Allocator retained for stream-owned storage. + @param context Execution context owning the stream executor. + */ + template + requires requires(Context& context) { context.get_executor(); } + tcp_stream(std::allocator_arg_t tag, const Allocator& allocator, Context& context) + : tcp_stream(tag, allocator, executor_type(context.get_executor())) {} + + /** + Returns the allocation resource retained by this stream. + @return The stream-owned resource; its lifetime is tied to retained resource ownership. + */ + [[nodiscard]] std::pmr::memory_resource* resource() const noexcept { return memory_.get(); } + + /** + Returns shared ownership of the stream allocation resource. + @return Shared ownership of the stream allocation resource. + */ + [[nodiscard]] const std::shared_ptr& resource_owner() + const noexcept { + return memory_; + } + + /** + Transfers the stream and its pending operation ownership. + @param other Stream whose state and operation ownership are transferred. + */ + tcp_stream(tcp_stream&& other) noexcept + : http_state(std::move(other.http_state)), + executor_(std::move(other.executor_)), + memory_(std::move(other.memory_)), + host_(std::move(other.host_)), + port_(other.port_), + response_body_limit_(other.response_body_limit_), + open_(std::exchange(other.open_, false)), + secure_(other.secure_), + deadline_(other.deadline_), + owner_(std::exchange(other.owner_, nullptr)), + cancel_(std::exchange(other.cancel_, nullptr)), + close_(std::exchange(other.close_, nullptr)) {} + + /** + Disables assignment of stream ownership. + */ + tcp_stream& operator=(tcp_stream&&) = delete; + /** + Disables copying of stream ownership. + */ + tcp_stream(const tcp_stream&) = delete; + /** + Disables assignment of stream ownership. + */ + tcp_stream& operator=(const tcp_stream&) = delete; + + /** + Aborts pending host operations and releases browser registrations. + */ + ~tcp_stream() { close(); } + + /** + Returns the executor used for asynchronous completions. + @return The executor associated with the underlying context. + */ + [[nodiscard]] executor_type get_executor() const noexcept { return executor_; } + + /** + Returns this authority record through the Beast lowest-layer interface. + @return A reference to this authority record. + */ + // lint-std: Beast basic_stream::socket returns its lowest transport layer + tcp_stream& socket() noexcept { return *this; } // lint-world: authority facade only + + /** + Returns this authority record through the Beast lowest-layer interface. + @return A reference to this authority record. + */ + // lint-std: Beast basic_stream::socket returns its lowest transport layer + [[nodiscard]] const tcp_stream& socket() const noexcept { // lint-world: authority facade only + return *this; + } + + /** + Reports whether a connection authority has been recorded. + @return True when the layer is available for operations. + */ + [[nodiscard]] bool is_open() const noexcept { return open_; } + + /** + Sets an absolute deadline relative to the current steady-clock time. + @tparam Rep Representation type of the duration count. + @tparam Period Tick period of the duration. + @param duration Time remaining until the deadline. + */ + template + void expires_after(std::chrono::duration duration) { + deadline_ = ::webcpp::beast::detail::browser::clock_type::now() + duration; + } + + /** + Sets the deadline for subsequent browser operations. + @param time Absolute steady-clock deadline. + */ + void expires_at(::webcpp::beast::detail::browser::clock_type::time_point time) { + deadline_ = time; + } + + /** + Disables the authority record deadline. + */ + void expires_never() { + deadline_ = ::webcpp::beast::detail::browser::clock_type::time_point::max(); + } + + /** + Returns the deadline recorded for browser operations. + @return The recorded deadline, or time_point::max() when disabled. + */ + [[nodiscard]] auto expiry() const noexcept { return deadline_; } + + /** + Cancels the active host operation and posts its aborted completion. + */ + void cancel() { + if (cancel_ != nullptr) { + cancel_(owner_); + } + } + + /** + Cancels the active host operation and posts its aborted completion. + @param ec Receives the operation error, or is cleared on success. + */ + void cancel(boost::system::error_code& ec) { + cancel(); + ec.clear(); + } + + /** + Closes the authority record and aborts its active host operation. + */ + void close() { + if (close_ != nullptr) { + close_(owner_); + } + open_ = false; + } + + /** + Closes the authority record and aborts its active host operation. + @param ec Receives the operation error, or is cleared on success. + */ + void close(boost::system::error_code& ec) { + close(); + ec.clear(); + } + + /** + Closes the browser operation and its authority record. + @param ec Receives the operation error, or is cleared on success. + */ + void shutdown(boost::asio::socket_base::shutdown_type /*unused*/, + boost::system::error_code& ec) { + close(ec); + } + + /** + Closes the browser operation and its authority record. + @param what Shutdown direction; browser host operations close as a whole. + */ + void shutdown(boost::asio::socket_base::shutdown_type what) { + boost::system::error_code ec; + shutdown(what, ec); + } + + /** + Records the destination authority without opening a raw TCP connection. + @param results Resolver results supplying the original hostname and service. + @param ec Receives the operation error, or is cleared on success. + @return The endpoint corresponding to the recorded authority, or an empty endpoint on failure. + */ + endpoint_type connect(const webcpp::asio::ip::tcp::resolver::results_type& results, + boost::system::error_code& ec) { + if (results.empty()) { + ec = boost::asio::error::host_not_found; + return {}; + } + reset_operation(); + const auto& entry = *results.begin(); + host_ = entry.host_name(std::pmr::polymorphic_allocator(memory_.get())); + port_ = entry.endpoint().port(); + if (host_.empty()) { + return connect(entry.endpoint(), ec); + } + if (host_.find(':') != std::string::npos && host_.front() != '[') { + host_.insert(host_.begin(), '['); + host_.push_back(']'); + } + open_ = true; + ec.clear(); + return entry.endpoint(); + } + + /** + Records the destination authority without opening a raw TCP connection. + @param results Resolver results supplying the original hostname and service. + @return The endpoint corresponding to the recorded authority, or an empty endpoint on failure. + */ + endpoint_type connect(const webcpp::asio::ip::tcp::resolver::results_type& results) { + boost::system::error_code ec; + auto result = connect(results, ec); + detail::browser::throw_error(ec); + return result; + } + + /** + Records the destination authority without opening a raw TCP connection. + @param endpoint Address and port to record as the destination. + @param ec Receives the operation error, or is cleared on success. + @return The endpoint corresponding to the recorded authority, or an empty endpoint on failure. + */ + endpoint_type connect(const endpoint_type& endpoint, boost::system::error_code& ec) { + if (endpoint.address().is_unspecified()) { + ec = make_error_code(browser_errc::no_host); + return {}; + } + reset_operation(); + std::array text{}; + const auto address = endpoint.address(); + if (address.is_v6()) { + const auto bytes = address.to_v6().to_bytes(); + if (inet_ntop(AF_INET6, bytes.data(), text.data(), text.size()) == nullptr) { + ec = boost::asio::error::invalid_argument; + return {}; + } + host_.assign(1, '['); + host_.append(text.data()); + if (const auto scope = address.to_v6().scope_id(); scope != 0) { + host_.push_back('%'); + const auto converted = std::to_chars(text.data(), text.data() + text.size(), scope); + host_.append(text.data(), converted.ptr); + } + host_.push_back(']'); + } else { + const auto bytes = address.to_v4().to_bytes(); + if (inet_ntop(AF_INET, bytes.data(), text.data(), text.size()) == nullptr) { + ec = boost::asio::error::invalid_argument; + return {}; + } + host_.assign(text.data()); + } + port_ = endpoint.port(); + open_ = true; + ec.clear(); + return endpoint; + } + + /** + Records the destination authority without opening a raw TCP connection. + @param endpoint Address and port to record as the destination. + */ + void connect(const endpoint_type& endpoint) { + boost::system::error_code ec; + connect(endpoint, ec); + detail::browser::throw_error(ec); + } + + /** + Records the destination authority and posts the result. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, endpoint_type)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param results Resolver results supplying the original hostname and service. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_connect(const webcpp::asio::ip::tcp::resolver::results_type& results, + Token&& token) { + return boost::asio::async_initiate( + [this, results](auto handler) { + boost::system::error_code ec; + auto endpoint = connect(results, ec); + detail::browser::post(executor_, std::move(handler), ec, endpoint); + }, + token); + } + + /** + Records the destination authority and posts the result. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param endpoint Address and port to record as the destination. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_connect(const endpoint_type& endpoint, Token&& token) { + return boost::asio::async_initiate( + [this, endpoint](auto handler) { + boost::system::error_code ec; + connect(endpoint, ec); + detail::browser::post(executor_, std::move(handler), ec); + }, + token); + } + + /** + Returns the recorded hostname or bracketed IPv6 address. + @return The hostname or bracketed IPv6 address. + */ + [[nodiscard]] std::string_view host() const noexcept { return host_; } + + /** + Returns the recorded service port. + @return The recorded service port. + */ + [[nodiscard]] std::uint16_t port() const noexcept { return port_; } + + /** + Sets the maximum decoded fetch body size in bytes. + @param value Maximum decoded response bytes; the default is 8 MiB. + */ + void response_body_limit(std::size_t value) noexcept { response_body_limit_ = value; } + + /** + Returns the maximum decoded fetch body size in bytes. + @return The maximum decoded body size in bytes. + */ + [[nodiscard]] std::size_t response_body_limit() const noexcept { return response_body_limit_; } + + /** + Reports whether browser URLs use TLS. + @return True when secure URL schemes are selected. + */ + [[nodiscard]] bool secure() const noexcept { return secure_; } + + /** + Records whether browser URLs use TLS. + @param value Whether subsequent URLs use https or wss. + */ + void secure(bool value) noexcept { secure_ = value; } + + /** + Checks a hostname or host-and-port against the recorded authority. + @param host Hostname to match against the recorded destination authority. + @return True if the value names the recorded destination. + */ + [[nodiscard]] bool authority_matches(std::string_view host) const { + if (host == std::string_view(host_)) { + return true; + } + if (!host.starts_with(host_) || host.size() <= host_.size() || host[host_.size()] != ':') { + return false; + } + const auto service = host.substr(host_.size() + 1); + std::array text{}; + const auto converted = std::to_chars(text.data(), text.data() + text.size(), port_); + return service == std::string_view(text.data(), converted.ptr - text.data()); + } + + /** + Builds a browser URL from the recorded authority and request target. + @param target Origin-form path and query for the browser URL. + @param websocket Selects ws or wss instead of http or https. + @return The fully qualified browser URL. + */ + [[nodiscard]] std::pmr::string url(std::string_view target, bool websocket = false) const { + const char* const scheme = websocket ? "ws" : "http"; + const char* const security = secure_ ? "s://" : "://"; + std::pmr::string result(scheme, memory_.get()); + result += security; + result += host_; + result += ':'; + std::array service{}; + const auto converted = + std::to_chars(service.data(), service.data() + service.size(), port_); + result.append(service.data(), converted.ptr); + result += target; + return result; + } + + /** + Connects host cancellation and closure to the authority record. + @param owner Object retained by the host operation owner. + @param cancel Callback invoked to cancel the active host operation. + @param close Callback invoked to close the active host operation. + */ + void bind(void* owner, void (*cancel)(void*), void (*close)(void*)) { + owner_ = owner; + cancel_ = cancel; + close_ = close; + } + + /** + Shared fetch transaction storage retained by the authority record. + */ + std::shared_ptr http_state; + +private: + void reset_operation() { + if (!open_ && !http_state) { + secure_ = false; + return; + } + close(); + bind(nullptr, nullptr, nullptr); + http_state.reset(); + secure_ = false; + } + + executor_type executor_; + std::shared_ptr memory_; + std::pmr::string host_; + std::uint16_t port_ = 0; + std::size_t response_body_limit_ = 8 * 1024 * 1024; + bool open_ = false; + bool secure_ = false; + ::webcpp::beast::detail::browser::clock_type::time_point deadline_ = + ::webcpp::beast::detail::browser::clock_type::time_point::max(); + void* owner_ = nullptr; + void (*cancel_)(void*) = nullptr; + void (*close_)(void*) = nullptr; +}; +} +} // namespace webcpp::beast +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/websocket.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/websocket.hpp new file mode 100644 index 0000000..426299e --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/browser/websocket.hpp @@ -0,0 +1,1451 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_BROWSER_WEBSOCKET_HPP +#define WEBCPP_BEAST_BROWSER_WEBSOCKET_HPP + +#include + +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: browser operation scheduling and handler associations +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include // lint-world: portable protocol data and explicit stream algorithms +#include +#include +#include +#include +#include +#include +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +/** Client or server role used by protocol options. */ +using boost::beast::role_type; +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace websocket { +/** WebSocket close status codes. */ +using boost::beast::websocket::close_code; +/** WebSocket close status and UTF-8 explanation. */ +using boost::beast::websocket::close_reason; +/** Errors produced by WebSocket protocol operations. */ +using boost::beast::websocket::error; +/** Tests whether a request asks to upgrade to WebSocket. */ +using boost::beast::websocket::is_upgrade; +/** Compatibility record for browser-owned compression negotiation. */ +using boost::beast::websocket::permessage_deflate; +/** Payload type for a WebSocket control frame. */ +using boost::beast::websocket::ping_data; +/** HTTP request shape supplied to a WebSocket decorator. */ +using request_type = boost::beast::http::request< + boost::beast::http::empty_body, + boost::beast::http::basic_fields>>; +/** HTTP response shape used by the guest WebSocket engine. */ +using boost::beast::websocket::response_type; +/** + Kind of WebSocket control event. + */ +enum class frame_type { + /** A closing handshake notification. */ + close, + /** A browser-owned ping control frame. */ + ping, + /** A browser-owned pong control frame. */ + pong, +}; + +/** + Browser-compatible options, with a deferred allocator-aware decorator. + */ +struct stream_base { + /** + Handshake and idle timeout options shared with Beast. + */ + using timeout = boost::beast::websocket::stream_base::timeout; + + /** + Stores a callable that records the browser-compatible handshake subprotocols. + @tparam Function Callable stored for request decoration or control notification. + */ + template + struct decorator { + /** + Callable retained for later protocol notification. + */ + Function function; + + /** + Retains a handshake request decorator. + @param fn Callable invoked with the handshake request before opening the browser socket. + */ + explicit decorator(Function fn) : function(std::move(fn)) {} + }; +}; + +/** + Bounds bytes buffered for sending and awaiting application reads. + */ +struct queue_limits { + /** + Maximum combined bufferedAmount and unsent fragment bytes, defaulting to 4 MiB. + */ + std::size_t send = 4 * 1024 * 1024; + /** + Maximum retained payload plus message-record bytes in Wasm, defaulting to 4 MiB. + + Includes browser arrivals awaiting executor dispatch, even while the context is stopped. + */ + std::size_t receive = 4 * 1024 * 1024; +}; +} // namespace websocket +} +} // namespace webcpp::beast + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::detail { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace browser { +/** + Type-erased decorator or control callback. + */ +struct callback_base { + /** + Invokes a request decorator when this object stores one. + */ + virtual void decorate(websocket::request_type& /*unused*/) {}; + /** + Invokes a control callback when this object stores one. + */ + virtual void control(websocket::frame_type /*unused*/, boost::beast::string_view /*unused*/){}; + /** + Releases registration and retained state during destruction. + */ + virtual ~callback_base() = default; +}; + +/** + Stores a callable using the stream allocator. + */ +template +struct callback final : callback_base { + /** + Callable retained for later protocol notification. + */ + Function function; + + /** + Initializes retained state and its executor or allocation resource. + */ + explicit callback(Function value) : function(std::move(value)) {} + + /** + Invokes a request decorator when this object stores one. + */ + void decorate(websocket::request_type& request) override { + if constexpr (Decorator) { + function(request); + } + } + + /** + Invokes a control callback when this object stores one. + */ + void control(websocket::frame_type kind, boost::beast::string_view value) override { + if constexpr (!Decorator) { + function(kind, value); + } + } +}; + +/** + Returns an English description of a browser error value. + */ +struct message { + /** + Decoded message bytes allocated from the stream resource. + */ + std::pmr::vector bytes; + /** + Whether this complete message contains UTF-8 text. + */ + bool text; + /** + Number of message bytes already delivered to the application. + */ + std::size_t offset = 0; + + /** + Initializes retained state and its executor or allocation resource. + */ + message(std::pmr::memory_resource* resource, bool is_text) : bytes(resource), text(is_text) {} +}; + +/** Payload bookkeeping and the two queue links charged for every received message. */ +inline constexpr std::size_t message_record_bytes = sizeof(message) + (2 * sizeof(void*)); + +/** + Owns browser WebSocket state independently of the facade lifetime. + */ +// Registry lookup and shared ownership have independent lifetimes. +// NOLINTNEXTLINE(misc-multiple-inheritance) +class websocket_state final : public webcpp::asio::browser::intrusive_registration, + public std::enable_shared_from_this { +public: + /** + Allocation resource kept alive while queued callbacks can access storage. + */ + std::shared_ptr resource; + /** + Executor that serializes state changes and completion posting. + */ + executor_type executor; + /** + Browser event registry owned by the execution context. + */ + webcpp::asio::browser::bridge* bridge; + /** + Timer enforcing the current operation deadline. + */ + boost::asio::steady_timer timer; // lint-world: browser operation deadline + /** + Registration key used to reject events from detached operations. + */ + std::uint64_t key = 0; + /** + JavaScript WebSocket handle owned by this state. + */ + emscripten::val socket = emscripten::val::undefined(); + /** + Complete browser messages awaiting application reads. + */ + std::pmr::list messages; + /** Browser arrivals charged to the receive budget before the executor runs. */ + std::pmr::list ingress; + /** One retained close event, whose callback runs only on the executor. */ + emscripten::val ingress_close = emscripten::val::undefined(); + /** Terminal ingress error awaiting executor-side completion. */ + error_code ingress_failure; + /** Whether an opening notification awaits the executor. */ + bool ingress_open = false; + /** Whether a single executor notification already owns the staged arrivals. */ + bool ingress_posted = false; + /** Connection identity checked by posted arrivals and deadline callbacks. */ + std::uint64_t generation = 0; + /** + Outgoing fragments assembled before one browser send. + */ + std::pmr::vector fragments; + /** + Allocator-owned request decorator, if installed. + */ + std::shared_ptr decorator; + /** + Allocator-owned close notification callback, if installed. + */ + std::shared_ptr control; + /** + Handshake and receive-idle timeout settings. + */ + websocket::stream_base::timeout timeout = + websocket::stream_base::timeout::suggested(boost::beast::role_type::client); + /** + Send and receive queue bounds enforced by this state. + */ + websocket::queue_limits limits; + /** + Most recent browser-reported close status and reason. + */ + websocket::close_reason reason; + /** + Terminal error retained for the next pending completion. + */ + error_code failure; + /** + Total retained payload and message-record bytes in the queue. + */ + std::size_t queued = 0; + /** + Maximum decoded message size accepted from the browser. + */ + std::size_t maximum = 16 * 1024 * 1024; + /** + Whether the browser WebSocket has reported an open event. + */ + bool opened = false; + /** + Whether the owning stream still accepts browser events. + */ + bool alive = true; + /** + Whether the next outgoing message uses a text opcode. + */ + bool send_text = false; + /** + Whether the last delivered message used a text opcode. + */ + bool received_text = false; + /** + Whether the last read consumed the end of its message. + */ + bool message_done = true; + /** + Pending opening-handshake completion, or null after completion. + */ + pending* handshake = nullptr; + /** + Pending application read completion, or null when no read is outstanding. + */ + pending* read = nullptr; + /** + Pending closing-handshake completion, or null after completion. + */ + pending* close = nullptr; + + /** + Initializes retained state and its executor or allocation resource. + */ + websocket_state(executor_type ex, std::shared_ptr storage) + : resource(std::move(storage)), + executor(std::move(ex)), + bridge(&boost::asio::use_service( + boost::asio::query(executor, boost::asio::execution::context))), + timer(executor), + messages(resource.get()), + ingress(resource.get()), + fragments(resource.get()) {} + + /** + Releases registration and retained state during destruction. + */ + ~websocket_state() { detach(); } + + /** Cancels the deadline without throwing during stream destruction. */ + void cancel_timer() noexcept { +#ifndef WEBCPP_BEAST_NO_EXCEPTIONS + try { + timer.cancel(); + } catch (...) { // NOLINT(bugprone-empty-catch): cleanup must still detach and abort the + // host resource + // Cleanup still detaches callbacks and aborts the host resource. + } +#else + timer.cancel(); +#endif + } + + /** + Removes the registration so later browser events cannot reach this state. + */ + void detach() { + if ((bridge != nullptr) && (key != 0u)) { + bridge->remove(std::exchange(key, 0)); + } + if (!socket.isUndefined()) { + for (const auto* name : {"onopen", "onmessage", "onclose", "onerror"}) { + socket.set(name, emscripten::val::null()); + } + } + } + + /** + Retains bounded arrivals and schedules at most one executor notification. + Browser callbacks never invoke application handlers or manipulate their buffers. + */ + bool deliver(const emscripten::val& event) override { + if (!alive) { + return false; + } + const auto type = event["type"].as(); + if (type == "message") { + if (failure || ingress_failure) { + return false; + } + receive_message(event); + } else if (type == "open") { + ingress_open = true; + } else if (type == "close") { + ingress_close = event; + } else { + // Browser error events carry no cause; close owns the terminal result. + return false; + } + if (!ingress_posted) { + ingress_posted = true; + const auto epoch = generation; + auto const self = shared_from_this(); + post(executor, + boost::asio::bind_allocator(owning_allocator(resource), [self, epoch] { + if (self->alive && self->generation == epoch) { + self->drain_ingress(); + } + })); + } + return false; + } + + /** Retires connection-specific storage without changing the configured options. */ + void reset_arrivals() { + ++generation; + ingress.clear(); + messages.clear(); + fragments.clear(); + queued = 0; + ingress_close = emscripten::val::undefined(); + ingress_failure.clear(); + ingress_open = false; + ingress_posted = false; + received_text = false; + message_done = true; + } + + /** Prepares a detached state for another browser connection. */ + void begin_connection() { + detach(); + cancel_timer(); + abort_socket(); + reset_arrivals(); + socket = emscripten::val::undefined(); + failure.clear(); + reason = {}; + alive = true; + } + + /** + Closes the browser operation and its authority record. + */ + void shutdown() noexcept override { + bridge = nullptr; + key = 0; + alive = false; + reset_arrivals(); + for (auto* const* item : {&handshake, &read, &close}) { + if ((*item) != nullptr) { + (*item)->discard(); + } + } + detach(); + abort_socket(); + } + + /** + Requests browser closure and marks the WebSocket unavailable. + */ + void abort_socket() { + if (!socket.isUndefined()) { + webcpp_beast_close(socket.as_handle(), 0, emscripten::val::undefined().as_handle()); + } + opened = false; + } + + /** + Completes each outstanding operation with the supplied terminal error. + */ + void finish(error_code ec) { + cancel_timer(); + for (auto* const* item : {&handshake, &read, &close}) { + if ((*item) != nullptr) { + (*item)->complete(ec); + } + } + } + + /** Retires the connection generation before completing a terminal operation. */ + void invalidate(error_code ec) { + failure = ec; + reset_arrivals(); + detach(); + abort_socket(); + cancel_timer(); + } + + /** + Detaches the host resource and aborts all pending operations. + */ + void stop() noexcept { + alive = false; + invalidate(boost::asio::error::operation_aborted); + finish(boost::asio::error::operation_aborted); + } + + /** + Aborts the WebSocket and completes pending operations as cancelled. + */ + void cancel_all() { + invalidate(boost::asio::error::operation_aborted); + finish(boost::asio::error::operation_aborted); + } + + /** + Schedules the absolute deadline for the active host operation. + */ + void arm(::webcpp::beast::detail::browser::clock_type::time_point deadline) { + cancel_timer(); + if (deadline == ::webcpp::beast::detail::browser::clock_type::time_point::max()) { + return; + } + timer.expires_at(deadline); + auto const weak = weak_from_this(); + const auto epoch = generation; + timer.async_wait(boost::asio::bind_allocator( + owning_allocator(resource), [weak, epoch](error_code ec) { + if (auto const self = weak.lock(); + self && !ec && self->alive && self->generation == epoch) { + self->invalidate(boost::beast::error::timeout); + self->finish(self->failure); + } + })); + } + + /** + Restarts the receive-idle timer after browser activity. + */ + void arm_idle() { + if (timeout.idle_timeout != boost::beast::websocket::stream_base::none()) { + arm(::webcpp::beast::detail::browser::clock_type::now() + timeout.idle_timeout); + } else { + cancel_timer(); + } + } + + /** Restores idle monitoring after cancellation without changing a handshake deadline. */ + void cancel_read() { + if (handshake == nullptr && close == nullptr) { + arm_idle(); + } + } + + /** Applies staged arrivals and all operation completions on the stream executor. */ + void drain_ingress() { + ingress_posted = false; + if (std::exchange(ingress_open, false)) { + opened = true; + arm_idle(); + if (handshake != nullptr) { + handshake->complete(); + } + } + if (ingress_failure) { + failure = std::exchange(ingress_failure, error_code{}); + ingress.clear(); + messages.clear(); + queued = 0; + abort_socket(); + if (read != nullptr) { + read->complete(failure); + } + } else if (!ingress.empty()) { + messages.splice(messages.end(), ingress); + if (close == nullptr) { + arm_idle(); + } + if (read != nullptr) { + read->complete(); + } + } + if (!ingress_close.isUndefined()) { + const auto event = std::exchange(ingress_close, emscripten::val::undefined()); + receive_close(event); + } + } + + /** Charges and copies an arrival before the browser can deliver another message. */ + void receive_message(const emscripten::val& event) { + const auto data = event["data"]; + const auto size = webcpp_beast_message_size(data.as_handle()); + const auto available = limits.receive - std::min(limits.receive, queued); + if (size > maximum || size > available || message_record_bytes > available - size) { + ingress_failure = size > maximum ? error_code(websocket::error::message_too_big) + : make_error_code(browser_errc::receive_limit); + // Stop host ingress immediately, even while the stream executor is paused. + // The executor still owns completions, control callbacks and timers. + webcpp_beast_close(socket.as_handle(), 0, emscripten::val::undefined().as_handle()); + return; + } + ingress.emplace_back(resource.get(), data.typeOf().as() == "string"); + auto& message = ingress.back(); + message.bytes.resize(size); + webcpp_beast_copy(data.as_handle(), message.bytes.data(), size); + queued += size + message_record_bytes; + } + + /** Records browser closure and completes pending operations with its status. */ + void receive_close(const emscripten::val& event) { + detach(); + const auto epoch = generation; + const bool was_open = opened; + opened = false; + cancel_timer(); + reason.code = static_cast(event["code"].as()); + const auto text = js_text(event["reason"], resource.get()); + reason.reason = boost::beast::string_view(text.data(), text.size()); + if (control) { + control->control(websocket::frame_type::close, reason.reason); + if (generation != epoch) { + return; + } + } + if (!failure) { + if (!was_open && handshake != nullptr) { + failure = make_error_code(browser_errc::connection_failed); + } else if (reason.code == 1006) { + failure = boost::asio::error::connection_reset; + } else { + failure = websocket::error::closed; + } + } + if (handshake != nullptr) { + handshake->complete(failure); + } + if ((read != nullptr) && messages.empty()) { + read->complete(failure); + } + if (close != nullptr) { + close->complete(reason.code == 1006 ? failure : error_code{}); + } + } + + /** + Copies queued message bytes and updates partial-read bookkeeping. + */ + template + std::size_t copy(const Buffers& buffers, std::size_t maximum_count) { + auto& message = messages.front(); + auto size = std::min(maximum_count, message.bytes.size() - message.offset); + size = boost::asio::buffer_copy( + buffers, boost::asio::buffer(message.bytes.data() + message.offset, size)); + received_text = message.text; + message.offset += size; + message_done = message.offset == message.bytes.size(); + if (message_done) { + queued -= message.bytes.size() + message_record_bytes; + messages.pop_front(); + } + return size; + } +}; + +/** + Allocates WebSocket state and its retained resource from the caller allocator. + */ +template +std::shared_ptr make_websocket_state(executor_type executor, + const Allocator& allocator) { + auto resource = std::allocate_shared>(allocator, allocator); + return std::allocate_shared(allocator, std::move(executor), + std::move(resource)); +} +} // namespace browser +} +} // namespace webcpp::beast::detail + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif + +namespace websocket { +/** + Browser WebSocket with layered operations and Asio completion tokens. + @tparam NextLayer Underlying browser authority or TLS-intent layer. + @tparam DeflateSupported Compatibility parameter; the browser owns extension negotiation. + */ +template +class stream { + NextLayer next_; + std::shared_ptr state_; + using ec_type = boost::system::error_code; + + void bind() { + get_lowest_layer(next_).bind( + state_.get(), + [](void* value) { + static_cast(value)->cancel_all(); + }, + [](void* value) { static_cast(value)->stop(); }); + } + + void arm(bool handshake = false) { + auto deadline = get_lowest_layer(next_).expiry(); + if (handshake && + state_->timeout.handshake_timeout != boost::beast::websocket::stream_base::none()) { + deadline = std::min(deadline, ::webcpp::beast::detail::browser::clock_type::now() + + state_->timeout.handshake_timeout); + } + if (deadline != ::webcpp::beast::detail::browser::clock_type::time_point::max()) { + state_->arm(deadline); + } + } + + template + void sync(Begin begin, ec_type& ec) { + auto& context = static_cast( + boost::asio::query(get_executor(), boost::asio::execution::context)); + if (context.get_executor().running_in_this_thread() || state_->bridge->delivering()) { + ec = boost::asio::error::operation_not_supported; + return; + } + bool done = false; + begin([&](ec_type result) { + ec = result; + done = true; + }); + context.restart(); + // NOLINTNEXTLINE(bugprone-infinite-loop): run_one invokes the callback that sets done + while (!done) { + context.run_one(); + } + } + + static void add_protocols(const emscripten::val& protocols, std::string_view value) { + while (!value.empty()) { + const auto comma = value.find(','); + auto name = value.substr(0, comma); + while (!name.empty() && name.front() == ' ') { + name.remove_prefix(1); + } + while (!name.empty() && name.back() == ' ') { + name.remove_suffix(1); + } + protocols.call("push", detail::browser::js_string(name)); + if (comma == std::string_view::npos) { + break; + } + value.remove_prefix(comma + 1); + } + } + + emscripten::val protocols(ec_type& ec) { + request_type request(std::piecewise_construct, std::tuple<>(), + std::make_tuple(state_->resource.get())); + if (state_->decorator) { + state_->decorator->decorate(request); + } + auto const protocols = emscripten::val::array(); + for (const auto& field : request) { + if (field.name() != boost::beast::http::field::sec_websocket_protocol) { + if (auto const error = detail::browser::unsupported()) { + ec = error; + } + } else { + add_protocols(protocols, {field.value().data(), field.value().size()}); + } + } + return protocols; + } + +public: + /** + Type of the layer immediately below this stream. + */ + using next_layer_type = NextLayer; + /** + Executor used to schedule stream operations and their completions. + */ + using executor_type = NextLayer::executor_type; + + /** + Selects the stream type for a different executor. + @tparam Executor Executor type to bind to the underlying layer. + */ + template + struct rebind_executor { + /** + Stream type with the requested executor binding. + */ + using other = + stream::other, DeflateSupported>; + }; + + /** + Constructs the next layer and allocator-owned WebSocket state. + @tparam First Type of the first argument forwarded to the next layer. + @tparam Args Types of the remaining arguments forwarded to the next layer. + @param first First argument forwarded to the next layer constructor. + @param args Remaining arguments forwarded to the next layer constructor. + */ + template + requires(!std::is_same_v, std::allocator_arg_t>) + explicit stream(First&& first, Args&&... args) + : next_(std::forward(first), std::forward(args)...), + state_(detail::browser::make_websocket_state(next_.get_executor(), + std::allocator{})) { + bind(); + } + + /** + Constructs the next layer and allocator-owned WebSocket state. + @tparam Allocator Allocator used for owned state and variable-sized stream storage. + @tparam Args Types of the remaining arguments forwarded to the next layer. + @param allocator Allocator retained for stream-owned storage. + @param args Remaining arguments forwarded to the next layer constructor. + */ + template + explicit stream(std::allocator_arg_t /*unused*/, const Allocator& allocator, Args&&... args) + : next_(std::allocator_arg, allocator, std::forward(args)...), + state_(detail::browser::make_websocket_state(next_.get_executor(), allocator)) { + bind(); + } + + /** + Disables copying of stream ownership. + */ + stream(const stream&) = delete; + /** + Disables assignment of stream ownership. + */ + stream& operator=(const stream&) = delete; + + /** + Transfers the stream and its pending operation ownership. + @param other Stream whose state and operation ownership are transferred. + */ + stream(stream&& other) noexcept + : next_(std::move(other.next_)), state_(std::move(other.state_)) { + bind(); + } + + /** + Disables assignment of stream ownership. + */ + stream& operator=(stream&&) = delete; + + /** + Aborts pending host operations and releases browser registrations. + */ + ~stream() { + if (state_) { + get_lowest_layer(next_).bind(nullptr, nullptr, nullptr); + state_->stop(); + } + } + + /** + Returns the immediately underlying layer. + @return A reference to the underlying stream. + */ + NextLayer& next_layer() noexcept { return next_; } + + /** + Returns the immediately underlying layer. + @return A reference to the underlying stream. + */ + [[nodiscard]] const NextLayer& next_layer() const noexcept { return next_; } + + /** + Returns the executor used for asynchronous completions. + @return The executor associated with the underlying context. + */ + [[nodiscard]] executor_type get_executor() const { return next_.get_executor(); } + + /** + Reports whether the browser WebSocket is currently open. + @return True when the layer is available for operations. + */ + [[nodiscard]] bool is_open() const noexcept { return state_->opened; } + + /** + Reports whether the last read delivered a text message. + @return True if the last delivered message was text. + */ + [[nodiscard]] bool got_text() const noexcept { return state_->received_text; } + + /** + Reports whether the last read delivered a binary message. + @return True if the last delivered message was binary. + */ + [[nodiscard]] bool got_binary() const noexcept { return !got_text(); } + + /** + Reports whether the last read reached the end of its message. + @return True when the last read consumed the message boundary. + */ + [[nodiscard]] bool is_message_done() const noexcept { return state_->message_done; } + + /** + Reports whether subsequent messages use text mode. + @return True if outgoing messages use text mode. + */ + [[nodiscard]] bool text() const noexcept { return state_->send_text; } + + /** + Selects text mode for subsequent messages. + @param value Whether subsequent messages are text. + */ + void text(bool value) noexcept { state_->send_text = value; } + + /** + Reports whether subsequent messages use binary mode. + @return True if outgoing messages use binary mode. + */ + [[nodiscard]] bool binary() const noexcept { return !text(); } + + /** + Selects binary mode for subsequent messages. + @param value Whether subsequent messages are binary. + */ + void binary(bool value) noexcept { text(!value); } + + /** + Returns the last close status and reason exposed by the browser. + @return The most recently observed close reason. + */ + [[nodiscard]] const close_reason& reason() const noexcept { return state_->reason; } + + /** + Sets the largest decoded message accepted from the browser. + @param value Maximum decoded message bytes; the default is 16 MiB. + */ + void read_message_max(std::size_t value) noexcept { state_->maximum = value; } + + /** + Returns the maximum accepted decoded message size. + @return The maximum accepted message bytes. + */ + [[nodiscard]] std::size_t read_message_max() const noexcept { return state_->maximum; } + + /** + Accepts the browser-owned fragmentation setting. + */ + void auto_fragment(bool /*unused*/) noexcept {} + + /** + Reports that fragmentation is owned by the browser. + @return True, because browser framing is not application-controlled. + */ + [[nodiscard]] bool auto_fragment() const noexcept { return true; } + + /** + Accepts a compatibility buffer hint without changing browser buffering. + */ + void write_buffer_bytes(std::size_t /*unused*/) noexcept {} + + /** + Returns the compatibility write-buffer hint. + @return The compatibility value 4096. + */ + [[nodiscard]] std::size_t write_buffer_bytes() const noexcept { return 4096; } + + /** + Accepts browser-owned compression negotiation options. + */ + void set_option(const permessage_deflate& /*unused*/) noexcept {} + + /** + Records timeout settings for subsequent host operations. + @param value Options to retain for subsequent operations. + */ + void set_option(const stream_base::timeout& value) { state_->timeout = value; } + + /** + Sets the byte limits enforced for outgoing and unread messages. + @param value Options to retain for subsequent operations. + */ + void set_option(queue_limits value) { state_->limits = value; } + + /** + Stores a request decorator using the stream allocator. + @tparam Function Callable stored for request decoration or control notification. + @param value Options to retain for subsequent operations. + */ + template + void set_option(stream_base::decorator value) { + state_->decorator = std::allocate_shared>( + detail::browser::owning_allocator(state_->resource), + std::move(value.function)); + } + + /** + Installs the callback notified of browser-visible close events. + @tparam Function Callable stored for request decoration or control notification. + @param function Callable receiving the control frame kind and payload. + */ + template + void control_callback(Function function) { + state_->control = std::allocate_shared>( + detail::browser::owning_allocator(state_->resource), std::move(function)); + } + + /** + Opens a browser WebSocket using the recorded authority and request target. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param host Hostname to match against the recorded destination authority. + @param target Origin-form path and query for the browser URL. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_handshake(boost::beast::string_view host, boost::beast::string_view target, + Token&& token) { + return boost::asio::async_initiate( + [this, host = std::pmr::string(host, state_->resource.get()), + target = std::pmr::string(target, state_->resource.get())](auto handler) { + auto& state = *state_; + auto const& record = get_lowest_layer(next_); + ec_type ec = detail::browser::unsupported(!record.authority_matches(host) || + state.timeout.keep_alive_pings); + if (!record.is_open()) { + ec = make_error_code(browser_errc::no_host); + } + if (state.handshake || state.opened || state.read || state.close) { + ec = boost::asio::error::already_started; + } + const emscripten::val protocols = this->protocols(ec); + if (ec) { + detail::browser::post(get_executor(), std::move(handler), ec); + return; + } + state.begin_connection(); + bind(); + detail::browser::start( + state.handshake, get_executor(), std::move(handler), + [](ec_type&, std::size_t&) {}, + boost::asio::cancellation_type::terminal | + boost::asio::cancellation_type::partial, + [state = state_] { state->invalidate(boost::asio::error::operation_aborted); }); + state.key = state.bridge->add(state); + auto const url = detail::browser::js_string(record.url(target, true)); + const emscripten::val result = emscripten::val::take_ownership( + webcpp_beast_open(url.as_handle(), protocols.as_handle(), + state.bridge->function(state.key).as_handle())); + const auto failure = result["error"].as(); + if (failure) { + state.handshake->complete(make_error_code(static_cast(failure))); + state.detach(); + return; + } + state.socket = result["socket"]; + arm(true); + }, + token); + } + + /** + Receives one complete WebSocket message into a dynamic buffer. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + Cancellation leaves queued messages available for a subsequent read. + Only one read may be outstanding, and the destination must outlive completion. + @tparam DynamicBuffer DynamicBuffer type receiving message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param buffer Dynamic buffer receiving message bytes and retained until completion. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_read(DynamicBuffer& buffer, Token&& token) { + return async_read_some(buffer, std::numeric_limits::max(), + std::forward(token)); + } + + /** + Receives part of one queued WebSocket message. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + Cancellation leaves queued messages available for a subsequent read. + Only one read may be outstanding, and the destination must outlive completion. + @tparam DynamicBuffer DynamicBuffer type receiving message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param buffer Dynamic buffer receiving message bytes and retained until completion. + @param maximum Maximum message bytes to append in this read. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_read_some(DynamicBuffer& buffer, std::size_t maximum, Token&& token) { + return boost::asio::async_initiate( + [this, &buffer, maximum](auto handler) { + if (state_->read) { + detail::browser::post(get_executor(), std::move(handler), + ec_type(boost::asio::error::already_started), + std::size_t{}); + return; + } + detail::browser::start( + state_->read, get_executor(), std::move(handler), + [state = state_, &buffer, maximum](ec_type& ec, std::size_t& count) { + if (ec) { + return; + } + auto const& message = state->messages.front(); + const auto size = std::min(maximum, message.bytes.size() - message.offset); + if (size > buffer.max_size() - buffer.size()) { + ec = boost::asio::error::no_buffer_space; + return; + } + count = state->copy(buffer.prepare(size), size); + buffer.commit(count); + }, + boost::asio::cancellation_type::all, + [state = state_] { state->cancel_read(); }); + if (!state_->messages.empty()) { + state_->read->complete(); + } else if (state_->failure) { + state_->read->complete(state_->failure); + } else if (!state_->opened) { + state_->read->complete(boost::asio::error::not_connected); + } else { + arm(); + } + }, + token); + } + + /** + Receives part of one queued WebSocket message. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + Cancellation leaves queued messages available for a subsequent read. + Only one read may be outstanding, and the destination must outlive completion. + @tparam Buffers MutableBufferSequence receiving response or message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param buffers Buffer sequence whose storage remains valid until completion. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_read_some(const Buffers& buffers, Token&& token) { + return boost::asio::async_initiate( + [this, buffers](auto handler) { + if (state_->read) { + detail::browser::post(get_executor(), std::move(handler), + ec_type(boost::asio::error::already_started), + std::size_t{}); + return; + } + detail::browser::start( + state_->read, get_executor(), std::move(handler), + [state = state_, buffers](ec_type& ec, std::size_t& count) { + if (!ec) { + count = state->copy(buffers, boost::asio::buffer_size(buffers)); + } + }, + boost::asio::cancellation_type::all, + [state = state_] { state->cancel_read(); }); + if (!state_->messages.empty()) { + state_->read->complete(); + } else if (state_->failure) { + state_->read->complete(state_->failure); + } else if (!state_->opened) { + state_->read->complete(boost::asio::error::not_connected); + } else { + arm(); + } + }, + token); + } + + /** + Buffers a message fragment and submits the assembled final message. + + Success means the browser accepted the bytes into its queue, not that the peer read them. + Exceeding queue_limits::send closes the connection with browser_errc::send_limit. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @param fin Whether this fragment finishes the message and submits it to the browser. + @param buffers Buffer sequence whose storage remains valid until completion. + @param ec Receives the operation error, or is cleared on success. + @return The number of input bytes accepted, or zero on failure. + */ + template + std::size_t write_some(bool fin, const Buffers& buffers, ec_type& ec) { + const auto count = boost::asio::buffer_size(buffers); + auto& state = *state_; + ec.clear(); + if (!state.opened) { + ec = boost::asio::error::not_connected; + return 0; + } + const auto queued = static_cast(state.socket["bufferedAmount"].as()); + if (queued > state.limits.send || state.fragments.size() > state.limits.send - queued || + count > state.limits.send - queued - state.fragments.size()) { + ec = make_error_code(browser_errc::send_limit); + state.failure = ec; + state.abort_socket(); + return 0; + } + const auto old = state.fragments.size(); + state.fragments.resize(old + count); + boost::asio::buffer_copy(boost::asio::buffer(state.fragments.data() + old, count), buffers); + if (fin) { + if (webcpp_beast_send(state.socket.as_handle(), state.fragments.data(), + state.fragments.size(), state.send_text)) { + ec = boost::asio::error::connection_reset; + } + state.fragments.clear(); + } + return ec ? 0 : count; + } + + /** + Submits a complete message to the browser send queue. + + Success means the browser accepted the bytes into its queue, not that the peer read them. + Exceeding queue_limits::send closes the connection with browser_errc::send_limit. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @param buffers Buffer sequence whose storage remains valid until completion. + @param ec Receives the operation error, or is cleared on success. + @return The number of input bytes accepted, or zero on failure. + */ + template + std::size_t write(const Buffers& buffers, ec_type& ec) { + return write_some(true, buffers, ec); + } + + /** + Submits a complete message to the browser send queue. + + Success means the browser accepted the bytes into its queue, not that the peer read them. + Exceeding queue_limits::send closes the connection with browser_errc::send_limit. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @param buffers Buffer sequence whose storage remains valid until completion. + @return The number of input bytes accepted, or zero on failure. + */ + template + std::size_t write(const Buffers& buffers) { + ec_type ec; + const auto n = write(buffers, ec); + detail::browser::throw_error(ec); + return n; + } + + /** + Buffers a message fragment and submits the assembled final message. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + Success means the browser accepted the bytes into its queue, not that the peer read them. + Exceeding queue_limits::send closes the connection with browser_errc::send_limit. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param fin Whether this fragment finishes the message and submits it to the browser. + @param buffers Buffer sequence whose storage remains valid until completion. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_write_some(bool fin, const Buffers& buffers, Token&& token) { + return boost::asio::async_initiate( + [this, fin, buffers](auto handler) { + ec_type ec; + auto count = write_some(fin, buffers, ec); + detail::browser::post(get_executor(), std::move(handler), ec, count); + }, + token); + } + + /** + Submits a complete message to the browser send queue. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code, std::size_t)`. + Success means the browser accepted the bytes into its queue, not that the peer read them. + Exceeding queue_limits::send closes the connection with browser_errc::send_limit. + @tparam Buffers ConstBufferSequence providing request or message bytes. + @tparam Token Asio completion token selecting the asynchronous result type. + @param buffers Buffer sequence whose storage remains valid until completion. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_write(const Buffers& buffers, Token&& token) { + return async_write_some(true, buffers, std::forward(token)); + } + + /** + Performs the browser closing handshake and waits for its close event. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param reason Close code and UTF-8 reason passed to the browser. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_close(close_reason reason, Token&& token) { + return boost::asio::async_initiate( + [this, reason](auto handler) mutable { + auto ec = detail::browser::unsupported(reason.code != 1000 && + (reason.code < 3000 || reason.code > 4999)); + if (state_->close) { + ec = boost::asio::error::already_started; + } + if (!state_->opened) { + ec = boost::asio::error::not_connected; + } + if (ec) { + detail::browser::post(get_executor(), std::move(handler), ec); + return; + } + if (reason.code != 1000 && (reason.code < 3000 || reason.code > 4999)) { + reason.code = 1000; + } + detail::browser::start( + state_->close, get_executor(), std::move(handler), + [](ec_type&, std::size_t&) {}, + boost::asio::cancellation_type::terminal | + boost::asio::cancellation_type::partial, + [] {}); + webcpp_beast_close(state_->socket.as_handle(), reason.code, + detail::browser::js_string(reason.reason).as_handle()); + arm(); + }, + token); + } + + /** + Completes according to the unsupported-operation policy for browser-owned control frames. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_ping(const ping_data& /*unused*/, Token&& token) { + return boost::asio::async_initiate( + [this](auto handler) { + detail::browser::post(get_executor(), std::move(handler), + detail::browser::unsupported()); + }, + token); + } + + /** + Completes according to the unsupported-operation policy for browser-owned control frames. + + The completion is posted through the associated executor and allocator. + The completion signature is `void(error_code)`. + @tparam Token Asio completion token selecting the asynchronous result type. + @param data Control payload, which the browser cannot transmit explicitly. + @param token Completion token controlling handler construction and the return type. + @return The result determined by the completion token. + */ + template + auto async_pong(const ping_data& data, Token&& token) { + return async_ping(data, std::forward(token)); + } + + /** + Opens a browser WebSocket using the recorded authority and request target. + + This synchronous facade suspends the main stack through JSPI or Asyncify. + Calling it from an executing handler returns operation_not_supported. + @param host Hostname to match against the recorded destination authority. + @param target Origin-form path and query for the browser URL. + @param ec Receives the operation error, or is cleared on success. + */ + void handshake(boost::beast::string_view host, boost::beast::string_view target, ec_type& ec) { + sync([&](auto handler) { async_handshake(host, target, std::move(handler)); }, ec); + } + + /** + Opens a browser WebSocket using the recorded authority and request target. + + This synchronous facade suspends the main stack through JSPI or Asyncify. + Calling it from an executing handler returns operation_not_supported. + @param host Hostname to match against the recorded destination authority. + @param target Origin-form path and query for the browser URL. + */ + void handshake(boost::beast::string_view host, boost::beast::string_view target) { + ec_type ec; + handshake(host, target, ec); + detail::browser::throw_error(ec); + } + + /** + Performs the browser closing handshake and waits for its close event. + + This synchronous facade suspends the main stack through JSPI or Asyncify. + Calling it from an executing handler returns operation_not_supported. + @param reason Close code and UTF-8 reason passed to the browser. + @param ec Receives the operation error, or is cleared on success. + */ + void close(close_reason reason, ec_type& ec) { + sync([&](auto handler) { async_close(reason, std::move(handler)); }, ec); + } + + /** + Performs the browser closing handshake and waits for its close event. + + This synchronous facade suspends the main stack through JSPI or Asyncify. + Calling it from an executing handler returns operation_not_supported. + @param reason Close code and UTF-8 reason passed to the browser. + */ + void close(close_reason reason) { + ec_type ec; + close(reason, ec); + detail::browser::throw_error(ec); + } + + /** + Receives one complete WebSocket message into a dynamic buffer. + + This synchronous facade suspends the main stack through JSPI or Asyncify. + Calling it from an executing handler returns operation_not_supported. + @tparam Buffer Dynamic buffer type retained for Beast call compatibility. + @param buffer Dynamic buffer receiving message bytes and retained until completion. + @param ec Receives the operation error, or is cleared on success. + @return The number of bytes delivered to the destination. + */ + template + std::size_t read(Buffer& buffer, ec_type& ec) { + std::size_t n = 0; + sync( + [&](auto handler) { + async_read(buffer, [&, handler = std::move(handler)](ec_type error, + std::size_t count) mutable { + n = count; + handler(error); + }); + }, + ec); + return n; + } + + /** + Receives one complete WebSocket message into a dynamic buffer. + + This synchronous facade suspends the main stack through JSPI or Asyncify. + Calling it from an executing handler returns operation_not_supported. + @tparam Buffer Dynamic buffer type retained for Beast call compatibility. + @param buffer Dynamic buffer receiving message bytes and retained until completion. + @return The number of bytes delivered to the destination. + */ + template + std::size_t read(Buffer& buffer) { + ec_type ec; + const auto n = read(buffer, ec); + detail::browser::throw_error(ec); + return n; + } +}; +} // namespace websocket +} +} // namespace webcpp::beast +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/config.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/config.hpp new file mode 100644 index 0000000..96c11b0 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/config.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_CONFIG_HPP +#define WEBCPP_BEAST_CONFIG_HPP + +#include + +#ifdef __MRDOCS__ +/** + Records the facade's exception policy for host-adapter implementations. + + Defined automatically when webcpp has no exceptions, or explicitly by the application. + Host adapters report recoverable failures through error codes. Inherited + upstream overloads and data types retain Boost's own exception configuration. +*/ +#define WEBCPP_BEAST_NO_EXCEPTIONS +#undef WEBCPP_BEAST_NO_EXCEPTIONS +/** Reports unsupported host operations as errors, the default policy. */ +#define WEBCPP_BEAST_UNSUPPORTED_ERROR +#undef WEBCPP_BEAST_UNSUPPORTED_ERROR +/** Allows documented unsupported settings to be ignored by host adapters. */ +#define WEBCPP_BEAST_UNSUPPORTED_IGNORE +#undef WEBCPP_BEAST_UNSUPPORTED_IGNORE +#endif + +#if !defined(WEBCPP_HAS_EXCEPTIONS) && !defined(WEBCPP_BEAST_NO_EXCEPTIONS) +#define WEBCPP_BEAST_NO_EXCEPTIONS +#endif + +#if defined(WEBCPP_BEAST_UNSUPPORTED_ERROR) && defined(WEBCPP_BEAST_UNSUPPORTED_IGNORE) +#error "Select only one WEBCPP_BEAST_UNSUPPORTED_ERROR or WEBCPP_BEAST_UNSUPPORTED_IGNORE policy" +#elif !defined(WEBCPP_BEAST_UNSUPPORTED_ERROR) && !defined(WEBCPP_BEAST_UNSUPPORTED_IGNORE) +/** Reports unsupported host operations as errors, the default policy. */ +#define WEBCPP_BEAST_UNSUPPORTED_ERROR +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/core.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/core.hpp new file mode 100644 index 0000000..b39722d --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/core.hpp @@ -0,0 +1,66 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_CORE_HPP +#define WEBCPP_BEAST_CORE_HPP + +#include + +#include + +#include // lint-world: binds handler arguments only +#include // lint-world: buffer-sequence views only +#include // lint-world: copies memory buffers only +#include // lint-world: error codes only +#include // lint-world: file access mode enumeration +#include // lint-world: memory buffers only +#include // lint-world: fixed-capacity memory buffers +#include // lint-world: buffer output formatting only +#include // lint-world: memory buffers only +#include // lint-world: writes into memory buffers +#include // lint-world: memory buffers only +#include // lint-world: string comparison only + +namespace webcpp::beast { +/** Upstream contiguous dynamic buffer with an application-supplied allocator. */ +using boost::beast::basic_flat_buffer; +/** Upstream segmented dynamic buffer with an application-supplied allocator. */ +using boost::beast::basic_multi_buffer; +/** Binds leading arguments to a completion handler. */ +using boost::beast::bind_front_handler; +/** Returns a view of the first bytes of a buffer sequence. */ +using boost::beast::buffers_prefix; +/** Copies a buffer sequence to a string. */ +using boost::beast::buffers_to_string; +/** Upstream common stream errors, including timeout. */ +using boost::beast::error; +/** The error-code type used by Beast operations. */ +using boost::beast::error_code; +/** Upstream generic error conditions. */ +namespace errc = boost::beast::errc; +/** Upstream file-opening modes for explicit file bodies. */ +using boost::beast::file_mode; +/** Upstream contiguous dynamic buffer. */ +using boost::beast::flat_buffer; +/** Upstream contiguous buffer with fixed capacity. */ +using boost::beast::flat_static_buffer; +/** Compares strings with HTTP's ASCII case-insensitive rules. */ +using boost::beast::iequals; +/** Formats a buffer sequence for diagnostic output. */ +using boost::beast::make_printable; +/** Upstream segmented dynamic buffer. */ +using boost::beast::multi_buffer; +/** Creates an output stream that appends to a dynamic buffer. */ +using boost::beast::ostream; +/** Upstream fixed-capacity buffer. */ +using boost::beast::static_buffer; +/** Upstream non-owning string view. */ +using boost::beast::string_view; +/** Upstream exception type for explicitly throwing application code. */ +using boost::beast::system_error; +} // namespace webcpp::beast + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/detail/socket_algorithms.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/detail/socket_algorithms.hpp new file mode 100644 index 0000000..f21edcc --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/detail/socket_algorithms.hpp @@ -0,0 +1,49 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_DETAIL_SOCKET_ALGORITHMS_HPP +#define WEBCPP_BEAST_DETAIL_SOCKET_ALGORITHMS_HPP + +#include + +#if defined(WEBCPP_TARGET_NATIVE) || defined(WEBCPP_TARGET_WASIP3) +#include // lint-world: composed operation support +#include // lint-world: explicitly selected socket backend +#include // lint-world: explicitly selected stream writes +#include // lint-world: TLS detection over a byte stream +#include // lint-world: stream rate policies +#include // lint-world: protocol role enumeration +#include // lint-world: stream concepts +#include // lint-world: explicit socket message writing + +namespace webcpp::beast { +/** Base for an allocator-aware composed asynchronous operation. */ +using boost::beast::async_base; +/** Detects a TLS ClientHello without consuming it. */ +using boost::beast::async_detect_ssl; +/** Writes a buffer generator to an asynchronous byte stream. */ +using boost::beast::async_write; +/** Upstream socket stream with deadlines and rate policies. */ +using boost::beast::basic_stream; +/** Upstream executor type customization. */ +using boost::beast::executor_type; +/** Tests whether a type satisfies Beast's asynchronous stream requirements. */ +using boost::beast::is_async_stream; +/** Identifies a protocol's client or server role. */ +using boost::beast::role_type; +/** Socket rate policy that does not limit throughput. */ +using boost::beast::unlimited_rate_policy; +/** Writes a buffer generator to a synchronous byte stream. */ +using boost::beast::write; +} // namespace webcpp::beast + +namespace webcpp::beast::http { +/** Type-erased message serializer for the explicitly selected socket backend. */ +using boost::beast::http::message_generator; +} // namespace webcpp::beast::http +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http.hpp new file mode 100644 index 0000000..05e4ab2 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http.hpp @@ -0,0 +1,78 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_HTTP_HPP +#define WEBCPP_BEAST_HTTP_HPP + +#include + +#include // lint-world: caller-owned memory buffers only +#include // lint-world: memory buffers only +#include // lint-world: a body without a payload +#include // lint-world: explicit file-backed HTTP bodies +#include // lint-world: HTTP message data only +#include // lint-world: parses caller-supplied bytes only +#include // lint-world: serializes into caller-owned buffers +#include // lint-world: memory buffers only + +namespace webcpp::beast::http { +/** Upstream body backed by a selected dynamic buffer type. */ +using boost::beast::http::basic_dynamic_body; +/** Upstream HTTP fields with an application-supplied allocator. */ +using boost::beast::http::basic_fields; +/** Upstream string body with an application-supplied allocator. */ +using boost::beast::http::basic_string_body; +/** Upstream body that reads or writes caller-owned buffers. */ +using boost::beast::http::buffer_body; +/** Upstream dynamically buffered body. */ +using boost::beast::http::dynamic_body; +/** Upstream body for messages without a payload. */ +using boost::beast::http::empty_body; +/** Upstream HTTP parser and serializer errors. */ +using boost::beast::http::error; +/** Upstream HTTP field names. */ +using boost::beast::http::field; +/** Upstream HTTP fields. */ +using boost::beast::http::fields; +/** Upstream file-backed message body. */ +using boost::beast::http::file_body; +/** Upstream request or response header. */ +using boost::beast::http::header; +/** Upstream HTTP request or response message. */ +using boost::beast::http::message; +/** Returns the conventional reason phrase for a status code. */ +using boost::beast::http::obsolete_reason; +/** Upstream incremental message parser. */ +using boost::beast::http::parser; +/** Upstream HTTP request. */ +using boost::beast::http::request; +/** Upstream HTTP request header. */ +using boost::beast::http::request_header; +/** Upstream incremental request parser. */ +using boost::beast::http::request_parser; +/** Upstream incremental request serializer. */ +using boost::beast::http::request_serializer; +/** Upstream HTTP response. */ +using boost::beast::http::response; +/** Upstream HTTP response header. */ +using boost::beast::http::response_header; +/** Upstream incremental response parser. */ +using boost::beast::http::response_parser; +/** Upstream incremental response serializer. */ +using boost::beast::http::response_serializer; +/** Upstream incremental message serializer. */ +using boost::beast::http::serializer; +/** Upstream HTTP status codes. */ +using boost::beast::http::status; +/** Upstream string message body. */ +using boost::beast::http::string_body; +/** Parses a method name while preserving upstream method semantics. */ +using boost::beast::http::string_to_verb; +/** Upstream HTTP methods. */ +using boost::beast::http::verb; +} // namespace webcpp::beast::http + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http/read.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http/read.hpp new file mode 100644 index 0000000..6dfbd0b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http/read.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_HTTP_READ_HPP +#define WEBCPP_BEAST_HTTP_READ_HPP + +#include + +#include // lint-world: explicit HTTP byte-stream operations + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::http { +/** Upstream HTTP read operation on a byte stream. */ +using boost::beast::http::read; +/** Upstream HTTP read header operation on a byte stream. */ +using boost::beast::http::read_header; +/** Upstream HTTP read some operation on a byte stream. */ +using boost::beast::http::read_some; +/** Upstream HTTP async read operation on a byte stream. */ +using boost::beast::http::async_read; +/** Upstream HTTP async read header operation on a byte stream. */ +using boost::beast::http::async_read_header; +/** Upstream HTTP async read some operation on a byte stream. */ +using boost::beast::http::async_read_some; +} // namespace webcpp::beast::http + +#ifdef WEBCPP_TARGET_EMSCRIPTEN +#include +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http/write.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http/write.hpp new file mode 100644 index 0000000..bca5b1a --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/http/write.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_HTTP_WRITE_HPP +#define WEBCPP_BEAST_HTTP_WRITE_HPP + +#include + +#include // lint-world: explicit HTTP byte-stream operations + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast::http { +/** Upstream HTTP write operation on a byte stream. */ +using boost::beast::http::write; +/** Upstream HTTP write header operation on a byte stream. */ +using boost::beast::http::write_header; +/** Upstream HTTP write some operation on a byte stream. */ +using boost::beast::http::write_some; +/** Upstream HTTP async write operation on a byte stream. */ +using boost::beast::http::async_write; +/** Upstream HTTP async write header operation on a byte stream. */ +using boost::beast::http::async_write_header; +/** Upstream HTTP async write some operation on a byte stream. */ +using boost::beast::http::async_write_some; +} // namespace webcpp::beast::http + +#ifdef WEBCPP_TARGET_EMSCRIPTEN +#include +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/ssl.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/ssl.hpp new file mode 100644 index 0000000..3e2bf39 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/ssl.hpp @@ -0,0 +1,58 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_SSL_HPP +#define WEBCPP_BEAST_SSL_HPP + +#include + +#if defined(WEBCPP_TARGET_NATIVE) || defined(WEBCPP_TARGET_WASIP3) +#include + +#include // lint-world: explicit guest-owned TLS stream +#include + +#include +#include +#include + +namespace webcpp::beast { +/** Upstream TLS stream, linked through the explicit guest TLS target. */ +using boost::beast::ssl_stream; + +/** + Sets the TLS Server Name Indication hostname on a guest-owned TLS stream. + + @tparam NextLayer The TLS stream's underlying stream type. + @param stream The TLS stream before its client handshake. + @param host The nonempty hostname, at most 255 bytes, without embedded NUL. + @return Success, invalid_argument for an invalid length or embedded NUL, or an OpenSSL error. + @note Copies the view before calling OpenSSL, so its storage need not be NUL-terminated. + This sets SNI only; peer and hostname verification remain the application's TLS policy. + Host-managed HTTPS uses a separate backend and does not call this helper. +*/ +template +[[nodiscard]] boost::system::result set_server_name(ssl_stream& stream, + std::string_view host) { + if (host.empty() || host.size() > 255 || host.find('\0') != std::string_view::npos) { + return boost::system::errc::make_error_code(boost::system::errc::invalid_argument); + } + std::array name{}; + std::ranges::copy(host, name.begin()); + if (SSL_set_tlsext_host_name(stream.native_handle(), name.data()) != 1) { + return boost::system::error_code(static_cast(ERR_get_error()), + boost::asio::error::get_ssl_category()); + } + return {}; +} +} // namespace webcpp::beast +#elif defined(WEBCPP_TARGET_EMSCRIPTEN) +#include +#else +#error "Guest-owned Beast TLS currently requires native or WASIp3 and /webcpp/beast//tls" +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/tcp_stream.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/tcp_stream.hpp new file mode 100644 index 0000000..e5a3557 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/tcp_stream.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_TCP_STREAM_HPP +#define WEBCPP_BEAST_TCP_STREAM_HPP + +#include + +#if defined(WEBCPP_TARGET_NATIVE) || defined(WEBCPP_TARGET_WASIP3) +#include // lint-world: stream-layer access +#include // lint-world: explicit guest TCP backend +#include + +namespace webcpp::beast { +/** Finds the bottom layer of a stream stack. */ +using boost::beast::get_lowest_layer; +/** + Upstream TCP stream with operation deadlines on the selected Asio socket backend. + + Link `/webcpp/beast//sockets` for WASIp3's Asio overlay. Host HTTP does not use this type. +*/ +using boost::beast::tcp_stream; +} // namespace webcpp::beast +#elif defined(WEBCPP_TARGET_EMSCRIPTEN) +#include +#else +#error "The Beast socket backend currently requires native or WASIp3; host transports are separate" +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/async.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/async.hpp new file mode 100644 index 0000000..14aa6af --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/async.hpp @@ -0,0 +1,839 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_WASI_ASYNC_HPP +#define WEBCPP_BEAST_WASI_ASYNC_HPP +#include + +#include +#if defined(WEBCPP_WASI_HTTP_P2) || defined(WEBCPP_WASI_HTTP_P3) +#include // lint-world: handler allocation association +#include // lint-world: caller cancellation +#include // lint-world: completion executor association +#include // lint-world: reactor-free completion tokens +#include // lint-world: completion allocation association +#include // lint-world: completion executor properties +#include // lint-world: associated outstanding work +#include // lint-world: non-inline completion dispatch +#include +#include +#include +#include + +namespace webcpp::beast::wasi { +namespace detail { +/** One intrusive operation in a reactor-free host readiness queue. */ +struct host_operation { + /** Next operation in the intrusive readiness queue. */ + host_operation* next = nullptr; + /** Advances one bounded readiness step and reports final completion. */ + virtual bool poll() = 0; + + /** Takes sole ownership of a completed node and releases its storage. */ + virtual void complete() { destroy(); } + + /** Destroys this node with its retained associated allocator. */ + virtual void destroy() noexcept = 0; + /** Releases pending host state and retained handler associations. */ + virtual ~host_operation() = default; +}; + +/** Constructs allocated state with cleanup if its constructor throws. */ +template +T* allocate_host_state(Allocator& allocator, Args&&... args) { + auto* memory = std::allocator_traits::allocate(allocator, 1); + auto const release = [&allocator](T* value) { + std::allocator_traits::deallocate(allocator, value, 1); + }; + std::unique_ptr guard(memory, release); + std::allocator_traits::construct(allocator, memory, std::forward(args)...); + return guard.release(); +} + +/** Retains outstanding work on either legacy or property-based associated executors. */ +template +struct host_work { + /** Selects tracked work only for executors that implement property-based execution. */ + static auto retain(const Executor& value) { + if constexpr (requires { value.on_work_started(); }) { + return value; + } else { + return boost::asio::prefer(value, boost::asio::execution::outstanding_work_t::tracked); + } + } + + /** Executor type with outstanding work retained where supported. */ + using tracked_type = decltype(retain(std::declval())); + /** Associated executor retained through completion scheduling. */ + tracked_type executor; + + /** Retains associated executor work for the pending operation. */ + explicit host_work(const Executor& value) : executor(retain(value)) { + if constexpr (requires { executor.on_work_started(); }) { + executor.on_work_started(); + } + } + + /** Releases retained outstanding executor work. */ + ~host_work() { + if constexpr (requires { executor.on_work_finished(); }) { + executor.on_work_finished(); + } + } +}; + +/** Allocator-owned posted function with no transport operation. */ +template +struct host_job final : host_operation { + /** Allocator rebound to this operation node. */ + using storage_allocator_type = + std::allocator_traits::template rebind_alloc; + /** Posted function retained until its queued invocation. */ + Function function; + /** Associated allocator retained for matching deallocation. */ + storage_allocator_type allocator; + + /** Constructs retained transfer state from caller-owned resources. */ + host_job(Function value, storage_allocator_type alloc) + : function(std::move(value)), allocator(alloc) {} + + /** Reports queued work ready without invoking its callback. */ + bool poll() override { return true; } + + /** Releases associated storage before invoking the moved callback. */ + void complete() override { + const auto release = [](host_job* value) { value->destroy(); }; + std::unique_ptr guard(this, release); + // Some handler types have a mutable call operator. + // NOLINTNEXTLINE(misc-const-correctness) + auto value = std::move(function); + guard.reset(); + value(); + } + + /** Destroys this node with its retained associated allocator. */ + void destroy() noexcept override { + auto copy = allocator; + std::allocator_traits::destroy(copy, this); + std::allocator_traits::deallocate(copy, this, 1); + } +}; +} // namespace detail + +/** Drives bounded host readiness operations without a socket reactor or worker thread. + + poll performs one bounded scan and never waits for data. run yields the current + component task between scans. Callers keep messages and resources alive until + their completion handler runs. Posted completion storage is released before + invoking the handler, so its associated allocator resource may be released there. + Destroying the context abandons pending handlers + and cancels their host resource operations before releasing state. */ +class http_context { + detail::host_operation* first_ = nullptr; + detail::host_operation* last_ = nullptr; + std::size_t size_ = 0; + std::size_t work_ = 0; + +public: + /** An executor that queues work on its owning host context. */ + class executor_type { + http_context* context_; + + public: + /** Refers to one host context. + @param context Owning execution context. */ + explicit executor_type(http_context& context) noexcept : context_(&context) {} + + /** Returns the owning context. + @return The owning host context. */ + [[nodiscard]] http_context& context() const noexcept { return *context_; } + + /** Retains externally associated outstanding work. */ + void on_work_started() const noexcept { ++context_->work_; } + + /** Releases externally associated outstanding work. */ + void on_work_finished() const noexcept { --context_->work_; } + + /** Queues a function using the supplied allocator. + @tparam Function Nullary callable. + @tparam Allocator State allocator. + @param function Work to execute on a subsequent poll. + @param allocator Allocator used for the queue node. */ + template + void post(Function&& function, const Allocator& allocator) const { + using job = detail::host_job, Allocator>; + typename job::storage_allocator_type alloc(allocator); + context_->enqueue( + detail::allocate_host_state(alloc, std::forward(function), alloc)); + } + + /** Queues a continuation without inline invocation. + @tparam Function Nullary callable. + @tparam Allocator State allocator. + @param function Work to execute. + @param allocator Allocator for the queue node. */ + template + void defer(Function&& function, const Allocator& allocator) const { + post(std::forward(function), allocator); + } + + /** Queues dispatch work without inline invocation. + @tparam Function Nullary callable. + @tparam Allocator State allocator. + @param function Work to execute. + @param allocator Allocator for the queue node. */ + template + void dispatch(Function&& function, const Allocator& allocator) const { + post(std::forward(function), allocator); + } + + /** Compares context identity. + @param other Executor to compare. + @return Whether the executors share a context. */ + bool operator==(const executor_type& other) const noexcept { + return context_ == other.context_; + } + }; + + /** Constructs an empty host context. */ + http_context() = default; + /** Forbids duplicated ownership of pending operations. */ + http_context(const http_context&) = delete; + /** Forbids duplicated ownership of pending operations. */ + http_context& operator=(const http_context&) = delete; + + /** Cancels and releases pending operations without invoking abandoned handlers. */ + ~http_context() { + while (first_ != nullptr) { + auto* value = first_; + first_ = value->next; + value->destroy(); + } + } + + /** Returns the executor of this context. + @return A borrowing executor. */ + executor_type get_executor() noexcept { return executor_type(*this); } + + /** Takes ownership of an intrusive readiness operation. + @param value Allocator-owned operation, with its matching destroy function. */ + void enqueue(detail::host_operation* value) { + value->next = nullptr; + if (last_ != nullptr) { + last_->next = value; + } else { + first_ = value; + } + last_ = value; + ++size_; + } + + /** Polls each initially queued operation once without waiting for readiness. + @return The number of completed operations or posted functions. */ + std::size_t poll() { + std::size_t completed = 0; + auto count = size_; + while (((count--) != 0u) && (first_ != nullptr)) { + auto* value = first_; + first_ = value->next; + --size_; + if (first_ == nullptr) { + last_ = nullptr; + } + auto const destroy = [](detail::host_operation* operation) { operation->destroy(); }; + std::unique_ptr guard(value, destroy); + if (value->poll()) { + guard.release()->complete(); + ++completed; + } else { + enqueue(guard.release()); + } + } + return completed; + } + + /** Runs until no owned operation or associated work remains. + @return The number of completed operations or posted functions. */ + std::size_t run() { + std::size_t completed = 0; + while ((first_ != nullptr) || (work_ != 0u)) { + completed += poll(); + if ((first_ != nullptr) || (work_ != 0u)) { + webcpp::wasi::http::detail::yield_polling_task(); + } + } + return completed; + } +}; + +namespace detail { +/** Posts a completion to its associated executor without inline invocation. */ +template +void host_post(const Executor& executor, const Allocator& allocator, Function&& function) { + if constexpr (requires { executor.post(std::forward(function), allocator); }) { + executor.post(std::forward(function), allocator); + } else { + boost::asio::require(executor, boost::asio::execution::blocking_t::never) + .execute(boost::asio::bind_allocator(allocator, std::forward(function))); + } +} + +/** Owns handler-associated allocation, cancellation and completion dispatch. */ +template +struct host_async_operation final : host_operation { + /** Allocator rebound to this operation node. */ + using storage_allocator_type = std::allocator_traits< + boost::asio::associated_allocator_t>::template rebind_alloc; + /** Handler-associated executor with the host executor fallback. */ + using executor_type = boost::asio::associated_executor_t; + /** Associated allocator retained for matching deallocation. */ + storage_allocator_type allocator; + /** Completion handler retained until the operation finishes. */ + Handler handler; + /** Associated executor retained through completion scheduling. */ + executor_type executor; + /** Outstanding associated executor work retained through completion posting. */ + host_work work; + /** Associated cancellation slot disconnected before state release. */ + boost::asio::associated_cancellation_slot_t slot; + /** Cancellation observed on the component task. */ + bool cancelled = false; + /** Owned bounded-step transfer state. */ + State state; + + /** Constructs retained state and its handler associations. */ + template + host_async_operation(storage_allocator_type alloc, Handler value, http_context& context, + Args&&... args) + : allocator(alloc), + handler(std::move(value)), + executor(boost::asio::get_associated_executor(handler, context.get_executor())), + work(executor), + slot(boost::asio::get_associated_cancellation_slot(handler)), + state(std::forward(args)...) { + if (slot.is_connected()) { + slot.assign([this](boost::asio::cancellation_type type) { + if (type != boost::asio::cancellation_type::none) { + cancelled = true; + } + }); + } + } + + /** Releases pending host state and retained handler associations. */ + ~host_async_operation() override { + if (slot.is_connected()) { + slot.clear(); + } + } + + /** Advances one bounded readiness step and reports final completion. */ + bool poll() override { + boost::system::error_code error; + if (!state.poll(cancelled, error)) { + return false; + } + if (slot.is_connected()) { + slot.clear(); + } + auto const count = state.total; + auto const alloc = boost::asio::get_associated_allocator(handler); + host_post(executor, alloc, + [value = std::move(handler), error, count]() mutable { value(error, count); }); + return true; + } + + /** Destroys this node with its retained associated allocator. */ + void destroy() noexcept override { + auto alloc = allocator; + std::allocator_traits::destroy(alloc, this); + std::allocator_traits::deallocate(alloc, this, 1); + } +}; + +/** Allocates one composed operation through the completion handler's allocator. */ +template +void start_host_operation(http_context& context, Handler&& handler, Args&&... args) { + using operation = host_async_operation>; + typename operation::storage_allocator_type allocator( + boost::asio::get_associated_allocator(handler)); + context.enqueue(allocate_host_state(allocator, allocator, + std::forward(handler), context, + std::forward(args)...)); +} + +/** Keeps decoded-body state and a stable pending read buffer in one allocation. */ +template +struct host_read_message { + /** Caller-owned Beast message retained by reference. */ + http::message& message; + /** Optional trailer fields retained until body completion. */ + Trailers* trailers; + /** Copied body limit, cancellation predicate and deadline. */ + transfer_options options; + /** Stable bounded payload storage borrowed by pending host reads. */ + std::array buffer{}; + /** Caller-selected BodyReader retained across partial input. */ + std::optional reader; + /** Owned nonblocking host input task. */ + std::optional source; + /** Logical body payload bytes transferred so far. */ + std::size_t total = 0; + + /** Constructs retained transfer state from caller-owned resources. */ + host_read_message(http::message& value, Trailers* final_fields, + transfer_options limits) + : message(value), trailers(final_fields), options(limits) {} + + /** Acquires the host body and initializes the caller-selected body algorithm. */ + void start(host::body_reader body, boost::system::error_code& error) { + source.emplace(std::move(body)); + reader.emplace(message.base(), message.body()); + reader->init(boost::none, error); + } + + /** Advances one bounded readiness step and reports final completion. */ + bool poll(bool cancelled, boost::system::error_code& error) { + if (cancelled) { + error = error_code({.code = host::message_errc::cancelled}); + return true; + } + assert(source.has_value()); + assert(reader.has_value()); + host::message_error failure; + if (!source->eof()) { + std::size_t count = 0; + if (!source->read(buffer, count, options, failure)) { + return false; + } + error = error_code(failure); + if (error) { + return true; + } + total += reader->put(boost::asio::buffer(buffer.data(), count), error); + return static_cast(error); + } + if (!source->finish( + [&](std::string_view name, std::string_view value) { + if (trailers) { + trailers->insert(view(name), view(value)); + } + }, + options, failure)) { + return false; + } + error = error_code(failure); + if (!error) { + reader->finish(error); + } + return true; + } +}; + +/** Keeps BodyWriter buffers stable across nonblocking partial host writes. */ +template +struct host_write_message { + /** Caller-owned Beast message retained by reference. */ + http::message& message; + /** Copied body limit, cancellation predicate and deadline. */ + transfer_options options; + /** Optional trailer fields retained until body completion. */ + std::optional trailers; + /** Caller-selected BodyWriter retained across partial output. */ + std::optional writer; + /** Optional BodyWriter buffer sequence and continuation marker. */ + using chunk_type = decltype(std::declval().get( + std::declval())); + /** Current BodyWriter buffers retained until every byte is consumed. */ + chunk_type chunk; + /** Bytes already consumed from the current buffer sequence. */ + std::size_t offset = 0; + /** Whether only trailer completion remains. */ + bool ending = false; + /** Logical body payload bytes transferred so far. */ + std::size_t total = 0; + /** Owned nonblocking host output task. */ + std::optional target; + + /** Constructs retained transfer state from caller-owned resources. */ + host_write_message(http::message& value, transfer_options limits) + : message(value), options(limits) {} + + /** Acquires the host body and initializes the caller-selected body algorithm. */ + void start(host::body_writer body, const Trailers* final_fields, + boost::system::error_code& error) { + target.emplace(std::move(body)); + if (final_fields) { + trailers.emplace(copy_fields(*final_fields, error)); + } + if (error) { + return; + } + writer.emplace(message.base(), message.body()); + writer->init(error); + } + + /** Advances one bounded readiness step and reports final completion. */ + bool poll(bool cancelled, boost::system::error_code& error) { + if (cancelled) { + error = error_code({.code = host::message_errc::cancelled}); + return true; + } + error = error_code(options.check()); + if (error) { + return true; + } + assert(target.has_value()); + assert(writer.has_value()); + host::message_error failure; + if (ending) { + if (!target->finish(trailers ? &*trailers : nullptr, failure)) { + return false; + } + error = error_code(failure); + return true; + } + if (!chunk) { + chunk = writer->get(error); + offset = 0; + } + if (error) { + return true; + } + if (!chunk) { + ending = true; + return false; + } + std::size_t skipped = 0; + for (auto const buffer : boost::beast::buffers_range_ref(chunk->first)) { + if (skipped + buffer.size() <= offset) { + skipped += buffer.size(); + continue; + } + const auto start = offset - skipped; + std::string_view const bytes(static_cast(buffer.data()) + start, + buffer.size() - start); + std::size_t count = 0; + if (!target->write(bytes, count, options, failure)) { + return false; + } + offset += count; + total += count; + error = error_code(failure); + return static_cast(error); + } + ending = !chunk->second; + chunk.reset(); + return false; + } +}; + +/** Composes incoming metadata, decoded body and trailers. */ +template +struct host_receive_state { + /** Incoming request or response resource retained by this state. */ + host::incoming_request& incoming; + /** Bounded message-body transfer state. */ + host_read_message body; + /** Whether the transfer has acquired its host body resource. */ + bool started = false; + /** Logical body payload bytes transferred so far. */ + std::size_t total = 0; + + /** Constructs retained transfer state from caller-owned resources. */ + host_receive_state(host::incoming_request& source, http::request& request, + transfer_options options, Trailers* trailers) + : incoming(source), body(request, trailers, options) {} + + /** Advances one bounded readiness step and reports final completion. */ + bool poll(bool cancelled, boost::system::error_code& error) { + if (!started) { + if (cancelled) { + error = error_code({.code = host::message_errc::cancelled}); + return true; + } + auto& request = body.message; + request.version(11); + request.method_string(view(incoming.method())); + request.target(view(incoming.target())); + incoming.headers().for_each([&](std::string_view name, std::string_view value) { + request.insert(view(name), view(value)); + }); + if (!incoming.authority().empty() && request.find(http::field::host) == request.end()) { + request.set(http::field::host, view(incoming.authority())); + } + host::message_error failure; + auto source = incoming.consume(failure); + error = error_code(failure); + if (error) { + return true; + } + body.start(std::move(source), error); + started = true; + if (error) { + return true; + } + } + auto const done = body.poll(cancelled, error); + total = body.total; + return done; + } +}; + +/** Composes a single response commitment, bounded body writes and trailers. */ +template +struct host_send_state { + /** Response commitment capability consumed at most once. */ + host::response_out output; + /** Bounded message-body transfer state. */ + host_write_message body; + /** Optional trailer fields retained until body completion. */ + const Trailers* trailers; + /** Whether the transfer has acquired its host body resource. */ + bool started = false; + /** Logical body payload bytes transferred so far. */ + std::size_t total = 0; + + /** Constructs retained transfer state from caller-owned resources. */ + host_send_state(host::response_out out, http::response& response, + transfer_options options, const Trailers* fields) + : output(out), body(response, options), trailers(fields) {} + + /** Releases pending host state and retained handler associations. */ + ~host_send_state() { + if (!started) { + host::refuse_response(output); + } + } + + /** Advances one bounded readiness step and reports final completion. */ + bool poll(bool cancelled, boost::system::error_code& error) { + if (!started) { + if (cancelled) { + error = error_code({.code = host::message_errc::cancelled}); + return true; + } + auto fields = copy_fields(body.message.base(), error); + if (error) { + return true; + } + host::message_error failure; + auto target = host::commit_response(output, body.message.result_int(), + std::move(fields), failure); + started = true; + error = error_code(failure); + if (error) { + return true; + } + body.start(std::move(target), trailers, error); + if (error) { + return true; + } + } + auto const done = body.poll(cancelled, error); + total = body.total; + return done; + } +}; + +/** Composes outgoing headers, upload, response headers and decoded response body. */ +template +struct host_client_state { + /** Borrowed host HTTP scheme for the pending exchange. */ + std::string_view scheme; + /** Borrowed host authority for the pending exchange. */ + std::string_view authority; + /** Outgoing host exchange retained until upload and response finish. */ + host::outgoing_exchange exchange; + /** Incoming request or response resource retained by this state. */ + host::incoming_response incoming; + /** Bounded outgoing request-body state. */ + host_write_message upload; + /** Bounded incoming response-body state. */ + host_read_message download; + /** Response-header readiness operation borrowing the exchange. */ + host::response_task response; + /** Optional caller-owned request trailers. */ + const Trailers* upload_trailers; + /** Current upload, response-header or download stage. */ + unsigned stage = 0; + /** Logical body payload bytes transferred so far. */ + std::size_t total = 0; + + /** Constructs retained transfer state from caller-owned resources. */ + host_client_state(client& connection, http::request& request, + http::response& reply, transfer_options options, + Trailers* response_trailers, const Trailers* request_trailers) + : scheme(connection.scheme()), + authority(connection.authority()), + upload(request, options), + download(reply, response_trailers, options), + response(exchange), + upload_trailers(request_trailers) {} + + /** Advances one bounded readiness step and reports final completion. */ + bool poll(bool cancelled, boost::system::error_code& error) { + if (cancelled) { + error = error_code({.code = host::message_errc::cancelled}); + return true; + } + error = error_code(upload.options.check()); + if (error) { + return true; + } + if (stage == 0) { + auto headers = copy_fields(upload.message.base(), error, authority); + if (error) { + return true; + } + host::message_error failure; + auto writer = + exchange.start(scheme, authority, view(upload.message.method_string()), + view(upload.message.target()), std::move(headers), failure); + error = error_code(failure); + if (error) { + return true; + } + upload.start(std::move(writer), upload_trailers, error); + if (error) { + return true; + } + stage = 1; + } + if (stage == 1) { + if (!upload.poll(cancelled, error)) { + return false; + } + if (error) { + return true; + } + stage = 2; + } + if (stage == 2) { + host::message_error failure; + if (!response.poll(incoming, download.options, failure)) { + return false; + } + error = error_code(failure); + if (error) { + return true; + } + download.message.version(11); + download.message.result(incoming.status()); + incoming.headers().for_each([&](std::string_view name, std::string_view value) { + download.message.insert(view(name), view(value)); + }); + auto reader = incoming.consume(failure); + error = error_code(failure); + if (error) { + return true; + } + download.start(std::move(reader), error); + if (error) { + return true; + } + stage = 3; + } + auto const done = download.poll(cancelled, error); + total = download.total; + return done; + } +}; +} // namespace detail + +/** Asynchronously reads a complete host request with bounded readiness steps. + @tparam Body Destination body type. + @tparam Fields Destination fields type. + @tparam CompletionToken Token accepting void(error_code, size_t). + @tparam Trailers Trailer fields type. + @param context Context driving host readiness. + @param source Incoming resource kept alive through completion. + @param request Initially empty destination kept alive through completion. + @param token Completion token preserving executor, allocator and cancellation slot. + @param options Body limit, cancellation and deadline. + @param trailers Optional destination kept alive through completion. + @return The completion token's result. */ +template +auto async_receive(http_context& context, detail::host::incoming_request& source, + http::request& request, CompletionToken&& token, + const transfer_options& options = transfer_options(), + Trailers* trailers = nullptr) { + return boost::asio::async_initiate( + [&context, &source, &request, options, trailers](auto&& handler) { + detail::start_host_operation>( + context, std::forward(handler), source, request, options, + trailers); + }, + token); +} + +/** Asynchronously commits and writes one host response with bounded readiness steps. + @tparam Body Source body type. + @tparam Fields Source fields type. + @tparam CompletionToken Token accepting void(error_code, size_t). + @tparam Trailers Trailer fields type. + @param context Context driving host readiness. + @param output Active response commitment capability. + @param response Source message kept alive through completion. + @param token Completion token preserving executor, allocator and cancellation slot. + @param options Cancellation and deadline. + @param trailers Optional source kept alive through completion. + @return The completion token's result. */ +template +auto async_send(http_context& context, detail::host::response_out output, + http::response& response, CompletionToken&& token, + const transfer_options& options = transfer_options(), + const Trailers* trailers = nullptr) { + return boost::asio::async_initiate( + [&context, output, &response, options, trailers](auto&& handler) { + detail::start_host_operation>( + context, std::forward(handler), output, response, options, + trailers); + }, + token); +} + +/** Asynchronously performs a host client exchange with bounded readiness steps. + @tparam RequestBody Outgoing body type. + @tparam RequestFields Outgoing fields type. + @tparam ResponseBody Incoming body type. + @tparam ResponseFields Incoming fields type. + @tparam CompletionToken Token accepting void(error_code, size_t). + @tparam Trailers Trailer fields type. + @param context Context driving host readiness. + @param connection Host client whose metadata storage remains alive through completion. + @param request Source message kept alive through completion. + @param response Initially empty destination kept alive through completion. + @param token Completion token preserving executor, allocator and cancellation slot. + @param options Body limit, cancellation and deadline. + @param response_trailers Optional destination kept alive through completion. + @param request_trailers Optional source kept alive through completion. + @return The completion token's result, with decoded response payload byte count. */ +template +auto async_perform(http_context& context, client& connection, + http::request& request, + http::response& response, CompletionToken&& token, + const transfer_options& options = transfer_options(), + Trailers* response_trailers = nullptr, + const Trailers* request_trailers = nullptr) { + return boost::asio::async_initiate( + [&context, &connection, &request, &response, options, response_trailers, + request_trailers](auto&& handler) { + detail::start_host_operation>( + context, std::forward(handler), connection, request, response, + options, response_trailers, request_trailers); + }, + token); +} +} // namespace webcpp::beast::wasi +#endif +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/http.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/http.hpp new file mode 100644 index 0000000..09aad43 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/http.hpp @@ -0,0 +1,433 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_WASI_HTTP_HPP +#define WEBCPP_BEAST_WASI_HTTP_HPP + +#include + +#if defined(WEBCPP_WASI_HTTP_P2) || defined(WEBCPP_WASI_HTTP_P3) +#include +#include + +#include // lint-world: caller-owned memory buffers only +#include // lint-world: memory buffer iteration only +#include + +#include +#include +#include +#include +#include + +namespace webcpp::beast::wasi { + +/** Transfer limits and cancellation shared with the host HTTP resources. */ +using webcpp::wasi::http::transfer_options; +/** Explicit streaming host input, independent of a socket. */ +using webcpp::wasi::http::body_reader; +/** Explicit streaming host output, independent of a socket. */ +using webcpp::wasi::http::body_writer; + +namespace detail { +/** Reusable host resource operations. */ +namespace host = webcpp::wasi::http; + +/** Error messages for host HTTP operations. */ +class host_category final : public boost::system::error_category { +public: + /** Returns the stable category name. + @return The stable error category name. */ + const char* name() const noexcept override { return "webcpp.beast.wasi"; } + + /** Describes a portable or host error. + @return A readable error description. */ + std::string message(int value) const override { + if (value >= 100) { + return "wasi:http error-code " + std::to_string(value - 100); + } + switch (static_cast(value)) { + case host::message_errc::success: return "success"; + case host::message_errc::invalid_message: return "invalid host HTTP message"; + case host::message_errc::forbidden_header: return "host forbids this HTTP field"; + case host::message_errc::body_limit: return "host HTTP body limit exceeded"; + case host::message_errc::cancelled: return "host HTTP operation cancelled"; + case host::message_errc::timed_out: return "host HTTP operation timed out"; + case host::message_errc::closed: return "host HTTP stream closed"; + case host::message_errc::host_error: return "host HTTP operation failed"; + case host::message_errc::invalid_state: return "invalid host HTTP operation state"; + } + return "unknown host HTTP error"; + } +}; + +/** Maps resource failures into Boost.System values. + @return The corresponding Boost.System error value. */ +inline boost::system::error_code error_code(host::message_error value) { + static const host_category category; + if (!value) { + return {}; + } + if (value.code == host::message_errc::body_limit) { + return http::error::body_limit; + } + return {value.code == host::message_errc::host_error ? 100 + value.host_code + : static_cast(value.code), + category}; +} + +/** Borrows a standard view as a Beast view. + @return A borrowed view of the same bytes. */ +inline boost::beast::string_view view(std::string_view value) { + return {value.data(), value.size()}; +} + +/** Borrows a Beast view as a standard view. + @return A borrowed view of the same bytes. */ +inline std::string_view view(boost::beast::string_view value) { + return {value.data(), value.size()}; +} + +/** Copies application fields into the host resource. */ +template +host::message_fields copy_fields(const Fields& fields, boost::system::error_code& error, + std::string_view authority = {}) { + host::message_fields result; + for (const auto& field : fields) { + if (!authority.empty() && field.name() == http::field::host) { + if (view(field.value()) != authority) { + error = error_code({.code = host::message_errc::invalid_message}); + } + if (error) { + return result; + } + continue; + } + error = error_code(result.append(view(field.name_string()), view(field.value()))); + if (error) { + return result; + } + } + return result; +} + +/** Delivers bounded host chunks to the caller-selected Beast BodyReader. + @return The number of bytes transferred before completion or failure. */ +template +std::size_t read_body(host::body_reader& source, http::message& message, + Trailers* trailers, const transfer_options& options, + boost::system::error_code& error) { + typename Body::reader reader(message.base(), message.body()); + // Do not reserve an untrusted content-length before applying the body limit. + reader.init(boost::none, error); + if (error) { + return 0; + } + std::array storage{}; + std::size_t total = 0; + host::message_error failure; + while (!source.eof()) { + const auto size = source.read_some(storage, options, failure); + if (failure) { + error = error_code(failure); + return total; + } + total += reader.put(boost::asio::buffer(storage.data(), size), error); + if (error) { + return total; + } + } + failure = source.finish( + [&](std::string_view name, std::string_view value) { + if (trailers) { + trailers->insert(view(name), view(value)); + } + }, + options); + error = error_code(failure); + if (!error) { + reader.finish(error); + } + return total; +} + +/** Delivers Beast BodyWriter buffers to host partial writes. + @return The number of bytes transferred before completion or failure. */ +template +std::size_t write_body(host::body_writer& target, http::message& message, + const transfer_options& options, boost::system::error_code& error) { + typename Body::writer writer(message.base(), message.body()); + writer.init(error); + if (error) { + return 0; + } + std::size_t total = 0; + for (;;) { + auto next = writer.get(error); + if (error || !next) { + break; + } + for (auto const buffer : boost::beast::buffers_range_ref(next->first)) { + auto bytes = std::string_view(static_cast(buffer.data()), buffer.size()); + while (!bytes.empty()) { + host::message_error failure; + const auto written = target.write_some(bytes, options, failure); + total += written; + error = error_code(failure); + if (error) { + return total; + } + bytes.remove_prefix(written); + } + } + if (!next->second) { + break; + } + } + return total; +} +} // namespace detail + +/** Reads a complete host request into the caller's allocator. + @tparam Body Beast body type with a BodyReader. + @tparam Fields Beast fields type. + @tparam Trailers Output fields type for trailers. + @param source Owned host request. + @param request Destination message, initially empty. + @param error Receives any transfer or parsing failure. + @param options Body limit, cancellation and deadline. + @param trailers Optional destination for incoming trailers. + @return The number of incoming body payload bytes. */ +template +std::size_t receive(webcpp::wasi::http::incoming_request& source, + http::request& request, boost::system::error_code& error, + const transfer_options& options = transfer_options(), + Trailers* trailers = nullptr) { + error.clear(); + request.version(11); + request.method_string(detail::view(source.method())); + request.target(detail::view(source.target())); + { + auto const headers = source.headers(); + headers.for_each([&](std::string_view name, std::string_view value) { + request.insert(detail::view(name), detail::view(value)); + }); + } + if (!source.authority().empty() && request.find(http::field::host) == request.end()) { + request.set(http::field::host, detail::view(source.authority())); + } + webcpp::wasi::http::message_error failure; + auto body = source.consume(failure); + if (failure) { + error = detail::error_code(failure); + return 0; + } + return detail::read_body(body, request, trailers, options, error); +} + +/** Sends one response, returning logical body payload bytes. + @tparam Body Beast body type with a BodyWriter. + @tparam Fields Beast fields type. + @tparam Trailers Input fields type for trailers. + @param out Active response commitment resource. + @param response Application response. + @param error Receives any transfer failure. + @param options Cancellation and deadline. + @param trailers Optional outgoing trailers. + @return The number of outgoing body payload bytes. */ +template +std::size_t send(webcpp::wasi::http::response_out out, http::response& response, + boost::system::error_code& error, + const transfer_options& options = transfer_options(), + const Trailers* trailers = nullptr) { + error.clear(); + auto headers = detail::copy_fields(response.base(), error); + if (error) { + webcpp::wasi::http::refuse_response(out); + return 0; + } + std::optional final_fields; + if (trailers) { + final_fields.emplace(detail::copy_fields(*trailers, error)); + if (error) { + webcpp::wasi::http::refuse_response(out); + return 0; + } + } + webcpp::wasi::http::message_error failure; + auto body = webcpp::wasi::http::commit_response(out, response.result_int(), std::move(headers), + failure); + if (failure) { + error = detail::error_code(failure); + return 0; + } + const auto total = detail::write_body(body, response, options, error); + if (!error) { + error = detail::error_code(body.finish(final_fields ? &*final_fields : nullptr)); + } + return total; +} + +/** A host HTTP client. + + The host owns DNS, connections and HTTPS trust. */ +class client { + std::string_view scheme_; + std::string_view authority_; + +public: + /** Borrows connection metadata, which must outlive this client. + @param scheme HTTP or HTTPS. + @param authority Host and optional port. */ + client(std::string_view scheme, std::string_view authority) + : scheme_(scheme), authority_(authority) {} + + /** Returns the borrowed request scheme. + @return HTTP or HTTPS, as supplied at construction. */ + [[nodiscard]] std::string_view scheme() const noexcept { return scheme_; } + + /** Returns the borrowed request authority. + @return Host and optional port, as supplied at construction. */ + [[nodiscard]] std::string_view authority() const noexcept { return authority_; } + + /** Performs a suspending exchange, preserving the caller's Beast body and field allocators. + + The request and response may use any synchronous Beast BodyReader/BodyWriter. Returned + bytes count decoded response payload only. Transfer encoding and connection ownership + remain host capabilities; forbidden fields produce a visible error. + @tparam RequestBody Outgoing Beast body type. + @tparam RequestFields Outgoing Beast fields type. + @tparam ResponseBody Incoming Beast body type. + @tparam ResponseFields Incoming Beast fields type. + @tparam Trailers Trailer fields type. + @param request Outgoing application message. + @param response Initially empty incoming message. + @param error Receives any transfer failure. + @param options Body limit, cancellation and deadline. + @param response_trailers Optional received trailers. + @param request_trailers Optional outgoing trailers. + @return The number of received response payload bytes. */ + template + std::size_t perform(http::request& request, + http::response& response, + boost::system::error_code& error, + const transfer_options& options = transfer_options(), + Trailers* response_trailers = nullptr, + const Trailers* request_trailers = nullptr) { + error = detail::error_code(options.check()); + if (error) { + return 0; + } + auto headers = detail::copy_fields(request.base(), error, authority_); + if (error) { + return 0; + } + std::optional final_fields; + if (request_trailers) { + final_fields.emplace(detail::copy_fields(*request_trailers, error)); + if (error) { + return 0; + } + } + webcpp::wasi::http::outgoing_exchange exchange; + webcpp::wasi::http::message_error failure; + { + auto body = exchange.start(scheme_, authority_, detail::view(request.method_string()), + detail::view(request.target()), std::move(headers), failure); + error = detail::error_code(failure); + if (error) { + return 0; + } + detail::write_body(body, request, options, error); + if (error) { + return 0; + } + error = detail::error_code(body.finish(final_fields ? &*final_fields : nullptr)); + if (error) { + return 0; + } + } + auto incoming = exchange.receive(options, failure); + if (failure) { + error = detail::error_code(failure); + return 0; + } + response.version(11); + response.result(incoming.status()); + { + auto const received = incoming.headers(); + received.for_each([&](std::string_view name, std::string_view value) { + response.insert(detail::view(name), detail::view(value)); + }); + } + auto body = incoming.consume(failure); + if (failure) { + error = detail::error_code(failure); + return 0; + } + return detail::read_body(body, response, response_trailers, options, error); + } +}; + +namespace detail { +/** Adapts only bootstrap and transport; the application's routing and response builder remain + * callable. */ +template +void handle(host::request_handle raw, host::response_out out, Handler&& handler, + const transfer_options& options = {}) { + host::incoming_request incoming(raw); + http::request request; + boost::system::error_code error; + receive(incoming, request, error, options); + if (error) { + http::response response{error == http::error::body_limit + ? http::status::payload_too_large + : http::status::bad_request, + 11}; + response.prepare_payload(); + send(out, response, error, options); + return; + } + auto response = handler(std::move(request)); + if constexpr (requires { + typename std::variant_size>::type; + }) { + std::visit([&](auto& value) { send(out, value, error, options); }, response); + } else { + send(out, response, error, options); + } +} +} // namespace detail +} // namespace webcpp::beast::wasi + +#ifdef WEBCPP_WASI_HTTP_P2 +/** Exports the P2 host server. + @param handler Callable building a response or variant for one request. */ +#define WEBCPP_BEAST_WASI_HTTP_EXPORT(handler) \ + extern "C" void exports_wasi_http_incoming_handler_handle( \ + exports_wasi_http_incoming_handler_own_incoming_request_t request, \ + exports_wasi_http_incoming_handler_own_response_outparam_t out) { \ + webcpp::beast::wasi::detail::handle(request, out, handler); \ + } +#else +/** Exports a P3 task with body resources scoped to its lifetime. + @param handler Callable building a response or variant for one request. */ +#define WEBCPP_BEAST_WASI_HTTP_EXPORT(handler) \ + extern "C" webcpp_wasi_http_callback_code_t exports_wasi_http_handler_handle( \ + exports_wasi_http_handler_own_request_t request) { \ + webcpp::beast::wasi::detail::handle(request, {}, handler); \ + return WEBCPP_WASI_HTTP_CALLBACK_CODE_EXIT; \ + } \ + extern "C" webcpp_wasi_http_callback_code_t exports_wasi_http_handler_handle_callback( \ + webcpp_wasi_http_event_t*) { \ + return WEBCPP_WASI_HTTP_CALLBACK_CODE_EXIT; \ + } +#endif + +#endif // Host HTTP bindings selected. + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/stream.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/stream.hpp new file mode 100644 index 0000000..cfa88da --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/wasi/stream.hpp @@ -0,0 +1,509 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_WASI_STREAM_HPP +#define WEBCPP_BEAST_WASI_STREAM_HPP + +#include +#include + +#include // lint-world: memory buffer sequences only +#include // lint-world: memory buffer iteration only +#include + +#ifndef _WIN32 +#include // lint-world: explicit borrowed descriptor stream +#include // lint-world: readiness for supplied descriptors, never socket creation +#include // lint-world: stdin/stdout and explicit descriptor I/O +#ifndef __wasi__ +#include // lint-world: calling-thread signal mask, no worker thread +#include // lint-world: scoped SIGPIPE handling for borrowed output +#endif +#endif +#include +#include +#include // lint-world: explicit stream deadlines +#include +#include +#include + +#ifdef __wasi__ +#include +#endif + +namespace webcpp::beast::wasi { + +/** Cancellation and a deadline for a supplied channel; no background worker is created. */ +struct stream_control { + /** Optional cancellation predicate. */ + bool (*cancelled)(void*) = nullptr; + /** Opaque cancellation predicate state. */ + void* cancellation_context = nullptr; + /** Absolute deadline, or the maximum time point for none. */ + std::chrono::steady_clock::time_point deadline = // lint-world: explicit channel deadline + std::chrono::steady_clock::time_point::max(); // lint-world: explicit deadline + + /** Reports cancellation or expiry. + @return An empty error value on success, otherwise the failure. */ + [[nodiscard]] boost::system::error_code check() const { + if ((cancelled != nullptr) && cancelled(cancellation_context)) { + return boost::system::errc::make_error_code(boost::system::errc::operation_canceled); + } + if (std::chrono::steady_clock::now() >= deadline) { // lint-world: explicit deadline + return boost::system::errc::make_error_code(boost::system::errc::timed_out); + } + return {}; + } +}; + +/** A borrowed pair of nonblocking host channels. + + A zero-byte successful read means EOF. A write of zero bytes means would-block. + Providers report would_block when unready and wait handles readiness, deadline and + cancellation. The adapter never buffers more than the caller supplies, never closes + a channel, and promises no path addressing, socket options or peer credentials. */ +class supplied_stream { +public: + /** Partial nonblocking read callback. + @return The number of bytes transferred before completion or failure. */ + using read_function = std::size_t (*)(void*, std::span, boost::system::error_code&); + /** Partial nonblocking write callback. + @return The number of bytes transferred before completion or failure. */ + using write_function = std::size_t (*)(void*, std::span, + boost::system::error_code&); + /** Readiness callback, with writing true for output. + @return The corresponding Boost.System error value. */ + using wait_function = void (*)(void*, bool, const stream_control&, boost::system::error_code&); + +private: + void* context_; + read_function read_{}; + write_function write_{}; + wait_function wait_; + stream_control control_; + +public: + /** Borrows a caller-supplied channel pair. + @param context State shared by channel callbacks. + @param reader Nonblocking partial read callback. + @param writer Nonblocking partial write callback. + @param wait Readiness and cancellation callback. + @param control Initial cancellation and deadline. */ + supplied_stream(void* context, read_function reader, write_function writer, wait_function wait, + stream_control control = {}) + : context_(context), read_(reader), write_(writer), wait_(wait), control_(control) {} + + /** Sets transfer cancellation and deadline. + @param value Settings for subsequent operations. */ + void control(stream_control value) { control_ = value; } + + /** Reads a partial mutable buffer sequence. + @tparam MutableBuffers Asio mutable buffer sequence. + @param buffers Destination buffers. + @param error Receives transfer failure or end_of_stream. + @return The number of bytes transferred before completion or failure. */ + template + std::size_t read_some(const MutableBuffers& buffers, boost::system::error_code& error) { + for (auto const buffer : boost::beast::buffers_range_ref(buffers)) { + if (buffer.size() == 0) { + continue; + } + for (;;) { + error = control_.check(); + if (error) { + return 0; + } + auto const count = + read_(context_, {static_cast(buffer.data()), buffer.size()}, error); + if (error == boost::system::errc::make_error_code( + boost::system::errc::operation_would_block) || + error == boost::system::errc::make_error_code( + boost::system::errc::resource_unavailable_try_again)) { + wait_(context_, false, control_, error); + if (error) { + return 0; + } + continue; + } + if (!error && count == 0) { + error = http::error::end_of_stream; + } + return count; + } + } + error.clear(); + return 0; + } + + /** Writes a partial constant buffer sequence. + @tparam ConstBuffers Asio constant buffer sequence. + @param buffers Source buffers. + @param error Receives any transfer failure. + @return The number of bytes transferred before completion or failure. */ + template + std::size_t write_some(const ConstBuffers& buffers, boost::system::error_code& error) { + for (auto const buffer : boost::beast::buffers_range_ref(buffers)) { + if (buffer.size() == 0) { + continue; + } + for (;;) { + error = control_.check(); + if (error) { + return 0; + } + auto const count = write_( + context_, {static_cast(buffer.data()), buffer.size()}, error); + if ((!error && count == 0) || + error == boost::system::errc::make_error_code( + boost::system::errc::operation_would_block) || + error == boost::system::errc::make_error_code( + boost::system::errc::resource_unavailable_try_again)) { + wait_(context_, true, control_, error); + if (error) { + return 0; + } + continue; + } + return count; + } + } + error.clear(); + return 0; + } +}; + +#ifndef _WIN32 +/** stdin/stdout or a supplied descriptor pair, borrowed exclusively for this object's lifetime. + + Descriptors are set nonblocking and restored on destruction, never closed. stdout is + protocol-only; diagnostics belong on stderr. Readiness and cancellation are checked every + ten milliseconds while blocked. This does not provide Unix-domain socket semantics. */ +class stdio_stream { + int input_; + int output_; + int input_flags_{}; + int output_flags_{}; + boost::system::error_code setup_error_; + supplied_stream stream_; +#ifdef __wasi__ + webcpp::wasi::stdio_channel host_streams_; + + static std::size_t translate(webcpp::wasi::stream_result result, + boost::system::error_code& error) { + switch (result.status) { + case webcpp::wasi::stream_status::ready: error.clear(); break; + case webcpp::wasi::stream_status::blocked: + error = boost::system::errc::make_error_code( + boost::system::errc::operation_would_block); + break; + case webcpp::wasi::stream_status::eof: error = http::error::end_of_stream; break; + case webcpp::wasi::stream_status::failed: + error = boost::system::errc::make_error_code(boost::system::errc::io_error); + break; + } + return result.count; + } +#endif + static std::size_t input(void* context, std::span buffer, + boost::system::error_code& error) { +#ifdef __wasi__ + auto& self = *static_cast(context); +#else + const auto& self = *static_cast(context); +#endif + error = self.setup_error_; + if (error) { + return 0; + } +#ifdef __wasi__ + if (self.input_ == STDIN_FILENO) { + return translate(self.host_streams_.read(buffer), error); + } +#endif + const auto count = + ::read(self.input_, buffer.data(), std::min(buffer.size(), 4096)); + if (count >= 0) { + error.clear(); + return static_cast(count); + } + error = + errno == EAGAIN || errno == EINTR + ? boost::system::errc::make_error_code(boost::system::errc::operation_would_block) + : boost::system::error_code(errno, boost::system::generic_category()); + return 0; + } + + static std::ptrdiff_t write_descriptor(int descriptor, const void* data, std::size_t size) { +#ifdef __wasi__ + return ::write(descriptor, data, size); +#else + // Block only this thread while writing, then restore its original mask. + // An already pending SIGPIPE belongs to the caller and must remain pending. + sigset_t selected{}; + sigset_t previous{}; + sigset_t pending{}; + static_cast(sigemptyset(&selected)); + static_cast(sigaddset(&selected, SIGPIPE)); + const auto failure = ::pthread_sigmask(SIG_BLOCK, &selected, &previous); + if (failure != 0) { + errno = failure; + return -1; + } + static_cast(::sigpending(&pending)); + const bool already_pending = sigismember(&pending, SIGPIPE) == 1; + const auto count = ::write(descriptor, data, size); + const auto saved_errno = errno; + if (count < 0 && saved_errno == EPIPE && !already_pending) { + static_cast(::sigpending(&pending)); + if (sigismember(&pending, SIGPIPE) == 1) { + int caught = 0; + static_cast(::sigwait(&selected, &caught)); + } + } + static_cast(::pthread_sigmask(SIG_SETMASK, &previous, nullptr)); + errno = saved_errno; + return count; +#endif + } + + static std::size_t output(void* context, std::span buffer, + boost::system::error_code& error) { + const auto& self = *static_cast(context); + error = self.setup_error_; + if (error) { + return 0; + } +#ifdef __wasi__ + if (self.output_ == STDOUT_FILENO) { + return translate(self.host_streams_.write(buffer), error); + } +#endif + const auto count = write_descriptor(self.output_, buffer.data(), + std::min(buffer.size(), 4096)); + if (count >= 0) { + error.clear(); + return static_cast(count); + } + error = + errno == EAGAIN || errno == EINTR + ? boost::system::errc::make_error_code(boost::system::errc::operation_would_block) + : boost::system::error_code(errno, boost::system::generic_category()); + return 0; + } + + static void wait(void* context, bool writing, const stream_control& control, + boost::system::error_code& error) { + const auto& self = *static_cast(context); +#ifdef __wasi__ + if ((!writing && self.input_ == STDIN_FILENO) || + (writing && self.output_ == STDOUT_FILENO)) { + error = control.check(); + return; + } +#endif + pollfd descriptor{ + .fd = writing ? self.output_ : self.input_, + .events = static_cast(writing ? POLLOUT : POLLIN), + .revents = 0, + }; + for (;;) { + error = control.check(); + if (error) { + return; + } + const auto ready = ::poll(&descriptor, 1, 10); + if (ready > 0) { + error.clear(); + return; + } + if (ready < 0 && errno != EINTR) { + error = {errno, boost::system::generic_category()}; + return; + } + } + } + +public: + /** Acquires standard streams or borrows an exclusive descriptor pair. + @param input_descriptor Input descriptor, normally stdin. + @param output_descriptor Output descriptor, normally stdout. + @param control Initial cancellation and deadline. */ + explicit stdio_stream(int input_descriptor = STDIN_FILENO, + int output_descriptor = STDOUT_FILENO, stream_control control = {}) + : input_(input_descriptor), + output_(output_descriptor), + input_flags_(::fcntl(input_, F_GETFL)), + output_flags_(::fcntl(output_, F_GETFL)), + stream_(this, input, output, wait, control) { +#ifdef __wasi__ + if (input_ == STDIN_FILENO && output_ == STDOUT_FILENO) { + return; + } +#endif + if (input_flags_ == -1 || output_flags_ == -1 || + ::fcntl(input_, F_SETFL, + static_cast(static_cast(input_flags_) | + static_cast(O_NONBLOCK))) == -1 || + ::fcntl(output_, F_SETFL, + static_cast(static_cast(output_flags_) | + static_cast(O_NONBLOCK))) == -1) { + setup_error_ = {errno, boost::system::generic_category()}; + } + } + + /** Forbids duplicated channel ownership. */ + stdio_stream(const stdio_stream&) = delete; + /** Forbids duplicated channel ownership. */ + stdio_stream& operator=(const stdio_stream&) = delete; + + /** Restores borrowed descriptor flags and releases host resources. */ + ~stdio_stream() { +#ifdef __wasi__ + if (input_ == STDIN_FILENO && output_ == STDOUT_FILENO) { + return; + } +#endif + if (input_flags_ != -1) { + static_cast(::fcntl(input_, F_SETFL, input_flags_)); + } + if (output_flags_ != -1) { + static_cast(::fcntl(output_, F_SETFL, output_flags_)); + } + } + + /** Sets transfer cancellation and deadline. + @param value Settings for subsequent operations. */ + void control(stream_control value) { stream_.control(value); } + + /** Reads a partial input span. + @tparam Buffers Asio mutable buffer sequence. + @param buffers Destination buffers. + @param error Receives any transfer failure. + @return The number of bytes transferred before completion or failure. */ + template + std::size_t read_some(const Buffers& buffers, boost::system::error_code& error) { + return stream_.read_some(buffers, error); + } + + /** Writes a partial output span. + @tparam Buffers Asio constant buffer sequence. + @param buffers Source buffers. + @param error Receives any transfer failure. + @return The number of bytes transferred before completion or failure. */ + template + std::size_t write_some(const Buffers& buffers, boost::system::error_code& error) { + return stream_.write_some(buffers, error); + } +}; + +#else +/** Unsupported standard-descriptor adapter on Windows. + + Use supplied_stream with caller-owned nonblocking read, write and wait callbacks. */ +class stdio_stream { +public: + /** Rejects construction where borrowed POSIX descriptor readiness is unavailable. + @tparam Platform Deferred platform diagnostic. + @param input_descriptor Input descriptor. + @param output_descriptor Output descriptor. + @param control Initial cancellation and deadline. */ + template + explicit stdio_stream(int input_descriptor = 0, int output_descriptor = 1, + stream_control control = stream_control()) { + static_cast(input_descriptor); + static_cast(output_descriptor); + static_cast(control); + static_assert(!std::is_same_v, + "stdio_stream requires WASI or POSIX descriptors; on Windows use " + "supplied_stream callbacks"); + } +}; +#endif + +/** Parses one message and retains overread in the caller's buffer. + + Reads fit the buffer's remaining maximum capacity. If an incomplete parser + needs more input while that capacity is exhausted, reports buffer_overflow. + @tparam Stream Supplied stream type. + @tparam DynamicBuffer Dynamic buffer type. + @tparam Request Whether the parser reads a request. + @tparam Body Beast body type. + @tparam Allocator Parser fields allocator. + @param stream Input channel. + @param buffer Retained input and overread. + @param parser Application parser with its limits. + @param error Receives channel or parser failure. + @return The number of bytes transferred before completion or failure. */ +template +std::size_t read(Stream& stream, DynamicBuffer& buffer, + http::parser& parser, boost::system::error_code& error) { + error.clear(); + parser.eager(true); + std::size_t total = 0; + while (!parser.is_done()) { + if (buffer.size() != 0) { + const auto consumed = parser.put(buffer.data(), error); + buffer.consume(consumed); + total += consumed; + if (error == http::error::need_more) { + error.clear(); + } + if (error || parser.is_done()) { + break; + } + } + const auto available = std::min(4096, buffer.max_size() - buffer.size()); + if (available == 0) { + error = http::error::buffer_overflow; + break; + } + const auto transferred = stream.read_some(buffer.prepare(available), error); + buffer.commit(transferred); + if (error == http::error::end_of_stream) { + if (parser.got_some()) { + parser.put_eof(error); + } else { + error = http::error::end_of_stream; + } + } + if (error || parser.is_done()) { + break; + } + } + return total; +} + +/** Serializes one message and returns actual channel bytes. + @tparam Stream Supplied stream type. + @tparam Request Whether the message is a request. + @tparam Body Beast body type. + @tparam Fields Beast fields type. + @param stream Output channel. + @param message Application message. + @param error Receives channel or serializer failure. + @return The number of bytes transferred before completion or failure. */ +template +std::size_t write(Stream& stream, http::message& message, + boost::system::error_code& error) { + error.clear(); + http::serializer serializer(message); + std::size_t total = 0; + while (!serializer.is_done()) { + std::size_t transferred = 0; + serializer.next(error, [&](boost::system::error_code& next_error, const auto& buffers) { + transferred = stream.write_some(buffers, next_error); + }); + if (error) { + break; + } + serializer.consume(transferred); + total += transferred; + } + return total; +} +} // namespace webcpp::beast::wasi + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/websocket.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/websocket.hpp new file mode 100644 index 0000000..df22682 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/websocket.hpp @@ -0,0 +1,115 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_WEBSOCKET_HPP +#define WEBCPP_BEAST_WEBSOCKET_HPP + +#include + +#if defined(WEBCPP_TARGET_NATIVE) || defined(WEBCPP_TARGET_WASIP2) || defined(WEBCPP_TARGET_WASIP3) +#include // lint-world: explicit guest WebSocket protocol engine + +#include +#include +#include + +namespace webcpp::beast::websocket { +/** Reports whether a request asks for a WebSocket upgrade. */ +using boost::beast::websocket::is_upgrade; +/** Upstream WebSocket closing status codes. */ +using boost::beast::websocket::close_code; +/** Upstream WebSocket close code and UTF-8 reason. */ +using boost::beast::websocket::close_reason; +/** Upstream WebSocket operation errors. */ +using boost::beast::websocket::error; +/** WebSocket control-frame category. */ +using boost::beast::websocket::frame_type; +/** Bounded WebSocket ping or pong payload. */ +using boost::beast::websocket::ping_data; +/** Upstream per-message compression settings. */ +using boost::beast::websocket::permessage_deflate; +/** Upstream handshake request type. */ +using boost::beast::websocket::request_type; +/** Upstream handshake response type. */ +using boost::beast::websocket::response_type; +/** Upstream WebSocket timeout and decorator settings. */ +using boost::beast::websocket::stream_base; + +/** + Runs the upstream WebSocket protocol over an explicitly selected byte stream. + + @tparam NextLayer The underlying AsyncStream or SyncStream type. + @tparam DeflateSupported Whether upstream per-message deflate is compiled in. + @note Native and WASI state allocation remains upstream Beast's; associated + handler allocators are preserved by upstream operations. +*/ +template +class stream : public boost::beast::websocket::stream { + using base = boost::beast::websocket::stream; + +public: + /** + Rebinds this facade to another executor. + @tparam Executor The executor type for the underlying stream. + */ + template + struct rebind_executor { + /** The facade stream using the rebound underlying stream. */ + using other = + stream::other, + DeflateSupported>; + }; + + /** Constructs a stream when the underlying stream is default constructible. */ + stream() + requires std::is_default_constructible_v + : base() {} + + /** + Constructs the underlying stream without consuming an allocator tag. + @tparam First The first underlying-stream argument type. + @tparam Rest The remaining argument types. + @param first The first underlying-stream argument. + @param rest The remaining underlying-stream arguments. + */ + template + requires(!std::is_same_v, std::allocator_arg_t>) + explicit stream(First&& first, Rest&&... rest) + : base(std::forward(first), std::forward(rest)...) {} + + /** + Converts an upstream-compatible stream with another underlying executor. + @tparam Other The source underlying stream type. + @param other The source stream, forwarded to upstream's converting constructor. + @note As upstream does, this moves the next layer, not established protocol state. + */ + template + explicit stream(stream&& other) + : base(std::move(other.next_layer())) {} + + /** + Constructs the socket backend with the facade's portable allocator syntax. + + @tparam Allocator The allocator type accepted for source compatibility. + @tparam Args The underlying stream's constructor argument types. + @param tag Selects the allocator-aware facade constructor. + @param allocator Accepted without changing upstream stream-state allocation. + @param args Arguments forwarded to the upstream stream. + @note This backend does not claim that the supplied allocator controls upstream state. + */ + template + explicit stream([[maybe_unused]] std::allocator_arg_t tag, + [[maybe_unused]] const Allocator& allocator, Args&&... args) + : base(std::forward(args)...) {} +}; +} // namespace webcpp::beast::websocket +#elif defined(WEBCPP_TARGET_EMSCRIPTEN) +#include +#else +#error "The Beast WebSocket socket backend currently requires native or WASIp3" +#endif + +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/websocket/guest.hpp b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/websocket/guest.hpp new file mode 100644 index 0000000..2ad3305 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/include/webcpp/beast/websocket/guest.hpp @@ -0,0 +1,167 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef WEBCPP_BEAST_WEBSOCKET_GUEST_HPP +#define WEBCPP_BEAST_WEBSOCKET_GUEST_HPP + +#include + +#include +#ifdef WEBCPP_TARGET_EMSCRIPTEN +#include // lint-world: explicitly selected guest protocol engine +#include +#include + +// NOLINTNEXTLINE(modernize-concat-nested-namespaces): policy selects an inline namespace +namespace webcpp::beast { +#ifdef WEBCPP_BEAST_UNSUPPORTED_IGNORE +inline namespace unsupported_ignore { +#else +inline namespace unsupported_error { +#endif +namespace websocket { +/** + Selects upstream framing for an explicitly supplied byte stream. + @tparam NextLayer User-supplied stream implementing the Beast byte-stream concepts. + @tparam DeflateSupported Whether the guest engine supports permessage-deflate. + */ +template + requires(!std::is_same_v && + !std::is_same_v>) +class stream + : public boost::beast::websocket::stream { + using base = boost::beast::websocket::stream; + std::shared_ptr memory_; + +public: + using base::base; + using base::set_option; + + /** Adapts facade request and response decorators to the upstream handshake. + @tparam Function Callable accepting the facade request or response type. + @param option Decorator applied before the guest engine writes its handshake. + */ + template + void set_option(stream_base::decorator option) { + base::set_option(boost::beast::websocket::stream_base::decorator( + [function = std::move(option.function), memory = memory_](auto& upstream) mutable { + if constexpr (std::is_same_v, + boost::beast::websocket::request_type>) { + if constexpr (std::is_invocable_v) { + request_type request( + std::piecewise_construct, std::tuple<>(), + std::make_tuple(memory ? memory.get() + : std::pmr::new_delete_resource())); + request.method(upstream.method()); + request.target(upstream.target()); + request.version(upstream.version()); + for (const auto& field : upstream) { + request.insert(field.name_string(), field.value()); + } + function(request); + upstream.clear(); + upstream.method(request.method()); + upstream.target(request.target()); + upstream.version(request.version()); + for (const auto& field : request) { + upstream.insert(field.name_string(), field.value()); + } + } + } else if constexpr (std::is_invocable_v) { + function(upstream); + } + })); + } + + /** Registers a control notification using the facade's portable frame category. + @param callback Callback invoked with the frame category and payload, or empty to clear. + */ + void control_callback(std::function callback) { + if (!callback) { + base::control_callback({}); + return; + } + base::control_callback( + [callback = std::move(callback)](boost::beast::websocket::frame_type kind, + boost::beast::string_view payload) { + switch (kind) { + case boost::beast::websocket::frame_type::close: + callback(frame_type::close, payload); + break; + case boost::beast::websocket::frame_type::ping: + callback(frame_type::ping, payload); + break; + case boost::beast::websocket::frame_type::pong: + callback(frame_type::pong, payload); + break; + } + }); + } + + /** Constructs the guest engine with the upstream allocation behavior. + + The allocator argument preserves constructor compatibility; Boost owns its protocol state. + @tparam Allocator Allocator used for the facade's request adaptation. + @tparam Args Constructor argument types of the next layer. + @param allocator Allocator retained for the facade's request adaptation. + @param args Arguments forwarded to the upstream stream constructor. + */ + template + explicit stream(std::allocator_arg_t /*unused*/, const Allocator& allocator, Args&&... args) + : base(std::forward(args)...), + memory_(std::allocate_shared>( + allocator, allocator)) {} + + /** Selects the guest stream type for another executor. + @tparam Executor Executor to bind to the next layer. + */ + template + struct rebind_executor { + /** Stream type with the requested executor binding. */ + using other = + stream::other, DeflateSupported>; + }; +}; +} // namespace websocket +} +} // namespace webcpp::beast + +namespace webcpp::asio { +/** Closes a user-supplied browser byte transport after the WebSocket close exchange. + @tparam Protocol Socket protocol of the supplied byte transport. + @tparam Executor Executor associated with the socket. + @param socket Byte transport to close. + @param ec Receives any error from closing the socket. + */ +template +void teardown(boost::beast::role_type /*unused*/, basic_stream_socket& socket, + boost::system::error_code& ec) { + socket.close(ec); +} + +/** Posts teardown completion using the handler's associations. + @tparam Protocol Socket protocol of the supplied byte transport. + @tparam Executor Executor associated with the socket. + @tparam Token Completion token for void(error_code). + @param role Protocol role passed through to teardown. + @param socket Byte transport to close. + @param token Completion token determining the result type. + @return The result determined by the completion token. + */ +template +auto async_teardown(boost::beast::role_type role, basic_stream_socket& socket, + Token&& token) { + return boost::asio::async_initiate( + [&socket, role](auto handler) { + boost::system::error_code ec; + teardown(role, socket, ec); + webcpp::beast::detail::browser::post(socket.get_executor(), std::move(handler), ec); + }, + token); +} +} // namespace webcpp::asio +#endif +#endif diff --git a/libraries/beast/openspec/changes/genesis/reference/source/meta/libraries.json b/libraries/beast/openspec/changes/genesis/reference/source/meta/libraries.json new file mode 100644 index 0000000..88df932 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/meta/libraries.json @@ -0,0 +1,17 @@ +{ + "key": "beast", + "name": "beast", + "authors": [ + "R" + ], + "description": "Beast-compatible HTTP and WebSocket interfaces for WebAssembly and native applications.", + "category": [ + "Concurrent", + "IO" + ], + "maintainers": [ + "R " + ], + "cxxstd": "20", + "port-of": null +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/.clang-tidy b/libraries/beast/openspec/changes/genesis/reference/source/test/.clang-tidy new file mode 100644 index 0000000..d1d6e30 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/.clang-tidy @@ -0,0 +1,7 @@ +# An uncaught allocation or operation error terminates the test and fails it. +# Keep exception-escape checks for noexcept functions, destructors and moves. +--- +InheritParentConfig: true +CheckOptions: + - key: bugprone-exception-escape.CheckMain + value: 'false' diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/test/Jamfile new file mode 100644 index 0000000..0212769 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/Jamfile @@ -0,0 +1,63 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# Socket contract tests need extended COFF sections for their many handlers. +project : requirements /webcpp/beast//beast + msvc:/bigobj ; + +import webcpp ; +import feature ; + +webcpp.targets native wasip2 wasip3 emscripten ; + +webcpp.headers-alone beast : ../include : beast.hpp beast/config.hpp + beast/core.hpp beast/http.hpp beast/browser/error.hpp ; +webcpp.compile config : config_test.cpp ; +webcpp.compile config_all_off : config_test.cpp + : WEBCPP_NO_EXCEPTIONS WEBCPP_TEST_ALL_OFF ; +webcpp.compile config_developer_off : config_test.cpp + : WEBCPP_BEAST_NO_EXCEPTIONS WEBCPP_TEST_DEVELOPER_OFF ; +webcpp.compile config_ignore : config_test.cpp : ignore ; +webcpp.compile-fail conflicting_policies : config_test.cpp + : WEBCPP_BEAST_UNSUPPORTED_ERROR WEBCPP_BEAST_UNSUPPORTED_IGNORE ; + +webcpp.run message : message_test.cpp ; + +webcpp.headers-alone beast : ../include : beast/tcp_stream.hpp beast/websocket.hpp beast/http/read.hpp beast/http/write.hpp + : /webcpp/beast//sockets : native wasip3 emscripten ; +webcpp.run socket : socket_test.cpp : /webcpp/beast//sockets : native wasip3 ; + +# One header unit supplies the combined dependencies for aggregate analysis. +# A browser parse must never acquire guest OpenSSL through that combination. +rule ssl-header-dependencies ( properties * ) +{ + if [ feature.get-values : $(properties) ] = emscripten + { + return /webcpp/beast//browser ; + } + return /webcpp/beast//tls /webcpp/beast//wasi-http ; +} +webcpp.headers-alone beast : ../include : beast/ssl.hpp + : @ssl-header-dependencies : native wasip3 emscripten ; +webcpp.run ssl : ssl_test.cpp : /webcpp/beast//tls : native wasip3 ; + +webcpp.headers-alone beast : ../include : beast/detail/socket_algorithms.hpp + : /webcpp/beast//sockets : native wasip3 ; +webcpp.headers-alone beast : ../include + : beast/browser/tcp_stream.hpp beast/browser/ssl_stream.hpp + beast/browser/websocket.hpp beast/browser/http.hpp + beast/browser/http_byte_stream.hpp beast/websocket/guest.hpp + beast/browser/detail/imports.hpp beast/browser/detail/support.hpp + : /webcpp/beast//browser : emscripten ; +webcpp.headers-alone beast : ../include : beast/wasi/http.hpp beast/wasi/async.hpp + : /webcpp/beast//wasi-http : wasip2 wasip3 ; +webcpp.headers-alone beast : ../include : beast/wasi/stream.hpp + : /webcpp/beast//wasi-streams : native wasip2 wasip3 ; + +build-project tls ; +build-project browser ; +build-project wasi ; +build-project applications ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/applications/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/Jamfile new file mode 100644 index 0000000..c6f0f9b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/Jamfile @@ -0,0 +1,880 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +# +# Generated by example/applications/tools/prepare.py. Edit the generator. +# Upstream authors and their original notice follow. + +# Fixtures read the environment fixed by their launching driver. +project : requirements msvc:_CRT_SECURE_NO_WARNINGS ; + +import webcpp ; +webcpp.targets native ; +webcpp.original python3 ; +webcpp.drive oracle-advanced-server : ../../example/applications/oracle/advanced/server/advanced_server.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : advanced-server : native ; +webcpp.drive port-advanced-server : ../../example/applications/port/advanced/server/advanced_server.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : advanced-server : native ; +webcpp.drive oracle-advanced-server-flex : ../../example/applications/oracle/advanced/server-flex/advanced_server_flex.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : advanced-server-flex : native ; +webcpp.drive port-advanced-server-flex : ../../example/applications/port/advanced/server-flex/advanced_server_flex.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : advanced-server-flex : native ; +webcpp.drive oracle-advanced-server-flex-awaitable : ../../example/applications/oracle/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : advanced-server-flex-awaitable : native ; +webcpp.drive port-advanced-server-flex-awaitable : ../../example/applications/port/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : advanced-server-flex-awaitable : native ; +webcpp.drive oracle-doc-ssl-client : ../../example/applications/oracle/doc/ssl/client.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : doc-ssl-client : native ; +webcpp.drive port-doc-ssl-client : ../../example/applications/port/doc/ssl/client.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : doc-ssl-client : native ; +webcpp.drive oracle-doc-ssl-server : ../../example/applications/oracle/doc/ssl/server.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : doc-ssl-server : native ; +webcpp.drive port-doc-ssl-server : ../../example/applications/port/doc/ssl/server.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : doc-ssl-server : native ; +webcpp.drive oracle-echo-op : ../../example/applications/oracle/echo-op/echo_op.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : echo-op : native ; +webcpp.drive port-echo-op : ../../example/applications/port/echo-op/echo_op.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : echo-op : native ; +webcpp.drive oracle-http-client-async : ../../example/applications/oracle/http/client/async/http_client_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async : native ; +webcpp.drive port-http-client-async : ../../example/applications/port/http/client/async/http_client_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async : native ; +webcpp.drive oracle-http-client-async-local : ../../example/applications/oracle/http/client/async-local/http_client_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async-local : native ; +webcpp.drive port-http-client-async-local : ../../example/applications/port/http/client/async-local/http_client_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async-local : native ; +webcpp.drive oracle-http-client-async-ssl : ../../example/applications/oracle/http/client/async-ssl/http_client_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async-ssl : native ; +webcpp.drive port-http-client-async-ssl : ../../example/applications/port/http/client/async-ssl/http_client_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async-ssl : native ; +webcpp.drive oracle-http-client-async-ssl-system-executor : ../../example/applications/oracle/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async-ssl-system-executor : native ; +webcpp.drive port-http-client-async-ssl-system-executor : ../../example/applications/port/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-async-ssl-system-executor : native ; +webcpp.drive oracle-http-client-awaitable : ../../example/applications/oracle/http/client/awaitable/http_client_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-awaitable : native ; +webcpp.drive port-http-client-awaitable : ../../example/applications/port/http/client/awaitable/http_client_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-awaitable : native ; +webcpp.drive oracle-http-client-awaitable-ssl : ../../example/applications/oracle/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-awaitable-ssl : native ; +webcpp.drive port-http-client-awaitable-ssl : ../../example/applications/port/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-awaitable-ssl : native ; +webcpp.drive oracle-json_client : ../../example/applications/oracle/http/client/body/json_client.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : json_client : native ; +webcpp.drive port-json_client : ../../example/applications/port/http/client/body/json_client.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : json_client : native ; +webcpp.drive oracle-http-client-coro : ../../example/applications/oracle/http/client/coro/http_client_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-coro : native ; +webcpp.drive port-http-client-coro : ../../example/applications/port/http/client/coro/http_client_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-coro : native ; +webcpp.drive oracle-http-client-coro-ssl : ../../example/applications/oracle/http/client/coro-ssl/http_client_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-coro-ssl : native ; +webcpp.drive port-http-client-coro-ssl : ../../example/applications/port/http/client/coro-ssl/http_client_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-coro-ssl : native ; +webcpp.drive oracle-http-crawl : ../../example/applications/oracle/http/client/crawl/http_crawl.cpp ../../example/applications/oracle/http/client/crawl/urls_large_data.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-crawl : native ; +webcpp.drive port-http-crawl : ../../example/applications/port/http/client/crawl/http_crawl.cpp ../../example/applications/port/http/client/crawl/urls_large_data.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-crawl : native ; +webcpp.drive oracle-http-client-methods : ../../example/applications/oracle/http/client/methods/http_client_methods.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-methods : native ; +webcpp.drive port-http-client-methods : ../../example/applications/port/http/client/methods/http_client_methods.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-methods : native ; +webcpp.drive oracle-http-client-sync : ../../example/applications/oracle/http/client/sync/http_client_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-sync : native ; +webcpp.drive port-http-client-sync : ../../example/applications/port/http/client/sync/http_client_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-sync : native ; +webcpp.drive oracle-http-client-sync-ssl : ../../example/applications/oracle/http/client/sync-ssl/http_client_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-sync-ssl : native ; +webcpp.drive port-http-client-sync-ssl : ../../example/applications/port/http/client/sync-ssl/http_client_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-client-sync-ssl : native ; +webcpp.drive oracle-http-server-async : ../../example/applications/oracle/http/server/async/http_server_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-async : native ; +webcpp.drive port-http-server-async : ../../example/applications/port/http/server/async/http_server_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-async : native ; +webcpp.drive oracle-http-server-async-local : ../../example/applications/oracle/http/server/async-local/http_server_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-async-local : native ; +webcpp.drive port-http-server-async-local : ../../example/applications/port/http/server/async-local/http_server_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-async-local : native ; +webcpp.drive oracle-http-server-async-ssl : ../../example/applications/oracle/http/server/async-ssl/http_server_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-async-ssl : native ; +webcpp.drive port-http-server-async-ssl : ../../example/applications/port/http/server/async-ssl/http_server_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-async-ssl : native ; +webcpp.drive oracle-http-server-awaitable : ../../example/applications/oracle/http/server/awaitable/http_server_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-awaitable : native ; +webcpp.drive port-http-server-awaitable : ../../example/applications/port/http/server/awaitable/http_server_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-awaitable : native ; +webcpp.drive oracle-http-server-coro : ../../example/applications/oracle/http/server/coro/http_server_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-coro : native ; +webcpp.drive port-http-server-coro : ../../example/applications/port/http/server/coro/http_server_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-coro : native ; +webcpp.drive oracle-http-server-coro-ssl : ../../example/applications/oracle/http/server/coro-ssl/http_server_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-coro-ssl : native ; +webcpp.drive port-http-server-coro-ssl : ../../example/applications/port/http/server/coro-ssl/http_server_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-coro-ssl : native ; +webcpp.drive oracle-http-server-fast : ../../example/applications/oracle/http/server/fast/http_server_fast.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-fast : native ; +webcpp.drive port-http-server-fast : ../../example/applications/port/http/server/fast/http_server_fast.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-fast : native ; +webcpp.drive oracle-http-server-flex : ../../example/applications/oracle/http/server/flex/http_server_flex.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-flex : native ; +webcpp.drive port-http-server-flex : ../../example/applications/port/http/server/flex/http_server_flex.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-flex : native ; +webcpp.drive oracle-http-server-small : ../../example/applications/oracle/http/server/small/http_server_small.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-small : native ; +webcpp.drive port-http-server-small : ../../example/applications/port/http/server/small/http_server_small.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-small : native ; +webcpp.drive oracle-http-server-stackless : ../../example/applications/oracle/http/server/stackless/http_server_stackless.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-stackless : native ; +webcpp.drive port-http-server-stackless : ../../example/applications/port/http/server/stackless/http_server_stackless.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-stackless : native ; +webcpp.drive oracle-http-server-stackless-ssl : ../../example/applications/oracle/http/server/stackless-ssl/http_server_stackless_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-stackless-ssl : native ; +webcpp.drive port-http-server-stackless-ssl : ../../example/applications/port/http/server/stackless-ssl/http_server_stackless_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-stackless-ssl : native ; +webcpp.drive oracle-http-server-sync : ../../example/applications/oracle/http/server/sync/http_server_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-sync : native ; +webcpp.drive port-http-server-sync : ../../example/applications/port/http/server/sync/http_server_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-sync : native ; +webcpp.drive oracle-http-server-sync-ssl : ../../example/applications/oracle/http/server/sync-ssl/http_server_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-sync-ssl : native ; +webcpp.drive port-http-server-sync-ssl : ../../example/applications/port/http/server/sync-ssl/http_server_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : http-server-sync-ssl : native ; +webcpp.drive oracle-websocket-client-async : ../../example/applications/oracle/websocket/client/async/websocket_client_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async : native ; +webcpp.drive port-websocket-client-async : ../../example/applications/port/websocket/client/async/websocket_client_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async : native ; +webcpp.drive oracle-websocket-client-async-local : ../../example/applications/oracle/websocket/client/async-local/websocket_client_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async-local : native ; +webcpp.drive port-websocket-client-async-local : ../../example/applications/port/websocket/client/async-local/websocket_client_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async-local : native ; +webcpp.drive oracle-websocket-client-async-ssl : ../../example/applications/oracle/websocket/client/async-ssl/websocket_client_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async-ssl : native ; +webcpp.drive port-websocket-client-async-ssl : ../../example/applications/port/websocket/client/async-ssl/websocket_client_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async-ssl : native ; +webcpp.drive oracle-websocket-client-async-ssl-system-executor : ../../example/applications/oracle/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async-ssl-system-executor : native ; +webcpp.drive port-websocket-client-async-ssl-system-executor : ../../example/applications/port/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-async-ssl-system-executor : native ; +webcpp.drive oracle-websocket-client-awaitable : ../../example/applications/oracle/websocket/client/awaitable/websocket_client_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-awaitable : native ; +webcpp.drive port-websocket-client-awaitable : ../../example/applications/port/websocket/client/awaitable/websocket_client_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-awaitable : native ; +webcpp.drive oracle-websocket-client-coro : ../../example/applications/oracle/websocket/client/coro/websocket_client_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-coro : native ; +webcpp.drive port-websocket-client-coro : ../../example/applications/port/websocket/client/coro/websocket_client_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-coro : native ; +webcpp.drive oracle-websocket-client-coro-ssl : ../../example/applications/oracle/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-coro-ssl : native ; +webcpp.drive port-websocket-client-coro-ssl : ../../example/applications/port/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-coro-ssl : native ; +webcpp.drive oracle-websocket-client-sync : ../../example/applications/oracle/websocket/client/sync/websocket_client_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-sync : native ; +webcpp.drive port-websocket-client-sync : ../../example/applications/port/websocket/client/sync/websocket_client_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-sync : native ; +webcpp.drive oracle-websocket-client-sync-ssl : ../../example/applications/oracle/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-sync-ssl : native ; +webcpp.drive port-websocket-client-sync-ssl : ../../example/applications/port/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-client-sync-ssl : native ; +webcpp.drive oracle-websocket-server-async : ../../example/applications/oracle/websocket/server/async/websocket_server_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-async : native ; +webcpp.drive port-websocket-server-async : ../../example/applications/port/websocket/server/async/websocket_server_async.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-async : native ; +webcpp.drive oracle-websocket-server-async-local : ../../example/applications/oracle/websocket/server/async-local/websocket_server_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-async-local : native ; +webcpp.drive port-websocket-server-async-local : ../../example/applications/port/websocket/server/async-local/websocket_server_async_local.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-async-local : native ; +webcpp.drive oracle-websocket-server-async-ssl : ../../example/applications/oracle/websocket/server/async-ssl/websocket_server_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-async-ssl : native ; +webcpp.drive port-websocket-server-async-ssl : ../../example/applications/port/websocket/server/async-ssl/websocket_server_async_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-async-ssl : native ; +webcpp.drive oracle-websocket-server-awaitable : ../../example/applications/oracle/websocket/server/awaitable/websocket_server_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-awaitable : native ; +webcpp.drive port-websocket-server-awaitable : ../../example/applications/port/websocket/server/awaitable/websocket_server_awaitable.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-awaitable : native ; +webcpp.drive oracle-websocket-chat-multi : ../../example/applications/oracle/websocket/server/chat-multi/http_session.cpp ../../example/applications/oracle/websocket/server/chat-multi/listener.cpp ../../example/applications/oracle/websocket/server/chat-multi/main.cpp ../../example/applications/oracle/websocket/server/chat-multi/shared_state.cpp ../../example/applications/oracle/websocket/server/chat-multi/websocket_session.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-chat-multi : native ; +webcpp.drive port-websocket-chat-multi : ../../example/applications/port/websocket/server/chat-multi/http_session.cpp ../../example/applications/port/websocket/server/chat-multi/listener.cpp ../../example/applications/port/websocket/server/chat-multi/main.cpp ../../example/applications/port/websocket/server/chat-multi/shared_state.cpp ../../example/applications/port/websocket/server/chat-multi/websocket_session.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-chat-multi : native ; +webcpp.drive oracle-websocket-server-coro : ../../example/applications/oracle/websocket/server/coro/websocket_server_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-coro : native ; +webcpp.drive port-websocket-server-coro : ../../example/applications/port/websocket/server/coro/websocket_server_coro.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-coro : native ; +webcpp.drive oracle-websocket-server-coro-ssl : ../../example/applications/oracle/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-coro-ssl : native ; +webcpp.drive port-websocket-server-coro-ssl : ../../example/applications/port/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp + : /webcpp/beast//tls /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-coro-ssl : native ; +webcpp.drive oracle-websocket-server-fast : ../../example/applications/oracle/websocket/server/fast/websocket_server_fast.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-fast : native ; +webcpp.drive port-websocket-server-fast : ../../example/applications/port/websocket/server/fast/websocket_server_fast.cpp + : /webcpp/beast//sockets /webcpp//boost_context on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-fast : native ; +webcpp.drive oracle-websocket-server-stackless : ../../example/applications/oracle/websocket/server/stackless/websocket_server_stackless.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-stackless : native ; +webcpp.drive port-websocket-server-stackless : ../../example/applications/port/websocket/server/stackless/websocket_server_stackless.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-stackless : native ; +webcpp.drive oracle-websocket-server-stackless-ssl : ../../example/applications/oracle/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-stackless-ssl : native ; +webcpp.drive port-websocket-server-stackless-ssl : ../../example/applications/port/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-stackless-ssl : native ; +webcpp.drive oracle-websocket-server-sync : ../../example/applications/oracle/websocket/server/sync/websocket_server_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-sync : native ; +webcpp.drive port-websocket-server-sync : ../../example/applications/port/websocket/server/sync/websocket_server_sync.cpp + : /webcpp/beast//sockets on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-sync : native ; +webcpp.drive oracle-websocket-server-sync-ssl : ../../example/applications/oracle/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/oracle + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-sync-ssl : native ; +webcpp.drive port-websocket-server-sync-ssl : ../../example/applications/port/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp + : /webcpp/beast//tls on + ../../example/applications/port + ../../example/applications multi + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 + : driver.py : websocket-server-sync-ssl : native ; +webcpp.run documentation_snippets : documentation_snippets.cpp + : /webcpp/beast//sockets ../../example/applications + ../../example/applications/port : native wasip3 ; +webcpp.run context_unwind : context_unwind.cpp + : /webcpp//boost_context on ; +webcpp.lane applications : + oracle-advanced-server + port-advanced-server + oracle-advanced-server-flex + port-advanced-server-flex + oracle-advanced-server-flex-awaitable + port-advanced-server-flex-awaitable + oracle-doc-ssl-client + port-doc-ssl-client + oracle-doc-ssl-server + port-doc-ssl-server + oracle-echo-op + port-echo-op + oracle-http-client-async + port-http-client-async + oracle-http-client-async-local + port-http-client-async-local + oracle-http-client-async-ssl + port-http-client-async-ssl + oracle-http-client-async-ssl-system-executor + port-http-client-async-ssl-system-executor + oracle-http-client-awaitable + port-http-client-awaitable + oracle-http-client-awaitable-ssl + port-http-client-awaitable-ssl + oracle-json_client + port-json_client + oracle-http-client-coro + port-http-client-coro + oracle-http-client-coro-ssl + port-http-client-coro-ssl + oracle-http-crawl + port-http-crawl + oracle-http-client-methods + port-http-client-methods + oracle-http-client-sync + port-http-client-sync + oracle-http-client-sync-ssl + port-http-client-sync-ssl + oracle-http-server-async + port-http-server-async + oracle-http-server-async-local + port-http-server-async-local + oracle-http-server-async-ssl + port-http-server-async-ssl + oracle-http-server-awaitable + port-http-server-awaitable + oracle-http-server-coro + port-http-server-coro + oracle-http-server-coro-ssl + port-http-server-coro-ssl + oracle-http-server-fast + port-http-server-fast + oracle-http-server-flex + port-http-server-flex + oracle-http-server-small + port-http-server-small + oracle-http-server-stackless + port-http-server-stackless + oracle-http-server-stackless-ssl + port-http-server-stackless-ssl + oracle-http-server-sync + port-http-server-sync + oracle-http-server-sync-ssl + port-http-server-sync-ssl + oracle-websocket-client-async + port-websocket-client-async + oracle-websocket-client-async-local + port-websocket-client-async-local + oracle-websocket-client-async-ssl + port-websocket-client-async-ssl + oracle-websocket-client-async-ssl-system-executor + port-websocket-client-async-ssl-system-executor + oracle-websocket-client-awaitable + port-websocket-client-awaitable + oracle-websocket-client-coro + port-websocket-client-coro + oracle-websocket-client-coro-ssl + port-websocket-client-coro-ssl + oracle-websocket-client-sync + port-websocket-client-sync + oracle-websocket-client-sync-ssl + port-websocket-client-sync-ssl + oracle-websocket-server-async + port-websocket-server-async + oracle-websocket-server-async-local + port-websocket-server-async-local + oracle-websocket-server-async-ssl + port-websocket-server-async-ssl + oracle-websocket-server-awaitable + port-websocket-server-awaitable + oracle-websocket-chat-multi + port-websocket-chat-multi + oracle-websocket-server-coro + port-websocket-server-coro + oracle-websocket-server-coro-ssl + port-websocket-server-coro-ssl + oracle-websocket-server-fast + port-websocket-server-fast + oracle-websocket-server-stackless + port-websocket-server-stackless + oracle-websocket-server-stackless-ssl + port-websocket-server-stackless-ssl + oracle-websocket-server-sync + port-websocket-server-sync + oracle-websocket-server-sync-ssl + port-websocket-server-sync-ssl + : native ; +build-project host ; +build-project wasip3 ; +build-project browser ; +build-project streams ; +build-project chat ; +build-project host-clients ; +build-project noexcept ; +build-project browser-noexcept ; +build-project host-extra ; +build-project host-tls ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser-noexcept/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser-noexcept/Jamfile new file mode 100644 index 0000000..a48dc52 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser-noexcept/Jamfile @@ -0,0 +1,190 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +# +# Generated by example/applications/tools/prepare.py. Edit the generator. +# Upstream authors and their original notice follow. + +import webcpp ; +webcpp.targets emscripten ; +webcpp.original node : .. ; +webcpp.variants http-client-async : ../../../example/applications/noexcept-browser/http/client/async/http_client_async.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-async : .//http-client-async + : http-client-async.variants.json 120 + : ../browser/run.mjs : --program http-client-async --expected "application http-client-async: passed" + : emscripten ; +webcpp.variants http-client-async-ssl : ../../../example/applications/noexcept-browser/http/client/async-ssl/http_client_async_ssl.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-async-ssl : .//http-client-async-ssl + : http-client-async-ssl.variants.json 120 + : ../browser/run.mjs : --program http-client-async-ssl --expected "application http-client-async-ssl: passed" + : emscripten ; +webcpp.variants http-client-async-ssl-system-executor : ../../../example/applications/noexcept-browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-async-ssl-system-executor : .//http-client-async-ssl-system-executor + : http-client-async-ssl-system-executor.variants.json 120 + : ../browser/run.mjs : --program http-client-async-ssl-system-executor --expected "application http-client-async-ssl-system-executor: passed" + : emscripten ; +webcpp.variants http-client-awaitable : ../../../example/applications/noexcept-browser/http/client/awaitable/http_client_awaitable.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-awaitable : .//http-client-awaitable + : http-client-awaitable.variants.json 120 + : ../browser/run.mjs : --program http-client-awaitable --expected "application http-client-awaitable: passed" + : emscripten ; +webcpp.variants http-client-awaitable-ssl : ../../../example/applications/noexcept-browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-awaitable-ssl : .//http-client-awaitable-ssl + : http-client-awaitable-ssl.variants.json 120 + : ../browser/run.mjs : --program http-client-awaitable-ssl --expected "application http-client-awaitable-ssl: passed" + : emscripten ; +webcpp.variants json_client : ../../../example/applications/noexcept-browser/http/client/body/json_client.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-json_client : .//json_client + : json_client.variants.json 120 + : ../browser/run.mjs : --program json_client --expected "application json_client: passed" + : emscripten ; +webcpp.variants http-crawl : ../../../example/applications/noexcept-browser/http/client/crawl/http_crawl.cpp ../../../example/applications/noexcept-browser/http/client/crawl/urls_large_data.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-crawl : .//http-crawl + : http-crawl.variants.json 120 + : ../browser/run.mjs : --program http-crawl --expected "application http-crawl: passed" + : emscripten ; +webcpp.variants http-client-methods : ../../../example/applications/noexcept-browser/http/client/methods/http_client_methods.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-methods : .//http-client-methods + : http-client-methods.variants.json 120 + : ../browser/run.mjs : --program http-client-methods --expected "application http-client-methods: passed" + : emscripten ; +webcpp.variants http-client-sync : ../../../example/applications/noexcept-browser/http/client/sync/http_client_sync.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-sync : .//http-client-sync + : http-client-sync.variants.json 120 + : ../browser/run.mjs : --program http-client-sync --expected "application http-client-sync: passed" + : emscripten ; +webcpp.variants http-client-sync-ssl : ../../../example/applications/noexcept-browser/http/client/sync-ssl/http_client_sync_ssl.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-sync-ssl : .//http-client-sync-ssl + : http-client-sync-ssl.variants.json 120 + : ../browser/run.mjs : --program http-client-sync-ssl --expected "application http-client-sync-ssl: passed" + : emscripten ; +webcpp.variants websocket-client-async : ../../../example/applications/noexcept-browser/websocket/client/async/websocket_client_async.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-async : .//websocket-client-async + : websocket-client-async.variants.json 120 + : ../browser/run.mjs : --program websocket-client-async --expected "application websocket-client-async: passed" + : emscripten ; +webcpp.variants websocket-client-async-ssl : ../../../example/applications/noexcept-browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-async-ssl : .//websocket-client-async-ssl + : websocket-client-async-ssl.variants.json 120 + : ../browser/run.mjs : --program websocket-client-async-ssl --expected "application websocket-client-async-ssl: passed" + : emscripten ; +webcpp.variants websocket-client-async-ssl-system-executor : ../../../example/applications/noexcept-browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-async-ssl-system-executor : .//websocket-client-async-ssl-system-executor + : websocket-client-async-ssl-system-executor.variants.json 120 + : ../browser/run.mjs : --program websocket-client-async-ssl-system-executor --expected "application websocket-client-async-ssl-system-executor: passed" + : emscripten ; +webcpp.variants websocket-client-awaitable : ../../../example/applications/noexcept-browser/websocket/client/awaitable/websocket_client_awaitable.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-awaitable : .//websocket-client-awaitable + : websocket-client-awaitable.variants.json 120 + : ../browser/run.mjs : --program websocket-client-awaitable --expected "application websocket-client-awaitable: passed" + : emscripten ; +webcpp.variants websocket-client-sync : ../../../example/applications/noexcept-browser/websocket/client/sync/websocket_client_sync.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-sync : .//websocket-client-sync + : websocket-client-sync.variants.json 120 + : ../browser/run.mjs : --program websocket-client-sync --expected "application websocket-client-sync: passed" + : emscripten ; +webcpp.variants websocket-client-sync-ssl : ../../../example/applications/noexcept-browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp + : /webcpp/beast//browser off + ../../../example/applications/noexcept-browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-sync-ssl : .//websocket-client-sync-ssl + : websocket-client-sync-ssl.variants.json 120 + : ../browser/run.mjs : --program websocket-client-sync-ssl --expected "application websocket-client-sync-ssl: passed" + : emscripten ; +webcpp.lane applications-browser : + run-http-client-async + run-http-client-async-ssl + run-http-client-async-ssl-system-executor + run-http-client-awaitable + run-http-client-awaitable-ssl + run-json_client + run-http-crawl + run-http-client-methods + run-http-client-sync + run-http-client-sync-ssl + run-websocket-client-async + run-websocket-client-async-ssl + run-websocket-client-async-ssl-system-executor + run-websocket-client-awaitable + run-websocket-client-sync + run-websocket-client-sync-ssl + : emscripten ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/Jamfile new file mode 100644 index 0000000..3fe1e8b --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/Jamfile @@ -0,0 +1,190 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +# +# Generated by example/applications/tools/prepare.py. Edit the generator. +# Upstream authors and their original notice follow. + +import webcpp ; +webcpp.targets emscripten ; +webcpp.original node : .. ; +webcpp.variants http-client-async : ../../../example/applications/browser/http/client/async/http_client_async.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-async : .//http-client-async + : http-client-async.variants.json 120 + : run.mjs : --program http-client-async --expected "application http-client-async: passed" + : emscripten ; +webcpp.variants http-client-async-ssl : ../../../example/applications/browser/http/client/async-ssl/http_client_async_ssl.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-async-ssl : .//http-client-async-ssl + : http-client-async-ssl.variants.json 120 + : run.mjs : --program http-client-async-ssl --expected "application http-client-async-ssl: passed" + : emscripten ; +webcpp.variants http-client-async-ssl-system-executor : ../../../example/applications/browser/http/client/async-ssl-system-executor/http_client_async_ssl_system_executor.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-async-ssl-system-executor : .//http-client-async-ssl-system-executor + : http-client-async-ssl-system-executor.variants.json 120 + : run.mjs : --program http-client-async-ssl-system-executor --expected "application http-client-async-ssl-system-executor: passed" + : emscripten ; +webcpp.variants http-client-awaitable : ../../../example/applications/browser/http/client/awaitable/http_client_awaitable.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-awaitable : .//http-client-awaitable + : http-client-awaitable.variants.json 120 + : run.mjs : --program http-client-awaitable --expected "application http-client-awaitable: passed" + : emscripten ; +webcpp.variants http-client-awaitable-ssl : ../../../example/applications/browser/http/client/awaitable-ssl/http_client_awaitable_ssl.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-awaitable-ssl : .//http-client-awaitable-ssl + : http-client-awaitable-ssl.variants.json 120 + : run.mjs : --program http-client-awaitable-ssl --expected "application http-client-awaitable-ssl: passed" + : emscripten ; +webcpp.variants json_client : ../../../example/applications/browser/http/client/body/json_client.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-json_client : .//json_client + : json_client.variants.json 120 + : run.mjs : --program json_client --expected "application json_client: passed" + : emscripten ; +webcpp.variants http-crawl : ../../../example/applications/browser/http/client/crawl/http_crawl.cpp ../../../example/applications/browser/http/client/crawl/urls_large_data.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-crawl : .//http-crawl + : http-crawl.variants.json 120 + : run.mjs : --program http-crawl --expected "application http-crawl: passed" + : emscripten ; +webcpp.variants http-client-methods : ../../../example/applications/browser/http/client/methods/http_client_methods.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-methods : .//http-client-methods + : http-client-methods.variants.json 120 + : run.mjs : --program http-client-methods --expected "application http-client-methods: passed" + : emscripten ; +webcpp.variants http-client-sync : ../../../example/applications/browser/http/client/sync/http_client_sync.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-sync : .//http-client-sync + : http-client-sync.variants.json 120 + : run.mjs : --program http-client-sync --expected "application http-client-sync: passed" + : emscripten ; +webcpp.variants http-client-sync-ssl : ../../../example/applications/browser/http/client/sync-ssl/http_client_sync_ssl.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-http-client-sync-ssl : .//http-client-sync-ssl + : http-client-sync-ssl.variants.json 120 + : run.mjs : --program http-client-sync-ssl --expected "application http-client-sync-ssl: passed" + : emscripten ; +webcpp.variants websocket-client-async : ../../../example/applications/browser/websocket/client/async/websocket_client_async.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-async : .//websocket-client-async + : websocket-client-async.variants.json 120 + : run.mjs : --program websocket-client-async --expected "application websocket-client-async: passed" + : emscripten ; +webcpp.variants websocket-client-async-ssl : ../../../example/applications/browser/websocket/client/async-ssl/websocket_client_async_ssl.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-async-ssl : .//websocket-client-async-ssl + : websocket-client-async-ssl.variants.json 120 + : run.mjs : --program websocket-client-async-ssl --expected "application websocket-client-async-ssl: passed" + : emscripten ; +webcpp.variants websocket-client-async-ssl-system-executor : ../../../example/applications/browser/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-async-ssl-system-executor : .//websocket-client-async-ssl-system-executor + : websocket-client-async-ssl-system-executor.variants.json 120 + : run.mjs : --program websocket-client-async-ssl-system-executor --expected "application websocket-client-async-ssl-system-executor: passed" + : emscripten ; +webcpp.variants websocket-client-awaitable : ../../../example/applications/browser/websocket/client/awaitable/websocket_client_awaitable.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-awaitable : .//websocket-client-awaitable + : websocket-client-awaitable.variants.json 120 + : run.mjs : --program websocket-client-awaitable --expected "application websocket-client-awaitable: passed" + : emscripten ; +webcpp.variants websocket-client-sync : ../../../example/applications/browser/websocket/client/sync/websocket_client_sync.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-sync : .//websocket-client-sync + : websocket-client-sync.variants.json 120 + : run.mjs : --program websocket-client-sync --expected "application websocket-client-sync: passed" + : emscripten ; +webcpp.variants websocket-client-sync-ssl : ../../../example/applications/browser/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp + : /webcpp/beast//browser on + ../../../example/applications/browser + ../../../example/applications single + BOOST_ASIO_HAS_CO_AWAIT=1 + BOOST_ASIO_HAS_STD_COROUTINE=1 ; +webcpp.drive run-websocket-client-sync-ssl : .//websocket-client-sync-ssl + : websocket-client-sync-ssl.variants.json 120 + : run.mjs : --program websocket-client-sync-ssl --expected "application websocket-client-sync-ssl: passed" + : emscripten ; +webcpp.lane applications-browser : + run-http-client-async + run-http-client-async-ssl + run-http-client-async-ssl-system-executor + run-http-client-awaitable + run-http-client-awaitable-ssl + run-json_client + run-http-crawl + run-http-client-methods + run-http-client-sync + run-http-client-sync-ssl + run-websocket-client-async + run-websocket-client-async-ssl + run-websocket-client-async-ssl-system-executor + run-websocket-client-awaitable + run-websocket-client-sync + run-websocket-client-sync-ssl + : emscripten ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/page.html b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/page.html new file mode 100644 index 0000000..d235fef --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/page.html @@ -0,0 +1,39 @@ + + + +Beast browser lane + diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/run.mjs b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/run.mjs new file mode 100644 index 0000000..62ccf65 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/applications/browser/run.mjs @@ -0,0 +1,456 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The real browser checks: idle waits, animation opportunities and variant loading. +// node run.mjs --mode +// CHROME names full Chromium; on macOS the newest cached Playwright Chromium is used. +// Each invocation owns its loopback server, Chrome process and temporary profile. +import assert from 'node:assert/strict' +import {spawn, execFileSync} from 'node:child_process' +import {once} from 'node:events' +import {existsSync, mkdtempSync, readFileSync, readdirSync, rmSync} from 'node:fs' +import {createServer} from 'node:http' +import {createServer as createSecureServer} from 'node:https' +import {createHash} from 'node:crypto' +import {homedir, tmpdir} from 'node:os' +import {dirname, extname, join, relative, resolve, sep} from 'node:path' +import {setTimeout as delay} from 'node:timers/promises' +import {fileURLToPath} from 'node:url' + +const isMain = process.argv[1] === fileURLToPath(import.meta.url) +const args = isMain ? process.argv.slice(2) : ["."] +let program = 'browser_test' +let expected = 'browser websocket and fetch: ok' +while (args[0]?.startsWith('--')) { + const option = args.shift() + if (option === '--program') program = args.shift() + else if (option === '--expected') expected = args.shift() + else throw new Error(`unknown option ${option}`) +} +assert.equal(args.length, 1, 'usage: run.mjs [--program name] [--expected line] ') +const mode = program +const here = dirname(fileURLToPath(import.meta.url)) +const artifact = resolve(args[0]) +const manifest = join(dirname(artifact).replace(`${sep}exception-handling-off`, ''), + `${program}.variants.json`) +let build = dirname(artifact) +while (!manifest.startsWith(build + sep) && dirname(build) !== build) build = dirname(build) +const manifestUrl = `/build/${relative(build, manifest).split(sep).join('/')}` +const findChrome = () => { + if (process.env.CHROME) return process.env.CHROME + assert.equal(process.platform, 'darwin', 'set CHROME to the Chrome executable') + const cache = join(homedir(), 'Library/Caches/ms-playwright') + const shells = existsSync(cache) ? readdirSync(cache) + .filter(name => /^chromium-\d+$/.test(name)) + .sort((a, b) => Number(b.split('-').at(-1)) - Number(a.split('-').at(-1))) : [] + for (const shell of shells) { + for (const arch of ['arm64', 'x64']) { + const path = join(cache, shell, `chrome-mac-${arch}`, 'Google Chrome for Testing.app', + 'Contents/MacOS/Google Chrome for Testing') + if (existsSync(path)) return path + } + } + throw new Error('no cached full Chromium found; set CHROME') +} + +const left = {chrome: null, profile: null, server: null, corsServer: null, secureServer: null, certificate: null, sockets: new Set(), networkSockets: new Set()} +const ownConnections = server => server.on('connection', socket => { + left.networkSockets.add(socket) + socket.on('close', () => left.networkSockets.delete(socket)) +}) +const exited = child => child.exitCode !== null || child.signalCode !== null +const signalChrome = (child, signal) => { + if (!child.pid) return + try { + if (process.platform === 'win32') child.kill(signal) + else process.kill(-child.pid, signal) + } catch (error) { + if (error.code !== 'ESRCH' && !(error.code === 'EPERM' && exited(child))) throw error + } +} +const stopChrome = async () => { + if (left.chrome && !exited(left.chrome) && left.chrome.pid) { + const ended = once(left.chrome, 'exit') + const stubborn = setTimeout(() => signalChrome(left.chrome, 'SIGKILL'), 5000) + signalChrome(left.chrome, 'SIGTERM') + try { await ended } finally { clearTimeout(stubborn) } + } + if (left.chrome) { + signalChrome(left.chrome, 'SIGKILL') + left.chrome.stderr.destroy() + } + left.chrome = null + if (left.profile) rmSync(left.profile, {recursive: true, force: true, maxRetries: 3}) + left.profile = null +} +let cleaning +const cleanUp = () => (cleaning ??= (async () => { + for (const socket of left.sockets) socket.close() + await stopChrome() + for (const socket of left.networkSockets) socket.destroy() + if (left.server) { + left.server.closeAllConnections() + await new Promise(resolve => left.server.close(resolve)) + } + if (left.corsServer) { + left.corsServer.closeAllConnections() + await new Promise(resolve => left.corsServer.close(resolve)) + } + if (left.secureServer) { + left.secureServer.closeAllConnections() + await new Promise(resolve => left.secureServer.close(resolve)) + } + if (left.certificate) rmSync(left.certificate, {recursive: true, force: true}) + if (left.profile) rmSync(left.profile, {recursive: true, force: true, maxRetries: 3}) +})()) +for (const [signal, code] of [['SIGHUP', 129], ['SIGINT', 130], ['SIGTERM', 143]]) { + process.on(signal, () => cleanUp().finally(() => process.exit(code))) +} + +const types = {'.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', + '.wasm': 'application/wasm', '.json': 'application/json'} +const roots = {'/build/': build, '/loader/': resolve(here, '../../../../asio/include/webcpp/asio'), '/': here} +let certificateAuthority +const trustHelper = join(here, '../host-tls/trust.py') +const trust = (...args) => execFileSync(process.env.PYTHON ?? 'python3', [trustHelper, ...args], + {encoding: 'utf8', timeout: 30000}) +const startServer = async () => { + left.certificate = mkdtempSync(join(tmpdir(), 'beast-browser-tls-')) + const certificates = JSON.parse(trust('create', left.certificate)) + certificateAuthority = certificates.der + const fixture = (request, response) => { + response.setHeader('Access-Control-Allow-Origin', '*') + response.setHeader('Access-Control-Allow-Methods', 'GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS') + response.setHeader('Access-Control-Allow-Headers', 'content-type') + if (request.method === 'OPTIONS') { response.writeHead(204).end(); return } + const chunks = [] + request.on('data', data => chunks.push(data)) + request.on('end', () => { + response.writeHead(200, + {'Content-Type': request.headers['content-type'] ?? 'text/plain'}) + console.log(JSON.stringify({fixture: request.method, target: request.url, + headers: response.getHeaders()})) + response.end(request.method === 'GET' ? 'fetch body' : Buffer.concat(chunks)) + }) + } + left.secureServer = createSecureServer({ + key: readFileSync(join(left.certificate, 'key.pem')), + cert: readFileSync(join(left.certificate, 'cert.pem')) + }, fixture) + ownConnections(left.secureServer) + left.secureServer.listen(0, '127.0.0.1') + await once(left.secureServer, 'listening') + const securePort = String(left.secureServer.address().port) + left.corsServer = createServer((request, response) => response.writeHead(200).end('cross origin')) + ownConnections(left.corsServer) + left.corsServer.listen(0, '127.0.0.1') + await once(left.corsServer, 'listening') + const corsPort = String(left.corsServer.address().port) + const server = createServer((request, response) => { + if (request.url === '/redirect') { response.writeHead(302, {Location: '/http'}).end(); return } + if (['/', '/http', '/get', '/post', '/put', '/patch', '/delete'].includes(request.url)) { + fixture(request, response) + return + } + try { + const path = decodeURIComponent(new URL(request.url, 'http://127.0.0.1').pathname) + const [prefix, root] = Object.entries(roots).find(([prefix]) => path.startsWith(prefix)) + const file = resolve(root, path.slice(prefix.length)) + if (!file.startsWith(root + sep)) { + response.writeHead(404).end() + return + } + let content = readFileSync(file) + if (path === '/page.html') content = Buffer.from(content.toString().replace(' diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer.mjs b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer.mjs new file mode 100644 index 0000000..76b0bf8 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer.mjs @@ -0,0 +1,63 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Native Beast owns HTTP and WebSocket protocols; Node only launches and reaps it. +import assert from 'node:assert/strict' +import {spawn, spawnSync} from 'node:child_process' +import {once} from 'node:events' +import {existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync} from 'node:fs' +import {tmpdir} from 'node:os' +import {join, resolve} from 'node:path' +import {setTimeout as delay} from 'node:timers/promises' + +function executables(directory) { + if (!existsSync(directory)) return [] + return readdirSync(directory, {withFileTypes: true}).flatMap(entry => { + const path = join(directory, entry.name) + return entry.isDirectory() ? executables(path) : entry.name === 'native_peer-program' || entry.name === 'native_peer-program.exe' ? [path] : [] + }) +} + +export async function startPeer() { + const executable = process.env.WEBCPP_BEAST_NATIVE_PEER ?? executables(resolve('bin/libs/beast/test/browser/peer'))[0] + assert.ok(executable, 'build libs/beast/test/browser/peer//native_peer-program with a native toolset, or set WEBCPP_BEAST_NATIVE_PEER') + const directory = mkdtempSync(join(tmpdir(), 'beast-peer-')) + let child + const stop = async () => { + if (child?.pid && child.exitCode === null && child.signalCode === null) { + const ended = once(child, 'exit') + const deadline = setTimeout(() => child.kill('SIGKILL'), 3000) + child.kill('SIGTERM') + try { await ended } finally { clearTimeout(deadline) } + } + child?.stdout.destroy() + child?.stderr.destroy() + rmSync(directory, {recursive: true, force: true}) + } + try { + const openssl = (...args) => { + const result = spawnSync('openssl', args, {cwd: directory, encoding: 'utf8', timeout: 10000}) + assert.equal(result.status, 0, result.stderr) + return result.stdout + } + writeFileSync(join(directory, 'ca.cnf'), '[req]\ndistinguished_name=dn\n[dn]\nCN=Beast contract CA\n[v3_ca]\nbasicConstraints=critical,CA:true\nkeyUsage=critical,keyCertSign,cRLSign\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid:always\n') + openssl('req', '-x509', '-newkey', 'rsa:2048', '-nodes', '-days', '2', '-subj', '/CN=Beast contract CA', '-keyout', 'ca.key', '-out', 'ca.crt', '-config', 'ca.cnf', '-extensions', 'v3_ca') + writeFileSync(join(directory, 'leaf.cnf'), 'subjectAltName=DNS:localhost,IP:127.0.0.1\nextendedKeyUsage=serverAuth\nbasicConstraints=critical,CA:false\nkeyUsage=critical,digitalSignature,keyEncipherment\n') + openssl('req', '-newkey', 'rsa:2048', '-nodes', '-subj', '/CN=localhost', '-keyout', 'server.key', '-out', 'server.csr') + openssl('x509', '-req', '-in', 'server.csr', '-CA', 'ca.crt', '-CAkey', 'ca.key', '-CAcreateserial', '-days', '2', '-extfile', 'leaf.cnf', '-out', 'server.crt') + openssl('x509', '-in', 'ca.crt', '-outform', 'DER', '-out', 'ca.der') + child = spawn(executable, [join(directory, 'server.crt'), join(directory, 'server.key')], {stdio: ['ignore', 'pipe', 'pipe']}) + let output = '', errors = '', launchError + child.on('error', error => { launchError = error }) + child.stdout.on('data', value => { output += value }) + child.stderr.on('data', value => { errors += value }) + const deadline = Date.now() + 10000 + while (!output.includes('\n') && Date.now() < deadline && child.exitCode === null && !launchError) await delay(10) + if (launchError) throw launchError + assert.ok(output.includes('\n'), `native peer failed to announce ports: ${errors}`) + return {...JSON.parse(output.split('\n')[0]), ca: join(directory, 'ca.crt'), caDer: join(directory, 'ca.der'), cert: join(directory, 'server.crt'), key: join(directory, 'server.key'), stop} + } catch (error) { await stop(); throw error } +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer/Jamfile b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer/Jamfile new file mode 100644 index 0000000..2c6e5a9 --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer/Jamfile @@ -0,0 +1,9 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +import webcpp ; +webcpp.targets native ; +webcpp.link native_peer : native_peer.cpp : /webcpp/beast//tls multi ; diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer/native_peer.cpp b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer/native_peer.cpp new file mode 100644 index 0000000..422294c --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/peer/native_peer.cpp @@ -0,0 +1,234 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Native Beast peers shared by the browser and Node contracts. The driver owns +// this process and bounds its lifetime, including deliberately stalled sessions. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +namespace beast = webcpp::beast; +namespace net = boost::asio; +namespace ssl = net::ssl; +using net::ip::tcp; + +struct barrier { + std::mutex mutex; + std::condition_variable changed; + bool released = false; +}; + +template +void websocket(Stream stream, const beast::http::request& request, + barrier& released) { + beast::websocket::stream socket(std::move(stream)); + boost::system::error_code ec; + const auto protocol = request[beast::http::field::sec_websocket_protocol]; + socket.set_option(beast::websocket::stream_base::decorator( + [protocol = std::string(protocol)](auto& response) { + if (!protocol.empty()) { + response.set(beast::http::field::sec_websocket_protocol, + protocol.substr(0, protocol.find(','))); + } + })); + socket.accept(request, ec); + if (ec) { + return; + } + socket.text(true); + if (request.target() == "/close") { + socket.close(beast::websocket::close_reason{static_cast(4001), + "peer close"}, + ec); + return; + } + if (request.target() == "/empty-flood") { + for (int n = 0; n != 64 && !ec; ++n) { + socket.write(net::buffer("", 0), ec); + } + } else if (request.target() == "/retained-flood") { + socket.write(net::buffer(std::string(128, 'A')), ec); + } + while (!ec) { + beast::flat_buffer buffer; + socket.read(buffer, ec); + if (ec) { + return; + } + if (request.target() == "/retained-flood") { + socket.write(net::buffer(std::string(128, 'B')), ec); + } else { + if (request.target() == "/delayed-echo") { + std::unique_lock lock(released.mutex); + released.changed.wait_for(lock, std::chrono::seconds(5), + [&] { return released.released; }); + released.released = false; + } + socket.text(socket.got_text()); + socket.write(buffer.data(), ec); + } + } +} + +std::string policy_headers(const beast::http::request& request) { + std::string result; + for (const auto* name : + {"set-cookie", "x-http-method", "x-http-method-override", "x-method-override"}) { + if (request.contains(name)) { + const auto value = request[name]; + result += std::string(name) + "=" + std::string(value.data(), value.size()) + "\n"; + } + } + return result; +} + +template +void session(Stream stream, barrier& headers) { + boost::system::error_code ec; + beast::flat_buffer buffer; + for (;;) { + beast::http::request request; + beast::http::read(stream, buffer, request, ec); + if (ec) { + return; + } + if (beast::websocket::is_upgrade(request) && request.target() != "/refuse") { + websocket(std::move(stream), request, headers); + return; + } + if (request.target() == "/empty-reason") { + const std::string wire = + "HTTP/1.1 200 \r\nContent-Length: 12\r\nConnection: close\r\n" + "Access-Control-Allow-Origin: *\r\n\r\nempty reason"; + net::write(stream, net::buffer(wire), ec); + return; + } + beast::http::response response{beast::http::status::ok, 11}; + response.keep_alive(request.keep_alive()); + response.set(beast::http::field::content_type, "text/plain"); + response.set(beast::http::field::access_control_allow_origin, "*"); + response.set(beast::http::field::access_control_allow_methods, "GET,POST,OPTIONS"); + response.set(beast::http::field::access_control_allow_headers, + "x-http-method,x-http-method-override,x-method-override,x-allocator-field"); + if (request.target() == "/refuse") { + response.result(beast::http::status::forbidden); + } else if (request.target() == "/redirect") { + response.result(beast::http::status::found); + response.set(beast::http::field::location, "/http"); + } else if (request.target() == "/release") { + { + const std::scoped_lock lock(headers.mutex); + headers.released = true; + } + headers.changed.notify_all(); + response.result(beast::http::status::no_content); + } else if (request.target() == "/request-headers") { + response.body() = policy_headers(request); + } else if (request.target() == "/custom-reason") { + response.reason("Fixture custom"); + response.body() = "custom reason"; + } else { + response.body() = + request.method() == beast::http::verb::get ? "fetch body" : request.body(); + } + if (request.target() == "/headers") { + response.body() = "released body"; + response.prepare_payload(); + beast::http::response_serializer serializer(response); + beast::http::write_header(stream, serializer, ec); + { + std::unique_lock lock(headers.mutex); + headers.changed.wait_for(lock, std::chrono::seconds(5), + [&] { return headers.released; }); + headers.released = false; + } + net::write(stream, net::buffer(response.body()), ec); + } else if (request.method() == beast::http::verb::head) { + // A HEAD response without Content-Length exercises metadata-only parsers. + beast::http::response_serializer serializer(response); + beast::http::write_header(stream, serializer, ec); + } else { + response.prepare_payload(); + beast::http::write(stream, response, ec); + } + if (ec || !response.keep_alive()) { + return; + } + } +} + +class listener { + tcp::acceptor acceptor_; + ssl::context* tls_; + barrier& headers_; + +public: + listener(net::io_context& io, ssl::context* tls, barrier& headers) + : acceptor_(io, {net::ip::make_address("127.0.0.1"), 0}), tls_(tls), headers_(headers) {} + + void run() { accept(); } + + [[nodiscard]] unsigned short port() const { return acceptor_.local_endpoint().port(); } + +private: + void accept() { + acceptor_.async_accept([this](boost::system::error_code ec, tcp::socket socket) { + if (!ec) { + std::thread([this, socket = std::move(socket)]() mutable { + if (tls_) { + ssl::stream stream(std::move(socket), *tls_); + boost::system::error_code handshake; + if (!stream.handshake(ssl::stream_base::server, handshake)) { + session(std::move(stream), headers_); + } + } else { + session(std::move(socket), headers_); + } + }).detach(); + } + accept(); + }); + } +}; +} // namespace + +int main(int argc, const char* const* argv) { + if (argc != 3) { + return 2; + } + net::io_context io; + ssl::context tls(ssl::context::tls_server); + boost::system::error_code ec; + if (tls.use_certificate_chain_file(argv[1], ec)) { + return 3; + } + if (tls.use_private_key_file(argv[2], ssl::context::pem, ec)) { + return 4; + } + barrier headers; + listener plain(io, nullptr, headers); + listener secure(io, &tls, headers); + plain.run(); + secure.run(); + std::printf("{\"plain\":%u,\"secure\":%u}\n", plain.port(), secure.port()); + if (std::fflush(stdout) != 0) { + return 5; + } + io.run(); // lint-run: fixture process is bounded and reaped by its driver +} diff --git a/libraries/beast/openspec/changes/genesis/reference/source/test/browser/run.mjs b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/run.mjs new file mode 100644 index 0000000..0ff9eba --- /dev/null +++ b/libraries/beast/openspec/changes/genesis/reference/source/test/browser/run.mjs @@ -0,0 +1,385 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Execute Beast contracts or tutorial variants against controlled HTTP and WebSocket peers. +// node run.mjs [--program name] [--expected line] [--environment] +// CHROME names full Chromium; on macOS the newest cached Playwright Chromium is used. +// Each invocation owns its loopback server, Chrome process and temporary profile. +import assert from 'node:assert/strict' +import {execFileSync, spawn} from 'node:child_process' +import {once} from 'node:events' +import {existsSync, mkdtempSync, readFileSync, readdirSync, rmSync} from 'node:fs' +import {createServer} from 'node:http' +import {createServer as createSecureServer} from 'node:https' +import {startPeer} from './peer.mjs' +import {homedir, tmpdir} from 'node:os' +import {dirname, extname, join, resolve, sep} from 'node:path' +import {setTimeout as delay} from 'node:timers/promises' +import {fileURLToPath} from 'node:url' + +const args = process.argv.slice(2) +let program = 'browser_test' +let expected = 'browser websocket and fetch: ok' +let environment = false +while (args[0]?.startsWith('--')) { + const option = args.shift() + if (option === '--program') program = args.shift() + else if (option === '--expected') expected = args.shift() + else if (option === '--environment') environment = true + else throw new Error(`unknown option ${option}`) +} +assert.equal(args.length, 1, 'usage: run.mjs [--program name] [--expected line] [--environment] ') +const mode = 'beast' +const here = dirname(fileURLToPath(import.meta.url)) +const build = dirname(resolve(args[0])) +const findChrome = () => { + if (process.env.CHROME) return process.env.CHROME + assert.equal(process.platform, 'darwin', 'set CHROME to the Chrome executable') + const cache = join(homedir(), 'Library/Caches/ms-playwright') + const shells = existsSync(cache) ? readdirSync(cache) + .filter(name => /^chromium-\d+$/.test(name)) + .sort((a, b) => Number(b.split('-').at(-1)) - Number(a.split('-').at(-1))) : [] + for (const shell of shells) { + for (const arch of ['arm64', 'x64']) { + const path = join(cache, shell, `chrome-mac-${arch}`, 'Google Chrome for Testing.app', + 'Contents/MacOS/Google Chrome for Testing') + if (existsSync(path)) return path + } + } + throw new Error('no cached full Chromium found; set CHROME') +} + +const left = {chrome: null, profile: null, server: null, secureServer: null, secureOrigin: null, corsServer: null, peer: null, sockets: new Set()} +const exited = child => child.exitCode !== null || child.signalCode !== null +const signalChrome = (child, signal) => { + if (!child.pid) return + try { + if (process.platform === 'win32') child.kill(signal) + else process.kill(-child.pid, signal) + } catch (error) { + if (error.code !== 'ESRCH' && !(error.code === 'EPERM' && exited(child))) throw error + } +} +const stopChrome = async () => { + if (left.chrome && !exited(left.chrome) && left.chrome.pid) { + const ended = once(left.chrome, 'exit') + const stubborn = setTimeout(() => signalChrome(left.chrome, 'SIGKILL'), 5000) + signalChrome(left.chrome, 'SIGTERM') + try { await ended } finally { clearTimeout(stubborn) } + } + // Chrome helpers may retain an inherited stderr pipe after the main process exits. + if (left.chrome) { + signalChrome(left.chrome, 'SIGKILL') + left.chrome.stderr.destroy() + } + left.chrome = null + if (left.profile) rmSync(left.profile, {recursive: true, force: true, maxRetries: 3}) + left.profile = null +} +let cleaning +const cleanUp = () => (cleaning ??= (async () => { + for (const socket of left.sockets) socket.close() + await stopChrome() + if (left.peer) await left.peer.stop() + if (left.server) { + left.server.closeAllConnections() + await new Promise(resolve => left.server.close(resolve)) + } + if (left.secureServer) { + left.secureServer.closeAllConnections() + await new Promise(resolve => left.secureServer.close(resolve)) + } + if (left.corsServer) { + left.corsServer.closeAllConnections() + await new Promise(resolve => left.corsServer.close(resolve)) + } +})()) +for (const [signal, code] of [['SIGHUP', 129], ['SIGINT', 130], ['SIGTERM', 143]]) { + process.on(signal, () => cleanUp().finally(() => process.exit(code))) +} + +const types = {'.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', + '.wasm': 'application/wasm', '.json': 'application/json'} +const roots = {'/build/': build, '/loader/': resolve(here, '../../../asio/include/webcpp/asio'), '/': here} +const startServer = async () => { + left.peer = await startPeer() + left.corsServer = createServer((request, response) => response.writeHead(200).end('cross origin')) + left.corsServer.listen(0, '127.0.0.1') + await once(left.corsServer, 'listening') + const corsPort = String(left.corsServer.address().port) + const serve = (request, response) => { + try { + const path = decodeURIComponent(new URL(request.url, 'http://127.0.0.1').pathname) + if (path === '/tls-control') { + response.writeHead(200, {'Content-Type': 'text/html'}).end('Beast TLS control') + return + } + const [prefix, root] = Object.entries(roots).find(([prefix]) => path.startsWith(prefix)) + const file = resolve(root, path.slice(prefix.length)) + if (!file.startsWith(root + sep)) { response.writeHead(404).end(); return } + let content = readFileSync(file) + if (path === '/page.html') content = Buffer.from(content.toString().replace('